Some work on project actions

This commit is contained in:
simon987
2019-02-22 20:44:27 -05:00
parent 016676e0f3
commit d44b9924e7
25 changed files with 237 additions and 30 deletions

View File

@@ -0,0 +1,13 @@
<div class="container">
<mat-card class="mat-elevation-z8">
<mat-card-header>
<mat-card-title>{{"admin_panel.title"|translate}}</mat-card-title>
<mat-card-subtitle>{{"admin_panel.subtitle"|translate}}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
</mat-card-content>
<mat-card-actions></mat-card-actions>
</mat-card>
</div>

View File

@@ -0,0 +1,16 @@
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-admin-panel',
templateUrl: './admin-panel.component.html',
styleUrls: ['./admin-panel.component.css']
})
export class AdminPanelComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View File

@@ -12,6 +12,7 @@ import {
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatFormFieldModule,
@@ -55,6 +56,8 @@ import {ManagerSelectComponent} from './manager-select/manager-select.component'
import {ProjectIconComponent} from './project-icon/project-icon.component';
import {IndexComponent} from './index/index.component';
import {ProjectSecretComponent} from './project-secret/project-secret.component';
import {AdminPanelComponent} from './admin-panel/admin-panel.component';
import {AreYouSureComponent} from './are-you-sure/are-you-sure.component';
export function createTranslateLoader(http: HttpClient) {
@@ -81,6 +84,8 @@ export function createTranslateLoader(http: HttpClient) {
ProjectIconComponent,
IndexComponent,
ProjectSecretComponent,
AdminPanelComponent,
AreYouSureComponent,
],
imports: [
BrowserModule,
@@ -120,7 +125,8 @@ export function createTranslateLoader(http: HttpClient) {
MatTabsModule,
MatListModule,
MatButtonToggleModule,
MatStepperModule
MatStepperModule,
MatDialogModule,
],
exports: [],
@@ -131,6 +137,7 @@ export function createTranslateLoader(http: HttpClient) {
],
entryComponents: [
SnackBarComponent,
AreYouSureComponent
],
bootstrap: [AppComponent]
})

View File

@@ -0,0 +1,3 @@
.mat-dialog-actions {
justify-content: end;
}

View File

@@ -0,0 +1,8 @@
<h1 mat-dialog-title>{{"dialog.confirmation"|translate}}</h1>
<div mat-dialog-content>
<p>{{"dialog.are_you_sure"|translate}}</p>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">{{"dialog.no"|translate}}</button>
<button mat-button color="warn" (click)="onYesClick()">{{"dialog.ok"|translate}}</button>
</div>

View File

@@ -0,0 +1,25 @@
import {Component, OnInit} from '@angular/core';
import {MatDialogRef} from "@angular/material";
@Component({
selector: 'app-are-you-sure',
templateUrl: './are-you-sure.component.html',
styleUrls: ['./are-you-sure.component.css']
})
export class AreYouSureComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<AreYouSureComponent>) {
}
ngOnInit() {
}
onNoClick() {
this.dialogRef.close(false)
}
onYesClick() {
this.dialogRef.close(true)
}
}

View File

@@ -9,4 +9,5 @@ export interface Project {
public: boolean;
chain: number;
hidden: boolean;
paused: boolean;
}

View File

@@ -38,3 +38,11 @@
display: none;
}
}
.project-actions {
margin-top: 1em;
}
.project-actions button {
margin-right: 1em;
}

View File

@@ -52,6 +52,28 @@
<pre>{{project | json}}</pre>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="project && auth.logged" class="project-actions">
<mat-expansion-panel-header>
<mat-panel-title>{{"dashboard.actions" | translate}}</mat-panel-title>
</mat-expansion-panel-header>
<button mat-raised-button color="accent" (click)="resetFailedTasks()">
<mat-icon>replay</mat-icon>
{{"dashboard.reset_failed"|translate}}
</button>
<button mat-raised-button
color="primary"
(click)="pauseProject()"
*ngIf="!project.paused"
[title]="'dashboard.pause_hint'|translate">{{"dashboard.pause"|translate}}</button>
<button mat-raised-button color="primary" (click)="pauseProject()">
<mat-icon>pause</mat-icon>
{{"dashboard.pause"|translate}}</button>
<button mat-raised-button color="warn" (click)="hardReset()">
<mat-icon>warning</mat-icon>
{{"dashboard.hard_reset"|translate}}
</button>
</mat-expansion-panel>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button [routerLink]="'/projects'">Back</button>

View File

