Commit 443cd846 authored by Lukas Burgey's avatar Lukas Burgey

Display the state of task items to the user

parent b228926c
...@@ -6,21 +6,32 @@ ...@@ -6,21 +6,32 @@
<table width="60%"> <table width="60%">
<tr style="margin-bottom: 15px;"> <tr style="margin-bottom: 15px;">
<td *ngFor="let site of serviceData.site"> <td *ngFor="let site of serviceData.site">
<span matTooltip="Provided at site {{ site.name }}"> <span matTooltip="Provided at site {{ site.name }}" style="margin-right: 10px;">
<mat-icon style="vertical-align: middle; padding-right: 5px;">storage</mat-icon> <mat-icon style="vertical-align: middle; padding-right: 5px;">storage</mat-icon>
{{ site.name }} {{ site.name }}
</span> </span>
<span *ngIf="userService.taskInProgress(site, serviceData); then progress else done"></span> <span [ngSwitch]="userService.taskState(site, serviceData)">
<ng-template #progress matTooltip="A task is in progress"> <span *ngSwitchCase="'pending'"
<span style="display: inline-block; vertical-align: middle"> style="display: inline-block; vertical-align: middle"
matTooltip="This deployment is in progress">
<mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner> <mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner>
</span> </span>
</ng-template> <span *ngSwitchCase="'done'"
<ng-template #done> style="display: inline-block; vertical-align: middle"
<span matTooltip="All tasks are done"> matTooltip="This deployment was successful">
<mat-icon style="vertical-align: middle">done</mat-icon> <mat-icon style="vertical-align: middle">done</mat-icon>
</span> </span>
</ng-template> <span *ngSwitchCase="'failed'"
style="display: inline-block; vertical-align: middle"
matTooltip="This deployment has failed">
<mat-icon style="vertical-align: middle">error</mat-icon>
</span>
<span *ngSwitchCase="'rejected'"
style="display: inline-block; vertical-align: middle"
matTooltip="This deployment was rejected. The client needs more data.">
<mat-icon style="vertical-align: middle">warning</mat-icon>
</span>
</span>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -49,7 +49,7 @@ export class UserService { ...@@ -49,7 +49,7 @@ export class UserService {
public getIdPPreference(): Observable<AllAuthInfo> { public getIdPPreference(): Observable<AllAuthInfo> {
let idpID = Number(this.cookieService.get(environment.idpCookieName)); let idpID = Number(this.cookieService.get(environment.idpCookieName));
return this.http.get('/backend/auth/v1/info/').map( return this.http.get('/backend/auth/v1/info').map(
(authInfo: AuthInfo) => { (authInfo: AuthInfo) => {
let selected = authInfo.idps[1]; let selected = authInfo.idps[1];
...@@ -136,7 +136,7 @@ export class UserService { ...@@ -136,7 +136,7 @@ export class UserService {
public updateState() { public updateState() {
this.http this.http
.get('/backend/api/state/') .get('/backend/api/state')
.subscribe( .subscribe(
(data: UserState) => { (data: UserState) => {
this.updateData(data); this.updateData(data);
...@@ -154,11 +154,11 @@ export class UserService { ...@@ -154,11 +154,11 @@ export class UserService {
public login(idp: IdP) { public login(idp: IdP) {
this.setIdPPreference(idp); this.setIdPPreference(idp);
window.location.href = 'https://hdf-portal.data.kit.edu/backend/auth/v1/request/'; window.location.href = 'https://hdf-portal.data.kit.edu/backend/auth/v1/request';
} }
public logout() { public logout() {
this.http.post('/backend/auth/v1/logout/', {}).subscribe( this.http.post('/backend/auth/v1/logout', {}).subscribe(
data => { data => {
this.updateData(data); this.updateData(data);
} }
...@@ -170,7 +170,7 @@ export class UserService { ...@@ -170,7 +170,7 @@ export class UserService {
'type': 'add', 'type': 'add',
'key': key, 'key': key,
}; };
return this.http.post('/backend/api/sshkey/', body).subscribe( return this.http.post('/backend/api/sshkey', body).subscribe(
data => { data => {
this.updateData(data); this.updateData(data);
}, },
...@@ -187,7 +187,7 @@ export class UserService { ...@@ -187,7 +187,7 @@ export class UserService {
'type': 'remove', 'type': 'remove',
'id': key.id, 'id': key.id,
}; };
return this.http.post('/backend/api/sshkey/', body).subscribe( return this.http.post('/backend/api/sshkey', body).subscribe(
(data) => { (data) => {
this.updateData(data); this.updateData(data);
}, },
...@@ -205,7 +205,7 @@ export class UserService { ...@@ -205,7 +205,7 @@ export class UserService {
'key': key.id, 'key': key.id,
'service': service.id, 'service': service.id,
}; };
return this.http.post('/backend/api/deployments/', body).subscribe( return this.http.post('/backend/api/deployments', body).subscribe(
(data) => { (data) => {
//this.snackBar.open('Deployed key ' + key.name); //this.snackBar.open('Deployed key ' + key.name);
this.updateData(data); this.updateData(data);
...@@ -225,7 +225,7 @@ export class UserService { ...@@ -225,7 +225,7 @@ export class UserService {
'service': service.id, 'service': service.id,
}; };
return this.http.post('/backend/api/deployments/', body).subscribe( return this.http.post('/backend/api/deployments', body).subscribe(
(data) => { (data) => {
//this.snackBar.open('Withdrew key ' + key.name); //this.snackBar.open('Withdrew key ' + key.name);
this.updateData(data); this.updateData(data);
...@@ -315,4 +315,16 @@ export class UserService { ...@@ -315,4 +315,16 @@ export class UserService {
} }
return false; return false;
} }
public taskState(site, service): string {
if (site && service) {
for (const item of this.user.deployment_task_items){
if (item.site.id == site.id && item.service.id == service.id) {
return item.state;
}
}
}
return "done";
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment