shortcuts and modal fixes

This commit is contained in:
Kyle Spearrin 2018-02-09 12:12:41 -05:00
parent f80ae40b1a
commit 481d04b2b9
6 changed files with 126 additions and 58 deletions

View File

@ -57,12 +57,12 @@
<div class="box-content condensed">
<div class="box-content-row box-content-row-input" appBoxRow>
<label for="min-number">{{'minNumbers' | i18n}}</label>
<input id="min-number" type="number" min="0" max="5" (change)="saveOptions()"
<input id="min-number" type="number" min="0" max="9" (change)="saveOptions()"
[(ngModel)]="options.minNumber">
</div>
<div class="box-content-row box-content-row-input" appBoxRow>
<label for="min-special">{{'minSpecial' | i18n}}</label>
<input id="min-special" type="number" min="0" max="5" (change)="saveOptions()"
<input id="min-special" type="number" min="0" max="9" (change)="saveOptions()"
[(ngModel)]="options.minSpecial">
</div>
<div class="box-content-row box-content-row-checkbox" appBoxRow>

View File

@ -84,6 +84,9 @@ export class PasswordGeneratorComponent implements OnInit {
}
private normalizeOptions() {
this.options.minLowercase = 0;
this.options.minUppercase = 0;
if (!this.options.uppercase && !this.options.lowercase && !this.options.number && !this.options.special) {
this.options.lowercase = true;
const lowercase = document.querySelector('#lowercase') as HTMLInputElement;
@ -91,22 +94,31 @@ export class PasswordGeneratorComponent implements OnInit {
lowercase.checked = true;
}
}
if (!this.options.minNumber) {
this.options.minNumber = 0;
} else if (this.options.minNumber > 5) {
this.options.minNumber = 5;
}
if (!this.options.minSpecial) {
this.options.minSpecial = 0;
} else if (this.options.minSpecial > 5) {
this.options.minSpecial = 5;
}
if (!this.options.length) {
this.options.length = 5;
} else if (this.options.length > 128) {
this.options.length = 128;
}
if (!this.options.minNumber) {
this.options.minNumber = 0;
} else if (this.options.minNumber > this.options.length) {
this.options.minNumber = this.options.length;
} else if (this.options.minNumber > 9) {
this.options.minNumber = 9;
}
if (!this.options.minSpecial) {
this.options.minSpecial = 0;
} else if (this.options.minSpecial > this.options.length) {
this.options.minSpecial = this.options.length;
} else if (this.options.minSpecial > 9) {
this.options.minSpecial = 9;
}
if (this.options.minSpecial + this.options.minNumber > this.options.length) {
this.options.minSpecial = this.options.length - this.options.minNumber;
}
}
}

View File

@ -27,7 +27,7 @@
(onDeletedCipher)="deletedCipher($event)"
(onEditAttachments)="editCipherAttachments($event)"
(onCancelled)="cancelledAddEdit($event)"
(onGeneratePassword)="openPasswordGenerator()">
(onGeneratePassword)="openPasswordGenerator(true)">
</app-vault-add-edit>
<div id="logo" *ngIf="action !== 'add' && action !== 'edit' && action !== 'view'">
<div class="content">

View File

