From 6e49c481f0c746c4daa3d9460fbc1949f56d8ae0 Mon Sep 17 00:00:00 2001 From: addison Date: Wed, 3 Feb 2021 16:24:49 -0500 Subject: [PATCH] Send layout & search --- jslib | 2 +- src/app/app-routing.module.ts | 6 + src/app/app.module.ts | 11 +- src/app/send/access.component.html | 7 + src/app/send/access.component.ts | 14 ++ src/app/send/add-edit.component.html | 7 + src/app/send/add-edit.component.ts | 26 ++++ src/app/send/send.component.html | 80 +++++++++++ src/app/send/send.component.ts | 126 +++++++++++++++++ src/app/vault/groupings.component.html | 179 +++++++++++++------------ src/app/vault/vault.component.html | 12 +- src/locales/en/messages.json | 13 ++ src/scss/buttons.scss | 12 +- src/scss/environment.scss | 6 +- src/scss/vault.scss | 18 ++- 15 files changed, 413 insertions(+), 106 deletions(-) create mode 100644 src/app/send/access.component.html create mode 100644 src/app/send/access.component.ts create mode 100644 src/app/send/add-edit.component.html create mode 100644 src/app/send/add-edit.component.ts create mode 100644 src/app/send/send.component.html create mode 100644 src/app/send/send.component.ts diff --git a/jslib b/jslib index d1c46e6bdc..a16d8f7de7 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit d1c46e6bdc9332bcf47acbd235c3a6278e086d8a +Subproject commit a16d8f7de7abe63532bcf7452cb7517f9174189a diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 8a22dcfdab..33b430fb03 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -15,6 +15,7 @@ import { SsoComponent } from './accounts/sso.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; import { VaultComponent } from './vault/vault.component'; +import { SendComponent } from './send/send.component'; const routes: Routes = [ { path: '', redirectTo: '/vault', pathMatch: 'full' }, @@ -30,6 +31,11 @@ const routes: Routes = [ { path: 'hint', component: HintComponent }, { path: 'set-password', component: SetPasswordComponent }, { path: 'sso', component: SsoComponent }, + { + path: 'send', + component: SendComponent, + canActivate: [AuthGuardService], + }, ]; @NgModule({ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 17854135e9..491786da50 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -10,6 +10,7 @@ import { AppRoutingModule } from './app-routing.module'; import { ServicesModule } from './services.module'; import { DragDropModule } from '@angular/cdk/drag-drop'; +import { DatePipe } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; @@ -62,6 +63,10 @@ import { ShareComponent } from './vault/share.component'; import { VaultComponent } from './vault/vault.component'; import { ViewComponent } from './vault/view.component'; +import { AccessComponent } from './send/access.component'; +import { AddEditComponent as SendAddEditComponent } from './send/add-edit.component'; +import { SendComponent } from './send/send.component'; + import { registerLocaleData } from '@angular/common'; import localeBe from '@angular/common/locales/be'; import localeBg from '@angular/common/locales/bg'; @@ -155,6 +160,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); ], declarations: [ A11yTitleDirective, + AccessComponent, AddEditComponent, ApiActionDirective, AppComponent, @@ -184,6 +190,8 @@ registerLocaleData(localeZhTw, 'zh-TW'); RegisterComponent, SearchCiphersPipe, SelectCopyDirective, + SendAddEditComponent, + SendComponent, SetPasswordComponent, SettingsComponent, ShareComponent, @@ -209,9 +217,10 @@ registerLocaleData(localeZhTw, 'zh-TW'); PremiumComponent, SettingsComponent, ShareComponent, + SendAddEditComponent, TwoFactorOptionsComponent, ], - providers: [], + providers: [DatePipe], bootstrap: [AppComponent], }) export class AppModule { } diff --git a/src/app/send/access.component.html b/src/app/send/access.component.html new file mode 100644 index 0000000000..2f45085ea4 --- /dev/null +++ b/src/app/send/access.component.html @@ -0,0 +1,7 @@ +
+
+
+

Under construction

+
+
+
diff --git a/src/app/send/access.component.ts b/src/app/send/access.component.ts new file mode 100644 index 0000000000..923fc5080a --- /dev/null +++ b/src/app/send/access.component.ts @@ -0,0 +1,14 @@ +import { + Component, + OnInit, +} from '@angular/core'; + +@Component({ + selector: 'app-send-access', + templateUrl: 'access.component.html', +}) +export class AccessComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} diff --git a/src/app/send/add-edit.component.html b/src/app/send/add-edit.component.html new file mode 100644 index 0000000000..2f45085ea4 --- /dev/null +++ b/src/app/send/add-edit.component.html @@ -0,0 +1,7 @@ +
+
+
+

Under construction

