2017-12-23 20:47:41 -05:00
|
|
|
import { Component } from "@angular/core";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { AdminApiService } from "../../shared/services/admin/admin-api.service";
|
2018-03-24 19:16:52 -04:00
|
|
|
import { FE_DimensionConfig } from "../../shared/models/admin-responses";
|
2019-03-12 21:08:12 -04:00
|
|
|
import { ToasterService } from "angular2-toaster";
|
|
|
|
import {
|
|
|
|
AdminLogoutConfirmationDialogComponent,
|
|
|
|
} from "./logout-confirmation/logout-confirmation.component";
|
2020-10-23 07:30:20 -04:00
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
2021-08-16 18:00:59 -04:00
|
|
|
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
|
2017-12-23 20:47:41 -05:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./home.component.html",
|
|
|
|
styleUrls: ["./home.component.scss"],
|
|
|
|
})
|
|
|
|
export class AdminHomeComponent {
|
|
|
|
|
2017-12-23 21:45:34 -05:00
|
|
|
public isLoading = true;
|
2017-12-24 04:02:57 -05:00
|
|
|
public config: FE_DimensionConfig;
|
2017-12-23 21:45:34 -05:00
|
|
|
|
2019-03-12 21:08:12 -04:00
|
|
|
constructor(private adminApi: AdminApiService,
|
2021-09-01 19:01:01 -04:00
|
|
|
private toaster: ToasterService,
|
|
|
|
private modal: NgbModal,
|
|
|
|
public translate: TranslateService) {
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate = translate;
|
2017-12-23 21:45:34 -05:00
|
|
|
adminApi.getConfig().then(config => {
|
|
|
|
this.config = config;
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
2017-12-23 20:47:41 -05:00
|
|
|
}
|
2019-03-12 21:08:12 -04:00
|
|
|
|
|
|
|
public logoutAll(): void {
|
2021-08-16 18:00:59 -04:00
|
|
|
const selfhostedRef = this.modal.open(AdminLogoutConfirmationDialogComponent, {
|
|
|
|
backdrop: 'static'
|
|
|
|
});
|
|
|
|
selfhostedRef.result.then(async () => {
|
|
|
|
try {
|
|
|
|
await this.adminApi.logoutAll();
|
2021-09-01 19:01:01 -04:00
|
|
|
this.translate.get('Everyone has been logged out').subscribe((res: string) => {
|
|
|
|
this.toaster.pop("success", res);
|
|
|
|
});
|
2019-03-12 21:08:12 -04:00
|
|
|
this.config.sessionInfo.numTokens = 0;
|
2021-08-16 18:00:59 -04:00
|
|
|
} catch (err) {
|
2019-03-12 21:08:12 -04:00
|
|
|
console.error(err);
|
2021-09-01 19:01:01 -04:00
|
|
|
this.translate.get('Error logging everyone out').subscribe((res: string) => {
|
|
|
|
this.toaster.pop("error", res);
|
|
|
|
});
|
2021-08-16 18:00:59 -04:00
|
|
|
}
|
2019-03-12 21:08:12 -04:00
|
|
|
});
|
|
|
|
}
|
2017-12-23 20:47:41 -05:00
|
|
|
}
|