From ba3b2fbed18e5ed99af2c647ef5ed5feede6e6e6 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 5 Jul 2018 14:40:53 -0400 Subject: [PATCH] exporting organization data --- jslib | 2 +- src/app/app-routing.module.ts | 16 ++++++- src/app/app.module.ts | 5 +++ .../organizations/tools/export.component.ts | 43 +++++++++++++++++++ .../organizations/tools/tools.component.html | 20 +++++++++ .../organizations/tools/tools.component.ts | 9 ++++ src/app/services/services.module.ts | 2 +- src/app/tools/export.component.html | 7 +-- 8 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 src/app/organizations/tools/export.component.ts create mode 100644 src/app/organizations/tools/tools.component.html create mode 100644 src/app/organizations/tools/tools.component.ts diff --git a/jslib b/jslib index 47ab71e730..87e273252b 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 47ab71e73098d1b83a1bdcbae3cd3e2b1d9ccacc +Subproject commit 87e273252be42dab90d9a33857fe7755f378338b diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 58cad9016e..d56cef6918 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -14,7 +14,10 @@ import { LoginComponent } from './accounts/login.component'; import { RegisterComponent } from './accounts/register.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; -import { VaultComponent as OrganizationVaultComponent } from './organizations/vault/vault.component'; +import { ExportComponent as OrgExportComponent } from './organizations/tools/export.component'; +import { ToolsComponent as OrgToolsComponent } from './organizations/tools/tools.component'; + +import { VaultComponent as OrgVaultComponent } from './organizations/vault/vault.component'; import { AccountComponent } from './settings/account.component'; import { CreateOrganizationComponent } from './settings/create-organization.component'; @@ -92,7 +95,16 @@ const routes: Routes = [ component: OrganizationLayoutComponent, children: [ { path: '', pathMatch: 'full', redirectTo: 'vault' }, - { path: 'vault', component: OrganizationVaultComponent, canActivate: [AuthGuardService] }, + { path: 'vault', component: OrgVaultComponent, canActivate: [AuthGuardService] }, + { + path: 'tools', + component: OrgToolsComponent, + children: [ + { path: '', pathMatch: 'full', redirectTo: 'export' }, + // { path: 'import', component: ImportComponent, canActivate: [AuthGuardService] }, + { path: 'export', component: OrgExportComponent, canActivate: [AuthGuardService] }, + ], + }, ], }, { path: '**', redirectTo: '' }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8f98a9eafb..51c28cb4bc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -32,6 +32,9 @@ import { RegisterComponent } from './accounts/register.component'; import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; +import { ExportComponent as OrgExportComponent } from './organizations/tools/export.component'; +import { ToolsComponent as OrgToolsComponent } from './organizations/tools/tools.component'; + import { AddEditComponent as OrgAddEditComponent } from './organizations/vault/add-edit.component'; import { AttachmentsComponent as OrgAttachmentsComponent } from './organizations/vault/attachments.component'; import { CiphersComponent as OrgCiphersComponent } from './organizations/vault/ciphers.component'; @@ -159,7 +162,9 @@ import { SearchCiphersPipe } from 'jslib/angular/pipes/search-ciphers.pipe'; OrgAttachmentsComponent, OrgCiphersComponent, OrgCollectionsComponent, + OrgExportComponent, OrgGroupingsComponent, + OrgToolsComponent, OrganizationsComponent, OrganizationLayoutComponent, OrgVaultComponent, diff --git a/src/app/organizations/tools/export.component.ts b/src/app/organizations/tools/export.component.ts new file mode 100644 index 0000000000..f55910af6e --- /dev/null +++ b/src/app/organizations/tools/export.component.ts @@ -0,0 +1,43 @@ +import { ToasterService } from 'angular2-toaster'; +import { Angulartics2 } from 'angulartics2'; + +import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { CryptoService } from 'jslib/abstractions/crypto.service'; +import { ExportService } from 'jslib/abstractions/export.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { UserService } from 'jslib/abstractions/user.service'; + +import { ExportComponent as BaseExportComponent } from '../../tools/export.component'; + +@Component({ + selector: 'app-org-export', + templateUrl: '../../tools/export.component.html', +}) +export class ExportComponent extends BaseExportComponent { + organizationId: string; + + constructor(analytics: Angulartics2, toasterService: ToasterService, + cryptoService: CryptoService, userService: UserService, + i18nService: I18nService, platformUtilsService: PlatformUtilsService, + exportService: ExportService, private route: ActivatedRoute, ) { + super(analytics, toasterService, cryptoService, userService, i18nService, platformUtilsService, + exportService); + } + + ngOnInit() { + this.route.parent.parent.params.subscribe(async (params) => { + this.organizationId = params.organizationId; + }); + } + + getExportData() { + return this.exportService.getOrganizationExport(this.organizationId, 'csv'); + } + + getFileName() { + return super.getFileName('org'); + } +} diff --git a/src/app/organizations/tools/tools.component.html b/src/app/organizations/tools/tools.component.html new file mode 100644 index 0000000000..72b7e77188 --- /dev/null +++ b/src/app/organizations/tools/tools.component.html @@ -0,0 +1,20 @@ +
+
+ +
+ +
+
+
diff --git a/src/app/organizations/tools/tools.component.ts b/src/app/organizations/tools/tools.component.ts new file mode 100644 index 0000000000..7b82b70f26 --- /dev/null +++ b/src/app/organizations/tools/tools.component.ts @@ -0,0 +1,9 @@ +import { + Component, +} from '@angular/core'; + +@Component({ + selector: 'app-org-tools', + templateUrl: 'tools.component.html', +}) +export class ToolsComponent { } diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index 83d0a9e766..c178772865 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -102,7 +102,7 @@ const totpService = new TotpService(storageService, cryptoFunctionService); const containerService = new ContainerService(cryptoService, platformUtilsService); const authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService, i18nService, platformUtilsService, messagingService); -const exportService = new ExportService(folderService, cipherService); +const exportService = new ExportService(folderService, cipherService, apiService); const auditService = new AuditService(cryptoFunctionService); const analytics = new Analytics(window, () => platformUtilsService.isDev(), diff --git a/src/app/tools/export.component.html b/src/app/tools/export.component.html index f54af725d0..a5f0319021 100644 --- a/src/app/tools/export.component.html +++ b/src/app/tools/export.component.html @@ -1,4 +1,4 @@ -
+ @@ -10,7 +10,8 @@ -