From 2e611befbf37d49ea9f2738ce6a18c877b0d70a7 Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 18 Dec 2017 17:10:34 +0200 Subject: [PATCH] dataset criteria --dmp&dataset delete --- dmp-frontend/src/app/app-routing.module.ts | 3 +- dmp-frontend/src/app/app.module.ts | 4 +- .../src/app/datasets/dataset.component.css | 56 ---- .../src/app/datasets/dataset.component.ts | 299 ----------------- dmp-frontend/src/app/datasets/dataset.html | 167 ---------- .../editor/dataset-editor.component.ts | 12 +- dmp-frontend/src/app/dmps/dmp.component.css | 158 --------- dmp-frontend/src/app/dmps/dmp.component.ts | 311 ------------------ dmp-frontend/src/app/dmps/dmps.html | 269 --------------- .../app/services/dataset/dataset.service.ts | 4 + .../datasets/datasets-criteria.component.ts | 35 +- 11 files changed, 21 insertions(+), 1297 deletions(-) delete mode 100644 dmp-frontend/src/app/datasets/dataset.component.css delete mode 100644 dmp-frontend/src/app/datasets/dataset.component.ts delete mode 100644 dmp-frontend/src/app/datasets/dataset.html delete mode 100644 dmp-frontend/src/app/dmps/dmp.component.css delete mode 100644 dmp-frontend/src/app/dmps/dmp.component.ts delete mode 100644 dmp-frontend/src/app/dmps/dmps.html diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index 459ab5d7d..acc108568 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -4,7 +4,6 @@ import { PageNotFoundComponent } from './not-found.component'; import { HomepageComponent } from './homepage/homepage.component'; import { DynamicFormComponent } from './form/dynamic-form.component'; import { AuthGuard } from './guards/auth.guard'; -import { DatasetsComponent } from './datasets/dataset.component'; import { AppComponent } from './app.component'; import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component'; import { DmpDetailedComponent } from './viewers/dmp-detailed/dmp-detailed.component'; @@ -19,7 +18,7 @@ import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.comp const appRoutes: Routes = [ { path: 'dynamic-form/:id', component: DynamicFormComponent, canActivate: [AuthGuard] }, - { path: 'dataset', component: DatasetsComponent }, + //{ path: 'dataset', component: DatasetsComponent }, { path: 'login', component: MainSignInComponent}, { path: 'projects', component: ProjectListingComponent}, { path: 'project/:id', component: ProjectEditorComponent}, diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index b2e81e013..480bf22eb 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -69,7 +69,6 @@ import { CommonModule } from '@angular/common'; import { DatasetTableFilterPipe } from './pipes/dataset-table-filter.pipe'; import { DatasetStatusFilterPipe } from './pipes/dataset-status-filter.pipe'; -import { DatasetsComponent } from './datasets/dataset.component'; import { DmpTableFilterPipe } from './pipes/dmp-table-filter.pipe'; import { DmpStatusFilterPipe } from './pipes/dmp-status-filter.pipe'; @@ -136,8 +135,7 @@ import { FigurecardComponent } from './shared/components/figurecard/figurecard.c ModalComponent, ProjectListingComponent, DatasetListingComponent, - DataManagementPlanListingComponent, - DatasetsComponent, + DataManagementPlanListingComponent, ConfirmationComponent, AutocompleteRemoteComponent, DynamicFieldDropdownComponent, diff --git a/dmp-frontend/src/app/datasets/dataset.component.css b/dmp-frontend/src/app/datasets/dataset.component.css deleted file mode 100644 index af312ae3f..000000000 --- a/dmp-frontend/src/app/datasets/dataset.component.css +++ /dev/null @@ -1,56 +0,0 @@ -.invisible { - display:none; -} - -.visible { - display:block; -} - -tr.hover:hover > * { - background-color: #eeeeee; -} - -.editor-container{ - padding-top: 10px; - padding-right: 10px; - padding-bottom: 10px; - padding-left: 10px; -} - -.button-150px { - max-width: 150px; -} - -.ng-template{ - text-align: right; -} - -.grayout-empty-table { - opacity: 0.6; /* Real browsers */ - filter: alpha(opacity = 60); /* MSIE */ - text-align: center; - vertical-align: middle; -} - -.btncustom{ - background-color:#337ab7; - color:white; - margin-top:15px; -} - -.cursor-hand{ - cursor: pointer; -} - -.hidden-keepspace{ - visibility: hidden; -} - - -.ui-autocomplete-multiple { - width: 100% !important; -} - -.ui-autocomplete-multiple-container { - width: 100% !important; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts deleted file mode 100644 index 7a50eea47..000000000 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ /dev/null @@ -1,299 +0,0 @@ -import { Component, OnInit, Input, ViewChild, NgZone, Output, EventEmitter, ViewEncapsulation } from '@angular/core'; -import { GoogleSignInSuccess } from 'angular-google-signin'; -import { Router, ActivatedRoute } from '@angular/router'; -import { ServerService } from '../../app/services/server.service'; -import { Project } from '../entities/model/project'; -import { Dataset } from '../entities/model/dataset'; -import { Dmp } from '../entities/model/dmp'; -import { DataTable } from 'angular2-datatable'; -import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown'; -import { Param } from '../entities/model/param'; -import { StatusToString } from '../pipes/various/status-to-string'; -import { ConfirmationComponent } from '../widgets/confirmation/confirmation.component'; -import { Ng4LoadingSpinnerService } from 'ng4-loading-spinner'; - -declare var $: any; - - -import '../../assets/custom.js'; -declare function simple_notifier(type: string, title: string, message: string): any; - -@Component({ - selector: 'datasets-table', - templateUrl: 'dataset.html', - styleUrls: ['./dataset.component.css'], - providers: [ServerService], - encapsulation: ViewEncapsulation.None -}) - -export class DatasetsComponent implements OnInit { - - // Start ALTERNATIVE - //whole dmp data model - tableData: any[] = new Array(); - - //organisation editor data model - editingOrganisation: any = {}; - organisationEditorForm: any; - - //required by the table - public filterQuery = ""; - public statusFilter = ""; - public rowsOnPage = 10; - public sortBy = "label"; - public sortOrder = "asc"; - - dmpIdforDatasets: string; - - - // for tableIds - showIDs: boolean = false; - // END ALTERNATIVE - - returnUrl: string; - @Input() datasets: Dataset[]; - @Input() datasetProfileDropDown: DropdownField; - @Input() datasetCount = 0; - - @Input() dmpLabelforDatasets: string; - @Input() statusDropDown: DropdownField; - dataset: any; - saveAndDescribe: boolean; - - dataSetValue: boolean = true; - - uriRegex = "/^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i"; - - filteredServices: any[]; - filteredRepositories: any[]; - filteredRegistries: any[]; - - constructor( - - private serverService: ServerService, - private route: ActivatedRoute, - private router: Router, - private ngZone: NgZone, - private spinnerService: Ng4LoadingSpinnerService) { - - this.dataset = this.createEmptyDataset(); - - this.datasetProfileDropDown = new DropdownField(); - this.datasetProfileDropDown.options = []; - this.saveAndDescribe = false; - this.statusDropDown = new DropdownField(); - this.statusDropDown.options = [{ key: '', value: null }, { key: '0', value: "Active" }, { key: '1', value: "Inactive" }] - - } - - ngOnInit() { - - - this.route - .queryParams - .subscribe(params => { - this.dmpIdforDatasets = params['dmpid']; - this.getDatasets(); - }); - - - this.serverService.getAllDatsetsProfile().subscribe( - response => { - response.forEach((datasetprofile) => { - let params = new Param(); - params.key = datasetprofile.id; - params.value = datasetprofile.label; - this.datasetProfileDropDown.options.push(params); - }, - error => { - simple_notifier("danger", null, "Could not load User's Dataset Profiles"); - } - - ); - - } - ) - } - - ngAfterViewInit() { - - $(function () { - $('#status-filter').append(""); - //$('#status-filter').value=; - }) - - } - - createEmptyDataset() { - return { - id: null, - label: '', - reference: '', - uri: '', - status: 0, - properties: '', - profile: { "id": '' }, - dmp: { "id": '' }, - services: [], - registries: [], - dataRepositories: [] - } - } - - SaveDataset() { - if (this.dataset.id == null) { - this.dataset.dmp = { "id": this.dmpIdforDatasets } - this.dataset.profile = { "id": this.dataset.profile } - this.serverService.createDatasetForDmp(this.dataset).subscribe( - response => { - simple_notifier("success", null, "Created dataset"); - this.getDatasets(); - if (this.saveAndDescribe == true) - this.describeDataset(response); - }, - error => { - simple_notifier("danger", null, "Could not create Dataset"); - } - ) - $("#newDatasetModal").modal("hide"); - - } - else { - - this.dataset.dmp = { "id": this.dmpIdforDatasets }; - this.dataset.profile = { "id": this.dataset.profile }; - this.dataset.creator = { "id": this.dataset.creator }; - - this.serverService.updateDatsetsProfile(this.dataset).subscribe( - response => { - simple_notifier("success", null, "Dataset edited"); - this.getDatasets(); - if (this.saveAndDescribe == true) - this.describeDataset(response); - }, - error => { - simple_notifier("danger", null, "Could not edit dataset"); - } - ) - $("#newDatasetModal").modal("hide"); - } - - } - - getDatasets(muted?: boolean) { - this.spinnerService.show(); - this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe( - response => { - this.tableData = response; - if (muted && muted != true) - simple_notifier("success", null, "Updated datasets table"); - }, - error => { - simple_notifier("danger", null, "Could not update datasets table"); - }, - () => { - this.spinnerService.hide(); - } - ); - } - - - getDatasetForDmpMethod(dmpid) { - this.spinnerService.show(); - this.serverService.getDatasetForDmp({ "id": dmpid }).subscribe( - response => { - this.tableData = response; - }, - error => { - console.log("could not retrieve dataset for dpm: " + dmpid); - }, - () => { - this.spinnerService.hide(); - } - ); - } - - editRow(item, event) { - if (event.toElement.id == "editDataset") { - this.spinnerService.show(); - this.serverService.getDatasetByID(item.id).subscribe(item => { - this.dataset = item; - this.dataset.profile = item.profile.id; - $("#newDatasetModal").modal("show"); - }, - error => simple_notifier("danger", null, "Could not Open Dataset"), - () => this.spinnerService.hide() - ) - } - else if (event.toElement.id == "describeDataset") { - this.describeDataset(item); - } - - } - - newDataset() { - this.dataset = this.createEmptyDataset(); - this.dataset.dmp = this.dmpLabelforDatasets; - this.dataset.status = 0; - $("#newDatasetModal").modal("show"); - } - - SaveDescribeDataset() { - this.saveAndDescribe = true; - this.SaveDataset(); - } - - describeDataset(item) { - this.router.navigate(['/dynamic-form/' + item.id]); - //this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profile.id, datasetId:item.id, label: item.label}])); - } - - markDatasetForDelete(dataset) { - this.dataset = dataset; - } - - deleteDataset(confirmation) { - if (confirmation == true) - this.deleteRow(this.dataset); - } - - - deleteRow(dataset) { - this.serverService.deleteDataset(dataset).subscribe( - response => { - simple_notifier("success", null, "Deleted dataset"); - this.getDatasets(); - }, - err => { - - if (err.status >= 200 && err.status < 300) - simple_notifier("success", null, "Deleted dataset"); - else - simple_notifier("danger", null, "Could not delete the dataset"); - this.getDatasets(); - - } - ); - } - - searchServices(event) { - let query = event.query; - this.serverService.searchDatasetService(query).subscribe(services => { - this.filteredServices = services; - }); - } - - searchRegistries(event) { - let query = event.query; - this.serverService.searchDatasetRegistry(query).subscribe(registries => { - this.filteredRegistries = registries; - }); - } - - searchRepositories(event) { - let query = event.query; - this.serverService.searchDatasetRepository(query).subscribe(repos => { - this.filteredRepositories = repos; - }); - } -} diff --git a/dmp-frontend/src/app/datasets/dataset.html b/dmp-frontend/src/app/datasets/dataset.html deleted file mode 100644 index 8856dd2ee..000000000 --- a/dmp-frontend/src/app/datasets/dataset.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- ID - - Label - - Uri - - Profile - - Description - - Created at - - Status - - Actions -
No elements
{{dataset.id}}{{(dataset?.label?.length > 80) ? (dataset?.label | slice:0:80)+'...':(dataset?.label) }}{{(dataset?.uri?.length > 40) ? (dataset?.uri | slice:0:40)+'...':(dataset?.uri) }}{{(dataset?.profile?.label?.length > 40) ? (dataset?.profile?.label | slice:0:40)+'...':(dataset?.profile?.label) - }} - {{(dataset?.description?.length > 40) ? (dataset?.description | slice:0:40)+'...':(dataset?.description) }}{{dataset?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}{{dataset?.status | statusToString }} - - - - - - - - - -
- - -
- - - - - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts index a1a974d42..c4b90e9d8 100644 --- a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts +++ b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts @@ -75,12 +75,12 @@ export class DatasetEditorComponent implements AfterViewInit { return this.formGroup.valid; } - // onSubmit(): void { - // this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe( - // complete => this.onCallbackSuccess(), - // error => this.onCallbackError(error) - // ); - // } + onSubmit(): void { + this.datasetService.createDataset(this.formGroup.value).subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + } onCallbackSuccess(): void { this.snackBar.openFromComponent(SnackBarNotificationComponent, { diff --git a/dmp-frontend/src/app/dmps/dmp.component.css b/dmp-frontend/src/app/dmps/dmp.component.css deleted file mode 100644 index a8cfa7f65..000000000 --- a/dmp-frontend/src/app/dmps/dmp.component.css +++ /dev/null @@ -1,158 +0,0 @@ -.invisible { - display:none; -} - -.visible { - display:block; -} - -tr.hover:hover > * { - background-color: #eeeeee; -} - -.editor-container{ - padding-top: 10px; - padding-right: 10px; - padding-bottom: 10px; - padding-left: 10px; -} - -.button-150px { - max-width: 150px; -} - -.ng-template{ - text-align: right; -} - -.grayout-empty-table { - opacity: 0.6; /* Real browsers */ - filter: alpha(opacity = 60); /* MSIE */ - text-align: center; - vertical-align: middle; -} - -.btncustom{ - background-color:#337ab7; - color:white; - margin-top:15px; -} - -.btnMoreFilters{ - background-color:#337ab7; - color:white; - margin-bottom:0px; -} - -.table>thead>tr.rowFilter>th { - border-bottom: 0px solid white; - -} - -.table>thead>tr>th.rowFilterTopBorder{ - border-top: 0px solid white; -} - -.table-button { - font-size: 1em; - padding: 2px; -} - - -.centered-text{ - text-align: center; -} - -.url-like{ - color: #0645AD; - cursor: pointer; -} - - -/*THE BELOW CSS ARE FOR HORIZONTALLY -COLLAPSING DIVS */ - - .collapse { - display: none; - visibility: hidden; - } - .collapse.in { - display: block; - visibility: visible; - } - tr.collapse.in { - display: table-row; - } - tbody.collapse.in { - display: table-row-group; - } - .collapsing { - position: relative; - height: 0; - overflow: hidden; - -webkit-transition-property: height, visibility; - transition-property: height, visibility; - -webkit-transition-duration: 0.35s; - transition-duration: 0.35s; - -webkit-transition-timing-function: ease; - transition-timing-function: ease; - } - .collapsing.width { - -webkit-transition-property: width, visibility; - transition-property: width, visibility; - width: 0; - height: auto; - } -/* END OF HORIZONTALLY -COLLAPSING DIVS */ - -.ui-autocomplete-multiple { - width: 100% !important; -} - -.ui-autocomplete-multiple-container { - width: 100% !important; -} - -/* - - .modal.modal-fullscreen .modal-dialog, - .modal.modal-fullscreen .modal-content { - position: absolute; - left: 1%; - right: 1%; - top: 1%; - bottom: 1%; - } - .modal.modal-fullscreen .modal-dialog { - margin: 0; - width: 98%; - animation-duration:0.5s; - } - .modal.modal-fullscreen .modal-content { - border: none; - -moz-border-radius: 0; - border-radius: 0; - -webkit-box-shadow: inherit; - -moz-box-shadow: inherit; - -o-box-shadow: inherit; - box-shadow: inherit; - - } - .modal.modal-fullscreen.force-fullscreen { - - } - .modal.modal-fullscreen.force-fullscreen .modal-body { - padding: 0; - } - .modal.modal-fullscreen.force-fullscreen .modal-header, - .modal.modal-fullscreen.force-fullscreen .modal-footer { - left: 0; - position: absolute; - right: 0; - } - .modal.modal-fullscreen.force-fullscreen .modal-header { - top: 0; - } - .modal.modal-fullscreen.force-fullscreen .modal-footer { - bottom: 0; - } - */ \ No newline at end of file diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts deleted file mode 100644 index 789baef11..000000000 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ /dev/null @@ -1,311 +0,0 @@ -import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ViewEncapsulation } from '@angular/core'; -import { GoogleSignInSuccess } from 'angular-google-signin'; -import { Router, ActivatedRoute } from '@angular/router'; -import { ServerService } from '../../app/services/server.service'; -import { Dmp } from '../entities/model/dmp'; -import { Dataset } from '../entities/model/dataset'; -import { Project } from '../entities/model/project'; -import { ConfirmationComponent } from '../widgets/confirmation/confirmation.component'; - -import { DataTable } from 'angular2-datatable'; -import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown'; -import { Param } from '../entities/model/param'; -import { ModalComponent } from '../modal/modal.component'; -import { HttpErrorResponse } from '@angular/common/http'; -import { FormGroup, FormControl } from '@angular/forms'; //na dw an xreiazontai -import { NgForm } from '@angular/forms'; -import { DatasetsComponent } from '../datasets/dataset.component'; -import { StatusToString } from '../pipes/various/status-to-string'; -import { MenuItem } from 'primeng/primeng'; -import { Ng4LoadingSpinnerService } from 'ng4-loading-spinner'; - -declare var $: any; - -import '../../assets/custom.js'; -declare function simple_notifier(type: string, title: string, message: string): any; - -@Component({ - selector: 'dmps', - templateUrl: 'dmps.html', - styleUrls: ['./dmp.component.css'], - providers: [ServerService], - encapsulation: ViewEncapsulation.None -}) - -export class DmpComponent implements OnInit { - - //whole dmp data model - tableData: any[] = new Array(); - - //required by the table - public filterQuery = ""; - public rowsOnPage = 10; - public sortBy = "label"; - public sortOrder = "asc"; - - // for tableIds - showIDs: boolean = false; - - - dmp: any; - - @Input() projectsDropDown: DropdownField; - @Input() statusDropDown: DropdownField; - - @ViewChild(DatasetsComponent) datasetsComponent: DatasetsComponent; - - filteredResearchers: any[]; - filteredOrganizations: any[]; - - constructor( - private serverService: ServerService, - private route: ActivatedRoute, - private router: Router, - private spinnerService: Ng4LoadingSpinnerService - ) { - this.projectsDropDown = new DropdownField(); - this.projectsDropDown.options = []; - this.statusDropDown = new DropdownField(); - this.statusDropDown.options = [{ key: '', value: null }, { key: '0', value: "Active" }, { key: '1', value: "Inactive" }] - //this.projects = []; - - } - - - clearDmp() { - - this.dmp = { - id: null, - label: '', - previous: '', - version: '', - organizations: [], - researchers: [] - } - - } - - ngOnInit() { - - this.getDmps(); - - this.serverService.getAllProjects().subscribe( - response => { - //let params = new Param(); - response.forEach((dmp) => { - let params = new Param(); - params.key = dmp.id; - params.value = dmp.label; - this.projectsDropDown.options.push(params); - }); - - }, - (err: HttpErrorResponse) => { - simple_notifier("danger", null, "Could not load User's Projects"); - } - ) - - this.clearDmp(); - - - } - - - getDmps(muted?: boolean) { - this.serverService.getDmpOfUser().subscribe( - response => { - this.tableData = response; - if (muted && muted != true) - simple_notifier("success", null, "Refreshed DMPs"); - - this.tableData.forEach(dmp => { - if (dmp.previous != null) - this.serverService.getDmp(dmp.previous).subscribe(previous => { dmp.previous = previous; }); - }); - - }, - (err: HttpErrorResponse) => { - simple_notifier("danger", null, "Could not refresh DMPs"); - } - ); - } - - newDMP() { - - this.dmp.project = { "id": this.dmp.project }; - this.dmp["version"] = 1; - - this.serverService.createDmpForCurrentUser(this.dmp) - .subscribe( - response => { - simple_notifier("success", null, "DMP created"); - this.getDmps(); - }, - error => { - simple_notifier("danger", null, "Could not create the DMP"); - } - ); - $("#newDmpModal").modal("hide"); - } - - updateDMP() { - - this.dmp.project = { "id": this.dmp.project }; - this.dmp.creator = { "id": this.dmp.creator }; - if (this.dmp.previous != null) - this.dmp.previous = this.dmp.previous.id; - - this.serverService.updateDmp(this.dmp) - .subscribe( - response => { - simple_notifier("success", null, "Edited the DMP"); - this.getDmps(); - }, - error => { - simple_notifier("danger", null, "Failed to edit the DMP"); - } - ); - $("#newDmpModal").modal("hide"); - $("#newVersionDmpModal").modal("hide"); - - } - - cloneDMP(dmp) { - dmp = { "id": dmp.id, "label": dmp.label }; - this.serverService.cloneDmp(dmp).subscribe( - response => { - simple_notifier("success", null, "Successfully cloned the DMP"); - this.getDmps(); - }, - error => { - simple_notifier("danger", null, "Failed to clone the DMP"); - } - ); - $("#newVersionDmpModal").modal("hide"); - } - - SaveDmp() { - if (this.dmp.id == null) - this.newDMP(); - else - this.updateDMP(); - } - - - editDmp(item) { - this.spinnerService.show(); - this.serverService.getDmp(item.id).subscribe(result => { - this.dmp = result; - this.dmp.project = result.project.id - $("#newDmpModal").modal("show"); - }, - error => simple_notifier("danger", null, "Failed to Open DMP"), - () => this.spinnerService.hide() - ) - - } - - cloneDmp(item) { - this.dmp = Object.assign({}, item); - this.dmp.project = item.project.id; - $("#newVersionDmpModal").modal("show"); - } - - newDmpForm(item) { - - this.clearDmp(); - - $("#newDmpModal").modal("show"); - } - - markDMPForDelete(dmp) { - this.dmp = dmp; - } - - deleteDMP(confirmation) { - if (confirmation == true) - this.deleteRow(this.dmp); - } - - deleteRow(dmp) { - - this.dmp = { "id": this.dmp.id }; //only id is needed to delete - - - this.serverService.deleteDmp(this.dmp).subscribe( - response => { - simple_notifier("success", null, "Successfully deleted the DMP"); - this.getDmps(); - }, - (err: HttpErrorResponse) => { - if (err.status >= 200 && err.status < 300) - simple_notifier("success", null, "Successfully deleted the DMP"); - else - simple_notifier("danger", null, "Failed to delete the DMP"); - this.getDmps(); - } - ); - - } - - clickFilters(element) { - if (element.textContent == "More filters") - element.textContent = "Less Filters"; - else - element.textContent = "More Filters"; - } - - SelectDMPStatus(dmp, event, oldValue) { - console.log(dmp); - let cannotChangeStatus: boolean; - if (dmp.status == 2) { - this.serverService.getDatasetForDmp({ "id": dmp.id }).subscribe( - response => { - response.forEach(dataset => { - if (dataset.status !== 2 || dataset.status !== 3) { - cannotChangeStatus = true; - } - return; - }); - if (cannotChangeStatus == true) { - dmp.status = 0; - $("#messageForChangingStatus").modal("show"); - } - }, - error => { - console.log("could not retrieve dataset for dpm: " + dmp.id); - } - ); - } - - } - - showDatasetsOfDmp(item) { - this.router.navigate(['/dataset'], { queryParams: { "dmpid": item.id, "label": item.label } }); - } - - viewDetailedDMP(dmp) { - let random = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5); - this.router.navigate(['/dmps/dmp'], { queryParams: { "dmpid": dmp.id, "label": dmp.label, random: random } }); - } - - viewDetailedProject(dmp) { - let random = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5); - this.router.navigate(['/dmps/project'], { queryParams: { "projectid": dmp.project.id, "label": dmp.project.label, random: random } }); - } - - searchResearchers(event) { - let query = event.query; - this.serverService.searchDMPResearchers(query).subscribe(researchers => { - this.filteredResearchers = researchers; - }); - } - - searchOrganizations(event) { - let query = event.query; - this.serverService.searchDMPOrganizations(query).subscribe(organizations => { - this.filteredOrganizations = organizations; - }); - } - -} diff --git a/dmp-frontend/src/app/dmps/dmps.html b/dmp-frontend/src/app/dmps/dmps.html deleted file mode 100644 index 959fc9247..000000000 --- a/dmp-frontend/src/app/dmps/dmps.html +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
- - -
-
- ID - - Label - - Version - - Previous - - Project - - Description - - Created at - - Status - - Actions - - -
No elements
{{dmp?.id}}{{(dmp?.label?.length > 40) ? (dmp?.label | slice:0:40)+'...':(dmp?.label) }} - - {{dmp?.version}}{{(dmp?.previous?.label?.length > 40) ? (dmp?.previous?.label | slice:0:40)+'...':(dmp?.previous?.label) }}{{(dmp?.project?.label?.length > 40) ? (dmp?.project?.label | slice:0:40)+'...':(dmp?.project?.label) }} - - {{(dmp?.description?.length > 40) ? (dmp?.description | slice:0:40)+'...':(dmp?.description) }}{{dmp?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}{{dmp?.status | statusToString }} - - - - - - - - - - - - -
- - - -
- - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/services/dataset/dataset.service.ts b/dmp-frontend/src/app/services/dataset/dataset.service.ts index 594b64e6b..808563f43 100644 --- a/dmp-frontend/src/app/services/dataset/dataset.service.ts +++ b/dmp-frontend/src/app/services/dataset/dataset.service.ts @@ -32,4 +32,8 @@ export class DatasetService { getSingle(id: string): Observable { return this.http.get(this.actionUrl + id, { headers: this.headers }); } + + createDataset(datasetModel: DatasetModel): Observable { + return this.http.post(this.actionUrl + 'add', datasetModel, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts index a47ecc2fb..3461dbd30 100644 --- a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts +++ b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts @@ -31,39 +31,22 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O ngOnInit() { super.ngOnInit(); if (this.criteria == null) { this.criteria = new DatasetCriteria(); } - if (this.formGroup == null) { this.formGroup = this.buildForm(); } } setCriteria(criteria: DatasetCriteria): void { this.criteria = criteria; - this.formGroup = this.buildForm(); } - public fromJSONObject(item: any): DatasetCriteria { - this.criteria = new DatasetCriteria(); - this.criteria.Name = new String(item.name); - this.criteria.Status = new Number(item.status); - return this.criteria; + onCallbackError(error: any) { + this.setErrorModel(error.error); } - buildForm(): FormGroup { - const context: ValidationContext = this.createValidationContext(); - - return this.formBuilder.group({ - name: [this.criteria.Name, context.getValidation('name').validators], - status: [this.criteria.Status, context.getValidation('status').validators], - // created: [this.criteria, context.getValidation('created').validators] - }); - } - - createValidationContext(): ValidationContext { - const validationContext: ValidationContext = new ValidationContext(); - const validationArray: Validation[] = new Array(); - - validationArray.push({ key: 'name', validators: [BackendErrorValidator(this.errorModel, 'Criteria.Name')] }); //must add 'Criteria.' because the criteria validator is inside the request validator - validationArray.push({ key: 'status', validators: [BackendErrorValidator(this.errorModel, 'Criteria.Status')] }); - - validationContext.validation = validationArray; - return validationContext; + controlModified(): void { + this.clearErrorModel(); + if (this.refreshCallback != null && + (this.criteria.like == null || this.criteria.like.length == 0 || this.criteria.like.length > 2) + ) { + this.refreshCallback(); + } } }