changes on projects

This commit is contained in:
Nikolaos Laskaris 2017-11-06 18:25:23 +02:00
parent 9428ab55a9
commit f1dbe240a4
17 changed files with 121 additions and 159 deletions

View File

@ -526,6 +526,12 @@
"graceful-fs": "4.1.11" "graceful-fs": "4.1.11"
} }
}, },
"moment": {
"version": "2.18.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz",
"integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=",
"dev": true
},
"ms": { "ms": {
"version": "0.7.2", "version": "0.7.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz",
@ -2220,6 +2226,11 @@
} }
} }
}, },
"date-fns": {
"version": "1.29.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz",
"integrity": "sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw=="
},
"date-now": { "date-now": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
@ -5404,10 +5415,9 @@
"dev": true "dev": true
}, },
"moment": { "moment": {
"version": "2.18.1", "version": "2.19.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.19.1.tgz",
"integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=", "integrity": "sha1-VtoaLRy/AdOLfhr8McELz6GSkWc="
"dev": true
}, },
"ms": { "ms": {
"version": "2.0.0", "version": "2.0.0",
@ -5490,6 +5500,20 @@
"resolved": "https://registry.npmjs.org/ng-sidebar/-/ng-sidebar-6.0.4.tgz", "resolved": "https://registry.npmjs.org/ng-sidebar/-/ng-sidebar-6.0.4.tgz",
"integrity": "sha1-QtxRdV6FPBiBs7iFg1T0yEWpbzM=" "integrity": "sha1-QtxRdV6FPBiBs7iFg1T0yEWpbzM="
}, },
"ng2-datepicker": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ng2-datepicker/-/ng2-datepicker-2.1.3.tgz",
"integrity": "sha512-09Hwrf9IHsWzp/2FPSGo00P/XtiHSsHLBCeFCK1LG1nuuhNZbQ7LXLR+e+znhjPJyTkhelmODkhmy5DByYWpcA==",
"requires": {
"date-fns": "1.29.0",
"ngx-slimscroll": "3.4.1"
}
},
"ngx-slimscroll": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/ngx-slimscroll/-/ngx-slimscroll-3.4.1.tgz",
"integrity": "sha512-PMbOai2OeXCFCHnPigYXquN6fAUeAc+CC3AhHugt9wIp8xUB6lIt8OqOWS3IPRRaeKQWyxFCuDfiPKY8n2QuOQ=="
},
"ngx-webstorage": { "ngx-webstorage": {
"version": "1.8.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/ngx-webstorage/-/ngx-webstorage-1.8.0.tgz", "resolved": "https://registry.npmjs.org/ngx-webstorage/-/ngx-webstorage-1.8.0.tgz",

View File

@ -31,7 +31,9 @@
"core-js": "^2.4.1", "core-js": "^2.4.1",
"flat": "^4.0.0", "flat": "^4.0.0",
"jquery": "^3.2.1", "jquery": "^3.2.1",
"moment": "^2.19.1",
"ng-sidebar": "^6.0.4", "ng-sidebar": "^6.0.4",
"ng2-datepicker": "^2.1.3",
"ngx-webstorage": "^1.8.0", "ngx-webstorage": "^1.8.0",
"rxjs": "^5.4.2", "rxjs": "^5.4.2",
"zone.js": "^0.8.17" "zone.js": "^0.8.17"

View File

@ -58,6 +58,7 @@ import { ProjectsComponent } from './projects/projects.component';
import { ProjectRoutingModule } from './projects/project-routing.module'; import { ProjectRoutingModule } from './projects/project-routing.module';
import { ProjectDetailComponent } from './projects/project.detail'; import { ProjectDetailComponent } from './projects/project.detail';
import { ModalComponent } from './modal/modal.component'; import { ModalComponent } from './modal/modal.component';
import { NgDatepickerModule } from 'ng2-datepicker';
import { StatusToString } from './pipes/various/status-to-string'; import { StatusToString } from './pipes/various/status-to-string';
import { SidebarModule } from 'ng-sidebar'; import { SidebarModule } from 'ng-sidebar';
@ -106,6 +107,7 @@ import { UserWorkspaceComponent } from './user-workspace/user-workspace.componen
AppRoutingModule, AppRoutingModule,
AngularDraggableModule, AngularDraggableModule,
DataTableModule, DataTableModule,
NgDatepickerModule,
SidebarModule.forRoot() SidebarModule.forRoot()
], ],

View File

