2024-12-28 01:37:44 +00:00
|
|
|
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
|
2024-10-17 08:48:15 +00:00
|
|
|
import { PolicyAddFormComponent } from "../policy-add-form/policy-add-form.component";
|
|
|
|
import { PolicyTableComponent } from "../policy-table/policy-table.component";
|
2024-12-28 01:36:33 +00:00
|
|
|
import { Policy, PolicyScope } from '../../shared/models/policy';
|
2024-12-28 01:37:44 +00:00
|
|
|
import { isPlatformBrowser } from '@angular/common';
|
2024-12-28 01:36:33 +00:00
|
|
|
import { HermesClientService } from '../../hermes-client.service';
|
2024-10-17 08:48:15 +00:00
|
|
|
import { Router, RouterModule } from '@angular/router';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'policy',
|
|
|
|
imports: [RouterModule, PolicyAddFormComponent, PolicyTableComponent],
|
|
|
|
templateUrl: './policy.component.html',
|
|
|
|
styleUrl: './policy.component.scss'
|
|
|
|
})
|
|
|
|
export class PolicyComponent implements OnInit, OnDestroy {
|
|
|
|
private isBrowser: boolean;
|
|
|
|
items: Policy[];
|
|
|
|
|
|
|
|
|
2024-12-28 01:37:44 +00:00
|
|
|
constructor(private client: HermesClientService, private router: Router, @Inject(PLATFORM_ID) private platformId: Object) {
|
2024-10-17 08:48:15 +00:00
|
|
|
this.isBrowser = isPlatformBrowser(this.platformId)
|
|
|
|
|
|
|
|
this.items = []
|
|
|
|
}
|
|
|
|
|
|
|
|
get policies() {
|
|
|
|
return this.items;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
if (!this.isBrowser)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!this.client.logged_in) {
|
|
|
|
this.router.navigate(["/tts-login"]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
}
|
|
|
|
}
|