Commit bcb8174b authored by Lukas Burgey's avatar Lukas Burgey

Add listing for separate keys

parent cd4c9614
...@@ -10,35 +10,47 @@ ...@@ -10,35 +10,47 @@
<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 [ngSwitch]="userService.taskState(site, serviceData)"> <div *ngIf="userService.user.ssh_keys.length > 0">
<span *ngSwitchCase="'pending'" <span *ngFor="let key of userService.user.ssh_keys"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle" [ngSwitch]="userService.taskState(site, serviceData, key)" class="childs-inline">
matTooltip="Waiting for site"> <!-- states with actions -->
<mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner> <button *ngSwitchCase="'deployed'" mat-button mat-icon-button
matTooltip="The credentials are deployed to the site.">
<mat-icon style="vertical-align: middle">call_made</mat-icon>
</button>
<button *ngSwitchCase="'questionnaire'" mat-button mat-icon-button
(click)="dialog.openQuestionnaire(userService.taskItem(site, serviceData))"
matTooltip="This site needs more data to deploy the credentials. Please click to
submit the data.">
<mat-icon>warning</mat-icon>
</button>
<!-- states without actions -->
<span *ngSwitchCase="'deployment_pending'"
matTooltip="Waiting for the deployment of the credentials from the site">
<mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner>
</span>
<span *ngSwitchCase="'removal_pending'"
matTooltip="Waiting for the removal of the credentials from the site">
<mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner>
</span>
<span *ngSwitchCase="'not_deployed'"
matTooltip="The credential is not deployed to this site.">
<mat-icon style="vertical-align: middle">call_received</mat-icon>
</span>
<span *ngSwitchCase="'failed'"
matTooltip="This site failed to deploy the credentials. The deployment will be retried.">
<mat-icon style="vertical-align: middle">error</mat-icon>
</span>
<span *ngSwitchCase="'rejected'"
matTooltip="This site rejected the deployment. You can not use this service.">
<mat-icon style="vertical-align: middle">error</mat-icon>
</span>
<span *ngSwitchDefault
matTooltip="Unrecognized state">
<mat-icon style="vertical-align: middle">details</mat-icon>
</span>
</span> </span>
<span *ngSwitchCase="'answered'" </div>
mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="Waiting for site">
<mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner>
</span>
<button *ngSwitchCase="'done'"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="The credentials have the supposed state.">
<mat-icon style="vertical-align: middle">done</mat-icon>
</button>
<button *ngSwitchCase="'failed'"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="This site failed to deploy the credentials. It will retry the deployment.">
<mat-icon style="vertical-align: middle">error</mat-icon>
</button>
<button *ngSwitchCase="'rejected'"
(click)="dialog.openQuestionnaire(userService.taskItem(site, serviceData))"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="This site needs more data to deploy the credentials. Please click to
submit the data.">
<mat-icon>warning</mat-icon>
</button>
</span>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -47,8 +47,8 @@ export interface User { ...@@ -47,8 +47,8 @@ export interface User {
userinfo: any; userinfo: any;
ssh_keys: SSHKey[]; ssh_keys: SSHKey[];
deployments: Deployment[]; deployments: Deployment[];
deployment_tasks: any[]; deployment_states: any[];
deployment_task_items: any[]; deployment_state_items: any[];
id: number; id: number;
} }
......
...@@ -237,8 +237,7 @@ export class UserService { ...@@ -237,8 +237,7 @@ export class UserService {
} }
public sentQuestionnaire(taskItemID: number, answers: any) { public sentQuestionnaire(taskItemID: number, answers: any) {
const body = answers; return this.http.post('/backend/api/questionnaire?id='+String(taskItemID), answers).subscribe(
return this.http.post('/backend/api/questionnaire?id='+String(taskItemID), body).subscribe(
(data) => { (data) => {
this.snackBar.open('Uploaded questionnaire'); this.snackBar.open('Uploaded questionnaire');
//this.snackBar.open('Deployed key ' + key.name); //this.snackBar.open('Deployed key ' + key.name);
...@@ -318,10 +317,12 @@ export class UserService { ...@@ -318,10 +317,12 @@ export class UserService {
}); });
} }
public taskItem(site, service): any { public taskItem(site: any, service: any, key: any): any {
if (this.user.deployment_task_items && site && service) { if (this.user.deployment_state_items && site && service && key) {
for (const item of this.user.deployment_task_items){ for (const item of this.user.deployment_state_items){
if (item.site.id == site.id && item.service.id == service.id) { if (item.site.id == site.id
&& item.key.id == key.id
&& item.service.id == service.id) {
return item; return item;
} }
} }
...@@ -329,11 +330,11 @@ export class UserService { ...@@ -329,11 +330,11 @@ export class UserService {
return null; return null;
} }
public taskState(site, service): string { public taskState(site: any, service: any, key: any): string {
let item = this.taskItem(site, service); let item = this.taskItem(site, service, key);
if (item !== null) { if (item !== null) {
return item.state; return item.state;
} }
return "done"; return "";
} }
} }
...@@ -40,6 +40,11 @@ body { ...@@ -40,6 +40,11 @@ body {
width: 100%; width: 100%;
} }
.childs-inline > * {
display: inline-block;
vertical-align: middle;
}
.form-vertical > button { .form-vertical > button {
width: 25%; width: 25%;
} }
......
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