no message
This commit is contained in:
parent
b9fa3d1dac
commit
6c2c0a8700
|
@ -34,7 +34,7 @@ import entities.security.UserAuth;
|
|||
@Entity
|
||||
@Table(name="\"UserInfo\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
public class UserInfo implements Serializable{
|
||||
public class UserInfo implements Serializable,DataEntity{
|
||||
|
||||
private static final long serialVersionUID = 1225151430484658395L;
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
|
|||
|
||||
Element dataElement = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "data");
|
||||
|
||||
this.data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle());
|
||||
this.data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle(),dataElement);
|
||||
if(this.data!=null)this.data.fromXml(dataElement);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.modeldefinition.Field toDatabaseDefinition(entities.xmlmodels.modeldefinition.Field field) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "field_"+RandomStringUtils.random(5, true, true);
|
||||
if(this.id == null||this.id.isEmpty())this.id = "field_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
field.setDatatype(this.datatype);
|
||||
field.setDefaultValue(this.defaultValue);
|
||||
|
@ -141,7 +141,7 @@ public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.Field toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Field field) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "field_"+RandomStringUtils.random(5, true, true);
|
||||
if(this.id == null||this.id.isEmpty())this.id = "field_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
field.setDefaultVisibility(this.defaultVisibility);
|
||||
field.setDescription(this.description);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FieldSet implements Comparable,ModelDefinition<entities.xmlmodels.m
|
|||
|
||||
@Override
|
||||
public entities.xmlmodels.modeldefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.modeldefinition.FieldSet fieldSet) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "fieldSet_"+RandomStringUtils.random(5, true, true);
|
||||
if(this.id == null||this.id.isEmpty())this.id = "fieldSet_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
fieldSet.setId(this.id);
|
||||
fieldSet.setOrdinal(this.ordinal);
|
||||
|
@ -71,7 +71,7 @@ public class FieldSet implements Comparable,ModelDefinition<entities.xmlmodels.m
|
|||
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.FieldSet toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.FieldSet item) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "fieldSet_"+RandomStringUtils.random(5, true, true);
|
||||
if(this.id == null||this.id.isEmpty())this.id = "fieldSet_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
List<entities.xmlmodels.viewstyledefinition.Field> viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, entities.xmlmodels.viewstyledefinition.Field.class);
|
||||
item.setFields(viewStylefields);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class Group implements ModelDefinition<entities.xmlmodels.modeldefinition
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.FieldGroup toDatabaseDefinition(FieldGroup item) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "group_"+RandomStringUtils.random(5, true, true);
|
||||
if(this.id == null||this.id.isEmpty())this.id = "group_"+RandomStringUtils.random(5, true, true);
|
||||
|
||||
item.setDefaultVisibility(this.defaultVisibility);
|
||||
item.setDescription(this.description);
|
||||
|
|
|
@ -68,7 +68,7 @@ public class Section implements Comparable,ViewStyleDefinition<entities.xmlmodel
|
|||
}
|
||||
@Override
|
||||
public entities.xmlmodels.viewstyledefinition.Section toDatabaseDefinition(entities.xmlmodels.viewstyledefinition.Section item) {
|
||||
if(this.id.isEmpty()||this.id == null)this.id = "section_"+RandomStringUtils.random(5, true, true);
|
||||
if(this.id == null||this.id.isEmpty())this.id = "section_"+RandomStringUtils.random(5, true, true);
|
||||
item.setDefaultVisibility(this.defaultVisibility);
|
||||
item.setDescription(this.description);
|
||||
if(this.fieldGroups!=null)item.setFieldGroups(new ModelBuilder().toViewStyleDefinition(this.fieldGroups, entities.xmlmodels.viewstyledefinition.FieldGroup.class));
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package models.components.commons.datafield;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import models.components.commons.datafield.ComboBoxData.Option;
|
||||
|
||||
public class AutoCompleteData extends ComboBoxData<AutoCompleteData>{
|
||||
private String url;
|
||||
private Option autoCompleteOptions;
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
|
||||
root.setAttribute("url", this.url);
|
||||
|
||||
Element element = doc.createElement("option");
|
||||
element.setAttribute("label", this.autoCompleteOptions.getLabel());
|
||||
element.setAttribute("value", autoCompleteOptions.getValue());
|
||||
root.appendChild(element);
|
||||
return root;
|
||||
}
|
||||
@Override
|
||||
public AutoCompleteData fromXml(Element item) {
|
||||
super.fromXml(item);
|
||||
this.url = item.getAttribute("url");
|
||||
Element optionElement = (Element)item.getElementsByTagName("option").item(0);
|
||||
|
||||
if(optionElement!=null){
|
||||
this.autoCompleteOptions = new Option();
|
||||
this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
|
||||
this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AutoCompleteData fromData(Object data) {
|
||||
super.fromData(data);
|
||||
this.autoCompleteOptions = new Option();
|
||||
if(data!=null){
|
||||
this.url = (String)((Map<String,Object>)data).get("url");
|
||||
Map<String,String> options = ((Map<String,Map<String,String>>)data).get("option");
|
||||
this.autoCompleteOptions.setLabel(options.get("label"));
|
||||
this.autoCompleteOptions.setValue(options.get("value"));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -11,8 +11,8 @@ import org.w3c.dom.NodeList;
|
|||
|
||||
import utilities.XmlSerializable;
|
||||
|
||||
public class ComboBoxData extends FieldData<ComboBoxData>{
|
||||
private class Option implements XmlSerializable<Option>{
|
||||
public abstract class ComboBoxData<T> extends FieldData<T>{
|
||||
public class Option implements XmlSerializable<Option>{
|
||||
private String label;
|
||||
private String value;
|
||||
public String getLabel() {
|
||||
|
@ -44,8 +44,6 @@ public class ComboBoxData extends FieldData<ComboBoxData>{
|
|||
}
|
||||
|
||||
private String type;
|
||||
private String url;
|
||||
private List<Option> options;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
|
@ -53,72 +51,27 @@ public class ComboBoxData extends FieldData<ComboBoxData>{
|
|||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
public List<Option> getOptions() {
|
||||
return options;
|
||||
}
|
||||
public void setOptions(List<Option> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = doc.createElement("data");
|
||||
root.setAttribute("type", this.type);
|
||||
root.setAttribute("url", this.url);
|
||||
|
||||
Element element = doc.createElement("options");
|
||||
if(this.options!=null){
|
||||
for(Option option : this.options){
|
||||
element.appendChild(option.toXml(doc));
|
||||
}
|
||||
}
|
||||
root.appendChild(element);
|
||||
return root;
|
||||
}
|
||||
@Override
|
||||
public ComboBoxData fromXml(Element item) {
|
||||
public T fromXml(Element item) {
|
||||
|
||||
this.url = item.getAttribute("url");
|
||||
this.type = item.getAttribute("type");
|
||||
this.options = new LinkedList<>();
|
||||
Element optionsElement = (Element)item.getElementsByTagName("options").item(0);
|
||||
|
||||
if(optionsElement!=null){
|
||||
NodeList optionElements = optionsElement.getChildNodes();
|
||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||
Node optionElement = optionElements.item(temp);
|
||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
this.options.add(new Option().fromXml((Element)optionElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
return (T)this;
|
||||
}
|
||||
@Override
|
||||
public ComboBoxData fromData(Object data) {
|
||||
this.options = new LinkedList();
|
||||
|
||||
public T fromData(Object data) {
|
||||
|
||||
if(data!=null){
|
||||
this.type = (String)((Map<String,Object>)data).get("type");
|
||||
this.url = (String)((Map<String,Object>)data).get("url");
|
||||
List<Map<String,String>> options = ((Map<String,List<Map<String,String>>>)data).get("options");
|
||||
if(options!=null){
|
||||
for(Map<String,String> map : options){
|
||||
Option newOption = new Option();
|
||||
newOption.setLabel(map.get("label"));
|
||||
newOption.setValue(map.get("value"));
|
||||
this.options.add(newOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
return (T)this;
|
||||
}
|
||||
@Override
|
||||
public Object toData() {
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package models.components.commons.datafield;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import models.components.commons.datafield.ComboBoxData.Option;
|
||||
|
||||
public class WordListData extends ComboBoxData<WordListData>{
|
||||
private List<Option> options;
|
||||
|
||||
public List<Option> getOptions() {
|
||||
return options;
|
||||
}
|
||||
public void setOptions(List<Option> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element root = super.toXml(doc);
|
||||
Element element = doc.createElement("options");
|
||||
if(this.options!=null){
|
||||
for(Option option : this.options){
|
||||
element.appendChild(option.toXml(doc));
|
||||
}
|
||||
}
|
||||
root.appendChild(element);
|
||||
return root;
|
||||
}
|
||||
@Override
|
||||
public WordListData fromXml(Element item) {
|
||||
super.fromXml(item);
|
||||
this.options = new LinkedList<>();
|
||||
Element optionsElement = (Element)item.getElementsByTagName("options").item(0);
|
||||
|
||||
if(optionsElement!=null){
|
||||
NodeList optionElements = optionsElement.getChildNodes();
|
||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||
Node optionElement = optionElements.item(temp);
|
||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
this.options.add(new Option().fromXml((Element)optionElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public WordListData fromData(Object data) {
|
||||
this.options = new LinkedList();
|
||||
|
||||
if(data!=null){
|
||||
List<Map<String,String>> options = ((Map<String,List<Map<String,String>>>)data).get("options");
|
||||
if(options!=null){
|
||||
for(Map<String,String> map : options){
|
||||
Option newOption = new Option();
|
||||
newOption.setLabel(map.get("label"));
|
||||
newOption.setValue(map.get("value"));
|
||||
this.options.add(newOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Object toData() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ public class DataManagementPlan implements DataModel<DMP>{
|
|||
private models.dmp.Project project;
|
||||
private List<Organisation> organizations;
|
||||
private List<Researcher> researchers;
|
||||
|
||||
private UserInfo creator;
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -84,7 +84,15 @@ public class DataManagementPlan implements DataModel<DMP>{
|
|||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(UserInfo creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
||||
this.id = entity.getId();
|
||||
this.organizations =new DomainModelConverter<entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class);
|
||||
|
@ -94,6 +102,8 @@ public class DataManagementPlan implements DataModel<DMP>{
|
|||
this.label = entity.getLabel();
|
||||
this.project = new models.dmp.Project();
|
||||
this.project.fromDataModel(entity.getProject());
|
||||
this.creator = new models.dmp.UserInfo();
|
||||
this.creator.fromDataModel(entity.getCreator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,24 +6,34 @@ import java.util.UUID;
|
|||
|
||||
public class Project implements DataModel<entities.Project>{
|
||||
private UUID id;
|
||||
|
||||
private String label;
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(entities.Project entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public entities.Project toDataModel() {
|
||||
entities.Project project = new entities.Project();
|
||||
project.setId(this.id);
|
||||
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
package models.dmp;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import entities.security.UserAuth;
|
||||
import models.DataModel;
|
||||
|
||||
public class UserInfo implements DataModel<entities.UserInfo>{
|
||||
private UUID id;
|
||||
|
||||
private String email = null;
|
||||
|
||||
private Short authorization_level; //0 admin, 1 user
|
||||
|
||||
private Short usertype; // 0 internal, 1 external
|
||||
|
||||
private Boolean verified_email = null;
|
||||
|
||||
private String name = null;
|
||||
|
||||
private Date created = null;
|
||||
|
||||
private Date lastloggedin = null;
|
||||
|
||||
private String additionalinfo;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Short getAuthorization_level() {
|
||||
return authorization_level;
|
||||
}
|
||||
|
||||
public void setAuthorization_level(Short authorization_level) {
|
||||
this.authorization_level = authorization_level;
|
||||
}
|
||||
|
||||
public Short getUsertype() {
|
||||
return usertype;
|
||||
}
|
||||
|
||||
public void setUsertype(Short usertype) {
|
||||
this.usertype = usertype;
|
||||
}
|
||||
|
||||
public Boolean getVerified_email() {
|
||||
return verified_email;
|
||||
}
|
||||
|
||||
public void setVerified_email(Boolean verified_email) {
|
||||
this.verified_email = verified_email;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Date getLastloggedin() {
|
||||
return lastloggedin;
|
||||
}
|
||||
|
||||
public void setLastloggedin(Date lastloggedin) {
|
||||
this.lastloggedin = lastloggedin;
|
||||
}
|
||||
|
||||
public String getAdditionalinfo() {
|
||||
return additionalinfo;
|
||||
}
|
||||
|
||||
public void setAdditionalinfo(String additionalinfo) {
|
||||
this.additionalinfo = additionalinfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(entities.UserInfo entity) throws InstantiationException, IllegalAccessException {
|
||||
this.name = entity.getName();
|
||||
this.email = entity.getEmail();
|
||||
this.usertype = entity.getUsertype();
|
||||
this.id = entity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public entities.UserInfo toDataModel() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -49,6 +49,7 @@ public class DatasetProfileController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ public class Datasets {
|
|||
|
||||
Dataset d = datasetDao.read(dataset.getId());
|
||||
d.setStatus(new Short("-1"));
|
||||
dataset = datasetDao.update(dataset);
|
||||
dataset = datasetDao.update(d);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"Deleted dataset!\"");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -3,12 +3,16 @@ package utilities.builders;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
|
||||
import entities.xmlmodels.viewstyledefinition.DatabaseViewStyleDefinition;
|
||||
import models.components.commons.datafield.AutoCompleteData;
|
||||
import models.components.commons.datafield.CheckBoxData;
|
||||
import models.components.commons.datafield.ComboBoxData;
|
||||
import models.components.commons.datafield.FieldData;
|
||||
import models.components.commons.datafield.RadioBoxData;
|
||||
import models.components.commons.datafield.WordListData;
|
||||
import utilities.ModelDefinition;
|
||||
import utilities.ViewStyleDefinition;
|
||||
|
||||
|
@ -63,8 +67,13 @@ public class ModelBuilder {
|
|||
return list;
|
||||
}
|
||||
|
||||
public <U extends FieldData<U>> U toFieldData(Object data,String type){
|
||||
if(type.equals("combobox")) return (U) new ComboBoxData().fromData(data);
|
||||
public <U extends FieldData<U>> U toFieldData(Object data,String type,Element dataElement){
|
||||
if(type.equals("combobox")){
|
||||
if(dataElement.getAttribute("type").equals("autocomplete")){
|
||||
return (U) new AutoCompleteData().fromData(data);
|
||||
}else if(dataElement.getAttribute("type").equals("wordlist"))
|
||||
return (U) new WordListData().fromData(data);
|
||||
}
|
||||
if(type.equals("booleanDecision"))return null;
|
||||
if(type.equals("radiobox"))return (U) new RadioBoxData().fromData(data);
|
||||
if(type.equals("checkBox"))return (U) new CheckBoxData().fromData(data);
|
||||
|
|
|
@ -202,6 +202,11 @@
|
|||
"tsickle": "0.21.6"
|
||||
}
|
||||
},
|
||||
"@ng-bootstrap/ng-bootstrap": {
|
||||
"version": "1.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-1.0.0-beta.5.tgz",
|
||||
"integrity": "sha1-2iuQZrNwGihMrFoWFop33vlHtKs="
|
||||
},
|
||||
"@ngtools/json-schema": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@ngtools/json-schema/-/json-schema-1.1.0.tgz",
|
||||
|
|
|
@ -12,15 +12,16 @@
|
|||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^4.3.6",
|
||||
"@angular/common": "^4.3.6",
|
||||
"@angular/compiler": "^4.3.6",
|
||||
"@angular/core": "^4.3.6",
|
||||
"@angular/forms": "^4.3.6",
|
||||
"@angular/http": "^4.3.6",
|
||||
"@angular/platform-browser": "^4.3.6",
|
||||
"@angular/platform-browser-dynamic": "^4.3.6",
|
||||
"@angular/router": "^4.3.6",
|
||||
"@angular/animations": "4.3.6",
|
||||
"@angular/common": "4.3.6",
|
||||
"@angular/compiler": "4.3.6",
|
||||
"@angular/core": "4.3.6",
|
||||
"@angular/forms": "4.3.6",
|
||||
"@angular/http": "4.3.6",
|
||||
"@angular/platform-browser": "4.3.6",
|
||||
"@angular/platform-browser-dynamic": "4.3.6",
|
||||
"@angular/router": "4.3.6",
|
||||
"@ng-bootstrap/ng-bootstrap": "1.0.0-beta.5",
|
||||
"@ngui/auto-complete": "^0.16.0",
|
||||
"angular-2-data-table": "^0.1.2",
|
||||
"angular-4-data-table-bootstrap-4": "^0.2.0",
|
||||
|
|
|
@ -31,7 +31,6 @@ import { FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/fo
|
|||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { RouterModule, Routes, Router } from '@angular/router';
|
||||
//import {DataTableModule } from 'angular-4-data-table-bootstrap-4';
|
||||
import { DataTableModule } from "angular2-datatable";
|
||||
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
@ -99,6 +98,7 @@ import {StepsModule,MenuItem} from 'primeng/primeng';
|
|||
import {CheckboxModule} from 'primeng/primeng';
|
||||
import {RadioButtonModule} from 'primeng/primeng';
|
||||
import {AutoCompleteModule} from 'primeng/primeng';
|
||||
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -156,6 +156,7 @@ import {AutoCompleteModule} from 'primeng/primeng';
|
|||
PanelModule,
|
||||
BrowserAnimationsModule,
|
||||
SidebarModule.forRoot(),
|
||||
NgbModule.forRoot(),
|
||||
StepsModule,
|
||||
CheckboxModule,
|
||||
RadioButtonModule,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<button type="button" *ngIf="dataModel&&dataModel?.status != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
|
||||
class="btn btn-primary" (click)="submit();">Save and Finalize</button>
|
||||
<div class="ui-g-12">
|
||||
<p-steps [model]="stepperItems" [activeIndex]="this.currentPageIndex" (activeIndexChange)="changePageIndex($event)" [readonly]="false"></p-steps>
|
||||
<ngb-pagination *ngIf="pages" [collectionSize]="pages.length*10" [page]="currentPageIndex" (pageChange)="changePageIndex($event)" aria-label="Default pagination"></ngb-pagination>
|
||||
</div>
|
||||
<div class="ui-g-12">
|
||||
<progress-bar *ngIf="form" [formGroup]="form"></progress-bar>
|
||||
|
|
|
@ -11,7 +11,7 @@ import { NgForm } from '@angular/forms';
|
|||
import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
|
||||
import { Ng4LoadingSpinnerService } from 'ng4-loading-spinner';
|
||||
//import { FieldBase } from '../../app/form/fields/field-base';
|
||||
import { FieldControlService } from '../../app/services/field-control.service';
|
||||
import { ServerService } from '../../app/services/server.service';
|
||||
import { TokenService, TokenProvider } from '../services/login/token.service';
|
||||
|
@ -72,9 +72,7 @@ export class DynamicFormComponent implements OnInit {
|
|||
private fragment: string;
|
||||
constructor(private serverService: ServerService, private router: Router, private pdfService: PDFService,
|
||||
private _location: Location, private route: ActivatedRoute, private tokenService: TokenService
|
||||
, private visibilityRulesService: VisibilityRulesService,
|
||||
private spinnerService: Ng4LoadingSpinnerService
|
||||
|
||||
, private visibilityRulesService: VisibilityRulesService
|
||||
) {
|
||||
this.datasetId = route.snapshot.params['id'];
|
||||
}
|
||||
|
@ -88,8 +86,8 @@ export class DynamicFormComponent implements OnInit {
|
|||
|
||||
this.serverService.getSingleDataset(this.datasetId).subscribe(
|
||||
response => {
|
||||
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
|
||||
this.pages = this.getPages(this.dataModel);
|
||||
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
|
||||
this.pages = this.getPages(this.dataModel);
|
||||
this.createPagination();
|
||||
this.form = this.dataModel.buildForm();
|
||||
this.visibilityRulesService.formGroup = this.form;
|
||||
|
@ -97,14 +95,14 @@ export class DynamicFormComponent implements OnInit {
|
|||
this.visibilityRulesService.buildVisibilityRules(rules)
|
||||
this.progressbar = true;
|
||||
|
||||
this.route.fragment.subscribe((fragment: string) => {
|
||||
var self = this;
|
||||
setTimeout(function () { self.scrollTo(fragment) });
|
||||
this.route.fragment.subscribe((fragment: string) => {
|
||||
var self = this;
|
||||
setTimeout(function () { self.scrollTo(fragment) });
|
||||
});
|
||||
|
||||
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
if (params && "page" in params)
|
||||
this.changeCurrentPage(params["page"]);
|
||||
if (params && "page" in params)
|
||||
this.changeCurrentPage(params["page"]);
|
||||
});
|
||||
},
|
||||
error => {
|
||||
|
@ -122,73 +120,131 @@ export class DynamicFormComponent implements OnInit {
|
|||
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
|
||||
this.visibilityRulesService.buildVisibilityRules(rules) */
|
||||
}
|
||||
save() {
|
||||
let data = this.form.value;
|
||||
data.status = 0;
|
||||
this.spinnerService.show();
|
||||
this.serverService.updateDataset(this.datasetId, data).subscribe(item=>{
|
||||
this.spinnerService.hide()
|
||||
this.router.navigate(["dmps"]);
|
||||
})
|
||||
}
|
||||
|
||||
submit() {
|
||||
let data = this.form.value;
|
||||
data.status = 1;
|
||||
this.spinnerService.show();
|
||||
this.serverService.updateDataset(this.datasetId, data).subscribe(item=>{
|
||||
this.spinnerService.hide()
|
||||
this.router.navigate(["dmps"]);
|
||||
})
|
||||
this.serverService.updateDataset(this.datasetId, this.form.value).subscribe()
|
||||
}
|
||||
|
||||
toggleSidebar() {
|
||||
this.visibleSidebar = !this.visibleSidebar;
|
||||
}
|
||||
|
||||
getPages(model: DatasetModel): Array<number> {
|
||||
let pageSet = new Set<number>();
|
||||
let pageSet = new Set<number>();
|
||||
|
||||
model.sections.forEach(section => {
|
||||
pageSet.add(section.page);
|
||||
});
|
||||
model.sections.forEach(section => {
|
||||
pageSet.add(section.page);
|
||||
});
|
||||
|
||||
return Array.from(pageSet).sort((a, b) => a - b);
|
||||
return Array.from(pageSet).sort((a, b) => a - b);
|
||||
}
|
||||
|
||||
shouldDisplaySection(section: Section): Boolean {
|
||||
return (section.page) == this.pages[this.currentPageIndex];
|
||||
return (section.page) == this.currentPageIndex;
|
||||
}
|
||||
|
||||
createPagination() {
|
||||
this.pages.forEach(item => {
|
||||
this.stepperItems.push({
|
||||
label: '',
|
||||
})
|
||||
this.stepperItems.push({
|
||||
label: '',
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
changePageIndex(index: any) {
|
||||
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index] } });
|
||||
this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index-1] } });
|
||||
}
|
||||
|
||||
scrollTo(sectionID: string) {
|
||||
if (!sectionID) return;
|
||||
var element = document.querySelector('#' + sectionID);
|
||||
if (!element) return;
|
||||
element.scrollIntoView();
|
||||
// this.visibleSidebar = true;
|
||||
//var scrollElement = document.querySelector('.scrollableContent');
|
||||
//scrollElement.scrollTop = topElement.offsetTop;
|
||||
if (!sectionID) return;
|
||||
var element = document.querySelector('#' + sectionID);
|
||||
if (!element) return;
|
||||
element.scrollIntoView();
|
||||
// this.visibleSidebar = true;
|
||||
//var scrollElement = document.querySelector('.scrollableContent');
|
||||
//scrollElement.scrollTop = topElement.offsetTop;
|
||||
}
|
||||
|
||||
changeCurrentPage(pageString: string) {
|
||||
if (!pageString) return;
|
||||
var page = parseInt(pageString);
|
||||
if (isNaN(page)) return;
|
||||
var pageIndex = this.pages.indexOf(page);
|
||||
if (pageIndex === -1) return;
|
||||
this.currentPageIndex = pageIndex;
|
||||
if (!pageString) return;
|
||||
var page = parseInt(pageString);
|
||||
if (isNaN(page)) return;
|
||||
var pageIndex = this.pages.indexOf(page);
|
||||
if (pageIndex === -1) return;
|
||||
this.currentPageIndex = page;
|
||||
}
|
||||
/* scrollToElemID(elemID) {
|
||||
scroll("#" + elemID);
|
||||
}
|
||||
|
||||
|
||||
private patchForm(flatList: any) {
|
||||
|
||||
|
||||
for (var prop in flatList) {
|
||||
if (flatList.hasOwnProperty(prop)) {
|
||||
if (prop.endsWith('.id') || prop.endsWith('.answer') || prop.endsWith('.value')) continue;
|
||||
//console.log("updating value of "+prop +" to "+flatList[prop].valueOf())
|
||||
this.form.get(prop).setValue(flatList[prop].valueOf());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewChecked(): void { //navigate to certain section of the page
|
||||
try {
|
||||
document.querySelector('#' + this.fragment).scrollIntoView();
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
SaveForm() {
|
||||
let final = false;
|
||||
this.submitForm(false);
|
||||
|
||||
this.payLoad = JSON.stringify(this.form.value);
|
||||
}
|
||||
|
||||
SaveFinalizeForm(){
|
||||
$("#confirmModal").modal("hide");
|
||||
let final = true;
|
||||
this.submitForm(final);
|
||||
}
|
||||
|
||||
shouldIShow(element) { //pagination , pages are declared in xml for every groupfield
|
||||
|
||||
if (this.pagination.currentPage == element.page){
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
setPage(page: number) {
|
||||
|
||||
if (page < 1 || page > this.pagination.totalPages) {
|
||||
return;
|
||||
}
|
||||
var pagesize = 4;
|
||||
// get pagination object from service
|
||||
this.pagination = this.pagerService.getPagination(this.dataModel.groups, this.dataModel.groups.length, page, pagesize);
|
||||
|
||||
//get current page of items
|
||||
// this.dataModel.sections.forEach(section => {
|
||||
// if (section.groupFields.length > 0) {
|
||||
// section.groupFields = this.dataModel.groups.slice(this.pagination.startIndex, this.pagination.endIndex + 1);
|
||||
// }
|
||||
// });
|
||||
//this.dataModel.groups = this.dataModel.groups.slice(this.pagination.startIndex, this.pagination.endIndex + 1);
|
||||
}
|
||||
|
||||
|
||||
toggleTOC(){
|
||||
this.expandedToc = !this.expandedToc;
|
||||
}
|
||||
*/
|
||||
|
||||
createPDF(elementID: string, pdffilename: string) {
|
||||
this.pdfService.toPDF(elementID, pdffilename);
|
||||
|
|
|
@ -18,7 +18,7 @@ export class RestBase {
|
|||
|
||||
|
||||
protocol: string = "http";
|
||||
hostname: string ="localhost"
|
||||
hostname: string ="192.168.32.103"
|
||||
port: number = 8080;
|
||||
webappname: string = "dmp-backend";
|
||||
|
||||
|
|
|
@ -48,13 +48,13 @@
|
|||
<div class="col-md-6 row-cell"><b>Researchers:</b>
|
||||
<div *ngIf="dmp?.researchers?.length==0" style="opacity: 0.5;">None</div>
|
||||
<ul *ngIf="dmp?.researchers?.length>1">
|
||||
<li *ngFor="let researcher of dmp?.researchers">{{ researcher?.label }}</li>
|
||||
<li *ngFor="let researcher of dmp?.researchers">{{ researcher?.name }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-6 row-cell"><b>Organisations:</b>
|
||||
<div *ngIf="dmp?.organisations?.length==0" style="opacity: 0.5;">None</div>
|
||||
<ul *ngIf="dmp?.organisations?.length>1">
|
||||
<li *ngFor="let organisation of dmp?.organisations">{{ organisation?.label }}</li>
|
||||
<div *ngIf="dmp?.organizations?.length==0" style="opacity: 0.5;">None</div>
|
||||
<ul *ngIf="dmp?.organizations?.length>1">
|
||||
<li *ngFor="let organisation of dmp?.organizations">{{ organisation?.name }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -47,7 +47,7 @@ export class DmpDetailedComponent implements OnInit {
|
|||
)
|
||||
}
|
||||
//fill-in also the creator
|
||||
this.serverService.getUserByID(this.dmp.creator).subscribe(
|
||||
this.serverService.getUserByID(this.dmp.creator.id).subscribe(
|
||||
response => {
|
||||
this.dmp.creator = response;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue