Commit 889f3187 authored by Lukas Burgey's avatar Lukas Burgey

Restructure the dialogues

parent eb7e9d3a
...@@ -6,59 +6,29 @@ import {JsonPipe} from '@angular/common'; ...@@ -6,59 +6,29 @@ import {JsonPipe} from '@angular/common';
import {HttpModule} from '@angular/http'; import {HttpModule} from '@angular/http';
import {HttpClientModule, HttpClientXsrfModule} from '@angular/common/http'; import {HttpClientModule, HttpClientXsrfModule} from '@angular/common/http';
import {MatButtonModule} from '@angular/material';
import {MatToolbarModule} from '@angular/material';
import {MatTableModule} from '@angular/material/table';
import {MatSnackBarModule} from '@angular/material/snack-bar';
import {MatExpansionModule} from '@angular/material/expansion';
import {MatIconModule} from '@angular/material/icon';
import {MatDialogModule} from '@angular/material/dialog';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatSelectModule} from '@angular/material/select';
import {MatInputModule} from '@angular/material/input';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatProgressBarModule} from '@angular/material/progress-bar';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
// Other libs // Other libs
import {StompRService} from '@stomp/ng2-stompjs'; import {StompRService} from '@stomp/ng2-stompjs';
import {CookieService} from 'ngx-cookie-service'; import {CookieService} from 'ngx-cookie-service';
// Our stuff // Our stuff
//
// services
import {UserService} from './user.service'; import {UserService} from './user.service';
import {SnackBarService} from './snackbar.service'; import {SnackBarService} from './snackbar.service';
import {DialogService} from './dialog.service';
// imports
import {DialoguesModule} from './dialogues/dialogues.module';
import {MaterialModule} from './material/material.module';
import {SharedModule} from './shared/shared.module';
// declarations
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
import {MgmtComponent} from './mgmt/mgmt.component'; import {MgmtComponent} from './mgmt/mgmt.component';
import {LoginComponent} from './login/login.component'; import {LoginComponent} from './login/login.component';
import {ProfileComponent} from './profile/profile.component';
import {QuestionnaireComponent} from './questionnaire/questionnaire.component';
import {ServiceComponent} from './service/service.component'; import {ServiceComponent} from './service/service.component';
import {SshKeysComponent} from './ssh-keys/ssh-keys.component';
import {AccountComponent} from './account/account.component';
@Pipe({ name: 'ObjNgFor', pure: false })
export class ObjNgFor implements PipeTransform {
transform(value: any, args: any[] = null): any {
return Object.keys(value);//.map(key => value[key]);
}
}
@NgModule({ @NgModule({
declarations: [
AppComponent,
MgmtComponent,
LoginComponent,
ProfileComponent,
QuestionnaireComponent,
ServiceComponent,
SshKeysComponent,
AccountComponent,
ObjNgFor,
],
imports: [ imports: [
BrowserModule, BrowserModule,
BrowserAnimationsModule, BrowserAnimationsModule,
...@@ -69,37 +39,24 @@ export class ObjNgFor implements PipeTransform { ...@@ -69,37 +39,24 @@ export class ObjNgFor implements PipeTransform {
cookieName: 'csrftoken', cookieName: 'csrftoken',
headerName: 'HTTP_X_CSRFTOKEN', headerName: 'HTTP_X_CSRFTOKEN',
}), }),
MatButtonModule, DialoguesModule,
MatToolbarModule, MaterialModule,
MatTableModule, SharedModule,
MatSnackBarModule, ],
MatExpansionModule, declarations: [
MatIconModule, AppComponent,
MatDialogModule, MgmtComponent,
MatFormFieldModule, LoginComponent,
MatSelectModule, ServiceComponent,
MatInputModule,
MatCheckboxModule,
MatTooltipModule,
MatProgressBarModule,
MatProgressSpinnerModule,
], ],
providers: [ providers: [
CookieService, CookieService,
UserService, UserService,
SnackBarService, SnackBarService,
DialogService,
StompRService, StompRService,
JsonPipe, JsonPipe,
ObjNgFor,
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
entryComponents: [
ProfileComponent,
SshKeysComponent,
AccountComponent,
QuestionnaireComponent,
],
}) })
export class AppModule { export class AppModule {
constructor() { constructor() {
......
import { TestBed, inject } from '@angular/core/testing';
import { DialogService } from './dialog.service';
describe('DialogService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [DialogService]
});
});
it('should be created', inject([DialogService], (service: DialogService) => {
expect(service).toBeTruthy();
}));
});
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { UserService } from '../user.service'; import { UserService } from '../../user.service';
@Component({ @Component({
selector: 'app-account', selector: 'app-account',
......
import { DialoguesModule } from './dialogues.module';
describe('DialoguesModule', () => {
let dialoguesModule: DialoguesModule;
beforeEach(() => {
dialoguesModule = new DialoguesModule();
});
it('should create an instance', () => {
expect(dialoguesModule).toBeTruthy();
});
});
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
// imports
import {MaterialModule} from '../material/material.module';
import {SharedModule} from '../shared/shared.module';
// declarations
import {QuestionnaireComponent} from './questionnaire/questionnaire.component';
import {ProfileComponent} from './profile/profile.component';
import {SshKeysComponent} from './ssh-keys/ssh-keys.component';
import {AccountComponent} from './account/account.component';
//providers
import {DialogService} from './dialog.service';
@NgModule({
imports: [
CommonModule,
FormsModule,
MaterialModule,
SharedModule,
],
declarations: [
QuestionnaireComponent,
ProfileComponent,
SshKeysComponent,
AccountComponent,
],
entryComponents: [
QuestionnaireComponent,
ProfileComponent,
SshKeysComponent,
AccountComponent,
],
providers: [
DialogService,
],
})
export class DialoguesModule { }
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material'; import { MatTableDataSource } from '@angular/material';
import { UserService } from '../user.service'; import { UserService } from '../../user.service';
@Component({ @Component({
selector: 'app-profile', selector: 'app-profile',
......
<div class="mat-typography"> <div class="mat-typography">
<h2>Parameter questionnaire</h2> <h2>Data questionnaire</h2>
<p> <p>
The following data is requirred to access the service. The site {{taskItem.site.name}} needs the following data to give you access to the service {{
taskItem.service.name}}.
</p> </p>
<form class="form-vertical" (ngSubmit)="sendAnswers()" #questionnaireForm="ngForm"> <form class="form-vertical" (ngSubmit)="sendAnswers()" #questionnaireForm="ngForm">
<mat-form-field *ngFor="let key of taskItem.questionnaire | ObjNgFor"> <mat-form-field *ngFor="let key of taskItem.questionnaire | ObjKeys">
<input matInput required <input matInput required
placeholder="{{taskItem.questionnaire[key]}}" [(ngModel)]="answers[key]" name="key"> placeholder="{{taskItem.questionnaire[key]}}" [(ngModel)]="answers[key]" name="key">
</mat-form-field> </mat-form-field>
......
import {Component, OnInit,Inject} from '@angular/core'; import {Component, OnInit,Inject} from '@angular/core';
import {MAT_DIALOG_DATA} from '@angular/material'; import {MAT_DIALOG_DATA} from '@angular/material';
import { UserService } from '../user.service'; import { UserService } from '../../user.service';
@Component({ @Component({
selector: 'app-questionnaire', selector: 'app-questionnaire',
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material'; import { MatTableDataSource } from '@angular/material';
import { UserService } from '../user.service'; import { UserService } from '../../user.service';
import { SSHKey, NewSSHKey } from '../types/types.module'; import { SSHKey, NewSSHKey } from '../../types/types.module';
@Component({ @Component({
selector: 'app-ssh-keys', selector: 'app-ssh-keys',
......
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { DialogService } from '../dialog.service'; import { DialogService } from '../dialogues/dialog.service';
import { UserService } from '../user.service'; import { UserService } from '../user.service';
import { AllAuthInfo, IdP } from '../types/types.module'; import { AllAuthInfo, IdP } from '../types/types.module';
......
import { MaterialModule } from './material.module';
describe('MaterialModule', () => {
let materialModule: MaterialModule;
beforeEach(() => {
materialModule = new MaterialModule();
});
it('should create an instance', () => {
expect(materialModule).toBeTruthy();
});
});
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {MatButtonModule} from '@angular/material';
import {MatToolbarModule} from '@angular/material';
import {MatTableModule} from '@angular/material/table';
import {MatSnackBarModule} from '@angular/material/snack-bar';
import {MatExpansionModule} from '@angular/material/expansion';
import {MatIconModule} from '@angular/material/icon';
import {MatDialogModule} from '@angular/material/dialog';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatSelectModule} from '@angular/material/select';
import {MatInputModule} from '@angular/material/input';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatProgressBarModule} from '@angular/material/progress-bar';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
@NgModule({
imports: [
CommonModule,
MatButtonModule,
MatToolbarModule,
MatTableModule,
MatSnackBarModule,
MatExpansionModule,
MatIconModule,
MatDialogModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule,
MatCheckboxModule,
MatTooltipModule,
MatProgressSpinnerModule,
],
exports: [
MatButtonModule,
MatToolbarModule,
MatTableModule,
MatSnackBarModule,
MatExpansionModule,
MatIconModule,
MatDialogModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule,
MatCheckboxModule,
MatTooltipModule,
MatProgressSpinnerModule,
],
})
export class MaterialModule { }
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ProfileComponent } from './profile.component';
describe('ProfileComponent', () => {
let component: ProfileComponent;
let fixture: ComponentFixture<ProfileComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ProfileComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ProfileComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});
...@@ -13,23 +13,29 @@ ...@@ -13,23 +13,29 @@
<span [ngSwitch]="userService.taskState(site, serviceData)"> <span [ngSwitch]="userService.taskState(site, serviceData)">
<span *ngSwitchCase="'pending'" <span *ngSwitchCase="'pending'"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle" mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="This deployment is in progress"> matTooltip="Waiting for site">
<mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner>
</span>
<span *ngSwitchCase="'answered'"
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> <mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner>
</span> </span>
<button *ngSwitchCase="'done'" <button *ngSwitchCase="'done'"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle" mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="This deployment was successful"> matTooltip="The credentials have the supposed state.">
<mat-icon style="vertical-align: middle">done</mat-icon> <mat-icon style="vertical-align: middle">done</mat-icon>
</button> </button>
<button *ngSwitchCase="'failed'" <button *ngSwitchCase="'failed'"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle" mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="This deployment has failed"> matTooltip="This site failed to deploy the credentials. It will retry the deployment.">
<mat-icon style="vertical-align: middle">error</mat-icon> <mat-icon style="vertical-align: middle">error</mat-icon>
</button> </button>
<button *ngSwitchCase="'rejected'" <button *ngSwitchCase="'rejected'"
(click)="dialog.openQuestionnaire(userService.taskItem(site, serviceData))" (click)="dialog.openQuestionnaire(userService.taskItem(site, serviceData))"
mat-button mat-icon-button style="display: inline-block; vertical-align: middle" mat-button mat-icon-button style="display: inline-block; vertical-align: middle"
matTooltip="This deployment was rejected. The client needs more data."> matTooltip="This site needs more data to deploy the credentials. Please click to
submit the data.">
<mat-icon>warning</mat-icon> <mat-icon>warning</mat-icon>
</button> </button>
</span> </span>
......
...@@ -2,8 +2,7 @@ import { Component, OnInit, Input } from '@angular/core'; ...@@ -2,8 +2,7 @@ import { Component, OnInit, Input } from '@angular/core';
import { MatCheckboxChange } from '@angular/material/checkbox'; import { MatCheckboxChange } from '@angular/material/checkbox';
import { UserService } from '../user.service'; import { UserService } from '../user.service';
import { DialogService } from '../dialog.service'; import { DialogService } from '../dialogues/dialog.service';
import { SshKeysComponent } from '../ssh-keys/ssh-keys.component';
@Component({ @Component({
selector: 'app-service', selector: 'app-service',
......
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'ObjKeys', pure: false })
export class ObjKeysPipe implements PipeTransform {
transform(value: any, args: any[] = null): any {
return Object.keys(value);//.map(key => value[key]);
}
}
import { SharedModule } from './shared.module';
describe('SharedModule', () => {
let sharedModule: SharedModule;
beforeEach(() => {
sharedModule = new SharedModule();
});
it('should create an instance', () => {
expect(sharedModule).toBeTruthy();
});
});
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {ObjKeysPipe} from './obj-keys.pipe';
@NgModule({
imports: [
CommonModule,
],
declarations: [
ObjKeysPipe,
],
exports: [
ObjKeysPipe,
],
})
export class SharedModule { }
...@@ -9,7 +9,6 @@ import {CookieService} from 'ngx-cookie-service'; ...@@ -9,7 +9,6 @@ import {CookieService} from 'ngx-cookie-service';
import {MatTableDataSource} from '@angular/material'; import {MatTableDataSource} from '@angular/material';
import {SnackBarService} from './snackbar.service'; import {SnackBarService} from './snackbar.service';
import {DialogService} from './dialog.service';
import {StompConfig, StompRService} from '@stomp/ng2-stompjs'; import {StompConfig, StompRService} from '@stomp/ng2-stompjs';
import {Message} from '@stomp/stompjs'; import {Message} from '@stomp/stompjs';
...@@ -28,7 +27,6 @@ export class UserService { ...@@ -28,7 +27,6 @@ export class UserService {
constructor( constructor(
public dialog: DialogService,
public cookieService: CookieService, public cookieService: CookieService,
public http: HttpClient, public http: HttpClient,
public snackBar: SnackBarService, public snackBar: SnackBarService,
...@@ -242,9 +240,8 @@ export class UserService { ...@@ -242,9 +240,8 @@ export class UserService {
public sentQuestionnaire(taskItemID: number, answers: any) { public sentQuestionnaire(taskItemID: number, answers: any) {
const body = answers; const body = answers;
return this.http.post('/backend/api/questionnaire/'+String(taskItemID), body).subscribe( return this.http.post('/backend/api/questionnaire?id='+String(taskItemID), body).subscribe(
(data) => { (data) => {
this.dialog.questionnaireDialog.close();
this.snackBar.open('Uploaded questionnaire'); this.snackBar.open('Uploaded questionnaire');
//this.snackBar.open('Deployed key ' + key.name); //this.snackBar.open('Deployed key ' + key.name);
this.updateData(data); this.updateData(data);
......
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