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 { Modal, overlayConfigFactory } from "ngx-modialog";
|
|
|
|
import {
|
|
|
|
AdminLogoutConfirmationDialogComponent,
|
|
|
|
LogoutConfirmationDialogContext
|
|
|
|
} from "./logout-confirmation/logout-confirmation.component";
|
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,
|
|
|
|
private toaster: ToasterService,
|
|
|
|
private modal: Modal) {
|
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 {
|
|
|
|
this.modal.open(AdminLogoutConfirmationDialogComponent, overlayConfigFactory({
|
|
|
|
isBlocking: true,
|
|
|
|
}, LogoutConfirmationDialogContext)).result.then(() => {
|
|
|
|
this.adminApi.logoutAll().then(() => {
|
|
|
|
this.toaster.pop("success", "Everyone has been logged out");
|
|
|
|
this.config.sessionInfo.numTokens = 0;
|
|
|
|
}).catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
this.toaster.pop("error", "Error logging everyone out");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2017-12-23 20:47:41 -05:00
|
|
|
}
|