1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { Component, OnInit, OnDestroy } from '@angular/core';
- import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
- import { Subscription } from 'rxjs';
- import { JhiEventManager, JhiAlertService } from 'ng-jhipster';
-
- import { IPrivacy } from 'app/shared/model/privacy.model';
- import { Principal } from 'app/core';
- import { PrivacyService } from './privacy.service';
-
- @Component({
- selector: 'jhi-privacy',
- templateUrl: './privacy.component.html'
- })
- export class PrivacyComponent implements OnInit, OnDestroy {
- privacies: IPrivacy[];
- currentAccount: any;
- eventSubscriber: Subscription;
-
- constructor(
- private privacyService: PrivacyService,
- private jhiAlertService: JhiAlertService,
- private eventManager: JhiEventManager,
- private principal: Principal
- ) {}
-
- loadAll() {
- this.privacyService.query().subscribe(
- (res: HttpResponse<IPrivacy[]>) => {
- this.privacies = res.body;
- },
- (res: HttpErrorResponse) => this.onError(res.message)
- );
- }
-
- ngOnInit() {
- this.loadAll();
- this.principal.identity().then(account => {
- this.currentAccount = account;
- });
- this.registerChangeInPrivacies();
- }
-
- ngOnDestroy() {
- this.eventManager.destroy(this.eventSubscriber);
- }
-
- trackId(index: number, item: IPrivacy) {
- return item.id;
- }
-
- registerChangeInPrivacies() {
- this.eventSubscriber = this.eventManager.subscribe('privacyListModification', response => this.loadAll());
- }
-
- private onError(errorMessage: string) {
- this.jhiAlertService.error(errorMessage, null, null);
- }
- }
|