forked from openMF/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
System Jobs using confirmation dialog
- Loading branch information
1 parent
29cda98
commit c4338b4
Showing
25 changed files
with
332 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ge-jobs/scheduler-jobs/run-selected-jobs-popover/run-selected-jobs-popover.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<h1 mat-dialog-title>{{'labels.heading.Selected Jobs' | translate}}:</h1> | ||
|
||
<mat-dialog-content> | ||
<div class="jobs-container"> | ||
<mifosx-run-selected-jobs-table [selectedJobs]="selectedJobs" (confirmedJobs)="runSelectedJobs()"> | ||
</mifosx-run-selected-jobs-table> | ||
</div> | ||
</mat-dialog-content> | ||
|
||
<mat-list> | ||
<mat-list-item *ngFor="let message of messages" class="message" ngClass]="{'green' : message.status}"> | ||
{{message.message}} | ||
</mat-list-item> | ||
</mat-list> | ||
<mat-dialog-actions> | ||
<button mat-raised-button color="primary" (click)="runSelectedJobs()"> | ||
<fa-icon icon="play" class="m-r-10"></fa-icon> | ||
{{'labels.buttons.Confirm' | translate}} | ||
</button> | ||
<button mat-raised-button color="warn" [mat-dialog-close]="{ show: 0 }"> | ||
{{'labels.buttons.Cancel' | translate}} | ||
</button> | ||
</mat-dialog-actions> |
9 changes: 9 additions & 0 deletions
9
...ge-jobs/scheduler-jobs/run-selected-jobs-popover/run-selected-jobs-popover.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.message { | ||
height: auto; | ||
font-weight: 500; | ||
color: #f44366; | ||
} | ||
|
||
.message.green { | ||
color: #32cd32; | ||
} |
23 changes: 23 additions & 0 deletions
23
...jobs/scheduler-jobs/run-selected-jobs-popover/run-selected-jobs-popover.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RunSelectedJobsPopoverComponent } from './run-selected-jobs-popover.component'; | ||
|
||
describe('RunSelectedJobsPopoverComponent', () => { | ||
let component: RunSelectedJobsPopoverComponent; | ||
let fixture: ComponentFixture<RunSelectedJobsPopoverComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ RunSelectedJobsPopoverComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RunSelectedJobsPopoverComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
81 changes: 81 additions & 0 deletions
81
...nage-jobs/scheduler-jobs/run-selected-jobs-popover/run-selected-jobs-popover.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { SelectionModel } from '@angular/cdk/collections'; | ||
import { | ||
Component, EventEmitter, Inject, OnInit, Output, QueryList, | ||
ViewChildren | ||
} from '@angular/core'; | ||
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
import { SystemService } from 'app/system/system.service'; | ||
import { RunSelectedJobsTableComponent } from './run-selected-jobs-table/run-selected-jobs-table.component'; | ||
|
||
interface SelectedJobsDataType { | ||
selectedJobs: SelectionModel<JobDataType>; | ||
} | ||
|
||
export interface JobDataType { | ||
active: boolean; | ||
cronExpression: string; | ||
currentlyRunning: boolean; | ||
displayName: string; | ||
jobId: number; | ||
lastRunHistory: { | ||
jobRunEndTime: string; | ||
jobRunStartTime: string; | ||
status: string; | ||
triggerType: string; | ||
version: number; | ||
}; | ||
nextRunTime: string; | ||
} | ||
|
||
@Component({ | ||
selector: 'mifosx-run-selected-jobs-popover', | ||
templateUrl: './run-selected-jobs-popover.component.html', | ||
styleUrls: ['./run-selected-jobs-popover.component.scss'] | ||
}) | ||
export class RunSelectedJobsPopoverComponent implements OnInit { | ||
|
||
/** Confirmed jobs event emitter */ | ||
@Output() confirmedJobs = new EventEmitter<JobDataType[]>(); | ||
|
||
/** Job table children */ | ||
@ViewChildren(RunSelectedJobsTableComponent) tableComponents: | ||
QueryList<RunSelectedJobsTableComponent>; | ||
|
||
/** Initialize Selected Jobs */ | ||
selectedJobs: JobDataType[] = []; | ||
|
||
/** Show modal or not */ | ||
show: number; | ||
|
||
/** API call response message */ | ||
messages: { message: string; status: number }[] = []; | ||
|
||
constructor(private systemService: SystemService, @Inject(MAT_DIALOG_DATA) | ||
public data: SelectedJobsDataType) { } | ||
ngOnInit(): void { | ||
this.selectedJobs = this.data.selectedJobs.selected.sort((a, b) => a.jobId - b.jobId); | ||
} | ||
|
||
/** | ||
* Run all confirmed jobs from table | ||
*/ | ||
runSelectedJobs(): void { | ||
this.messages = []; | ||
let tableData: JobDataType[] = []; | ||
this.tableComponents.forEach((tableComponent) => { | ||
tableData = (tableComponent.getTableData()); | ||
}); | ||
|
||
tableData.forEach((job) => { | ||
this.systemService.runSelectedJob(job.jobId.toString()) | ||
.then((response) => { | ||
this.messages.push({ | ||
message: `${job.displayName}: ${response.statusText} (${response.status})`, | ||
status: response.ok | ||
}); | ||
}); | ||
}); | ||
|
||
this.confirmedJobs.emit(tableData); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../run-selected-jobs-popover/run-selected-jobs-table/run-selected-jobs-table.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div> | ||
<table mat-table [dataSource]="selectedJobs"> | ||
<ng-container matColumnDef="displayName"> | ||
<th mat-header-cell *matHeaderCellDef>{{'labels.inputs.Display Name' | | ||
translate}}</th> | ||
<td mat-cell *matCellDef="let element; index as i">{{ element.displayName | ||
}}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="actions"> | ||
<th mat-header-cell *matHeaderCellDef></th> | ||
<td mat-cell *matCellDef="let row; let rowIndex = index"> | ||
<button type="button" mat-icon-button color="warn" (click)="removeJobFromSelection(rowIndex)" | ||
matTooltip="Delete" matTooltipPosition="left"> | ||
<fa-icon icon="trash"></fa-icon> | ||
</button> | ||
</td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="columnsToDisplay" class="first-row"></tr> | ||
<tr mat-row *matRowDef="let selectedJobs; columns: columnsToDisplay"></tr> | ||
</table> | ||
</div> |
13 changes: 13 additions & 0 deletions
13
.../run-selected-jobs-popover/run-selected-jobs-table/run-selected-jobs-table.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
table td { | ||
padding-right: 50px; | ||
} | ||
|
||
.jobs-container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} | ||
|
||
.jobs-container table td { | ||
padding-right: 50px; | ||
} |
23 changes: 23 additions & 0 deletions
23
...n-selected-jobs-popover/run-selected-jobs-table/run-selected-jobs-table.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RunSelectedJobsTableComponent } from './run-selected-jobs-table.component'; | ||
|
||
describe('RunSelectedJobsTableComponent', () => { | ||
let component: RunSelectedJobsTableComponent; | ||
let fixture: ComponentFixture<RunSelectedJobsTableComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ RunSelectedJobsTableComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RunSelectedJobsTableComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.