matrix-dimension/web/app/admin/home/home.component.ts

43 lines
1.5 KiB
TypeScript
Raw Normal View History

2017-12-23 20:47:41 -05:00
import { Component } from "@angular/core";
import { AdminApiService } from "../../shared/services/admin/admin-api.service";
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 {
public isLoading = true;
public config: FE_DimensionConfig;
2019-03-12 21:08:12 -04:00
constructor(private adminApi: AdminApiService,
private toaster: ToasterService,
private modal: Modal) {
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
}