diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 8baafd160..c8403eaff 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -98,6 +98,7 @@ import {ProgressBarModule} from 'primeng/primeng'; import {StepsModule,MenuItem} from 'primeng/primeng'; import {CheckboxModule} from 'primeng/primeng'; import {RadioButtonModule} from 'primeng/primeng'; +import {AutoCompleteModule} from 'primeng/primeng'; @NgModule({ declarations: [ @@ -157,7 +158,8 @@ import {RadioButtonModule} from 'primeng/primeng'; SidebarModule.forRoot(), StepsModule, CheckboxModule, - RadioButtonModule + RadioButtonModule, + AutoCompleteModule ], providers: [{ provide: HTTP_INTERCEPTORS, diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index 21273a751..17d643d14 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -5,7 +5,7 @@ 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 { 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'; @@ -16,7 +16,7 @@ declare var $: any; import '../../assets/custom.js'; -declare function simple_notifier(type: string, title: string, message:string): any; +declare function simple_notifier(type: string, title: string, message: string): any; @Component({ selector: 'datasets-table', @@ -29,11 +29,11 @@ export class DatasetsComponent implements OnInit { // Start ALTERNATIVE //whole dmp data model - tableData : any[] = new Array(); + tableData: any[] = new Array(); //organisation editor data model editingOrganisation: any = {}; - organisationEditorForm : any; + organisationEditorForm: any; //required by the table public filterQuery = ""; @@ -46,8 +46,8 @@ export class DatasetsComponent implements OnInit { // for tableIds - showIDs : boolean = false; -// END ALTERNATIVE + showIDs: boolean = false; + // END ALTERNATIVE returnUrl: string; @Input() datasets: Dataset[]; @@ -57,12 +57,15 @@ export class DatasetsComponent implements OnInit { @Input() dmpLabelforDatasets: string; @Input() statusDropDown: DropdownField; dataset: any; - saveAndDescribe:boolean; + 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( @@ -78,7 +81,7 @@ export class DatasetsComponent implements OnInit { this.datasetProfileDropDown.options = []; this.saveAndDescribe = false; this.statusDropDown = new DropdownField(); - this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}] + this.statusDropDown.options = [{ key: '', value: null }, { key: '0', value: "Active" }, { key: '1', value: "Inactive" }] } @@ -101,26 +104,26 @@ export class DatasetsComponent implements OnInit { params.value = datasetprofile.label; this.datasetProfileDropDown.options.push(params); }, - error => { - simple_notifier("danger",null,"Could not load User's Dataset Profiles"); - } + error => { + simple_notifier("danger", null, "Could not load User's Dataset Profiles"); + } - ); + ); } ) } - ngAfterViewInit(){ + ngAfterViewInit() { - $( function() { + $(function () { $('#status-filter').append(""); //$('#status-filter').value=; - }) - + }) + } - createEmptyDataset(){ + createEmptyDataset() { return { id: null, label: '', @@ -129,43 +132,46 @@ export class DatasetsComponent implements OnInit { status: 0, properties: '', profile: { "id": '' }, - dmp: { "id": '' } + dmp: { "id": '' }, + services:[], + registries:[], + repositories:[] } } - SaveDataset(){ - if(this.dataset.id ==null){ + 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"); + simple_notifier("success", null, "Created dataset"); this.getDatasets(); if (this.saveAndDescribe == true) this.describeDataset(response); }, - error=>{ - simple_notifier("danger",null,"Could not create Dataset"); + error => { + simple_notifier("danger", null, "Could not create Dataset"); } ) $("#newDatasetModal").modal("hide"); } - else{ + else { this.dataset.dmp = { "id": this.dmpIdforDatasets }; this.dataset.profile = { "id": this.dataset.profile }; - this.dataset.creator = {"id" : this.dataset.creator }; + this.dataset.creator = { "id": this.dataset.creator }; this.serverService.updateDatsetsProfile(this.dataset).subscribe( response => { - simple_notifier("success",null,"Dataset edited"); + simple_notifier("success", null, "Dataset edited"); this.getDatasets(); if (this.saveAndDescribe == true) - this.describeDataset(response); + this.describeDataset(response); }, error => { - simple_notifier("danger",null,"Could not edit dataset"); + simple_notifier("danger", null, "Could not edit dataset"); } ) $("#newDatasetModal").modal("hide"); @@ -173,18 +179,18 @@ export class DatasetsComponent implements OnInit { } - getDatasets(muted?: boolean){ + 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"); + if (muted && muted != true) + simple_notifier("success", null, "Updated datasets table"); }, error => { - simple_notifier("danger",null,"Could not update datasets table"); + simple_notifier("danger", null, "Could not update datasets table"); }, - () =>{ + () => { this.spinnerService.hide(); } ); @@ -199,16 +205,16 @@ export class DatasetsComponent implements OnInit { }, error => { - console.log("could not retrieve dataset for dpm: "+dmpid); + console.log("could not retrieve dataset for dpm: " + dmpid); }, - () =>{ + () => { this.spinnerService.hide(); } ); } editRow(item, event) { - if (event.toElement.id == "editDataset"){ + if (event.toElement.id == "editDataset") { //this.dataset = item; this.dataset.label = item.label; this.dataset.uri = item.uri; @@ -216,12 +222,12 @@ export class DatasetsComponent implements OnInit { this.dataset.status = item.status; this.dataset.description = item.description; //this.dataset.dmp = item.dmp; - this.dataset.profile = item.profile==null ? null : item.profile.id; + this.dataset.profile = item.profile == null ? null : item.profile.id; this.dataset.id = item.id; this.dataset.creator = item.creator; $("#newDatasetModal").modal("show"); } - else if(event.toElement.id == "describeDataset"){ + else if (event.toElement.id == "describeDataset") { this.describeDataset(item); } @@ -229,49 +235,67 @@ export class DatasetsComponent implements OnInit { newDataset() { this.dataset = this.createEmptyDataset(); - this.dataset.dmp =this.dmpLabelforDatasets; + this.dataset.dmp = this.dmpLabelforDatasets; this.dataset.status = 0; $("#newDatasetModal").modal("show"); } - SaveDescribeDataset(){ + SaveDescribeDataset() { this.saveAndDescribe = true; this.SaveDataset(); } describeDataset(item) { - this.router.navigate(['/dynamic-form/'+item.id]); + 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){ + markDatasetForDelete(dataset) { this.dataset = dataset; } - deleteDataset(confirmation){ - if(confirmation==true) + deleteDataset(confirmation) { + if (confirmation == true) this.deleteRow(this.dataset); } - deleteRow(dataset){ + deleteRow(dataset) { this.serverService.deleteDataset(dataset).subscribe( response => { - simple_notifier("success",null,"Deleted dataset"); + simple_notifier("success", null, "Deleted dataset"); this.getDatasets(); }, err => { - if(err.status>=200 && err.status<300) - simple_notifier("success",null,"Deleted dataset"); + if (err.status >= 200 && err.status < 300) + simple_notifier("success", null, "Deleted dataset"); else - simple_notifier("danger",null,"Could not delete the dataset"); + 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 index d7763f690..e7e27c7cc 100644 --- a/dmp-frontend/src/app/datasets/dataset.html +++ b/dmp-frontend/src/app/datasets/dataset.html @@ -1,7 +1,6 @@ - - +
@@ -11,19 +10,20 @@ @@ -32,7 +32,7 @@ + @@ -63,17 +63,24 @@ - + + + + @@ -93,9 +100,11 @@ - - + + \ No newline at end of file diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index 37e73f14a..2dcd2e613 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -1,8 +1,8 @@ -import {Injectable, ReflectiveInjector, Injector} from '@angular/core'; -import {JsonObjest} from '../../app/entities/JsonObject.class'; +import { Injectable, ReflectiveInjector, Injector } from '@angular/core'; +import { JsonObjest } from '../../app/entities/JsonObject.class'; import { DatasetProfile } from '../entities/datasetprofile'; -import {Project} from '../entities/model/project'; -import {RestBase} from './rest-base'; +import { Project } from '../entities/model/project'; +import { RestBase } from './rest-base'; import 'rxjs/Rx'; import './../../assets/xml2json.min.js'; @@ -12,168 +12,176 @@ declare var X2JS: any; export class ServerService { xml2jsonOBJ: any; - + constructor(private restBase: RestBase) { this.xml2jsonOBJ = new X2JS(); } - public listDatasetIDs(){ + public listDatasetIDs() { return this.restBase.get("dataset"); } - public getAllDatasets(){ - return this.restBase.get("getAllDatasets"); + public getAllDatasets() { + return this.restBase.get("getAllDatasets"); } - public getAllDatasetIDs(datasetId: string){ - return this.restBase.get("dataset/"+datasetId); + public getAllDatasetIDs(datasetId: string) { + return this.restBase.get("dataset/" + datasetId); } - public getDatasetByID(datasetId: string){ - return this.restBase.get("datasets/"+datasetId); + public getDatasetByID(datasetId: string) { + return this.restBase.get("datasets/" + datasetId); } - public setDataset(dataset){ + public setDataset(dataset) { return this.restBase.post("dataset/update", dataset); } - public getAllDmps(){ + public getAllDmps() { return this.restBase.get("dmp/getAll"); } - public listDmpsLabelID(){ + public listDmpsLabelID() { return this.restBase.get("dmp/listDMPLabelID"); - } + } - public getDmp(dmpid : string, eager? : boolean){ - if(eager) - return this.restBase.get("dmps/"+dmpid, {"eager": true}); + public getDmp(dmpid: string, eager?: boolean) { + if (eager) + return this.restBase.get("dmps/" + dmpid, { "eager": true }); else - return this.restBase.get("dmps/"+dmpid, {"eager": true}); + return this.restBase.get("dmps/" + dmpid, { "eager": true }); } - public getDmpHistory(dmpid: string){ - return this.restBase.get("dmp/history/"+dmpid); + public getDmpHistory(dmpid: string) { + return this.restBase.get("dmp/history/" + dmpid); } - public listDmpIDs(){ + public listDmpIDs() { return this.restBase.get("dmps"); } - public listProjectIDs(){ + public listProjectIDs() { return this.restBase.get("projects"); } - public getAllProjects(){ + public getAllProjects() { return this.restBase.get("project/getAll"); } - public getProject(projectID : string, eager? : boolean){ - if(eager) - return this.restBase.get("projects/"+projectID, {"eager": true}); + public getProject(projectID: string, eager?: boolean) { + if (eager) + return this.restBase.get("projects/" + projectID, { "eager": true }); else - return this.restBase.get("projects/"+projectID, {"eager": false}); + return this.restBase.get("projects/" + projectID, { "eager": false }); } - public listProjectsLabelID(){ + public listProjectsLabelID() { return this.restBase.get("project/listAllLabelIDs"); } - public listDmpsUser(){ + public listDmpsUser() { return this.restBase.get("dmp/listDMPLabelID"); } - public getProjectsOfUser(){ + public getProjectsOfUser() { return this.restBase.get("project/getofuser"); } - public createProject(data:any){ + public createProject(data: any) { return this.restBase.post("project/createofuser", data); } - public updateProject(data:any){ + public updateProject(data: any) { return this.restBase.post("project/update", data); } - public getDmpsOfProject(projectID: string){ - return this.restBase.get("project/dmps", {"id":projectID}); + public getDmpsOfProject(projectID: string) { + return this.restBase.get("project/dmps", { "id": projectID }); } - public getAllDataSet(){ - return this.restBase.get("dataset/getAll"); + public getAllDataSet() { + return this.restBase.get("dataset/getAll"); } - public getDmpOfUser(){ - return this.restBase.get("dmp/getofuser"); + public getDmpOfUser() { + return this.restBase.get("dmp/getofuser"); } - public createDmpForCurrentUser(data:any){ - return this.restBase.post("dmp/createofuser", data); + public createDmpForCurrentUser(data: any) { + return this.restBase.post("dmp/createofuser", data); } - public updateDmp(data:any){ + public updateDmp(data: any) { return this.restBase.post("dmp/update", data); } - public cloneDmp(data: any){ + public cloneDmp(data: any) { return this.restBase.post("dmp/cloneforuser", data); } - public deleteDmp(dmp: any){ + public deleteDmp(dmp: any) { return this.restBase.post("dmp/softdelete", dmp); } - public getDatasetForDmp(data:any){ - return this.restBase.post("dmp/getdatasets", data); + public getDatasetForDmp(data: any) { + return this.restBase.post("dmp/getdatasets", data); } - public createDatasetForDmp(data:any){ - return this.restBase.post("dataset/create", data); + public createDatasetForDmp(data: any) { + return this.restBase.post("dataset/create", data); } - public getAllDatsetsProfile(){ - return this.restBase.get("datasetprofile/getAll"); + public getAllDatsetsProfile() { + return this.restBase.get("datasetprofile/getAll"); } - public getDatasetProfileByID(id){ - return this.restBase.get("datasetprofiles/"+id); + public getDatasetProfileByID(id) { + return this.restBase.get("datasetprofiles/" + id); } - public updateDatsetsProfile(data:any){ - return this.restBase.post("dataset/update", data); + public updateDatsetsProfile(data: any) { + return this.restBase.post("dataset/update", data); } - - public deleteDataset(dataset: any){ + + public deleteDataset(dataset: any) { return this.restBase.post("dataset/softdelete", dataset); } - public getUserByID(id : string){ - return this.restBase.get("users/"+id); + public getUserByID(id: string) { + return this.restBase.get("users/" + id); } - public whoami(){ + public whoami() { return this.restBase.get("user/whoami"); } - public updateDataset(id:string,properties:any){ - return this.restBase.post("datasetprofile/save/"+id,properties); + public updateDataset(id: string, properties: any) { + return this.restBase.post("datasetprofile/save/" + id, properties); } - public getSingleDataset(id){ - return this.restBase.get("datasetprofile/get/"+id); + public getSingleDataset(id) { + return this.restBase.get("datasetprofile/get/" + id); } - - getThroughProxy(url : string, query: string){ + + getThroughProxy(url: string, query: string) { return this.restBase.proxy_get_wQuery(url, query); } + public searchDatasetRegistry(like: string) { + return this.restBase.get("external/registries" + "?query=" + like); + } - + public searchDatasetRepository(like: string) { + return this.restBase.get("external/datarepos" + "?query=" + like); + } + public searchDatasetService(like: string) { + return this.restBase.get("external/services" + "?query=" + like); + } } \ No newline at end of file
- - - + - - + +
Label - Uri {{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?.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 }} - - + + + - + + -