Commit d61c0cbf authored by Lukas Burgey's avatar Lukas Burgey

Fix bug opening dialogues

parent b186c66c
import {Component, OnInit,Inject} from '@angular/core';
import {MAT_DIALOG_DATA} from '@angular/material';
import {MatTableDataSource} from '@angular/material';
import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatTableDataSource } from '@angular/material';
import { UserService } from '../../user.service';
import * as t from '../../types/types.module';
......@@ -11,6 +10,7 @@ import * as t from '../../types/types.module';
styleUrls: ['./credentials.component.css']
})
export class CredentialsComponent implements OnInit {
public columns = ["name", "value"];
public stateItem: t.DeploymentStateItem;
public service: t.Service;
......@@ -21,23 +21,26 @@ export class CredentialsComponent implements OnInit {
public userService: UserService,
@Inject(MAT_DIALOG_DATA) public data: any,
) {
this.stateItem = data.stateItem;
this.service = data.stateItem.service;
}
ngOnInit() {
const credentialList = [];
for (const key in this.stateItem.credentials) {
if (this.stateItem.credentials.hasOwnProperty(key)) {
credentialList.push(
{
name: key,
value: this.stateItem.credentials[key],
}
);
if (this.data) {
this.stateItem = this.data.stateItem;
this.service = this.stateItem.service;
const credentialList = [];
for (const key in this.stateItem.credentials) {
if (this.stateItem.credentials.hasOwnProperty(key)) {
credentialList.push(
{
name: key,
value: this.stateItem.credentials[key],
}
);
}
}
this.credentialCount = credentialList.length;
this.table = new MatTableDataSource(credentialList);
}
this.credentialCount = credentialList.length;
this.table = new MatTableDataSource(credentialList);
}
}
......@@ -58,7 +58,7 @@ export class UserService {
private connect(): void {
this.subscribeState().subscribe(
(state: SAR) => {
//console.log('sar$ yielded', state);
console.log('State:', state);
// update users
const user = this.userSelector(state);
......@@ -147,8 +147,7 @@ export class UserService {
this.messages.push(update.error);
}
if (update.user_state) {
console.log('stomp received stateAPIUpdate', update.user_state);
this.updateUserState(update.user_state);
this.userStateUpdate(update.user_state);
}
},
(error: any) => {
......@@ -157,7 +156,9 @@ export class UserService {
);
}
private updateUserState(newState: t.UserState): void {
private userStateUpdate(newState: t.UserState): void {
console.log('userStateUpdate:', newState);
// did a login occur?
let login = (!this.loggedIn && newState);
// did a logout occur?
......@@ -182,6 +183,7 @@ export class UserService {
private stateAPIUpdate(update: t.StateAPIResult) {
console.log('stateAPIUpdate:', update);
if (update) {
// report an occured error
if (update.error) {
......@@ -193,7 +195,7 @@ export class UserService {
return
}
this.updateUserState(update.user_state);
this.userStateUpdate(update.user_state);
this.sar = update;
this.sar$.next(update);
......@@ -279,7 +281,7 @@ export class UserService {
return this.http.post('/backend/api/questionnaire?id='+String(stateItemID), answers).subscribe(
(data: t.UserState) => {
this.snackBar.open('Uploaded questionnaire');
this.updateUserState(data);
this.userStateUpdate(data);
},
(err) => {
this.snackBar.open('Error uploading questionnaire');
......
......@@ -3,6 +3,7 @@ import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { UserService } from '../user.service';
import { DialogService } from '../dialogues/dialog.service';
import * as t from '../types/types.module';
@Component({
......@@ -27,6 +28,7 @@ export class VoDataComponent implements OnInit {
constructor(
public userService: UserService,
public dialog: DialogService,
) {
}
......
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