Forked from an inaccessible project.
-
Paulina Nogal authoredPaulina Nogal authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
dars-view.component.ts 2.30 KiB
import { Component, OnInit } from '@angular/core';
import { AuditMetadata } from '../models/audit-metadata';
import { MatDialog } from '@angular/material';
import { NewAuditOptionsComponent } from '../new-audit-options/new-audit-options.component';
import { DARSState } from '../store/state';
import { Store } from '@ngrx/store';
import { GlobalState } from '@app/core/state';
import * as selectors from '../store/selectors';
import { Observable } from 'rxjs';
import * as darsActions from '../store/actions';
import { Audit } from '../models/audit/audit';
import { DarsApiService } from '../services/api.service';
import { Alert } from '@app/core/models/alert';
@Component({
selector: 'cse-dars-view',
templateUrl: './dars-view.component.html',
styleUrls: ['./dars-view.component.scss'],
})
export class DARSViewComponent implements OnInit {
public metadataStatus$: Observable<DARSState['metadata']['status']>;
public programMetadata$: Observable<AuditMetadata[]>;
public whatIfMetadata$: Observable<AuditMetadata[]>;
public visibleAuditStatus$: Observable<DARSState['visibleAudit']['status']>;
public audit$: Observable<Audit | null>;
public alerts$: Observable<Alert[]>;
constructor(
private store: Store<GlobalState>,
public dialog: MatDialog,
private api: DarsApiService,
) {}
public ngOnInit() {
this.store.dispatch(new darsActions.StartLoadingMetadata());
this.metadataStatus$ = this.store.select(selectors.metadataStatus);
this.programMetadata$ = this.store.select(selectors.programMetadata);
this.whatIfMetadata$ = this.store.select(selectors.whatIfMetadata);
this.visibleAuditStatus$ = this.store.select(selectors.visibleAuditStatus);
// this.audit$ = this.store.select(selectors.visibleAudit);
this.audit$ = this.api.getAudit(3);
this.alerts$ = this.store.select(selectors.alerts);
}
public onDismissAlert(key: string) {
this.store.dispatch(new darsActions.DismissAlert({ key }));
}
public openNewAuditOptionsDialog(selectedAuditType) {
this.dialog.open(NewAuditOptionsComponent, {
data: { selectedAuditType: selectedAuditType },
});
}
public openAudit(metadata: AuditMetadata) {
this.store.dispatch(new darsActions.StartLoadingAudit(metadata));
}
public closeAudit() {
this.store.dispatch(new darsActions.CloseAudit());
}
}