services, repos, registries added to dataset creation

This commit is contained in:
Diamantis Tziotzios 2017-12-08 11:51:39 +02:00
parent 65831fff1f
commit 028410c128
4 changed files with 206 additions and 152 deletions

View File

@ -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,

View File

@ -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("<option value='' style='text-color: #cccccc' selected disabled hidden>Filter by status</option>");
//$('#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;
});
}
}

View File

@ -1,7 +1,6 @@
<app-spinner> </app-spinner>
<table class="table table-striped" [mfData]="tableData | datasetTableFilter : filterQuery | datasetstatusFilter: statusFilter" #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage"
[(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
<table class="table table-striped" [mfData]="tableData | datasetTableFilter : filterQuery | datasetstatusFilter: statusFilter"
#mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
<thead>
<tr>
@ -15,7 +14,8 @@
<select [ngClass]="{'semi-visible': statusFilter==''}" class="form-control" id="status-filter" [(ngModel)]="statusFilter" [name]="statusDropDown" #datasetfield>
<select [ngClass]="{'semi-visible': statusFilter==''}" class="form-control" id="status-filter" [(ngModel)]="statusFilter"
[name]="statusDropDown" #datasetfield>
<option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select>
@ -23,7 +23,7 @@
<th>
<button class="btn btn-default" (click)="getDatasets('false')">
<span class="glyphicon glyphicon-refresh"></span>
</button>
</button>
</th>
</tr>
<tr>
@ -63,17 +63,24 @@
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dataset.id}}</td>
<td>{{(dataset?.label?.length > 80) ? (dataset?.label | slice:0:80)+'...':(dataset?.label) }}</td>
<td>{{(dataset?.uri?.length > 40) ? (dataset?.uri | slice:0:40)+'...':(dataset?.uri) }}</td>
<td>{{(dataset?.profile?.label?.length > 40) ? (dataset?.profile?.label | slice:0:40)+'...':(dataset?.profile?.label) }}</td>
<td>{{(dataset?.profile?.label?.length > 40) ? (dataset?.profile?.label | slice:0:40)+'...':(dataset?.profile?.label)
}}
</td>
<td>{{(dataset?.description?.length > 40) ? (dataset?.description | slice:0:40)+'...':(dataset?.description) }}</td>
<td>{{dataset?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}</td>
<td>{{dataset?.status | statusToString }}</td>
<td>
<a [ngClass]="{'hidden-keepspace': dataset.status==2 }" class="editGridColumn cursor-hand disabled" (click)="editRow(dataset, $event)">
<i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit Properties" id="editDataset"></i></a>
<a [ngClass]="{'hidden-keepspace': dataset.status==2 }" class="editGridColumn cursor-hand disabled" (click)="editRow(dataset, $event)">
<i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit Properties" id="editDataset"></i>
</a>
<a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)">
<i class="fa fa-eraser fa-fw" data-toggle="modal" data-target="#delete-dataset-confirm" (click)="markDatasetForDelete(dataset)" title="delete Dataset"></i></a>
<i class="fa fa-eraser fa-fw" data-toggle="modal" data-target="#delete-dataset-confirm" (click)="markDatasetForDelete(dataset)"
title="delete Dataset"></i>
</a>
<a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)">
<i class="fa fa-list-alt fa-fw" data-toggle="tooltip" title="describe dataset" id="describeDataset"></i></a></td>
<i class="fa fa-list-alt fa-fw" data-toggle="tooltip" title="describe dataset" id="describeDataset"></i>
</a>
</td>
</tr>
</tbody>
@ -93,9 +100,11 @@
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel"><b>{{ dataset?.id ? "Edit Dataset" : "New Dataset" }}</b></h4>
<h4 class="modal-title" id="modalLabel">
<b>{{ dataset?.id ? "Edit Dataset" : "New Dataset" }}</b>
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
@ -115,23 +124,33 @@
<input class="form-control" id="uri-text" [(ngModel)]="dataset.uri" name="uri" pattern="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?">
</div>
<div class="form-group">
<label for="status-name" class="col-form-label">Status:</label>
<select class="form-control" id="statusid" [(ngModel)]="dataset.status" name="statusDropDown" #datasetfield>
<label for="status-name" class="col-form-label">Status:</label>
<select class="form-control" id="statusid" [(ngModel)]="dataset.status" name="statusDropDown" #datasetfield>
<option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select>
</div>
<div class="form-group">
<label for="abbreviation-text" class="form-control-label">Description:</label>
<textarea rows="3" class="form-control" id="abbreviation-text" [(ngModel)]="dataset.description" name="description"></textarea>
</div>
<!-- <div class="form-group">
<label for="start-date" class="form-control-label">Properties:</label>
<input class="form-control" id="startDate-date" [(ngModel)]= "dataset.properties" name = "properties">
</div> -->
<!-- <div class="form-group">
<label for="end-date" class="form-control-label">End Date:</label>
<input class="form-control" id="endDate-date" [(ngModel)]= "dataset.endDate" name = "endDate">
</div> -->
</select>
</div>
<div class="form-group">
<label for="abbreviation-text" class="form-control-label">Description:</label>
<textarea rows="3" class="form-control" id="abbreviation-text" [(ngModel)]="dataset.description" name="description"></textarea>
</div>
<div class="form-group">
<label for="services-dropdown" class="form-control-label">Services:</label>
<p-autoComplete id="services-dropdown" [(ngModel)]="dataset.services" [suggestions]="filteredServices" (completeMethod)="searchServices($event)"
styleClass="wid100" [minLength]="1" name="services" [multiple]="true" [emptyMessage]="true" field="name">
</p-autoComplete>
</div>
<div class="form-group">
<label for="registries-dropdown" class="form-control-label">Registries:</label>
<p-autoComplete id="registries-dropdown" [(ngModel)]="dataset.registries" [suggestions]="filteredRegistries" (completeMethod)="searchRegistries($event)"
styleClass="wid100" [minLength]="1" name="registries" [multiple]="true" [emptyMessage]="true" field="name">
</p-autoComplete>
</div>
<div class="form-group">
<label for="repositories-dropdown" class="form-control-label">Repositories:</label>
<p-autoComplete id="repositories-dropdown" [(ngModel)]="dataset.repositories" [suggestions]="filteredRepositories" (completeMethod)="searchRepositories($event)"
styleClass="wid100" [minLength]="1" name="repositories" [multiple]="true" [emptyMessage]="true" field="name">
</p-autoComplete>
</div>
</form>
</div>
<div class="modal-footer">
@ -144,4 +163,5 @@
</div>
<!-- Confirmation module- do not delete -->
<confirmation [confirmationID]="'delete-dataset-confirm'" [confirmationTitle]="'Caution'" [confirmationDescr]="'This action will delete this dataset. Are you sure you want to delete this dataset ? This is not revertable !'" (responseSender)="deleteDataset($event)"></confirmation>
<confirmation [confirmationID]="'delete-dataset-confirm'" [confirmationTitle]="'Caution'" [confirmationDescr]="'This action will delete this dataset. Are you sure you want to delete this dataset ? This is not revertable !'"
(responseSender)="deleteDataset($event)"></confirmation>

View File

@ -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';
@ -18,162 +18,170 @@ export class ServerService {
}
public listDatasetIDs(){
public listDatasetIDs() {
return this.restBase.get("dataset");
}
public 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(){
public getAllDataSet() {
return this.restBase.get("dataset/getAll");
}
public getDmpOfUser(){
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){
public getDatasetForDmp(data: any) {
return this.restBase.post("dmp/getdatasets", data);
}
public createDatasetForDmp(data:any){
public createDatasetForDmp(data: any) {
return this.restBase.post("dataset/create", data);
}
public getAllDatsetsProfile(){
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){
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);
}
}