@ -192,7 +192,7 @@ export class DatasetsComponent implements OnInit {
this.SaveDataset(); this.SaveDataset();
} }
describeDataset(item) {debugger; describeDataset(item) {
this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profile.id, datasetId:item.id}])); this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profile.id, datasetId:item.id}]));
} }

View File

@ -1,36 +0,0 @@
/*
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {DataTableModule} from 'angular2-datatable';
import { DatasetTableFilterPipe } from '../pipes/dataset-table-filter.pipe';
import { DatasetStatusFilterPipe } from '../pipes/dataset-status-filter.pipe';
import { DatasetsComponent } from './dataset.component';
import { DatasetRoutingModule } from './dataset-routing.module';
//import { ProjectDetailComponent } from './project.detail';
@NgModule({
imports: [
CommonModule,
FormsModule,
DatasetRoutingModule,
DataTableModule
],
declarations: [
DatasetsComponent,
StatusToString,
DatasetTableFilterPipe,
DatasetStatusFilterPipe
//ProjectDetailComponent
],
providers: [ ],
exports: [
DatasetsComponent
]
})
export class DatasetsModule {}
*/

View File

@ -123,7 +123,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="abbreviation-text" class="form-control-label">Description:</label> <label for="abbreviation-text" class="form-control-label">Description:</label>
<textarea class="form-control" id="abbreviation-text" [(ngModel)]="dmp.description" name="description"></textarea> <textarea rows="3" class="form-control" id="abbreviation-text" [(ngModel)]="dmp.description" name="description"></textarea>
</div> </div>
<!-- <div class="form-group"> <!-- <div class="form-group">
<label for="reference-text" class="form-control-label">Profile Data:</label> <label for="reference-text" class="form-control-label">Profile Data:</label>

View File

@ -1,4 +1,3 @@
import { Pipe, PipeTransform } from '@angular/core'; import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ @Pipe({

View File

@ -30,10 +30,10 @@
<mfDefaultSorter by="endDate">End Date</mfDefaultSorter> <mfDefaultSorter by="endDate">End Date</mfDefaultSorter>
</th> </th>
<th> <th>
<mfDefaultSorter by="description">Description</mfDefaultSorter> <mfDefaultSorter by="status">Status</mfDefaultSorter>
</th> </th>
<th> <th>
<mfDefaultSorter by="status">Status</mfDefaultSorter> <mfDefaultSorter by="description">Definition</mfDefaultSorter>
</th> </th>
<th> <th>
<mfDefaultSorter>Actions </mfDefaultSorter> <mfDefaultSorter>Actions </mfDefaultSorter>
@ -47,13 +47,13 @@
</tr> </tr>
<tr *ngFor="let project of mf.data" class="hover"> <tr *ngFor="let project of mf.data" class="hover">
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{project.id}}</td> <td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{project?.id}}</td>
<td>{{project?.label}}</td> <td>{{project?.label}}</td>
<td>{{project?.abbreviation}}</td> <td>{{project?.abbreviation}}</td>
<td>{{project?.startDate}}</td> <td>{{project?.startdate | date:'yyyy-MM-dd HH:mm:ss Z' }}</td>
<td>{{project?.endDate}}</td> <td>{{project?.enddate | date:'yyyy-MM-dd HH:mm:ss Z'}}</td>
<td>{{project?.description}}</td> <td>{{project?.status | statusToString}}</td>
<td>{{project?.status}}</td> <td>{{project?.definition}}</td>
<td><a class="editGridColumn" (click)="editRow(project, $event)"><i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit properties" id="editDMP"></i> <td><a class="editGridColumn" (click)="editRow(project, $event)"><i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit properties" id="editDMP"></i>
<i class="fa fa-eraser fa-fw" data-toggle="tooltip" title="delete project"></i></a></td> <i class="fa fa-eraser fa-fw" data-toggle="tooltip" title="delete project"></i></a></td>
@ -80,7 +80,7 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form #newProjectForm="ngForm" (ngSubmit)="SaveNewProject()"> <form #newProjectForm="ngForm" (ngSubmit)="SaveProject()">
<div class="form-group"> <div class="form-group">
<label for="label-name" class="form-control-label">Label:</label> <label for="label-name" class="form-control-label">Label:</label>
<input type="text" class="form-control" id="label-name" [(ngModel)]= "project.label" name = "label"> <input type="text" class="form-control" id="label-name" [(ngModel)]= "project.label" name = "label">
@ -99,21 +99,21 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="start-date" class="form-control-label">Start Date:</label> <label for="start-date" class="form-control-label">Start Date:</label>
<input class="form-control" id="startDate-date" [(ngModel)]= "project.startDate" name = "startDate"> <input class="form-control" type='date' class="form-control" [(ngModel)]= "project.startdate" id='start-date' name = "startdate"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="end-date" class="form-control-label">End Date:</label> <label for="end-date" class="form-control-label">End Date:</label>
<input class="form-control" id="endDate-date" [(ngModel)]= "project.endDate" name = "endDate"> <input class="form-control" type='date' class="form-control" [(ngModel)]= "project.enddate" id='end-date' name = "enddate"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="code-name" class="form-control-label">Description:</label> <label for="code-name" class="form-control-label">Definition:</label>
<input type="text" class="form-control" name="desc" id="descr" [(ngModel)]= "project.description"> <textarea rows="3" class="form-control" name="desc" id="definition" [(ngModel)]= "project.definition"> </textarea>
</div> </div>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" (click)="SaveNewProject();">Save project</button> <button type="submit" class="btn btn-primary" (click)="SaveProject();">Save project</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,33 +0,0 @@
/*
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {DataTableModule} from 'angular2-datatable';
import { ProjectTableFilterPipe } from '../pipes/project-table-filter.pipe';
import { ProjectsComponent } from './projects.component';
import { ProjectRoutingModule } from './project-routing.module';
import { ProjectDetailComponent } from './project.detail';
import { DatasetsModule } from '../datasets/dataset.module';
import { ModalComponent } from '../modal/modal.component';
@NgModule({
imports: [
CommonModule,
FormsModule,
ProjectRoutingModule,
DataTableModule,
DatasetsModule
],
declarations: [
ProjectsComponent,
ProjectDetailComponent,
ModalComponent,
ProjectTableFilterPipe
],
providers: [ ]
})
export class ProjectsModule {}
*/

