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

47 lines
1.7 KiB
TypeScript
Raw Normal View History

2017-12-24 01:47:41 +00: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-13 01:08:12 +00:00
import { ToasterService } from "angular2-toaster";
import {
AdminLogoutConfirmationDialogComponent,
} from "./logout-confirmation/logout-confirmation.component";
import { TranslateService } from "@ngx-translate/core";
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
2017-12-24 01:47:41 +00:00
@Component({
templateUrl: "./home.component.html",
styleUrls: ["./home.component.scss"],
})
export class AdminHomeComponent {
public isLoading = true;
public config: FE_DimensionConfig;
2019-03-13 01:08:12 +00:00
constructor(private adminApi: AdminApiService,
private toaster: ToasterService,
private modal: NgbModal,
public translate: TranslateService) {
this.translate = translate;
adminApi.getConfig().then(config => {
this.config = config;
this.isLoading = false;
});
2017-12-24 01:47:41 +00:00
}
2019-03-13 01:08:12 +00:00
public logoutAll(): void {
const selfhostedRef = this.modal.open(AdminLogoutConfirmationDialogComponent, {
backdrop: 'static'
});
selfhostedRef.result.then(async () => {
try {
await this.adminApi.logoutAll();
this.translate.get('Everyone has been logged out').subscribe((res: string) => {this.toaster.pop("success", res); });
2019-03-13 01:08:12 +00:00
this.config.sessionInfo.numTokens = 0;
} catch (err) {
2019-03-13 01:08:12 +00:00
console.error(err);
this.translate.get('Error logging everyone out').subscribe((res: string) => {this.toaster.pop("error", res); });
}
2019-03-13 01:08:12 +00:00
});
}
2017-12-24 01:47:41 +00:00
}