diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2516873e331760f405d12e160465e70ff88dd551..b5da66d56f5235ad854d5a471633d846dd21d275 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -13,22 +13,23 @@ import { DocumentDetailComponent } from './document-detail/document-detail.compo import { MessagesComponent } from './messages/messages.component'; import { LoginService } from './services/login.service'; import { HttpModule } from '@angular/http'; -import {CookieService} from 'ngx-cookie-service'; +import { CookieService } from 'ngx-cookie-service'; import { PretoxsentencesTabulatorComponent } from './pretoxsentences-tabulator/pretoxsentences-tabulator.component'; import { SrdomaintemplateTabulatorComponent } from './srdomaintemplate-tabulator/srdomaintemplate-tabulator.component'; -import {MatToolbarModule} from '@angular/material/toolbar'; -import {MatTabsModule} from '@angular/material/tabs'; -import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatTabsModule } from '@angular/material/tabs'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { LogoutComponent } from './logout/logout.component'; import { HistoryTrackingComponent } from './history-tracking/history-tracking.component'; -import {MatProgressSpinnerModule, MatProgressBarModule} from '@angular/material' -import {OAuthModule} from "angular-oauth2-oidc"; +import { MatProgressSpinnerModule, MatProgressBarModule, MatDialogModule } from '@angular/material' +import { OAuthModule } from "angular-oauth2-oidc"; import { UploadFilesComponent } from './upload-files/upload-files.component'; import { authConfigFactory } from './auth-config-factory'; -import { OAuthModuleConfig} from 'angular-oauth2-oidc'; +import { OAuthModuleConfig } from 'angular-oauth2-oidc'; import { ConfigServiceService } from './services/config-service.service'; import { WorkflowExecutionComponent } from './workflow-execution/workflow-execution.component'; import { ReportsComponent } from './reports/reports.component'; +import { DeleteReportDialog } from './delete-report-dialog/delete-report-dialog.component'; @NgModule({ @@ -47,9 +48,13 @@ import { ReportsComponent } from './reports/reports.component'; HistoryTrackingComponent, UploadFilesComponent, WorkflowExecutionComponent, - ReportsComponent + ReportsComponent, + DeleteReportDialog - ], + ], + entryComponents: [ + DeleteReportDialog + ], imports: [ BrowserModule, AppRoutingModule, @@ -62,6 +67,7 @@ import { ReportsComponent } from './reports/reports.component'; MatProgressSpinnerModule, MatProgressBarModule, OAuthModule.forRoot(), + MatDialogModule /*OAuthModule.forRoot({ resourceServer: { //allowedUrls: [environment.apiUrl], @@ -75,8 +81,8 @@ import { ReportsComponent } from './reports/reports.component'; } }),*/ ], - providers: [LoginService, CookieService, - { provide: OAuthModuleConfig , useFactory: authConfigFactory, deps: [ConfigServiceService] }, + providers: [LoginService, CookieService, + { provide: OAuthModuleConfig, useFactory: authConfigFactory, deps: [ConfigServiceService] }, //{ provide: OAuthModuleConfig , useFactory: authConfigFactory}, ], bootstrap: [AppComponent], diff --git a/src/app/delete-report-dialog/delete-report-dialog.component.css b/src/app/delete-report-dialog/delete-report-dialog.component.css new file mode 100644 index 0000000000000000000000000000000000000000..f3e7c4b6ffe6ff5a97b4934b9592bfecc3d18c41 --- /dev/null +++ b/src/app/delete-report-dialog/delete-report-dialog.component.css @@ -0,0 +1,15 @@ +.dialog-buttons { + justify-content: end; +} + +.dialog-button { + background-color: white; + border: 1px solid gray; + border-radius: 4px; + margin-right: 10px; + width: 15%; +} + +.dialog-button:hover { + border: 1px solid black; +} \ No newline at end of file diff --git a/src/app/delete-report-dialog/delete-report-dialog.component.html b/src/app/delete-report-dialog/delete-report-dialog.component.html new file mode 100644 index 0000000000000000000000000000000000000000..90b1fe944a276a41dcf5f54ec24bc5bd18a653c6 --- /dev/null +++ b/src/app/delete-report-dialog/delete-report-dialog.component.html @@ -0,0 +1,7 @@ +
+

This operation cannot be undone. Do you still want to delete this report?