View File

@ -1,4 +1,5 @@
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {GoogleSignInSuccess} from 'angular-google-signin'; import {GoogleSignInSuccess} from 'angular-google-signin';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { ServerService } from '../../app/services/server.service'; import { ServerService } from '../../app/services/server.service';
@ -13,12 +14,16 @@ import { ModalComponent } from '../modal/modal.component';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { FormGroup, FormControl } from '@angular/forms'; //na dw an xreiazontai import { FormGroup, FormControl } from '@angular/forms'; //na dw an xreiazontai
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { DatepickerOptions } from 'ng2-datepicker';
import { StatusToString} from '../pipes/various/status-to-string';
import { ProjectTableFilterPipe } from '../pipes/project-table-filter.pipe'; import { ProjectTableFilterPipe } from '../pipes/project-table-filter.pipe';
declare var $ :any; declare var $ :any;
@Component({ @Component({
selector: 'projects', selector: 'projects',
templateUrl: 'project.html', templateUrl: 'project.html',
@ -52,7 +57,6 @@ export class ProjectsComponent implements OnInit{
// END ALTERNATIVE // END ALTERNATIVE
returnUrl: string; returnUrl: string;
@Input() projects: Project[];
@Input() projectCount = 0; @Input() projectCount = 0;
@Input() datasetDropDown:DropdownField; @Input() datasetDropDown:DropdownField;
//@Input() dataSetVisibe:boolean; //@Input() dataSetVisibe:boolean;
@ -66,6 +70,17 @@ export class ProjectsComponent implements OnInit{
@ViewChild(DataTable) datasetsTable; @ViewChild(DataTable) datasetsTable;
@ViewChild('isignOutBtn') isignOutBtn; @ViewChild('isignOutBtn') isignOutBtn;
options: DatepickerOptions = {
minYear: 1900,
maxYear: 2050,
displayFormat: 'MMM D[,] YYYY',
barTitleFormat: 'MMMM YYYY',
firstCalendarDay: 0 // 0 - Sunday, 1 - Monday
};
constructor( constructor(
private serverService: ServerService, private serverService: ServerService,
private route: ActivatedRoute, private route: ActivatedRoute,
@ -73,55 +88,43 @@ export class ProjectsComponent implements OnInit{
this.datasetDropDown = new DropdownField(); this.datasetDropDown = new DropdownField();
this.datasetDropDown.options = []; this.datasetDropDown.options = [];
this.datasets = []; this.datasets = [];
this.project = { this.project = this.getEmptyProject();
}
ngAfterViewInit() {
}
getEmptyProject(){
return {
label: '', label: '',
abbreviation:'', abbreviation:'',
reference:'', reference:'',
uri:'', uri:'',
definition:'', definition:'',
endDate:'', enddate:'',
startDate:'' startdate:''
} }
} }
ngOnInit() { ngOnInit() {
this.projects = [];
this.getProjects(); this.getProjects();
} }
getProjects(){ getProjects(){
this.serverService.getProjectOfUer().subscribe( this.serverService.getProjectsOfUser().subscribe(
response => { response => {
this.tableData = response; this.tableData = response;
console.log(this.tableData)
},
err => {
response.forEach(resp => {
let pr = new Project();
pr.id = resp.id;
pr.label = resp.label;
pr.abbreviation = resp.abbreviation;
pr.definition = resp.definition;
pr.uri = resp.uri;
this.projects.push(pr);
} }
); );
} }
// (err: HttpErrorResponse) => {
// if (err.error instanceof Error) {
// // A client-side or network error occurred. Handle it accordingly.
// console.log('An error occurred:', err.error.message);
// } else {
// // The backend returned an unsuccessful response code.
// // The response body may contain clues as to what went wrong,
// if(err.status == 401){
// this.isignOutBtn.nativeElement.click();
// }
// console.log(`Backend returned code ${err.status}, body was: ${err.error}`);
// }
// }
);
}
getDMPs(){ getDMPs(){
@ -146,45 +149,36 @@ showDatasets(){debugger; //dmpId, event
} }
// editRow(item){
// this.show = true;
// this.item = item;
// }
SaveNewProject(){ SaveProject(){
console.log(this.project);
//this.http.post('http://someurl', JSON.stringify(this.project)) let action : Observable<any>;
this.serverService.createProject(this.project)
.subscribe( if(this.project.id == null) //means it's a new one
action = this.serverService.createProject(this.project);
else
action = this.serverService.updateProject(this.project);
action.subscribe(
response =>{ response =>{
console.log("response"); console.log("response");
console.log(response); console.log(response);
} }
); );
$("#newEditProjectModal").modal("hide"); $("#newEditProjectModal").modal("hide");
} }
newProject(item){ newProject(item){
this.project.label = ""; this.project = this.getEmptyProject();
this.project.id = null;
this.project.abbreviation = "";
this.project.reference = "";
this.project.uri = "";
this.project.definition = "";
$("#newEditProjectModal").modal("show"); $("#newEditProjectModal").modal("show");
} }
editRow(item, event){ editRow(item, event){
if (event.toElement.id == "editDMP"){
this.project.label = item.label; this.project = item; //this will have id - that defines whether it's an update or not
this.project.abbreviation = item.abbreviation;
this.project.reference = item.reference;
this.project.uri = item.uri;
this.project.definition = item.definition;
this.project.id = item.id;
$("#newEditProjectModal").modal("show"); $("#newEditProjectModal").modal("show");
}

View File

@ -81,7 +81,7 @@ export class ServerService {
return this.restBase.get("dmp/listDMPLabelID"); return this.restBase.get("dmp/listDMPLabelID");
} }
public getProjectOfUer(){ public getProjectsOfUser(){
return this.restBase.get("project/getofuser"); return this.restBase.get("project/getofuser");
} }
@ -89,6 +89,10 @@ export class ServerService {
return this.restBase.post("project/createofuser", data); return this.restBase.post("project/createofuser", data);
} }
public updateProject(data:any){
return this.restBase.post("project/update", data);
}
public getAllDataSet(){ public getAllDataSet(){
return this.restBase.get("dataset/getAll"); return this.restBase.get("dataset/getAll");
} }

View File

@ -5,7 +5,7 @@ import { ProjectsComponent } from '../projects/projects.component';
@Component({ @Component({
selector: 'app-user-workspace', selector: 'user-workspace',
templateUrl: './user-workspace.component.html', templateUrl: './user-workspace.component.html',
styleUrls: ['./user-workspace.component.css'] styleUrls: ['./user-workspace.component.css']
}) })

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,14 +38,12 @@
<!-- font-awesome css --> <!-- font-awesome css -->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- my custom global code and css --> <!-- my custom global code and css -->
<link rel="stylesheet" type="text/css" href="assets/custom.css"> <link rel="stylesheet" type="text/css" href="assets/custom.css">
<script src="assets/custom.js"></script> <script src="assets/custom.js"></script>
</head> </head>
<body> <body>
<script> <script>