+
+
+
diff --git a/src/app/send/add-edit.component.ts b/src/app/send/add-edit.component.ts new file mode 100644 index 0000000000..bbffa41ba4 --- /dev/null +++ b/src/app/send/add-edit.component.ts @@ -0,0 +1,26 @@ +import { DatePipe } from '@angular/common'; + +import { Component } from '@angular/core'; + +import { EnvironmentService } from 'jslib/abstractions/environment.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { SendService } from 'jslib/abstractions/send.service'; +import { UserService } from 'jslib/abstractions/user.service'; + +import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/send/add-edit.component'; + +@Component({ + selector: 'app-send-add-edit', + templateUrl: 'add-edit.component.html', +}) +export class AddEditComponent extends BaseAddEditComponent { + constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService, + environmentService: EnvironmentService, datePipe: DatePipe, + sendService: SendService, userService: UserService, + messagingService: MessagingService) { + super(i18nService, platformUtilsService, environmentService, + datePipe, sendService, userService, messagingService); + } +} diff --git a/src/app/send/send.component.html b/src/app/send/send.component.html new file mode 100644 index 0000000000..327e9e5b83 --- /dev/null +++ b/src/app/send/send.component.html @@ -0,0 +1,80 @@ +
+
+
+
+
+
+

{{'filters' | i18n}}

+ +

{{'types' | i18n}}

+ +
+
+ +
+
+
+
+
+ +
+ +
+ + + +

{{'noItemsInList' | i18n}}

+
+
+
+ +
+ + +
diff --git a/src/app/send/send.component.ts b/src/app/send/send.component.ts new file mode 100644 index 0000000000..49f54937d1 --- /dev/null +++ b/src/app/send/send.component.ts @@ -0,0 +1,126 @@ +import { + Component, + NgZone, + OnInit, +} from '@angular/core'; + +import { + ActivatedRoute , + Router, +} from '@angular/router'; + +import { EnvironmentService } from 'jslib/abstractions/environment.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { SearchService } from 'jslib/abstractions/search.service'; +import { SendService } from 'jslib/abstractions/send.service'; + +import { ModalComponent } from 'jslib/angular/components/modal.component'; +import { SendComponent as BaseSendComponent } from 'jslib/angular/components/send/send.component'; + +import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; + +import { SendType } from 'jslib/enums/sendType'; +import { SendView } from 'jslib/models/view/sendView'; + +enum Action { + None = '', + Add = 'add', + Edit = 'edit', + View = 'view', +} + +@Component({ + selector: 'app-send', + templateUrl: 'send.component.html', +}) +export class SendComponent extends BaseSendComponent implements OnInit { + sendId: string; + modal: ModalComponent = null; + action: Action = Action.None; + + constructor(sendService: SendService, i18nService: I18nService, + platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService, + broadcasterService: BroadcasterService, ngZone: NgZone, + private router: Router, private route: ActivatedRoute, searchService: SearchService) { + super(sendService, i18nService, platformUtilsService, + environmentService, broadcasterService, ngZone, searchService); + } + + async load(filter: (send: SendView) => boolean = null) { + this.loading = true; + this.sends = await this.sendService.getAllDecrypted(); + + this.route.queryParams.subscribe(async (params) => { + if (params == null) { + this.selectedAll = true; + await this.reload(); + } else { + const sendView = new SendView(); + if (params.sendId) { + sendView.id = params.sendId; + if (params.action === 'edit') { + this.editSend(sendView); + } else if (params.action === 'view') { + // TODO: this + // this.viewSend(sendView); + } + } else if (params.action === 'add') { + this.addSend(); + } else { + if (params.files) { + sendView.type = SendType.File; + this.filter = (s) => { + return filter(s) && s.text != null; + }; + this.filter(sendView); + } else if (params.text) { + sendView.type = SendType.Text; + this.filter = (s) => { + return filter(s) && s.file != null; + }; + this.filter(sendView); + } else { + this.selectAll(); + } + } + } + }); + + this.loading = false; + this.loaded = true; + } + + addSend() { + if (this.action === Action.Add) { + return; + } + + this.action = Action.Add; + this.sendId = null; + this.go(); + } + + editSend(send: SendView) { + if (this.action === Action.Edit && this.sendId === send.id) { + return; + } + this.action = Action.Edit; + this.sendId = send.id; + this.go(); + } + + private go(queryParams: any = null) { + if (queryParams == null) { + queryParams = { + id: this.sendId, + action: this.action, + }; + } + this.router.navigate([], { + relativeTo: this.route, + queryParams: queryParams, + replaceUrl: true, + }); + } +} diff --git a/src/app/vault/groupings.component.html b/src/app/vault/groupings.component.html index 75c88863f6..f177c11adb 100644 --- a/src/app/vault/groupings.component.html +++ b/src/app/vault/groupings.component.html @@ -1,101 +1,106 @@
-

{{'filters' | i18n}}

- -

{{'types' | i18n}}

- -

{{'loading' | i18n}}

- -
-

{{'folders' | i18n}}

- -
+
+

{{'filters' | i18n}}

-
-

{{'collections' | i18n}}

+

{{'types' | i18n}}

+ +

{{'loading' | i18n}}

+ +
+

{{'folders' | i18n}}

+ +
- +
+

{{'collections' | i18n}}

+ +
+ +
+
+ +
diff --git a/src/app/vault/vault.component.html b/src/app/vault/vault.component.html index 93938ac95f..e6740c1dea 100644 --- a/src/app/vault/vault.component.html +++ b/src/app/vault/vault.component.html @@ -1,19 +1,19 @@ -
- + - - - -