Commit b717a992 authored by Lukas Burgey's avatar Lukas Burgey

Add listing of unfinished tasks

parent c418b031
<div *ngIf="userService.loggedIn">
<h4>Services</h4>
<div *ngIf="userService.services.length > 0">
<mat-accordion>
<app-service *ngFor="let service of userService.services"
[serviceData]="service"></app-service>
</mat-accordion>
<div>
<h4>Services</h4>
<div *ngIf="userService.services.length > 0">
<mat-accordion>
<app-service *ngFor="let service of userService.services"
[serviceData]="service"></app-service>
</mat-accordion>
</div>
<p *ngIf="userService.services?.length == 0">
You have no available services.<br/>
This is due services requiring users to be member of a certain group.
</p>
</div>
<div *ngIf="userService.user.deployment_tasks.length > 0">
<h4>Uncompleted tasks</h4>
<div>
<p *ngFor="let task of userService.user.deployment_tasks">
{{ task.action }}: {{ task.key }}
</p>
</div>
</div>
<p *ngIf="userService.services?.length == 0">
You have no available services.<br/>
This is due services requiring users to be member of a certain group.
</p>
</div>
......@@ -13,6 +13,7 @@ export class SnackBarService {
}
public open(message: string) {
console.log(message);
return this.snackBar.open(message, '', this.config);
}
}
......@@ -72,22 +72,17 @@ export class UserService {
);
}
public updateData(data: any) {
if (data['error']) {
this.snackBar.open(data['error']);
}
if (!this.services) {
this.services = data.services;
}
this.user = data.user;
private _handleValueChange(newData: any) {
}
private _updateUserValues(newUser: any) {
this.user = newUser;
if (this.user) {
// build sshKeyData
if ('ssh_keys' in this.user) {
this.sshKeyData = new MatTableDataSource(this.user.ssh_keys);
} else {
this.sshKeyData = null;
this.sshKeyData = undefined;
}
// build userInfoData
......@@ -100,16 +95,41 @@ export class UserService {
this.userInfoData = new MatTableDataSource(userInfoList);
} else {
this.sshKeyData = null;
this.userInfoData = null;
this.sshKeyData = undefined;
this.userInfoData = undefined;
}
}
public updateData(newData: any) {
// did a login occur?
let login = (!this.loggedIn && newData.logged_in);
// did a logout occur?
let logout = (this.loggedIn && !newData.logged_in);
if (!this.loggedIn && data.logged_in) {
// report an occured error
if (newData.error) {
this.snackBar.open(newData.error);
}
// -- Value updating --
this.loggedIn = newData.logged_in;
// this check is needed because the accordeon collapses if we overwrite the list
if (!this.services) {
this.services = newData.services;
}
this._updateUserValues(newData.user);
if (login) {
this.snackBar.open('Logged in');
// TODO dirty
this.connectLiveUpdates()
}
this.loggedIn = data.logged_in;
if (logout) {
this.snackBar.open('Logged out');
this._stompService.disconnect();
// reset some attributes
this.services = [];
}
}
public updateState() {
......@@ -185,7 +205,7 @@ export class UserService {
};
return this.http.post('/backend/api/deployments/', body).subscribe(
(data) => {
this.snackBar.open('Deployed key ' + key.name);
//this.snackBar.open('Deployed key ' + key.name);
this.updateData(data);
},
(err) => {
......@@ -205,7 +225,7 @@ export class UserService {
return this.http.post('/backend/api/deployments/', body).subscribe(
(data) => {
this.snackBar.open('Withdrew key ' + key.name);
//this.snackBar.open('Withdrew key ' + key.name);
this.updateData(data);
},
(err) => {
......@@ -256,7 +276,7 @@ export class UserService {
reconnect_delay: 5000,
// Will log diagnostics on console
debug: true
debug: false,
};
this._stompService.config = stompConfig;
this._stompService.initAndConnect();
......@@ -270,13 +290,14 @@ export class UserService {
subscription.map((message: Message) => {
return message.body;
}).subscribe((msg_body: string) => {
this.snackBar.open(
'Backend: ' + msg_body
);
console.log(`Received: ${msg_body}`);
}).subscribe((body: any) => {
let json = JSON.parse(body);
if (json.message && json.message != '') {
this.snackBar.open( json.message);
}
if (json.user_state) {
this._updateUserValues(json.user_state);
}
});
}
}
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