@ -43,9 +43,9 @@ export class VaultComponent implements OnInit {
@ViewChild(AddEditComponent) addEditComponent: AddEditComponent;
@ViewChild(CiphersComponent) ciphersComponent: CiphersComponent;
@ViewChild(GroupingsComponent) groupingsComponent: GroupingsComponent;
@ViewChild('passwordGenerator', { read: ViewContainerRef }) passwordGeneratorModal: ViewContainerRef;
@ViewChild('attachments', { read: ViewContainerRef }) attachmentsModal: ViewContainerRef;
@ViewChild('folderAddEdit', { read: ViewContainerRef }) folderAddEditModal: ViewContainerRef;
@ViewChild('passwordGenerator', { read: ViewContainerRef }) passwordGeneratorModalRef: ViewContainerRef;
@ViewChild('attachments', { read: ViewContainerRef }) attachmentsModalRef: ViewContainerRef;
@ViewChild('folderAddEdit', { read: ViewContainerRef }) folderAddEditModalRef: ViewContainerRef;
action: string;
cipherId: string = null;
@ -55,6 +55,10 @@ export class VaultComponent implements OnInit {
collectionId: string = null;
addType: CipherType = null;
private passwordGeneratorModal: ModalComponent = null;
private folderAddEditModal: ModalComponent = null;
private attachmentsModal: ModalComponent = null;
constructor(private route: ActivatedRoute, private router: Router, private location: Location,
private componentFactoryResolver: ComponentFactoryResolver, private i18nService: I18nService,
private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef,
@ -82,6 +86,13 @@ export class VaultComponent implements OnInit {
case 'newFolder':
await this.addFolder();
break;
case 'focusSearch':
(document.querySelector('#search') as HTMLInputElement).focus();
detectChanges = false;
break;
case 'openPasswordGenerator':
await this.openPasswordGenerator(false);
break;
default:
detectChanges = false;
break;
@ -103,9 +114,10 @@ export class VaultComponent implements OnInit {
}
async load(params?: { [key: string]: any }) {
await this.groupingsComponent.load();
if (params == null) {
this.groupingsComponent.selectedAll = true;
await this.groupingsComponent.load();
await this.ciphersComponent.load();
return;
}
@ -138,7 +150,6 @@ export class VaultComponent implements OnInit {
await this.filterCollection(params.collectionId);
} else {
this.groupingsComponent.selectedAll = true;
await this.groupingsComponent.load();
await this.ciphersComponent.load();
}
}
@ -189,11 +200,20 @@ export class VaultComponent implements OnInit {
}
editCipherAttachments(cipher: CipherView) {
if (this.attachmentsModal != null) {
this.attachmentsModal.close();
}
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
const modal = this.attachmentsModal.createComponent(factory).instance;
const childComponent = modal.show<AttachmentsComponent>(AttachmentsComponent, this.attachmentsModal);
this.attachmentsModal = this.attachmentsModalRef.createComponent(factory).instance;
const childComponent = this.attachmentsModal.show<AttachmentsComponent>(
AttachmentsComponent, this.attachmentsModalRef);
childComponent.cipherId = cipher.id;
this.attachmentsModal.onClosed.subscribe(() => {
this.attachmentsModal = null;
});
}
cancelledAddEdit(cipher: CipherView) {
@ -242,48 +262,66 @@ export class VaultComponent implements OnInit {
this.go();
}
async openPasswordGenerator() {
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
const modal = this.passwordGeneratorModal.createComponent(factory).instance;
const childComponent = modal.show<PasswordGeneratorComponent>(PasswordGeneratorComponent,
this.passwordGeneratorModal);
async openPasswordGenerator(showSelect: boolean) {
if (this.passwordGeneratorModal != null) {
this.passwordGeneratorModal.close();
}
childComponent.showSelect = true;
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
this.passwordGeneratorModal = this.passwordGeneratorModalRef.createComponent(factory).instance;
const childComponent = this.passwordGeneratorModal.show<PasswordGeneratorComponent>(PasswordGeneratorComponent,
this.passwordGeneratorModalRef);
childComponent.showSelect = showSelect;
childComponent.onSelected.subscribe((password: string) => {
modal.close();
this.passwordGeneratorModal.close();
if (this.addEditComponent != null && this.addEditComponent.cipher != null &&
this.addEditComponent.cipher.login != null) {
this.addEditComponent.cipher.login.password = password;
}
});
this.passwordGeneratorModal.onClosed.subscribe(() => {
this.passwordGeneratorModal = null;
});
}
async addFolder() {
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
const modal = this.folderAddEditModal.createComponent(factory).instance;
const childComponent = modal.show<FolderAddEditComponent>(FolderAddEditComponent, this.folderAddEditModal);
this.folderAddEditModal = this.folderAddEditModalRef.createComponent(factory).instance;
const childComponent = this.folderAddEditModal.show<FolderAddEditComponent>(
FolderAddEditComponent, this.folderAddEditModalRef);
childComponent.folderId = null;
childComponent.onSavedFolder.subscribe(async (folder: FolderView) => {
modal.close();
this.folderAddEditModal.close();
await this.groupingsComponent.loadFolders();
});
this.folderAddEditModal.onClosed.subscribe(() => {
this.folderAddEditModal = null;
});
}
async editFolder(folderId: string) {
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
const modal = this.folderAddEditModal.createComponent(factory).instance;
const childComponent = modal.show<FolderAddEditComponent>(FolderAddEditComponent, this.folderAddEditModal);
this.folderAddEditModal = this.folderAddEditModalRef.createComponent(factory).instance;
const childComponent = this.folderAddEditModal.show<FolderAddEditComponent>(
FolderAddEditComponent, this.folderAddEditModalRef);
childComponent.folderId = folderId;
childComponent.onSavedFolder.subscribe(async (folder: FolderView) => {
modal.close();
this.folderAddEditModal.close();
await this.groupingsComponent.loadFolders();
});
childComponent.onDeletedFolder.subscribe(async (folder: FolderView) => {
modal.close();
this.folderAddEditModal.close();
await this.groupingsComponent.loadFolders();
});
this.folderAddEditModal.onClosed.subscribe(() => {
this.folderAddEditModal = null;
});
}
private clearFilters() {

View File

@ -30,7 +30,7 @@
"message": "Collections"
},
"searchVault": {
"message": "Search vault"
"message": "Search Vault"
},
"addItem": {
"message": "Add Item"
@ -335,16 +335,16 @@
"message": "Avoid Ambiguous Characters"
},
"searchCollection": {
"message": "Search collection"
"message": "Search Collection"
},
"searchFolder": {
"message": "Search folder"
"message": "Search Folder"
},
"searchFavorites": {
"message": "Search favorites"
"message": "Search Favorites"
},
"searchType": {
"message": "Search type",
"message": "Search Type",
"description": "Search item type"
},
"newAttachment": {
@ -624,5 +624,11 @@
},
"loading": {
"message": "Loading..."
},
"lock": {
"message": "Lock"
},
"passwordGenerator": {
"message": "Password Generator"
}
}

View File

@ -18,7 +18,7 @@ export class MenuMain {
const template: MenuItemConstructorOptions[] = [
{
label: 'File',
label: this.i18nService.t('file'),
submenu: [
{
label: this.i18nService.t('addNewLogin'),
@ -34,25 +34,29 @@ export class MenuMain {
label: this.i18nService.t('typeLogin'),
click() {
self.send('newLogin');
}
},
accelerator: 'Alt+L'
},
{
label: this.i18nService.t('typeCard'),
click() {
self.send('newCard');
}
},
accelerator: 'Alt+C'
},
{
label: this.i18nService.t('typeIdentity'),
click() {
self.send('newIdentity');
}
},
accelerator: 'Alt+I'
},
{
label: this.i18nService.t('typeSecureNote'),
click() {
self.send('newSecureNote');
}
},
accelerator: 'Alt+S'
}
]
},
@ -71,7 +75,7 @@ export class MenuMain {
}
},
{
label: 'Lock',
label: this.i18nService.t('lock'),
click() {
self.send('lockApp');
},
@ -94,22 +98,30 @@ export class MenuMain {
{
label: this.i18nService.t('view'),
submenu: [
{ role: 'reload' },
{ role: 'forcereload' },
{ role: 'toggledevtools' },
{ type: 'separator' },
{
role: 'resetzoom',
accelerator: 'CmdOrCtrl+0' },
label: this.i18nService.t('passwordGenerator'),
click() {
self.send('openPasswordGenerator');
},
accelerator: 'CmdOrCtrl+G'
},
{
role: 'zoomin',
accelerator: 'CmdOrCtrl+=' },
{
role: 'zoomout',
accelerator: 'CmdOrCtrl+-'
label: this.i18nService.t('searchVault'),
click() {
self.send('focusSearch');
},
accelerator: 'CmdOrCtrl+F'
},
{ type: 'separator' },
{ role: 'togglefullscreen' }
{ role: 'resetzoom', accelerator: 'CmdOrCtrl+0' },
{ role: 'zoomin', accelerator: 'CmdOrCtrl+=' },
{ role: 'zoomout', accelerator: 'CmdOrCtrl+-' },
{ type: 'separator' },
{ role: 'togglefullscreen' },
{ type: 'separator' },
{ role: 'reload', accelerator: 'Alt+Shift+R' },
{ role: 'forcereload' },
{ role: 'toggledevtools' },
]
},
{