+
+
+ + +
diff --git a/src/app/delete-report-dialog/delete-report-dialog.component.ts b/src/app/delete-report-dialog/delete-report-dialog.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fffe4ee74d77264659fea76219b34d3480f8e14 --- /dev/null +++ b/src/app/delete-report-dialog/delete-report-dialog.component.ts @@ -0,0 +1,14 @@ +import { Component } from "@angular/core"; +import { MatDialogRef } from "@angular/material"; + + +@Component({ + selector: 'app-delete-report-dialog', + templateUrl: 'delete-report-dialog.component.html', + styleUrls: ['./delete-report-dialog.component.css'] +}) +export class DeleteReportDialog { + constructor( + public dialogRef: MatDialogRef, + ) { } +} \ No newline at end of file diff --git a/src/app/reports/reports.component.ts b/src/app/reports/reports.component.ts index dbd3028a436fa331b1ea3a1b9149722be0d6fd63..bb58d2aeef093a90b8dfea8379c8a31a275416ad 100644 --- a/src/app/reports/reports.component.ts +++ b/src/app/reports/reports.component.ts @@ -2,31 +2,34 @@ import { Component, Input, OnInit, SimpleChanges } from '@angular/core'; import { DocumentService } from '../services/document.service'; import { Report } from '../model/report'; import { Router } from '@angular/router'; -import {TabulatorFull as Tabulator} from 'tabulator-tables'; +import { TabulatorFull as Tabulator } from 'tabulator-tables'; import { WorkflowService } from '../services/workflow.service'; +import { MatDialog } from '@angular/material'; +import { DeleteReportDialog } from '../delete-report-dialog/delete-report-dialog.component'; @Component({ selector: 'app-reports', templateUrl: './reports.component.html', styleUrls: ['./reports.component.css'] }) + export class ReportsComponent implements OnInit { selectedReport: Report; reports: Report[]; - - message=''; - messages=[]; - validation_errors=[]; - + + message = ''; + messages = []; + validation_errors = []; + tableData: any[] = []; @Input() report: Report; @Input() height = '100%'; tab = document.createElement('div'); - constructor(private documentService: DocumentService, private workflowService: WorkflowService, - private router: Router) { } + constructor(private documentService: DocumentService, private workflowService: WorkflowService, + private router: Router, public dialog: MatDialog) { } ngOnInit() { this.getReports(); @@ -36,138 +39,151 @@ export class ReportsComponent implements OnInit { this.drawTable(this); } - - onSelect(report: Report): void { this.selectedReport = report; } getReports(): void { this.documentService.getReports() - .subscribe(reports => { - this.reports = reports; - var data = []; - reports.forEach(report => { - data.push({ - id : report.id, - fileName: report.fileName, - uploadDate: report.uploadDate, - status:report.status, - gridfsId: report.gridFSId + .subscribe(reports => { + this.reports = reports; + var data = []; + reports.forEach(report => { + data.push({ + id: report.id, + fileName: report.fileName, + uploadDate: report.uploadDate, + status: report.status, + gridfsId: report.gridFSId + }); }); + + this.tableData = data; + this.drawTable(this); }); - this.tableData = data; - this.drawTable(this); - }); } - runWorkflow(): void{ + runWorkflow(): void { var ids = []; this.tableData.forEach(report => { - if(report.runWF==true){ - ids.push(report.id); - } - }); - if(ids.length<1){ + if (report.runWF == true) { + ids.push(report.id); + } + }); + + if (ids.length < 1) { alert('No reports were selected'); - }else{ + } else { this.workflowService.runWorkflow(ids).subscribe(event => { this.message = 'The workflow with id: ' + event.id + ' was launched. \n' + - 'Workflow status: ' + event.status + '. \n' + - 'Please go to the workflows or reports tab to see the progress.'; - this.messages=[]; + 'Workflow status: ' + event.status + '. \n' + + 'Please go to the workflows or reports tab to see the progress.'; + this.messages = []; this.validation_errors = []; this.getReports(); }, - err => { - this.message=''; - this.messages=[]; - this.validation_errors = err.error; - }); + err => { + this.message = ''; + this.messages = []; + this.validation_errors = err.error; + }); } - } delete(reportId): void { this.documentService.deleteReport(reportId).subscribe(event => { - this.messages=[]; + this.messages = []; this.validation_errors = []; this.getReports(); }, - err => { - this.message=''; - this.messages=[]; - this.validation_errors = err.error; - }); - + err => { + this.message = ''; + this.messages = []; + this.validation_errors = err.error; + }); + } - openDocument(documentId){ - this.router.navigate(['/find/'+documentId]); + openDocument(documentId) { + this.router.navigate(['/find/' + documentId]); } - - openLegacyReport(gridFSId){ + openLegacyReport(gridFSId) { this.documentService.openLegacyReport(gridFSId); } - + openDialog(reportId) { + const dialogRef = this.dialog.open(DeleteReportDialog); -drawTable(documentTab): void { + dialogRef.afterClosed().subscribe(isDeletionConfirmed => { + if (isDeletionConfirmed) { + this.delete(reportId) + } + }); + } + + drawTable(documentTab): void { const table = new Tabulator(this.tab, { layout: 'fitColumns', - data:this.tableData, + data: this.tableData, pagination: true, selectable: false, debugInvalidOptions: false, paginationSize: 20, - paginationSizeSelector: [ 10, 20, 40], - columns:[ - {title:'', width: 5, hozAlign: 'center', headerSort: false, - cellClick: function(e, cell){ - var data = cell.getRow().getData(); - if(data.runWF==undefined || data.runWF==false){ - cell.getRow().getData().runWF = true; - cell.getElement().innerHTML=''; - }else if (data.runWF==true){ - cell.getRow().getData().runWF = false; - cell.getElement().innerHTML=''; - }; - }, - formatter: function(cell, formatterParams, onRendered) { - var data = cell.getRow().getData(); - if(data.status=='READY'){ - if (data.runWF==undefined || data.runWF==false){ - return ''; - }else{ - return ''; + paginationSizeSelector: [10, 20, 40], + columns: [ + { + title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "run-wf-checkbox", + cellClick: function (e, cell) { + var data = cell.getRow().getData(); + if (data.status == 'READY') { + if (data.runWF) { + cell.getElement().innerHTML = ' '; + } else { + cell.getElement().innerHTML = ' '; + } + + data.runWF = !data.runWF; + } + }, + formatter: function (cell, formatterParams, onRendered) { + var data = cell.getRow().getData(); + if (data.status == 'READY') { + if (data.runWF) { + return ' '; + } else { + return ' '; + } } } - - }}, - {title: 'Name', field: 'fileName', headerSort: true , headerFilter: true}, - {title: 'Upload Date', field: 'uploadDate', headerSort: true , headerFilter: true}, - {title: 'Status', field: 'status', headerSort: true , headerFilter: true}, - {title:'', width: 5, hozAlign: 'center', headerSort: false, - cellClick: function(e, cell){ - var data = cell.getRow().getData(); - documentTab.openLegacyReport(data.gridfsId); - },formatter: function(cell, formatterParams, onRendered) { - return ''; - }}, - {title:'', width: 5, hozAlign: 'center', headerSort: false, - cellClick: function(e, cell){ - var data = cell.getRow().getData(); - documentTab.delete(data.id); - } - ,formatter:function(cell, formatterParams, onRendered){ - return ''; + }, + { title: 'Name', field: 'fileName', headerSort: true, headerFilter: true }, + { title: 'Upload Date', field: 'uploadDate', headerSort: true, headerFilter: true }, + { title: 'Status', field: 'status', headerSort: true, headerFilter: true }, + { + title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "download-report-button", + cellClick: function (e, cell) { + var data = cell.getRow().getData(); + documentTab.openLegacyReport(data.gridfsId); + }, formatter: function (cell, formatterParams, onRendered) { + return ''; + } + }, + { + title: '', width: 5, hozAlign: 'center', headerSort: false, cssClass: "delete-report-button", + cellClick: function (e, cell) { + + var data = cell.getRow().getData(); + documentTab.openDialog(data.id); + } + , formatter: function (cell, formatterParams, onRendered) { + return ''; + } } - } ] }); + document.getElementById('my-tabular-table-reports').appendChild(this.tab); //table.redraw(true); } - } diff --git a/src/tabulator.css b/src/tabulator.css index d7dfa61147e39bc19ea13e25464e3f0b1d9e9012..9a4af5b90b8d2cfc10849d94a434c4d8242c1882 100644 --- a/src/tabulator.css +++ b/src/tabulator.css @@ -1,3 +1,15 @@ +.tabulator-cell.run-wf-checkbox { + cursor: pointer; +} + +.tabulator-cell.run-wf-checkbox .fa-solid.fa-square-check { + color: green; +} + +.tabulator-cell.download-report-button .fa-solid.fa-file-pdf { + color: black; + cursor: pointer; +} .tabulator-cell .non-curated .fa.fa-square { color: grey; cursor: pointer; @@ -51,6 +63,12 @@ cursor: pointer; } + +.tabulator-cell.delete-report-button .fa.fa-trash { + color: red; + cursor: pointer; +} + .tabulator-cell .cancel-edition .fa-solid.fa-pencil { color: #abb2b9; cursor: pointer; @@ -82,3 +100,4 @@ .tabulator-row.evidence-selected { border: 1px solid black; } +