External events management view
This commit is contained in:
committed by
Arnold Gálovics
parent
11b1e6793b
commit
eaa58a7caf
@@ -0,0 +1,46 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div #filter fxLayout="row">
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label>Filter</mat-label>
|
||||||
|
<input matInput (keyup)="applyFilter($event.target.value)">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div class="action-button" fxLayoutGap="25px">
|
||||||
|
<button mat-raised-button color="primary" (click)="applyChanges()"
|
||||||
|
[disabled]="!existAnyUpdate" *mifosxHasPermission="'UPDATE_EXTERNAL_EVENT_CONFIGURATION'">
|
||||||
|
Apply Changes
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div #eventsTable class="mat-elevation-z8">
|
||||||
|
|
||||||
|
<table mat-table [dataSource]="dataSource" matSort>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="eventType">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Event Type </th>
|
||||||
|
<td mat-cell *matCellDef="let event"> {{ event.type }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="status">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
|
||||||
|
<td mat-cell *matCellDef="let event">
|
||||||
|
<mat-slide-toggle [(ngModel)]="event.enabled" name="{{event.type}}" (click)="toggleStatus(event)">
|
||||||
|
<div [className]="event.enabled ? 'enabled' : 'disabled'">
|
||||||
|
<span *ngIf="event.enabled">Enabled</span>
|
||||||
|
<span *ngIf="!event.enabled">Disabled</span>
|
||||||
|
</div>
|
||||||
|
</mat-slide-toggle>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row"></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
.container {
|
||||||
|
.action-button {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ManageExternalEventsComponent } from './manage-external-events.component';
|
||||||
|
|
||||||
|
describe('ManageExternalEventsComponent', () => {
|
||||||
|
let component: ManageExternalEventsComponent;
|
||||||
|
let fixture: ComponentFixture<ManageExternalEventsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ ManageExternalEventsComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ManageExternalEventsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
|
import { MatSort } from '@angular/material/sort';
|
||||||
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { SystemService } from '../system.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-manage-external-events',
|
||||||
|
templateUrl: './manage-external-events.component.html',
|
||||||
|
styleUrls: ['./manage-external-events.component.scss']
|
||||||
|
})
|
||||||
|
export class ManageExternalEventsComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Events Data. */
|
||||||
|
eventsData: any;
|
||||||
|
externalEventConfigurations: any = {};
|
||||||
|
|
||||||
|
existAnyUpdate = false;
|
||||||
|
|
||||||
|
/** Columns to be displayed in events table. */
|
||||||
|
displayedColumns: string[] = ['eventType', 'status'];
|
||||||
|
/** Data source for reports table. */
|
||||||
|
dataSource: MatTableDataSource<any>;
|
||||||
|
|
||||||
|
/** Paginator for reports table. */
|
||||||
|
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||||
|
/** Sorter for reports table. */
|
||||||
|
@ViewChild(MatSort, { static: true }) sort: MatSort;
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
|
private systemService: SystemService) {
|
||||||
|
this.route.data.subscribe((data: { events: any }) => {
|
||||||
|
this.eventsData = data.events.externalEventConfiguration;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.setEventDatasource();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the data source, paginator and sorter for events table.
|
||||||
|
*/
|
||||||
|
setEventDatasource() {
|
||||||
|
this.dataSource = new MatTableDataSource(this.eventsData);
|
||||||
|
this.dataSource.paginator = this.paginator;
|
||||||
|
this.dataSource.sort = this.sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables/Disables respective event
|
||||||
|
*/
|
||||||
|
toggleStatus(event: any) {
|
||||||
|
this.externalEventConfigurations[event.type] = !event.enabled;
|
||||||
|
this.existAnyUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter using the event type value
|
||||||
|
*/
|
||||||
|
applyFilter(filterValue: string) {
|
||||||
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* send the changes to the backend
|
||||||
|
*/
|
||||||
|
applyChanges() {
|
||||||
|
const payload = {
|
||||||
|
externalEventConfigurations: this.externalEventConfigurations
|
||||||
|
};
|
||||||
|
|
||||||
|
this.systemService.putExternalEventConfiguration(payload).subscribe(() => {
|
||||||
|
this.existAnyUpdate = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ManageExternalEventsResolver } from './manage-external-events.resolver';
|
||||||
|
|
||||||
|
describe('ManageExternalEventsResolver', () => {
|
||||||
|
let resolver: ManageExternalEventsResolver;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
resolver = TestBed.inject(ManageExternalEventsResolver);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(resolver).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import {
|
||||||
|
Router, Resolve,
|
||||||
|
RouterStateSnapshot,
|
||||||
|
ActivatedRouteSnapshot
|
||||||
|
} from '@angular/router';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
import { SystemService } from '../system.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ManageExternalEventsResolver implements Resolve<boolean> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SystemService} systemService System service.
|
||||||
|
*/
|
||||||
|
constructor(private systemService: SystemService) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Configuration data.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||||
|
return this.systemService.getExternalEventConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -87,6 +87,8 @@ import { ConfigurationsComponent } from './configurations/configurations.compone
|
|||||||
import { GlobalConfigurationResolver } from './configurations/global-configurations-tab/global-configuration.resolver';
|
import { GlobalConfigurationResolver } from './configurations/global-configurations-tab/global-configuration.resolver';
|
||||||
import { EditConfigurationComponent } from './configurations/global-configurations-tab/edit-configuration/edit-configuration.component';
|
import { EditConfigurationComponent } from './configurations/global-configurations-tab/edit-configuration/edit-configuration.component';
|
||||||
import { ManageJobsComponent } from './manage-jobs/manage-jobs.component';
|
import { ManageJobsComponent } from './manage-jobs/manage-jobs.component';
|
||||||
|
import { ManageExternalEventsComponent } from './manage-external-events/manage-external-events.component';
|
||||||
|
import { ManageExternalEventsResolver } from './manage-external-events/manage-external-events.resolver';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
Route.withShell([
|
Route.withShell([
|
||||||
@@ -137,7 +139,19 @@ const routes: Routes = [
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'external-events',
|
||||||
|
data: { title: extract('Manage External Events'), breadcrumb: 'Manage External Events' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: ManageExternalEventsComponent,
|
||||||
|
resolve: {
|
||||||
|
events: ManageExternalEventsResolver
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'entity-to-entity-mapping',
|
path: 'entity-to-entity-mapping',
|
||||||
|
|||||||
@@ -72,6 +72,14 @@
|
|||||||
<p matLine>Manage your Services</p>
|
<p matLine>Manage your Services</p>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
|
||||||
|
<mat-list-item [routerLink]="['external-events']" *mifosxHasPermission="'READ_EXTERNAL_EVENT_CONFIGURATION'">
|
||||||
|
<mat-icon matListIcon>
|
||||||
|
<fa-icon icon="anchor" size="sm"></fa-icon>
|
||||||
|
</mat-icon>
|
||||||
|
<h4 matLine>Manage External Events</h4>
|
||||||
|
<p matLine>External Events configuration, to enable or disable the event publication</p>
|
||||||
|
</mat-list-item>
|
||||||
|
|
||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import { NgxGraphModule } from '@swimlane/ngx-graph';
|
|||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { WorkflowJobsComponent } from './manage-jobs/workflow-jobs/workflow-jobs.component';
|
import { WorkflowJobsComponent } from './manage-jobs/workflow-jobs/workflow-jobs.component';
|
||||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||||
|
import { ManageExternalEventsComponent } from './manage-external-events/manage-external-events.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -137,7 +138,8 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
|
|||||||
ManageJobsComponent,
|
ManageJobsComponent,
|
||||||
ManageSchedulerJobsComponent,
|
ManageSchedulerJobsComponent,
|
||||||
WorkflowJobsComponent,
|
WorkflowJobsComponent,
|
||||||
WorkflowDiagramComponent
|
WorkflowDiagramComponent,
|
||||||
|
ManageExternalEventsComponent
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SystemModule { }
|
export class SystemModule { }
|
||||||
|
|||||||
@@ -670,5 +670,18 @@ export class SystemService {
|
|||||||
return this.http.put('/permissions', data, { params: httpParams });
|
return this.http.put('/permissions', data, { params: httpParams });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
getExternalEventConfiguration(): Observable<any> {
|
||||||
|
return this.http.get('/externalevents/configuration');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
putExternalEventConfiguration(payload: any): Observable<any> {
|
||||||
|
return this.http.put('/externalevents/configuration', payload);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user