From a89cf28812e60b86406cdeebb8279ee062663da2 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 6 Jun 2018 17:25:57 -0400 Subject: [PATCH] get vault working --- package-lock.json | 6 + package.json | 1 + src/app/app.module.ts | 15 +- src/app/modal.component.ts | 62 ++++ src/app/vault/add-edit.component.html | 309 +++++++++++++++++++ src/app/vault/add-edit.component.ts | 34 ++ src/app/vault/attachments.component.html | 50 +++ src/app/vault/attachments.component.ts | 26 ++ src/app/vault/ciphers.component.html | 43 +++ src/app/vault/ciphers.component.ts | 15 + src/app/vault/folder-add-edit.component.html | 35 +++ src/app/vault/folder-add-edit.component.ts | 24 ++ src/app/vault/groupings.component.html | 72 +++++ src/app/vault/groupings.component.ts | 16 + src/app/vault/vault.component.html | 159 ++-------- src/app/vault/vault.component.ts | 203 +++++++++++- src/scss/styles.scss | 23 +- src/services/webStorage.service.ts | 18 +- 18 files changed, 960 insertions(+), 151 deletions(-) create mode 100644 src/app/modal.component.ts create mode 100644 src/app/vault/add-edit.component.html create mode 100644 src/app/vault/add-edit.component.ts create mode 100644 src/app/vault/attachments.component.html create mode 100644 src/app/vault/attachments.component.ts create mode 100644 src/app/vault/ciphers.component.html create mode 100644 src/app/vault/ciphers.component.ts create mode 100644 src/app/vault/folder-add-edit.component.html create mode 100644 src/app/vault/folder-add-edit.component.ts create mode 100644 src/app/vault/groupings.component.html create mode 100644 src/app/vault/groupings.component.ts diff --git a/package-lock.json b/package-lock.json index bac478103f..85f3155a8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -165,6 +165,12 @@ "debug": "2.6.9" } }, + "@types/jquery": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.2.tgz", + "integrity": "sha512-ByZwKSEqteAta4VrIalqGJZmMq9lWPD3H3f5Xs6RR8B7zQRDPGUtjoKBYNtKTz/7LgBEQMdlxVbbjQfUaEIItA==", + "dev": true + }, "@types/lunr": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.1.5.tgz", diff --git a/package.json b/package.json index 1c85e2bfe1..7f9c5c67fa 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "devDependencies": { "@angular/compiler-cli": "5.2.0", "@ngtools/webpack": "1.10.2", + "@types/jquery": "^3.3.2", "@types/lunr": "2.1.5", "@types/node": "8.0.19", "@types/node-forge": "0.6.10", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 92bbea4934..31021126fd 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -15,6 +15,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ServicesModule } from './services.module'; import { AppComponent } from './app.component'; +import { ModalComponent } from './modal.component'; import { HintComponent } from './accounts/hint.component'; import { LoginComponent } from './accounts/login.component'; @@ -22,6 +23,10 @@ import { RegisterComponent } from './accounts/register.component'; import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; +import { AttachmentsComponent } from './vault/attachments.component'; +import { CiphersComponent } from './vault/ciphers.component'; +import { FolderAddEditComponent } from './vault/folder-add-edit.component'; +import { GroupingsComponent } from './vault/groupings.component'; import { VaultComponent } from './vault/vault.component'; import { IconComponent } from 'jslib/angular/components/icon.component'; @@ -37,6 +42,7 @@ import { StopPropDirective } from 'jslib/angular/directives/stop-prop.directive' import { I18nPipe } from 'jslib/angular/pipes/i18n.pipe'; import { SearchCiphersPipe } from 'jslib/angular/pipes/search-ciphers.pipe'; +import { Folder } from 'jslib/models/domain'; @NgModule({ imports: [ @@ -55,15 +61,20 @@ import { SearchCiphersPipe } from 'jslib/angular/pipes/search-ciphers.pipe'; declarations: [ ApiActionDirective, AppComponent, + AttachmentsComponent, AutofocusDirective, BlurClickDirective, BoxRowDirective, + CiphersComponent, FallbackSrcDirective, + FolderAddEditComponent, + GroupingsComponent, HintComponent, IconComponent, I18nPipe, InputVerbatimDirective, LoginComponent, + ModalComponent, RegisterComponent, SearchCiphersPipe, StopClickDirective, @@ -73,7 +84,9 @@ import { SearchCiphersPipe } from 'jslib/angular/pipes/search-ciphers.pipe'; VaultComponent, ], entryComponents: [ - + AttachmentsComponent, + FolderAddEditComponent, + ModalComponent, ], providers: [], bootstrap: [AppComponent], diff --git a/src/app/modal.component.ts b/src/app/modal.component.ts new file mode 100644 index 0000000000..51d040ad0a --- /dev/null +++ b/src/app/modal.component.ts @@ -0,0 +1,62 @@ +import * as jq from 'jquery'; + +import { + Component, + ComponentFactoryResolver, + Type, + ViewContainerRef, +} from '@angular/core'; + +import { ModalComponent as BaseModalComponent } from 'jslib/angular/components/modal.component'; + +@Component({ + selector: 'app-modal', + template: ``, +}) +export class ModalComponent extends BaseModalComponent { + el: any = null; + + constructor(componentFactoryResolver: ComponentFactoryResolver) { + super(componentFactoryResolver); + } + + ngOnDestroy() { /* Nothing */ } + + show(type: Type, parentContainer: ViewContainerRef, fade: boolean = true): T { + this.parentContainer = parentContainer; + this.fade = fade; + + const factory = this.componentFactoryResolver.resolveComponentFactory(type); + const componentRef = this.container.createComponent(factory); + + const modals = Array.from(document.querySelectorAll('.modal')); + if (modals.length > 0) { + this.el = jq(modals[0]); + this.el.modal('show'); + + this.el.on('show.bs.modal', () => { + this.onShow.emit(); + }); + this.el.on('shown.bs.modal', () => { + this.onShown.emit(); + }); + this.el.on('hide.bs.modal', () => { + this.onClose.emit(); + }); + this.el.on('hidden.bs.modal', () => { + this.onClosed.emit(); + if (this.parentContainer != null) { + this.parentContainer.clear(); + } + }); + } + + return componentRef.instance; + } + + close() { + if (this.el != null) { + this.el.modal('hide'); + } + } +} diff --git a/src/app/vault/add-edit.component.html b/src/app/vault/add-edit.component.html new file mode 100644 index 0000000000..4a619fb88d --- /dev/null +++ b/src/app/vault/add-edit.component.html @@ -0,0 +1,309 @@ +
+
+
+
+
+ {{title}} +
+
+
+ + +
+
+ + +
+ +
+
+ + +
+
+
+ + +
+
+ + + + + + + +
+
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+ + + +
+ + + + +
+
+ + + +
+
+
+ + {{'newUri' | i18n}} + +
+
+
+
+
+ + +
+
+ + +
+ +
{{'attachments' | i18n}}
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+ {{'customFields' | i18n}} +
+
+ +
+ + + + + +
+ + + +
+ +
+ + + +
+
+
+
+ + {{'newCustomField' | i18n}} + + + +
+
+
+
+
+ +
diff --git a/src/app/vault/add-edit.component.ts b/src/app/vault/add-edit.component.ts new file mode 100644 index 0000000000..132f94d269 --- /dev/null +++ b/src/app/vault/add-edit.component.ts @@ -0,0 +1,34 @@ +import { + Component, + OnChanges, +} from '@angular/core'; + +import { ToasterService } from 'angular2-toaster'; +import { Angulartics2 } from 'angulartics2'; + +import { AuditService } from 'jslib/abstractions/audit.service'; +import { CipherService } from 'jslib/abstractions/cipher.service'; +import { FolderService } from 'jslib/abstractions/folder.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { StateService } from 'jslib/abstractions/state.service'; + +import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/add-edit.component'; + +@Component({ + selector: 'app-vault-add-edit', + templateUrl: 'add-edit.component.html', +}) +export class AddEditComponent extends BaseAddEditComponent implements OnChanges { + constructor(cipherService: CipherService, folderService: FolderService, + i18nService: I18nService, platformUtilsService: PlatformUtilsService, + analytics: Angulartics2, toasterService: ToasterService, + auditService: AuditService, stateService: StateService) { + super(cipherService, folderService, i18nService, platformUtilsService, analytics, + toasterService, auditService, stateService); + } + + async ngOnChanges() { + await super.load(); + } +} diff --git a/src/app/vault/attachments.component.html b/src/app/vault/attachments.component.html new file mode 100644 index 0000000000..86394e8654 --- /dev/null +++ b/src/app/vault/attachments.component.html @@ -0,0 +1,50 @@ + diff --git a/src/app/vault/attachments.component.ts b/src/app/vault/attachments.component.ts new file mode 100644 index 0000000000..279b162326 --- /dev/null +++ b/src/app/vault/attachments.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; + +import { ToasterService } from 'angular2-toaster'; +import { Angulartics2 } from 'angulartics2'; + +import { CipherService } from 'jslib/abstractions/cipher.service'; +import { CryptoService } from 'jslib/abstractions/crypto.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { TokenService } from 'jslib/abstractions/token.service'; + +import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/components/attachments.component'; + +@Component({ + selector: 'app-vault-attachments', + templateUrl: 'attachments.component.html', +}) +export class AttachmentsComponent extends BaseAttachmentsComponent { + constructor(cipherService: CipherService, analytics: Angulartics2, + toasterService: ToasterService, i18nService: I18nService, + cryptoService: CryptoService, tokenService: TokenService, + platformUtilsService: PlatformUtilsService) { + super(cipherService, analytics, toasterService, i18nService, cryptoService, tokenService, + platformUtilsService); + } +} diff --git a/src/app/vault/ciphers.component.html b/src/app/vault/ciphers.component.html new file mode 100644 index 0000000000..734ebaf183 --- /dev/null +++ b/src/app/vault/ciphers.component.html @@ -0,0 +1,43 @@ + + + + + + + + + + +
+ + + + + + + + {{c.name}} + + + + {{c.subTitle}} +
+
+ + + +

{{'noItemsInList' | i18n}}

+ +
+
+
diff --git a/src/app/vault/ciphers.component.ts b/src/app/vault/ciphers.component.ts new file mode 100644 index 0000000000..83bf1eef90 --- /dev/null +++ b/src/app/vault/ciphers.component.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; + +import { CipherService } from 'jslib/abstractions/cipher.service'; + +import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component'; + +@Component({ + selector: 'app-vault-ciphers', + templateUrl: 'ciphers.component.html', +}) +export class CiphersComponent extends BaseCiphersComponent { + constructor(cipherService: CipherService) { + super(cipherService); + } +} diff --git a/src/app/vault/folder-add-edit.component.html b/src/app/vault/folder-add-edit.component.html new file mode 100644 index 0000000000..b6dce984f7 --- /dev/null +++ b/src/app/vault/folder-add-edit.component.html @@ -0,0 +1,35 @@ + diff --git a/src/app/vault/folder-add-edit.component.ts b/src/app/vault/folder-add-edit.component.ts new file mode 100644 index 0000000000..685a8d09c5 --- /dev/null +++ b/src/app/vault/folder-add-edit.component.ts @@ -0,0 +1,24 @@ +import { Component } from '@angular/core'; + +import { ToasterService } from 'angular2-toaster'; +import { Angulartics2 } from 'angulartics2'; + +import { FolderService } from 'jslib/abstractions/folder.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; + +import { + FolderAddEditComponent as BaseFolderAddEditComponent, +} from 'jslib/angular/components/folder-add-edit.component'; + +@Component({ + selector: 'app-folder-add-edit', + templateUrl: 'folder-add-edit.component.html', +}) +export class FolderAddEditComponent extends BaseFolderAddEditComponent { + constructor(folderService: FolderService, i18nService: I18nService, + analytics: Angulartics2, toasterService: ToasterService, + platformUtilsService: PlatformUtilsService) { + super(folderService, i18nService, analytics, toasterService, platformUtilsService); + } +} diff --git a/src/app/vault/groupings.component.html b/src/app/vault/groupings.component.html new file mode 100644 index 0000000000..5fbc44ff9a --- /dev/null +++ b/src/app/vault/groupings.component.html @@ -0,0 +1,72 @@ +
+
+ Filters +
+
+ + +

Types

+ +

Loading...

+ +

+ Folders + +

+ +
+

Collections

+ +
+
+
+
diff --git a/src/app/vault/groupings.component.ts b/src/app/vault/groupings.component.ts new file mode 100644 index 0000000000..d3ce89619f --- /dev/null +++ b/src/app/vault/groupings.component.ts @@ -0,0 +1,16 @@ +import { Component } from '@angular/core'; + +import { CollectionService } from 'jslib/abstractions/collection.service'; +import { FolderService } from 'jslib/abstractions/folder.service'; + +import { GroupingsComponent as BaseGroupingsComponent } from 'jslib/angular/components/groupings.component'; + +@Component({ + selector: 'app-vault-groupings', + templateUrl: 'groupings.component.html', +}) +export class GroupingsComponent extends BaseGroupingsComponent { + constructor(collectionService: CollectionService, folderService: FolderService) { + super(collectionService, folderService); + } +} diff --git a/src/app/vault/vault.component.html b/src/app/vault/vault.component.html index 22e4d63ef4..6b34d8d6fe 100644 --- a/src/app/vault/vault.component.html +++ b/src/app/vault/vault.component.html @@ -11,16 +11,6 @@ -