1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

implement search service

This commit is contained in:
Kyle Spearrin
2018-08-13 14:38:04 -04:00
parent ee73f9a51a
commit 314cef78fd
8 changed files with 25 additions and 26 deletions

View File

@@ -8,6 +8,7 @@ import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { FolderService } from 'jslib/abstractions/folder.service';
import { SearchService } from 'jslib/abstractions/search.service';
import { TokenService } from 'jslib/abstractions/token.service';
import { TotpService } from 'jslib/abstractions/totp.service';
import { UserService } from 'jslib/abstractions/user.service';
@@ -43,7 +44,8 @@ export class GetCommand {
constructor(private cipherService: CipherService, private folderService: FolderService,
private collectionService: CollectionService, private totpService: TotpService,
private auditService: AuditService, private cryptoService: CryptoService,
private tokenService: TokenService, private userService: UserService) { }
private tokenService: TokenService, private userService: UserService,
private searchService: SearchService) { }
async run(object: string, id: string, cmd: program.Command): Promise<Response> {
if (id != null) {
@@ -87,7 +89,7 @@ export class GetCommand {
}
} else if (id.trim() !== '') {
let ciphers = await this.cipherService.getAllDecrypted();
ciphers = CliUtils.searchCiphers(ciphers, id);
ciphers = this.searchService.searchCiphersBasic(ciphers, id);
if (ciphers.length > 1) {
return Response.multipleResults(ciphers.map((c) => c.id));
}

View File

@@ -3,6 +3,7 @@ import * as program from 'commander';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { FolderService } from 'jslib/abstractions/folder.service';
import { SearchService } from 'jslib/abstractions/search.service';
import { UserService } from 'jslib/abstractions/user.service';
import { Response } from '../models/response';
@@ -16,7 +17,8 @@ import { CliUtils } from '../utils';
export class ListCommand {
constructor(private cipherService: CipherService, private folderService: FolderService,
private collectionService: CollectionService, private userService: UserService) { }
private collectionService: CollectionService, private userService: UserService,
private searchService: SearchService) { }
async run(object: string, cmd: program.Command): Promise<Response> {
switch (object.toLowerCase()) {
@@ -75,7 +77,7 @@ export class ListCommand {
}
if (cmd.search != null && cmd.search.trim() !== '') {
ciphers = CliUtils.searchCiphers(ciphers, cmd.search);
ciphers = this.searchService.searchCiphersBasic(ciphers, cmd.search);
}
const res = new ListResponse(ciphers.map((o) => new CipherResponse(o)));