diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index f247dcb5..02d16446 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -65,20 +65,9 @@ export class AppComponent implements OnInit {
private componentFactoryResolver: ComponentFactoryResolver, private messagingService: MessagingService) { }
ngOnInit() {
- this.ngZone.runOutsideAngular(() => {
- window.setTimeout(async () => {
- await this.updateAppMenu();
- }, 1000);
- });
-
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
- case 'loggedIn':
- case 'unlocked':
- case 'loggedOut':
- this.updateAppMenu();
- break;
case 'logout':
this.logOut(!!message.expired);
break;
@@ -92,12 +81,6 @@ export class AppComponent implements OnInit {
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
}
- private async updateAppMenu() {
- this.messagingService.send('updateAppMenu', {
- isAuthenticated: await this.userService.isAuthenticated(),
- });
- }
-
private async logOut(expired: boolean) {
const userId = await this.userService.getUserId();
diff --git a/src/app/tabs/settings.component.html b/src/app/tabs/settings.component.html
index 6c1b7d2c..c6777b98 100644
--- a/src/app/tabs/settings.component.html
+++ b/src/app/tabs/settings.component.html
@@ -87,10 +87,15 @@
{{'ex' | i18n}} 39204722352
+
+
+ {{'ex' | i18n}} My Project-jksd3jd223.json
+
+
-
+
diff --git a/src/app/tabs/settings.component.ts b/src/app/tabs/settings.component.ts
index 90ce89c1..e97fb3b1 100644
--- a/src/app/tabs/settings.component.ts
+++ b/src/app/tabs/settings.component.ts
@@ -1,5 +1,7 @@
import {
+ ChangeDetectorRef,
Component,
+ NgZone,
OnDestroy,
OnInit,
} from '@angular/core';
@@ -28,7 +30,8 @@ export class SettingsComponent implements OnInit, OnDestroy {
sync = new SyncConfiguration();
directoryOptions: any[];
- constructor(private i18nService: I18nService, private configurationService: ConfigurationService) {
+ constructor(private i18nService: I18nService, private configurationService: ConfigurationService,
+ private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) {
this.directoryOptions = [
{ name: i18nService.t('select'), value: null },
{ name: 'Active Directory / LDAP', value: DirectoryType.Ldap },
@@ -72,4 +75,32 @@ export class SettingsComponent implements OnInit, OnDestroy {
await this.configurationService.saveDirectory(DirectoryType.AzureActiveDirectory, this.azure);
await this.configurationService.saveSync(this.sync);
}
+
+ async parseKeyFile() {
+ const filePicker = (document.getElementById('keyFile') as HTMLInputElement);
+ if (filePicker.files == null || filePicker.files.length < 0) {
+ return;
+ }
+
+ const reader = new FileReader();
+ reader.readAsText(filePicker.files[0], 'utf-8');
+ reader.onload = (evt) => {
+ this.ngZone.run(async () => {
+ try {
+ const result = JSON.parse((evt.target as FileReader).result);
+ if (result.client_email != null && result.private_key != null) {
+ this.gsuite.clientEmail = result.client_email;
+ this.gsuite.privateKey = result.private_key;
+ }
+ } catch { }
+ this.changeDetectorRef.detectChanges();
+ });
+
+ // reset file input
+ // ref: https://stackoverflow.com/a/20552042
+ filePicker.type = '';
+ filePicker.type = 'file';
+ filePicker.value = '';
+ };
+ }
}
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index 47a38c66..0a092201 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -231,8 +231,8 @@
"view": {
"message": "View"
},
- "file": {
- "message": "File"
+ "jsonKeyFile": {
+ "message": "JSON Key File"
},
"edit": {
"message": "Edit"
diff --git a/src/main/menu.main.ts b/src/main/menu.main.ts
index f0eb5973..2d592ef8 100644
--- a/src/main/menu.main.ts
+++ b/src/main/menu.main.ts
@@ -10,7 +10,6 @@ import { BaseMenu } from 'jslib/electron/baseMenu';
export class MenuMain extends BaseMenu {
menu: Menu;
- logOut: MenuItem;
constructor(main: Main) {
super(main.i18nService, main.windowMain, main.i18nService.t('bitwardenDirectoryConnector'),
@@ -21,21 +20,10 @@ export class MenuMain extends BaseMenu {
this.initProperties();
this.initContextMenu();
this.initApplicationMenu();
-
- this.logOut = this.menu.getMenuItemById('logOut');
- this.updateApplicationMenuState(false);
- }
-
- updateApplicationMenuState(isAuthenticated: boolean) {
- this.logOut.enabled = isAuthenticated;
}
private initApplicationMenu() {
const template: MenuItemConstructorOptions[] = [
- {
- label: this.i18nService.t('file'),
- submenu: [this.logOutMenuItemOptions],
- },
this.editMenuItemOptions,
{
label: this.i18nService.t('view'),
@@ -44,54 +32,21 @@ export class MenuMain extends BaseMenu {
this.windowMenuItemOptions,
];
- const firstMenuOptions: MenuItemConstructorOptions[] = [
- { type: 'separator' },
- {
- label: this.i18nService.t('settings'),
- id: 'settings',
- click: () => { /* Something */ },
- },
- ];
-
- const updateMenuItem = {
- label: this.i18nService.t('checkForUpdates'),
- click: () => { /* Something */ },
- id: 'checkForUpdates',
- };
-
if (process.platform === 'darwin') {
const firstMenuPart: MenuItemConstructorOptions[] = [
{
label: this.i18nService.t('aboutBitwarden'),
role: 'about',
},
- updateMenuItem,
];
template.unshift({
label: this.appName,
- submenu: firstMenuPart.concat(firstMenuOptions, [
- { type: 'separator' },
- ], this.macAppMenuItemOptions),
+ submenu: firstMenuPart.concat(this.macAppMenuItemOptions),
});
// Window menu
template[template.length - 1].submenu = this.macWindowSubmenuOptions;
- } else {
- // File menu
- template[0].submenu = (template[0].submenu as MenuItemConstructorOptions[]).concat(
- firstMenuOptions);
-
- // About menu
- const aboutMenuAdditions: MenuItemConstructorOptions[] = [
- { type: 'separator' },
- updateMenuItem,
- ];
-
- aboutMenuAdditions.push(this.aboutMenuItemOptions);
-
- template[template.length - 1].submenu =
- (template[template.length - 1].submenu as MenuItemConstructorOptions[]).concat(aboutMenuAdditions);
}
this.menu = Menu.buildFromTemplate(template);
diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts
index bb15a7d4..a2673805 100644
--- a/src/main/messaging.main.ts
+++ b/src/main/messaging.main.ts
@@ -24,9 +24,6 @@ export class MessagingMain {
case 'scheduleNextSync':
this.scheduleNextSync();
break;
- case 'updateAppMenu':
- this.menuMain.updateApplicationMenuState(message.isAuthenticated);
- break;
default:
break;
}
diff --git a/src/scss/misc.scss b/src/scss/misc.scss
index 52cf69e7..1af1b43c 100644
--- a/src/scss/misc.scss
+++ b/src/scss/misc.scss
@@ -43,11 +43,7 @@ h4 {
}
app-root > #loading {
- display: flex;
text-align: center;
- justify-content: center;
- align-items: center;
- height: 100%;
- width: 100%;
+ margin-top: 20px;
color: $text-muted;
}