mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-18 09:13:28 +00:00
get sync status. clear sync cache
This commit is contained in:
@@ -81,6 +81,10 @@ export class AppComponent implements OnInit {
|
||||
this.stateService.save('profileOrganizations', profile.organizations);
|
||||
}
|
||||
break;
|
||||
case 'syncScheduleStarted':
|
||||
case 'syncScheduleStopped':
|
||||
this.stateService.save('syncingDir', message.command === 'syncScheduleStarted');
|
||||
break;
|
||||
case 'logout':
|
||||
this.logOut(!!message.expired);
|
||||
break;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<div class="card">
|
||||
<h3 class="card-header">Testing</h3>
|
||||
<div class="card-body">
|
||||
<p>You can run tests to see how your directory and sync settings are working. Tests will not sync to your Bitwarden organization.</p>
|
||||
<button #simBtn (click)="simulate()" [appApiAction]="simPromise" class="btn btn-primary" [disabled]="simBtn.loading">
|
||||
<i class="fa fa-spinner fa-fw fa-spin" [hidden]="!simBtn.loading"></i>
|
||||
<i class="fa fa-bug fa-fw" [hidden]="simBtn.loading"></i>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { StateService } from 'jslib/abstractions/state.service';
|
||||
|
||||
import { AzureDirectoryService } from '../../services/azure-directory.service';
|
||||
import { GSuiteDirectoryService } from '../../services/gsuite-directory.service';
|
||||
@@ -46,7 +47,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
constructor(private i18nService: I18nService, private syncService: SyncService,
|
||||
private configurationService: ConfigurationService, private broadcasterService: BroadcasterService,
|
||||
private ngZone: NgZone, private messagingService: MessagingService,
|
||||
private toasterService: ToasterService, private changeDetectorRef: ChangeDetectorRef) { }
|
||||
private toasterService: ToasterService, private changeDetectorRef: ChangeDetectorRef,
|
||||
private stateService: StateService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
|
||||
@@ -63,6 +65,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
});
|
||||
|
||||
this.syncRunning = !!(await this.stateService.get('syncingDir'));
|
||||
this.updateLastSync();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<button class="btn btn-primary" type="button" (click)="logOut()">
|
||||
{{'logOut' | i18n}}
|
||||
</button>
|
||||
<button class="btn btn-primary" type="button" (click)="clearCache()">
|
||||
{{'clearSyncCache' | i18n}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,9 +3,12 @@ import {
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-more',
|
||||
@@ -16,7 +19,8 @@ export class MoreComponent implements OnInit {
|
||||
year: string;
|
||||
|
||||
constructor(private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
|
||||
private messagingService: MessagingService) { }
|
||||
private messagingService: MessagingService, private configurationService: ConfigurationService,
|
||||
private toasterService: ToasterService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.year = new Date().getFullYear().toString();
|
||||
@@ -33,4 +37,9 @@ export class MoreComponent implements OnInit {
|
||||
this.messagingService.send('logout');
|
||||
}
|
||||
}
|
||||
|
||||
async clearCache() {
|
||||
await this.configurationService.clearStatefulSettings(true);
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t('syncCacheCleared'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,14 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
this.sync.groupNameAttribute = 'name';
|
||||
}
|
||||
|
||||
if (this.sync.interval != null) {
|
||||
if (this.sync.interval <= 0) {
|
||||
this.sync.interval = null;
|
||||
} else if (this.sync.interval < 5) {
|
||||
this.sync.interval = 5;
|
||||
}
|
||||
}
|
||||
|
||||
await this.configurationService.saveOrganizationId(this.organizationId);
|
||||
await this.configurationService.saveDirectoryType(this.directory);
|
||||
await this.configurationService.saveDirectory(DirectoryType.Ldap, this.ldap);
|
||||
|
||||
@@ -440,5 +440,11 @@
|
||||
},
|
||||
"token": {
|
||||
"message": "Token"
|
||||
},
|
||||
"clearSyncCache": {
|
||||
"message": "Clear Sync Cache"
|
||||
},
|
||||
"syncCacheCleared": {
|
||||
"message": "The sync cache has been cleared."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ export class MessagingMain {
|
||||
this.scheduleNextSync();
|
||||
break;
|
||||
case 'cancelDirSync':
|
||||
this.windowMain.win.webContents.send('messagingService', {
|
||||
command: 'syncScheduleStopped',
|
||||
});
|
||||
if (this.syncTimeout) {
|
||||
global.clearTimeout(this.syncTimeout);
|
||||
}
|
||||
@@ -35,6 +38,10 @@ export class MessagingMain {
|
||||
}
|
||||
|
||||
private scheduleNextSync() {
|
||||
this.windowMain.win.webContents.send('messagingService', {
|
||||
command: 'syncScheduleStarted',
|
||||
});
|
||||
|
||||
if (this.syncTimeout) {
|
||||
global.clearTimeout(this.syncTimeout);
|
||||
}
|
||||
|
||||
@@ -198,10 +198,13 @@ export class ConfigurationService {
|
||||
}
|
||||
}
|
||||
|
||||
private async clearStatefulSettings() {
|
||||
async clearStatefulSettings(hashToo = false) {
|
||||
await this.saveUserDeltaToken(null);
|
||||
await this.saveGroupDeltaToken(null);
|
||||
await this.saveLastGroupSyncDate(null);
|
||||
await this.saveLastUserSyncDate(null);
|
||||
if (hashToo) {
|
||||
await this.saveLastSyncHash(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user