@@ -8,6 +8,8 @@ import {AssignedTasks, MonitoringSnapshot} from "../models/monitoring";
import {TranslateService} from "@ngx-translate/core";
import {MessengerService} from "../messenger.service";
import {AuthService} from "../auth.service";
import {MatDialog} from "@angular/material";
import {AreYouSureComponent} from "../are-you-sure/are-you-sure.component";
@Component({
@@ -48,6 +50,7 @@ export class ProjectDashboardComponent implements OnInit {
private route: ActivatedRoute,
private translate: TranslateService,
public auth: AuthService,
public dialog: MatDialog,
private messenger: MessengerService) {
}
@@ -340,4 +343,32 @@ export class ProjectDashboardComponent implements OnInit {
this.messenger.show(t))
})
}
resetFailedTasks() {
this.dialog.open(AreYouSureComponent, {
width: '250px',
}).afterClosed().subscribe(result => {
if (result) {
alert("yes")
}
});
}
pauseProject() {
this.dialog.open(AreYouSureComponent, {
width: '250px',
}).afterClosed().subscribe(result => {
if (result) {
this.project.paused = true;
this.apiService.updateProject(this.project).subscribe(() => {
this.translate.get("messenger.acknowledged").subscribe(t =>
this.messenger.show(t))
})
}
});
}
hardReset() {
}
}

View File

@@ -1,3 +1,5 @@
<mat-icon *ngIf="project.public" [title]="'project.public' | translate">public</mat-icon>
<mat-icon *ngIf="!project.public && !project.hidden" [title]="'project.private'|translate">lock</mat-icon>
<mat-icon *ngIf="project.hidden" [title]="'project.hidden'|translate">visibility_off</mat-icon>
<mat-icon *ngIf="project.public && !project.paused" [title]="'project.public' | translate">public</mat-icon>
<mat-icon *ngIf="!project.public && !project.hidden && !project.paused" [title]="'project.private'|translate">lock
</mat-icon>
<mat-icon *ngIf="project.hidden && !project.paused" [title]="'project.hidden'|translate">visibility_off</mat-icon>
<mat-icon *ngIf="project.paused" [title]="'project.paused'|translate">pause</mat-icon>

View File

@@ -5,3 +5,11 @@ button {
mat-panel-title > project-icon {
margin-right: 1em;
}
.paused {
color: #9a9a9a;
}
.mat-expansion-panel-header-description {
flex-grow: 0;
}

View File

@@ -12,11 +12,12 @@
<mat-accordion>
<mat-expansion-panel *ngFor="let project of projects" style="margin-top: 1em">
<mat-expansion-panel-header>
<mat-panel-title>
<mat-panel-title [class.paused]="project.paused">
<project-icon [project]="project"></project-icon>
<span style="width: 3em">{{project.id}}</span>{{project.name}}
<span style="width: 3em; align-self: center">{{project.id}}</span>
<span style="align-self: center">{{project.name}}</span>
</mat-panel-title>
<mat-panel-description>{{project.motd}}</mat-panel-description>
<mat-panel-description style="align-self: center">{{project.motd}}</mat-panel-description>
</mat-expansion-panel-header>
<pre>{{project | json}}</pre>
<div>

View File

@@ -74,7 +74,12 @@
"title": "Dashboard for",
"metadata": "Project metadata",
"empty": "No tasks",
"refresh": "Refresh"
"refresh": "Refresh",
"actions": "Actions",
"reset_failed": "Reset failed tasks",
"pause": "Pause",
"resume": "Resume",
"hard_reset": "Hard_reset"
},
"login": {
"title": "Login",
@@ -121,7 +126,8 @@
},
"messenger": {
"close": "Close",
"unauthorized": "Unauthorized"
"unauthorized": "Unauthorized",
"acknowledged": "Changes saved"
},
"manager_list": {
"title": "Manager list",
@@ -149,5 +155,11 @@
"secret": "Secret",
"update": "Update",
"ok": "Updated"
},
"dialog": {
"confirmation": "Confirmation",
"are_you_sure": "Are you sure?",
"no": "No",
"ok": "Ok"
}
}

View File

@@ -74,7 +74,8 @@
"title": "Tableau de bord pour ",
"metadata": "Métadonnés du projet",
"empty": "Aucune tâche",
"refresh": "Rafraîchir"
"refresh": "Rafraîchir",
"actions": "Actions"
},
"login": {
"title": "Ouvrir un session",
@@ -123,7 +124,8 @@
},
"messenger": {
"close": "Fermer",
"unauthorized": "Non autorisé"
"unauthorized": "Non autorisé",
"acknowledged": "Changements enregistrés"
},
"manager_list": {
"title": "Liste ",