mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-19 02:51:14 +02:00
inherit local base for groupings and ciphers
This commit is contained in:
parent
f578ebe4ef
commit
f089b5e3d1
@ -1,9 +1,4 @@
|
|||||||
import {
|
import { Component } from '@angular/core';
|
||||||
Component,
|
|
||||||
EventEmitter,
|
|
||||||
Input,
|
|
||||||
Output,
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
import { ToasterService } from 'angular2-toaster';
|
||||||
import { Angulartics2 } from 'angulartics2';
|
import { Angulartics2 } from 'angulartics2';
|
||||||
@ -13,31 +8,24 @@ import { CipherService } from 'jslib/abstractions/cipher.service';
|
|||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
|
||||||
import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component';
|
|
||||||
|
|
||||||
import { CipherType } from 'jslib/enums/cipherType';
|
|
||||||
|
|
||||||
import { CipherData } from 'jslib/models/data/cipherData';
|
import { CipherData } from 'jslib/models/data/cipherData';
|
||||||
import { Cipher } from 'jslib/models/domain/cipher';
|
import { Cipher } from 'jslib/models/domain/cipher';
|
||||||
import { Organization } from 'jslib/models/domain/organization';
|
import { Organization } from 'jslib/models/domain/organization';
|
||||||
import { CipherView } from 'jslib/models/view/cipherView';
|
import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
|
|
||||||
|
import { CiphersComponent as BaseCiphersComponent } from '../vault/ciphers.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-org-vault-ciphers',
|
selector: 'app-org-vault-ciphers',
|
||||||
templateUrl: '../vault/ciphers.component.html',
|
templateUrl: '../vault/ciphers.component.html',
|
||||||
})
|
})
|
||||||
export class CiphersComponent extends BaseCiphersComponent {
|
export class CiphersComponent extends BaseCiphersComponent {
|
||||||
@Input() showAddNew = true;
|
|
||||||
@Output() onAttachmentsClicked = new EventEmitter<CipherView>();
|
|
||||||
@Output() onCollectionsClicked = new EventEmitter<CipherView>();
|
|
||||||
|
|
||||||
organization: Organization;
|
organization: Organization;
|
||||||
cipherType = CipherType;
|
|
||||||
|
|
||||||
constructor(cipherService: CipherService, private analytics: Angulartics2,
|
constructor(cipherService: CipherService, analytics: Angulartics2,
|
||||||
private toasterService: ToasterService, private i18nService: I18nService,
|
toasterService: ToasterService, i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService, private apiService: ApiService) {
|
platformUtilsService: PlatformUtilsService, private apiService: ApiService) {
|
||||||
super(cipherService);
|
super(cipherService, analytics, toasterService, i18nService, platformUtilsService);
|
||||||
}
|
}
|
||||||
|
|
||||||
async load(filter: (cipher: CipherView) => boolean = null) {
|
async load(filter: (cipher: CipherView) => boolean = null) {
|
||||||
@ -76,37 +64,4 @@ export class CiphersComponent extends BaseCiphersComponent {
|
|||||||
checkCipher(c: CipherView) {
|
checkCipher(c: CipherView) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
attachments(c: CipherView) {
|
|
||||||
this.onAttachmentsClicked.emit(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
collections(c: CipherView) {
|
|
||||||
this.onCollectionsClicked.emit(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(c: CipherView): Promise<boolean> {
|
|
||||||
const confirmed = await this.platformUtilsService.showDialog(
|
|
||||||
this.i18nService.t('deleteItemConfirmation'), this.i18nService.t('deleteItem'),
|
|
||||||
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
|
||||||
if (!confirmed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.cipherService.deleteWithServer(c.id);
|
|
||||||
this.analytics.eventTrack.next({ action: 'Deleted Cipher' });
|
|
||||||
this.toasterService.popAsync('success', null, this.i18nService.t('deletedItem'));
|
|
||||||
this.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
copy(value: string, typeI18nKey: string, aType: string) {
|
|
||||||
if (value == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.analytics.eventTrack.next({ action: 'Copied ' + aType.toLowerCase() + ' from listing.' });
|
|
||||||
this.platformUtilsService.copyToClipboard(value, { doc: window.document });
|
|
||||||
this.toasterService.popAsync('info', null,
|
|
||||||
this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +1,29 @@
|
|||||||
import {
|
import { Component } from '@angular/core';
|
||||||
Component,
|
|
||||||
EventEmitter,
|
|
||||||
Input,
|
|
||||||
Output,
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
import { CollectionService } from 'jslib/abstractions/collection.service';
|
import { CollectionService } from 'jslib/abstractions/collection.service';
|
||||||
import { FolderService } from 'jslib/abstractions/folder.service';
|
import { FolderService } from 'jslib/abstractions/folder.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
|
|
||||||
import { GroupingsComponent as BaseGroupingsComponent } from 'jslib/angular/components/groupings.component';
|
|
||||||
|
|
||||||
import { CollectionData } from 'jslib/models/data/collectionData';
|
import { CollectionData } from 'jslib/models/data/collectionData';
|
||||||
import { Collection } from 'jslib/models/domain/collection';
|
import { Collection } from 'jslib/models/domain/collection';
|
||||||
import { Organization } from 'jslib/models/domain/organization';
|
import { Organization } from 'jslib/models/domain/organization';
|
||||||
import { CollectionView } from 'jslib/models/view/collectionView';
|
import { CollectionView } from 'jslib/models/view/collectionView';
|
||||||
|
|
||||||
|
import { GroupingsComponent as BaseGroupingsComponent } from '../vault/groupings.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-org-vault-groupings',
|
selector: 'app-org-vault-groupings',
|
||||||
templateUrl: '../vault/groupings.component.html',
|
templateUrl: '../vault/groupings.component.html',
|
||||||
})
|
})
|
||||||
export class GroupingsComponent extends BaseGroupingsComponent {
|
export class GroupingsComponent extends BaseGroupingsComponent {
|
||||||
@Output() onSearchTextChanged = new EventEmitter<string>();
|
|
||||||
|
|
||||||
organization: Organization;
|
organization: Organization;
|
||||||
searchText: string = '';
|
|
||||||
searchPlaceholder: string = null;
|
|
||||||
|
|
||||||
constructor(collectionService: CollectionService, folderService: FolderService,
|
constructor(collectionService: CollectionService, folderService: FolderService,
|
||||||
private apiService: ApiService, private i18nService: I18nService) {
|
private apiService: ApiService, private i18nService: I18nService) {
|
||||||
super(collectionService, folderService);
|
super(collectionService, folderService);
|
||||||
}
|
}
|
||||||
|
|
||||||
searchTextChanged() {
|
|
||||||
this.onSearchTextChanged.emit(this.searchText);
|
|
||||||
}
|
|
||||||
|
|
||||||
async loadCollections() {
|
async loadCollections() {
|
||||||
if (this.organization.isAdmin) {
|
if (this.organization.isAdmin) {
|
||||||
const collections = await this.apiService.getCollections(this.organization.id);
|
const collections = await this.apiService.getCollections(this.organization.id);
|
||||||
|
@ -32,9 +32,9 @@ export class CiphersComponent extends BaseCiphersComponent {
|
|||||||
|
|
||||||
cipherType = CipherType;
|
cipherType = CipherType;
|
||||||
|
|
||||||
constructor(cipherService: CipherService, private analytics: Angulartics2,
|
constructor(cipherService: CipherService, protected analytics: Angulartics2,
|
||||||
private toasterService: ToasterService, private i18nService: I18nService,
|
protected toasterService: ToasterService, protected i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService) {
|
protected platformUtilsService: PlatformUtilsService) {
|
||||||
super(cipherService);
|
super(cipherService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import { GroupingsComponent as BaseGroupingsComponent } from 'jslib/angular/comp
|
|||||||
})
|
})
|
||||||
export class GroupingsComponent extends BaseGroupingsComponent {
|
export class GroupingsComponent extends BaseGroupingsComponent {
|
||||||
@Output() onSearchTextChanged = new EventEmitter<string>();
|
@Output() onSearchTextChanged = new EventEmitter<string>();
|
||||||
|
|
||||||
searchText: string = '';
|
searchText: string = '';
|
||||||
searchPlaceholder: string = null;
|
searchPlaceholder: string = null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user