Newer
Older
import { Component, ViewChild } from '@angular/core';
import { MatSidenav } from '@angular/material';
import { DarsApiService } from '../services/api.service';
import { Audit } from '../models/audit';
@Component({
selector: 'cse-dars-view',
templateUrl: './dars-view.component.html',
styleUrls: ['./dars-view.component.scss'],
})
export class DARSViewComponent {
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
displayedColumns = [
'view',
'school',
'program',
'honors',
'plan',
'status',
'download',
];
dataSource = [
{
pending: true,
school: 'Letters & Science',
program: 'Psychology',
honors: 'keep',
plan: 12345,
},
{
pending: false,
school: 'Letters & Science',
program: 'Psychology',
honors: 'keep',
plan: 12345,
},
{
pending: false,
school: 'Letters & Science',
program: 'Psychology',
honors: 'keep',
plan: 12345,
},
{
pending: false,
school: 'Letters & Science',
program: 'Psychology',
honors: 'keep',
plan: 12345,
},
];
@ViewChild('auditSideNav') auditSideNav: MatSidenav;
public isLoading: boolean;
public auditId: number | null;
public audit: Audit;
constructor(private api: DarsApiService) {
this.isLoading = false;
this.auditId = null;
}
public openAudit(auditId: number) {
// if user is loading a new audit
if (auditId !== this.auditId) {
this.isLoading = true;
this.auditId = null;
this.api
.getAudit(auditId)
.toPromise()
.then(audit => {
this.isLoading = false;
this.auditId = auditId;
this.audit = audit;
console.log(audit);
})
.catch(e => {
console.log(e);
});
}
this.auditSideNav.open();
}