1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-30 12:54:31 +01:00

implement search service

This commit is contained in:
Kyle Spearrin 2018-08-13 09:43:46 -04:00
parent d4d57064a7
commit a9067f5618
6 changed files with 29 additions and 35 deletions

2
jslib

@ -1 +1 @@
Subproject commit 4ca7a9709e9ccd0e67ce09309ae605f2057bf089
Subproject commit b724448081a0962d3c3894319502ed380fe40145

35
package-lock.json generated
View File

@ -142,9 +142,9 @@
}
},
"@types/lunr": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.1.5.tgz",
"integrity": "sha512-esk3CG25hRtHsVHm+LOjiSFYdw8be3uIY653WUwR43Bro914HSimPgPpqgajkhTJ0awK3RQfaIxP7zvbtCpcyg==",
"version": "2.1.6",
"resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.1.6.tgz",
"integrity": "sha512-Bz6fUhX1llTa7ygQJN3ttoVkkrpW7xxSEP7D7OYFO/FCBKqKqruRUZtJzTtYA0GkQX13lxU5u+8LuCviJlAXkQ==",
"dev": true
},
"@types/node": {
@ -4125,14 +4125,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -4147,20 +4145,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@ -4277,8 +4272,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@ -4290,7 +4284,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -4305,7 +4298,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -4424,8 +4416,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@ -4437,7 +4428,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -4559,7 +4549,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -6544,9 +6533,9 @@
}
},
"lunr": {
"version": "2.1.6",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.1.6.tgz",
"integrity": "sha512-ydJpB8CX8cZ/VE+KMaYaFcZ6+o2LruM6NG76VXdflYTgluvVemz1lW4anE+pyBbLvxJHZdvD1Jy/fOqdzAEJog=="
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.1.tgz",
"integrity": "sha1-ETYWorYC3cEJMqe/ik5uV+v+zfI="
},
"magic-string": {
"version": "0.22.5",

View File

@ -192,7 +192,7 @@
"@angular/compiler-cli": "5.2.0",
"@ngtools/webpack": "1.10.2",
"@types/lowdb": "^1.0.1",
"@types/lunr": "2.1.5",
"@types/lunr": "^2.1.6",
"@types/node": "8.0.19",
"@types/node-forge": "0.7.1",
"@types/papaparse": "4.1.31",
@ -246,7 +246,7 @@
"electron-updater": "3.0.3",
"keytar": "4.2.1",
"lowdb": "1.0.0",
"lunr": "2.1.6",
"lunr": "2.3.1",
"node-forge": "0.7.1",
"nord": "0.2.1",
"papaparse": "4.3.5",

View File

@ -37,6 +37,7 @@ import { FolderService } from 'jslib/services/folder.service';
import { LockService } from 'jslib/services/lock.service';
import { LowdbStorageService } from 'jslib/services/lowdbStorage.service';
import { PasswordGenerationService } from 'jslib/services/passwordGeneration.service';
import { SearchService } from 'jslib/services/search.service';
import { SettingsService } from 'jslib/services/settings.service';
import { StateService } from 'jslib/services/state.service';
import { SyncService } from 'jslib/services/sync.service';
@ -64,6 +65,7 @@ import {
PasswordGenerationService as PasswordGenerationServiceAbstraction,
} from 'jslib/abstractions/passwordGeneration.service';
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from 'jslib/abstractions/platformUtils.service';
import { SearchService as SearchServiceAbstraction } from 'jslib/abstractions/search.service';
import { SettingsService as SettingsServiceAbstraction } from 'jslib/abstractions/settings.service';
import { StateService as StateServiceAbstraction } from 'jslib/abstractions/state.service';
import { StorageService as StorageServiceAbstraction } from 'jslib/abstractions/storage.service';
@ -90,13 +92,15 @@ const apiService = new ApiService(tokenService, platformUtilsService,
const environmentService = new EnvironmentService(apiService, storageService);
const userService = new UserService(tokenService, storageService);
const settingsService = new SettingsService(userService, storageService);
export let searchService: SearchService = null;
const cipherService = new CipherService(cryptoService, userService, settingsService,
apiService, storageService, i18nService, platformUtilsService);
apiService, storageService, i18nService, platformUtilsService, () => searchService);
const folderService = new FolderService(cryptoService, userService, apiService, storageService,
i18nService, cipherService);
const collectionService = new CollectionService(cryptoService, userService, storageService, i18nService);
const lockService = new LockService(cipherService, folderService, collectionService,
cryptoService, platformUtilsService, storageService, messagingService, null);
searchService = new SearchService(cipherService, platformUtilsService);
const syncService = new SyncService(userService, apiService, settingsService,
folderService, cipherService, cryptoService, collectionService, storageService, messagingService,
async (expired: boolean) => messagingService.send('logout', { expired: expired }));
@ -181,6 +185,7 @@ export function initFactory(): Function {
{ provide: StateServiceAbstraction, useValue: stateService },
{ provide: LogServiceAbstraction, useValue: logService },
{ provide: ExportServiceAbstraction, useValue: exportService },
{ provide: SearchServiceAbstraction, useValue: searchService },
{
provide: APP_INITIALIZER,
useFactory: initFactory,

View File

@ -1,14 +1,14 @@
<div class="header header-search">
<div class="search">
<input type="search" placeholder="{{searchPlaceholder || ('searchVault' | i18n)}}" id="search"
[(ngModel)]="searchText" appAutofocus>
[(ngModel)]="searchText" (ngModelChange)="search(200)" appAutofocus>
<i class="fa fa-search"></i>
</div>
</div>
<div class="content">
<ng-container *ngIf="(ciphers | searchCiphers: searchText) as searchedCiphers">
<div class="list" *ngIf="searchedCiphers.length > 0">
<a *ngFor="let c of searchedCiphers" appStopClick (click)="selectCipher(c)"
<ng-container *ngIf="ciphers">
<div class="list" *ngIf="ciphers.length > 0">
<a *ngFor="let c of ciphers" appStopClick (click)="selectCipher(c)"
(contextmenu)="rightClickCipher(c)" href="#" title="{{'viewItem' | i18n}}"
[ngClass]="{'active': c.id === activeCipherId}">
<app-vault-icon [cipher]="c"></app-vault-icon>
@ -22,7 +22,7 @@
<span class="detail">{{c.subTitle}}</span>
</a>
</div>
<div class="no-items" *ngIf="searchedCiphers.length === 0">
<div class="no-items" *ngIf="ciphers.length === 0">
<i class="fa fa-spinner fa-spin fa-3x" *ngIf="!loaded"></i>
<ng-container *ngIf="loaded">
<i class="fa fa-frown-o fa-4x"></i>

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { SearchService } from 'jslib/abstractions/search.service';
import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component';
@ -9,7 +9,7 @@ import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/componen
templateUrl: 'ciphers.component.html',
})
export class CiphersComponent extends BaseCiphersComponent {
constructor(cipherService: CipherService) {
super(cipherService);
constructor(searchService: SearchService) {
super(searchService);
}
}