Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
# Conflicts: # dmp-frontend/src/app/app-routing.module.ts # dmp-frontend/src/app/app.module.ts
This commit is contained in:
commit
e0426f1193
|
@ -17,6 +17,7 @@ import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
|||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -70,15 +71,15 @@ public class DMPs {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DataManagementPlan>> getPaged(@RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
||||
public @ResponseBody ResponseItem<DataTableData<DataManagementPlanListingModel>> getPaged(@RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
||||
try {
|
||||
DataTableData<eu.eudat.models.dmp.DataManagementPlan> dataTable = new DataManagementPlanManager().getPaged(dMPDao, dataManagementPlanTableRequest);
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(dMPDao, dataManagementPlanTableRequest);
|
||||
|
||||
return new ResponseItem<DataTableData<DataManagementPlan>>().status(HttpStatus.OK).payload(dataTable);
|
||||
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DataTableData<DataManagementPlan>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import eu.eudat.managers.DatasetManager;
|
|||
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -41,7 +42,6 @@ import eu.eudat.dao.entities.UserInfoDao;
|
|||
import eu.eudat.models.criteria.DataRepositoryCriteria;
|
||||
import eu.eudat.models.criteria.RegistryCriteria;
|
||||
import eu.eudat.models.criteria.ServiceCriteria;
|
||||
import eu.eudat.responses.RestResponse;
|
||||
|
||||
|
||||
@RestController
|
||||
|
@ -66,14 +66,14 @@ public class Datasets {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasets/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<eu.eudat.models.dataset.Dataset>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) {
|
||||
public @ResponseBody ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) {
|
||||
try {
|
||||
DataTableData<eu.eudat.models.dataset.Dataset> dataTable = new DatasetManager().getPaged(datasetDao, datasetTableRequest);
|
||||
return new ResponseItem<DataTableData<eu.eudat.models.dataset.Dataset>>().status(HttpStatus.OK).payload(dataTable);
|
||||
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(datasetDao, datasetTableRequest);
|
||||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DataTableData<eu.eudat.models.dataset.Dataset>>().status(HttpStatus.OK).message(ex.getMessage());
|
||||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/15/2017.
|
||||
*/
|
||||
|
@ -23,6 +25,8 @@ public class Login {
|
|||
|
||||
@Autowired
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/externallogin" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<Principal> googleLogin(@RequestBody LoginInfo credentials) {
|
||||
try {
|
||||
|
|
|
@ -7,6 +7,9 @@ import java.util.UUID;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.entities.Organisation;
|
||||
import eu.eudat.models.external.OrganisationsExternalSourcesModel;
|
||||
import eu.eudat.models.external.ProjectsExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -58,16 +61,19 @@ public class Organisations {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/organisations" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Map<String,String>>> listExternalOrganisations(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseItem<OrganisationsExternalSourcesModel> listExternalOrganisations(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getOrganisations(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(remoteRepos);
|
||||
OrganisationsExternalSourcesModel projectsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(null); //the ex.getMessage has the appropriate text description
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import java.util.UUID;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
import eu.eudat.models.external.ProjectsExternalSourcesModel;
|
||||
import eu.eudat.models.external.RegistriesExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
import eu.eudat.models.project.ProjectCriteriaRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -137,16 +139,19 @@ public class Projects {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/projects" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Map<String,String>>> listExternalProjects(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseItem<ProjectsExternalSourcesModel> listExternalProjects(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getProjects(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(remoteRepos);
|
||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(null); //the ex.getMessage has the appropriate text description
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.entities.Registry;
|
||||
import eu.eudat.models.external.RegistriesExternalSourcesModel;
|
||||
import eu.eudat.models.external.ResearchersExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -58,16 +61,19 @@ public class Registries {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/registries" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Map<String,String>>> listExternalRegistries(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseItem<RegistriesExternalSourcesModel> listExternalRegistries(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getRegistries(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(remoteRepos);
|
||||
RegistriesExternalSourcesModel registriesExternalSourcesModel = new RegistriesExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().payload(registriesExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(null); //the ex.getMessage has the appropriate text description
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ import java.util.UUID;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.entities.Researcher;
|
||||
import eu.eudat.models.external.ResearchersExternalSourcesModel;
|
||||
import eu.eudat.models.external.ServiceExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -57,16 +60,19 @@ public class Researchers {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/researchers" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Map<String,String>>> listExternalResearchers(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseItem<ResearchersExternalSourcesModel> listExternalResearchers(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getResearchers(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(remoteRepos);
|
||||
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().payload(researchersExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(null); //the ex.getMessage has the appropriate text description
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.UUID;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.entities.Service;
|
||||
import eu.eudat.models.external.ServiceExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -57,20 +59,29 @@ public class Services {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/services" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Map<String,String>>> listExternalServices(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseItem<ServiceExternalSourcesModel> listExternalServices(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getServices(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(remoteRepos);
|
||||
ServiceExternalSourcesModel serviceExternalSourcesModel = new ServiceExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().payload(serviceExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(null); //the ex.getMessage has the appropriate text description
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// MANAGE SERVICE(S)
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/services" })
|
||||
|
|
|
@ -51,7 +51,6 @@ import eu.eudat.entities.Researcher;
|
|||
import eu.eudat.entities.Service;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.helpers.Transformers;
|
||||
import eu.eudat.responses.RestResponse;
|
||||
|
||||
|
||||
@RestController
|
||||
|
|
|
@ -28,9 +28,13 @@ public class DatabaseContext<T extends DataEntity<T>> {
|
|||
public T createOrUpdate(T item, Class<T> type) {
|
||||
if (item.getKeys()[0] != null) {
|
||||
T oldItem = entityManager.find(type, item.getKeys()[0]);
|
||||
oldItem.update(item);
|
||||
entityManager.merge(oldItem);
|
||||
return oldItem;
|
||||
if(oldItem!=null) {
|
||||
oldItem.update(item);
|
||||
entityManager.merge(oldItem);
|
||||
return oldItem;
|
||||
}else {
|
||||
entityManager.persist(item);
|
||||
}
|
||||
} else entityManager.persist(item);
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.dao.entities.security;
|
|||
|
||||
import eu.eudat.dao.Dao;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.Project;
|
||||
import eu.eudat.entities.UserToken;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -9,5 +10,8 @@ import java.util.UUID;
|
|||
/**
|
||||
* Created by ikalyvas on 12/15/2017.
|
||||
*/
|
||||
public interface CredentialDao extends Dao<Credential, UUID> {
|
||||
public interface CredentialDao {
|
||||
|
||||
Credential createOrUpdate(Credential item);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package eu.eudat.dao.entities.security;
|
||||
|
||||
import eu.eudat.dao.JpaDao;
|
||||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.Project;
|
||||
import eu.eudat.entities.UserToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -11,9 +14,13 @@ import java.util.UUID;
|
|||
* Created by ikalyvas on 12/15/2017.
|
||||
*/
|
||||
@Component("credentialDao")
|
||||
public class CredentialDaoImpl extends JpaDao<Credential, UUID> implements CredentialDao {
|
||||
public class CredentialDaoImpl implements CredentialDao {
|
||||
|
||||
@Autowired
|
||||
DatabaseService<Credential> databaseService;
|
||||
|
||||
@Override
|
||||
public Credential loadDetails(Credential credential) {
|
||||
return null;
|
||||
public Credential createOrUpdate(Credential item) {
|
||||
return this.databaseService.createOrUpdate(item,Credential.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.UUID;
|
|||
*/
|
||||
@Entity
|
||||
@Table(name="\"Credential\"")
|
||||
public class Credential {
|
||||
public class Credential implements DataEntity<Credential> {
|
||||
|
||||
@Id
|
||||
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
|
@ -113,4 +113,17 @@ public class Credential {
|
|||
public int hashCode() {
|
||||
return provider.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Credential entity) {
|
||||
this.status = entity.status;
|
||||
this.publicValue = entity.getPublicValue();
|
||||
this.secret = entity.getSecret();
|
||||
this.lastUpdateTime = new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,18 +10,19 @@ import eu.eudat.models.dmp.DataManagementPlan;
|
|||
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
public class DataManagementPlanManager {
|
||||
|
||||
public DataTableData<eu.eudat.models.dmp.DataManagementPlan> getPaged(DMPDao dmpsRepository, DataManagementPlanTableRequest dataManagementPlanTableRequest) throws IllegalAccessException, InstantiationException{
|
||||
public DataTableData<DataManagementPlanListingModel> getPaged(DMPDao dmpsRepository, DataManagementPlanTableRequest dataManagementPlanTableRequest) throws IllegalAccessException, InstantiationException{
|
||||
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(items,dataManagementPlanTableRequest);
|
||||
List<eu.eudat.models.dmp.DataManagementPlan> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, eu.eudat.models.dmp.DataManagementPlan>().fromDataModel( pagedItems.toList(), eu.eudat.models.dmp.DataManagementPlan.class);
|
||||
DataTableData<eu.eudat.models.dmp.DataManagementPlan> dataTable = new DataTableData<eu.eudat.models.dmp.DataManagementPlan>();
|
||||
List<DataManagementPlanListingModel> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, DataManagementPlanListingModel>().fromDataModel( pagedItems.toList(), DataManagementPlanListingModel.class);
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<DataManagementPlanListingModel>();
|
||||
dataTable.setData(datamanagementPlans);
|
||||
dataTable.setTotalCount(datamanagementPlans.size());
|
||||
dataTable.setTotalCount(items.count());
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.dao.entities.ProjectDao;
|
|||
import eu.eudat.models.dataset.Dataset;
|
||||
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.project.ProjectTableRequest;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
@ -18,13 +19,13 @@ import java.util.UUID;
|
|||
*/
|
||||
public class DatasetManager {
|
||||
|
||||
public DataTableData<Dataset> getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{
|
||||
public DataTableData<DatasetListingModel> getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{
|
||||
QueryableList<eu.eudat.entities.Dataset> items = datatasetRepository.getWithCriteria(datasetTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging( items ,datasetTableRequest);
|
||||
List<Dataset> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, Dataset>().fromDataModel( pagedItems.toList(), eu.eudat.models.dataset.Dataset.class);
|
||||
DataTableData<eu.eudat.models.dataset.Dataset> dataTable = new DataTableData<eu.eudat.models.dataset.Dataset>();
|
||||
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel( pagedItems.toList(), DatasetListingModel.class);
|
||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
|
||||
dataTable.setData(datasets);
|
||||
dataTable.setTotalCount(datasets.size());
|
||||
dataTable.setTotalCount(items.count());
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ProjectManager {
|
|||
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(pagedItems.toList(), eu.eudat.models.project.Project.class);
|
||||
DataTableData<eu.eudat.models.project.Project> dataTable = new DataTableData<eu.eudat.models.project.Project>();
|
||||
dataTable.setData(projects);
|
||||
dataTable.setTotalCount(projects.size());
|
||||
dataTable.setTotalCount(items.count());
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package eu.eudat.models.dataset;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class DataRepository implements DataModel<eu.eudat.entities.DataRepository>{
|
||||
public class DataRepository implements DataModel<eu.eudat.entities.DataRepository>,LabelGenerator{
|
||||
private String pid;
|
||||
private String name;
|
||||
private String uri;
|
||||
|
@ -49,4 +50,9 @@ public class DataRepository implements DataModel<eu.eudat.entities.DataRepositor
|
|||
entity.setStatus((short)0);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,80 @@
|
|||
package eu.eudat.models.dataset;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
public class Registry implements DataModel<eu.eudat.entities.Registry>{
|
||||
import javax.persistence.Column;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Registry implements DataModel<eu.eudat.entities.Registry>,LabelGenerator {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String abbreviation;
|
||||
private String reference;
|
||||
private String uri;
|
||||
private String definition;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return getLabel();
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public void fromDataModel(eu.eudat.entities.Registry entity){
|
||||
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
this.uri = entity.getUri();
|
||||
this.definition = entity.getDefinition();
|
||||
}
|
||||
|
||||
public eu.eudat.entities.Registry toDataModel(){
|
||||
|
|
|
@ -1,14 +1,88 @@
|
|||
package eu.eudat.models.dataset;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Service implements DataModel<eu.eudat.entities.Service>,LabelGenerator{
|
||||
private UUID id;
|
||||
private String label;
|
||||
|
||||
private String abbreviation;
|
||||
|
||||
private String reference;
|
||||
|
||||
private String uri;
|
||||
|
||||
private String definition;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public class Service implements DataModel<eu.eudat.entities.Service>{
|
||||
public void fromDataModel(eu.eudat.entities.Service entity){
|
||||
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
this.uri = entity.getUri();
|
||||
this.definition = entity.getDefinition();
|
||||
}
|
||||
|
||||
public eu.eudat.entities.Service toDataModel(){
|
||||
eu.eudat.entities.Service entity = new eu.eudat.entities.Service();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.label;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package eu.eudat.models.dmp;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Organisation implements DataModel<eu.eudat.entities.Organisation> {
|
||||
public class Organisation implements DataModel<eu.eudat.entities.Organisation>,LabelGenerator {
|
||||
private String pid;
|
||||
private String name;
|
||||
private String uri;
|
||||
|
@ -51,4 +52,9 @@ public class Organisation implements DataModel<eu.eudat.entities.Organisation> {
|
|||
organisationEntity.setStatus((short)this.status);
|
||||
return organisationEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package eu.eudat.models.dmp;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Researcher implements DataModel<eu.eudat.entities.Researcher> {
|
||||
public class Researcher implements DataModel<eu.eudat.entities.Researcher>,LabelGenerator {
|
||||
private String pid;
|
||||
private String name;
|
||||
private String uri;
|
||||
|
@ -59,4 +60,9 @@ public class Researcher implements DataModel<eu.eudat.entities.Researcher> {
|
|||
researcher.setStatus((short)this.status);
|
||||
return researcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateLabel() {
|
||||
return this.getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public interface ExternalItem<T> {
|
||||
T fromExternalItem(List<Map<String,String>> values);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public abstract class ExternalListingItem<T> implements ExternalItem<T>{
|
||||
private List<ExternalSourcesItemModel> data;
|
||||
|
||||
public List<ExternalSourcesItemModel> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<ExternalSourcesItemModel> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
34
dmp-backend/src/main/java/eu/eudat/models/external/ExternalSourcesItemModel.java
vendored
Normal file
34
dmp-backend/src/main/java/eu/eudat/models/external/ExternalSourcesItemModel.java
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class ExternalSourcesItemModel{
|
||||
private String id;
|
||||
private String name;
|
||||
private String label;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
24
dmp-backend/src/main/java/eu/eudat/models/external/OrganisationsExternalSourcesModel.java
vendored
Normal file
24
dmp-backend/src/main/java/eu/eudat/models/external/OrganisationsExternalSourcesModel.java
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class OrganisationsExternalSourcesModel extends ExternalListingItem<OrganisationsExternalSourcesModel>{
|
||||
@Override
|
||||
public OrganisationsExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
|
||||
List<ExternalSourcesItemModel> items = new LinkedList<>();
|
||||
for(Map<String,String> item : values){
|
||||
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
||||
model.setId(item.get("pid"));
|
||||
model.setLabel(item.get("uri"));
|
||||
model.setName(item.get("name"));
|
||||
items.add(model);
|
||||
}
|
||||
this.setData(items);
|
||||
return this;
|
||||
}
|
||||
}
|
24
dmp-backend/src/main/java/eu/eudat/models/external/ProjectsExternalSourcesModel.java
vendored
Normal file
24
dmp-backend/src/main/java/eu/eudat/models/external/ProjectsExternalSourcesModel.java
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsExternalSourcesModel> {
|
||||
@Override
|
||||
public ProjectsExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
|
||||
List<ExternalSourcesItemModel> items = new LinkedList<>();
|
||||
for(Map<String,String> item : values){
|
||||
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
||||
model.setId(item.get("pid"));
|
||||
model.setLabel(item.get("uri"));
|
||||
model.setName(item.get("name"));
|
||||
items.add(model);
|
||||
}
|
||||
this.setData(items);
|
||||
return this;
|
||||
}
|
||||
}
|
24
dmp-backend/src/main/java/eu/eudat/models/external/RegistriesExternalSourcesModel.java
vendored
Normal file
24
dmp-backend/src/main/java/eu/eudat/models/external/RegistriesExternalSourcesModel.java
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class RegistriesExternalSourcesModel extends ExternalListingItem<RegistriesExternalSourcesModel> {
|
||||
@Override
|
||||
public RegistriesExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
|
||||
List<ExternalSourcesItemModel> items = new LinkedList<>();
|
||||
for(Map<String,String> item : values){
|
||||
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
||||
model.setId(item.get("pid"));
|
||||
model.setLabel(item.get("uri"));
|
||||
model.setName(item.get("name"));
|
||||
items.add(model);
|
||||
}
|
||||
this.setData(items);
|
||||
return this;
|
||||
}
|
||||
}
|
24
dmp-backend/src/main/java/eu/eudat/models/external/ResearchersExternalSourcesModel.java
vendored
Normal file
24
dmp-backend/src/main/java/eu/eudat/models/external/ResearchersExternalSourcesModel.java
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class ResearchersExternalSourcesModel extends ExternalListingItem<ResearchersExternalSourcesModel> {
|
||||
@Override
|
||||
public ResearchersExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
|
||||
List<ExternalSourcesItemModel> items = new LinkedList<>();
|
||||
for(Map<String,String> item : values){
|
||||
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
||||
model.setId(item.get("pid"));
|
||||
model.setLabel(item.get("uri"));
|
||||
model.setName(item.get("name"));
|
||||
items.add(model);
|
||||
}
|
||||
this.setData(items);
|
||||
return this;
|
||||
}
|
||||
}
|
24
dmp-backend/src/main/java/eu/eudat/models/external/ServiceExternalSourcesModel.java
vendored
Normal file
24
dmp-backend/src/main/java/eu/eudat/models/external/ServiceExternalSourcesModel.java
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
package eu.eudat.models.external;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class ServiceExternalSourcesModel extends ExternalListingItem<ServiceExternalSourcesModel> {
|
||||
@Override
|
||||
public ServiceExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
|
||||
List<ExternalSourcesItemModel> items = new LinkedList<>();
|
||||
for(Map<String,String> item : values){
|
||||
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
||||
model.setId(item.get("pid"));
|
||||
model.setLabel(item.get("label"));
|
||||
model.setName(item.get("name"));
|
||||
items.add(model);
|
||||
}
|
||||
this.setData(items);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -3,13 +3,13 @@ package eu.eudat.models.helpers;
|
|||
import java.util.List;
|
||||
|
||||
public class DataTableData<T> {
|
||||
private Integer totalCount;
|
||||
private Long totalCount;
|
||||
private List<T> data;
|
||||
|
||||
public Integer getTotalCount() {
|
||||
public Long getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
public void setTotalCount(Integer totalCount) {
|
||||
public void setTotalCount(Long totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
public List<T> getData() {
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package eu.eudat.models.listingmodels;
|
||||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.DataRepository;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dmp.Organisation;
|
||||
import eu.eudat.models.dmp.Researcher;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.utilities.helpers.LabelBuilder;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class DataManagementPlanListingModel implements DataModel<DMP> {
|
||||
private String id;
|
||||
private String label;
|
||||
private String project;
|
||||
private String profile;
|
||||
private String researchers;
|
||||
private String organisations;
|
||||
private String version;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(String project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getResearchers() {
|
||||
return researchers;
|
||||
}
|
||||
|
||||
public void setResearchers(String researchers) {
|
||||
this.researchers = researchers;
|
||||
}
|
||||
|
||||
public String getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
|
||||
public void setOrganisations(String organisations) {
|
||||
this.organisations = organisations;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
||||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
this.project = entity.getProject().getLabel();
|
||||
this.profile = entity.getProfile().getLabel();
|
||||
this.organisations =LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class));
|
||||
this.researchers =LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.Researcher,Researcher>().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class));
|
||||
this.version = ""+entity.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMP toDataModel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package eu.eudat.models.listingmodels;
|
||||
|
||||
import eu.eudat.entities.*;
|
||||
import eu.eudat.entities.DataRepository;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.Organisation;
|
||||
import eu.eudat.entities.Registry;
|
||||
import eu.eudat.entities.Researcher;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dataset.*;
|
||||
import eu.eudat.models.dataset.Service;
|
||||
import eu.eudat.models.dmp.*;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.utilities.helpers.LabelBuilder;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class DatasetListingModel implements DataModel<Dataset> {
|
||||
private String id;
|
||||
private String label;
|
||||
private String dmp;
|
||||
private String profile;
|
||||
private String dataRepositories;
|
||||
private String registries;
|
||||
private String services;
|
||||
private String status;
|
||||
private String created;
|
||||
private String description;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
|
||||
public void setDmp(String dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getDataRepositories() {
|
||||
return dataRepositories;
|
||||
}
|
||||
|
||||
public void setDataRepositories(String dataRepositories) {
|
||||
this.dataRepositories = dataRepositories;
|
||||
}
|
||||
|
||||
public String getRegistries() {
|
||||
return registries;
|
||||
}
|
||||
|
||||
public void setRegistries(String registries) {
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
public String getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(String services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(String created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(Dataset entity) throws InstantiationException, IllegalAccessException {
|
||||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
this.created = entity.getCreated().toString();
|
||||
this.dmp = entity.getDmp()!=null? entity.getDmp().getLabel():"";
|
||||
this.profile = entity.getProfile()!=null? entity.getProfile().getLabel():"";
|
||||
this.description = entity.getDescription();
|
||||
this.status = ""+entity.getStatus();
|
||||
this.registries = LabelBuilder.getLabel(new DomainModelConverter<Registry, eu.eudat.models.dataset.Registry>().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), eu.eudat.models.dataset.Registry.class));
|
||||
this.dataRepositories = LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.DataRepository, eu.eudat.models.dataset.DataRepository>().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), eu.eudat.models.dataset.DataRepository.class));
|
||||
this.services = LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.Service, eu.eudat.models.dataset.Service>().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset toDataModel() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -21,4 +21,6 @@ public interface QueryableList<T> {
|
|||
QueryableList<T> distinct();
|
||||
|
||||
QueryableList<T> orderBy(OrderByPredicate<T> predicate);
|
||||
|
||||
Long count();
|
||||
}
|
||||
|
|
|
@ -83,6 +83,16 @@ public class QueryableHibernateList<T> implements QueryableList<T> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Long count(){
|
||||
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
||||
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
|
||||
criteriaQuery.select(criteriaBuilder.count(criteriaQuery.from(this.tClass)));
|
||||
Predicate[] array = new Predicate[this.predicates.size()];
|
||||
this.predicates.toArray(array);
|
||||
criteriaQuery.where(array);
|
||||
return this.manager.createQuery(criteriaQuery).getSingleResult();
|
||||
}
|
||||
|
||||
public List<T> toList() {
|
||||
Predicate[] array = new Predicate[this.predicates.size()];
|
||||
this.predicates.toArray(array);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package eu.eudat.responses;
|
||||
|
||||
public class RestResponse {
|
||||
|
||||
private String message;
|
||||
private String objID;
|
||||
|
||||
public RestResponse(String message, String objID) {
|
||||
super();
|
||||
this.message = message;
|
||||
this.objID = objID;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
public String getObjID() {
|
||||
return objID;
|
||||
}
|
||||
public void setObjID(String objID) {
|
||||
this.objID = objID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"message\":\"" + message + "\", \"objID\":\"" + objID + "\"}";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.security;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.naming.NameAlreadyBoundException;
|
||||
|
@ -32,7 +33,7 @@ public class CustomAuthenticationProvider {
|
|||
@Autowired private GoogleTokenValidator googleTokenValidator;
|
||||
@Autowired private NativeTokenValidator nativeTokenValidator;
|
||||
|
||||
public Principal authenticate(LoginInfo credentials) throws AuthenticationException {
|
||||
public Principal authenticate(LoginInfo credentials) throws AuthenticationException, GeneralSecurityException {
|
||||
String token = credentials.getTicket();
|
||||
try {
|
||||
Principal principal = googleTokenValidator.validateToken(token);
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.io.IOException;
|
|||
import java.security.GeneralSecurityException;
|
||||
import java.security.Principal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.api.client.googleapis.auth.oauth2.*;
|
||||
import eu.eudat.dao.entities.security.CredentialDao;
|
||||
|
@ -38,53 +40,39 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
@Autowired private CredentialDao credentialDao;
|
||||
@Autowired private AuthenticationService authenticationService;
|
||||
@Autowired private UserTokenDao userTokenDao;
|
||||
|
||||
private GoogleTokenResponse verifyUser(String authCode) throws IOException {
|
||||
|
||||
GoogleTokenResponse tokenResponse =
|
||||
new GoogleAuthorizationCodeTokenRequest(
|
||||
new NetHttpTransport(),
|
||||
JacksonFactory.getDefaultInstance(),
|
||||
"https://www.googleapis.com/oauth2/v4/token",
|
||||
"524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com",
|
||||
"IQjhbYdExPIsjy37mOfB103F",
|
||||
authCode,
|
||||
"postmessage") // Specify the same redirect URI that you use with your web
|
||||
// app. If you don't have a web version of your app, you can
|
||||
// specify an empty string.
|
||||
.execute();
|
||||
return tokenResponse;
|
||||
private GoogleIdTokenVerifier verifier;
|
||||
public GoogleTokenValidator(){
|
||||
verifier = new GoogleIdTokenVerifier.Builder(transport, JacksonFactory.getDefaultInstance())
|
||||
.setAudience(Collections.singletonList("524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com"))
|
||||
// Or, if multiple clients access the backend:
|
||||
//.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3))
|
||||
.build();
|
||||
}
|
||||
|
||||
private String getAccessToken(GoogleTokenResponse response){
|
||||
return response.getAccessToken();
|
||||
private GoogleIdToken verifyUserAndGetUser(String idTokenString) throws IOException, GeneralSecurityException {
|
||||
|
||||
GoogleIdToken idToken = verifier.verify(idTokenString);
|
||||
|
||||
return idToken;
|
||||
}
|
||||
|
||||
private GoogleIdToken getUser(GoogleTokenResponse response) throws IOException {
|
||||
return response.parseIdToken();
|
||||
}
|
||||
@Override
|
||||
public eu.eudat.models.security.Principal validateToken(String authCode) throws NonValidTokenException, IOException {
|
||||
|
||||
GoogleTokenResponse tokenResponse = this.verifyUser(authCode);
|
||||
String token = getAccessToken(tokenResponse);
|
||||
GoogleIdToken idToken = getUser(tokenResponse);
|
||||
public eu.eudat.models.security.Principal validateToken(String token) throws NonValidTokenException, IOException, GeneralSecurityException {
|
||||
|
||||
GoogleIdToken idToken = this.verifyUserAndGetUser(token);
|
||||
Payload payload = idToken.getPayload();
|
||||
|
||||
UserInfo userInfo = userInfoDao.getByMail(payload.getEmail());
|
||||
|
||||
Credential credential = new Credential();
|
||||
final Credential credential = new Credential();
|
||||
credential.setCreationTime(new Date());
|
||||
credential.setId(UUID.randomUUID());
|
||||
credential.setStatus(1);
|
||||
credential.setLastUpdateTime(new Date());
|
||||
credential.setProvider(1);
|
||||
credential.setSecret(token);
|
||||
credential.setPublicValue(userInfo.getName());
|
||||
credential.setUserInfo(userInfo);
|
||||
credentialDao.create(credential);
|
||||
if(userInfo == null) { //means not existing in db, so create one
|
||||
if(userInfo == null) {
|
||||
credential.setId(UUID.randomUUID());
|
||||
userInfo = new UserInfo();
|
||||
userInfo.setName((String)payload.get("name"));
|
||||
userInfo.setVerified_email(payload.getEmailVerified());
|
||||
|
@ -94,14 +82,24 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
userInfo.setAuthorization_level(new Short("1"));
|
||||
userInfo.setUsertype(new Short("1"));
|
||||
userInfo = userInfoDao.create(userInfo);
|
||||
credential = credentialDao.create(credential);
|
||||
credential.setUserInfo(userInfo);
|
||||
credentialDao.createOrUpdate(credential);
|
||||
}
|
||||
else {
|
||||
userInfo.setLastloggedin(new Date());
|
||||
Set<Credential> credentials = userInfo.getCredentials();
|
||||
if(credentials.contains(credential))credentials.remove(credential);
|
||||
credentials.add(credential);
|
||||
if(credentials.contains(credential)){
|
||||
Credential oldCredential = credentials.stream().filter(item->credential.getProvider().equals(item.getProvider())).findFirst().get();
|
||||
credential.setId(oldCredential.getId());
|
||||
}
|
||||
else{
|
||||
credential.setUserInfo(userInfo);
|
||||
credential.setId(UUID.randomUUID());
|
||||
credentialDao.createOrUpdate(credential);
|
||||
userInfo.getCredentials().add(credential);
|
||||
}
|
||||
userInfo = userInfoDao.update(userInfo);
|
||||
|
||||
}
|
||||
|
||||
UserToken userToken = new UserToken();
|
||||
|
|
|
@ -5,9 +5,10 @@ import eu.eudat.exceptions.NonValidTokenException;
|
|||
import eu.eudat.models.security.Principal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
public interface TokenValidator {
|
||||
|
||||
public Principal validateToken(String token) throws NonValidTokenException, IOException;
|
||||
public Principal validateToken(String token) throws NonValidTokenException, IOException, GeneralSecurityException;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package eu.eudat.utilities.helpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class LabelBuilder {
|
||||
private static <T extends LabelGenerator> String generateLabel(List<T> items){
|
||||
String label="";
|
||||
for(T item : items){
|
||||
if(items.indexOf(item)==3){
|
||||
label+="...";
|
||||
break;
|
||||
}
|
||||
if(items.indexOf(item)>1){
|
||||
label+=", ";
|
||||
}
|
||||
label+=item.generateLabel();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
public static <T extends LabelGenerator> String getLabel(List<T> items){
|
||||
return generateLabel(items);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package eu.eudat.utilities.helpers;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public interface LabelGenerator {
|
||||
String generateLabel();
|
||||
}
|
|
@ -19,12 +19,9 @@
|
|||
"testTsconfig": "tsconfig.spec.json",
|
||||
"prefix": "app",
|
||||
"styles": [
|
||||
"./../node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||
"styles.scss"
|
||||
],
|
||||
"scripts": [
|
||||
"./../node_modules/bootstrap/dist/js/bootstrap.min.js",
|
||||
"./assets/xml2json.min.js"
|
||||
],
|
||||
"environmentSource": "environments/environment.ts",
|
||||
"environments": {
|
||||
|
|
|
@ -285,11 +285,6 @@
|
|||
"tslib": "1.7.1"
|
||||
}
|
||||
},
|
||||
"@ng-bootstrap/ng-bootstrap": {
|
||||
"version": "1.0.0-beta.7",
|
||||
"resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-1.0.0-beta.7.tgz",
|
||||
"integrity": "sha1-WLyB9hACj0BSZSnOQEg6lQKBY7A="
|
||||
},
|
||||
"@ngtools/json-schema": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@ngtools/json-schema/-/json-schema-1.1.0.tgz",
|
||||
|
@ -1389,11 +1384,6 @@
|
|||
"hoek": "2.16.3"
|
||||
}
|
||||
},
|
||||
"bootstrap": {
|
||||
"version": "3.3.7",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.3.7.tgz",
|
||||
"integrity": "sha1-WjiTlFSfIzMIdaOxUGVldPip63E="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
|
||||
|
|
|
@ -6,7 +6,6 @@ import { HomepageComponent } from './homepage/homepage.component';
|
|||
import { DynamicFormComponent } from './form/dynamic-form.component';
|
||||
import { AuthGuard } from './guards/auth.guard';
|
||||
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';
|
||||
import { ProjectDetailedComponent } from './viewers/project-detailed/project-detailed.component';
|
||||
import { ProjectListingModel } from './models/projects/ProjectListingModel';
|
||||
|
@ -16,22 +15,25 @@ import { ProjectEditorComponent } from './projects/editor/project-editor.compone
|
|||
import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.component';
|
||||
import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.component';
|
||||
import { DatasetListingComponent } from './datasets_new/dataset-listing.component';
|
||||
import { DataManagementPlanWizardComponent } from './dmp-wizard/dmp-wizard.component';
|
||||
import { LoginComponent } from './login/login.component';
|
||||
|
||||
|
||||
const appRoutes: Routes = [
|
||||
|
||||
{ path: 'dynamic-form/:id', component: DynamicFormComponent, canActivate: [AuthGuard] },
|
||||
//{ path: 'dataset', component: DatasetsComponent },
|
||||
{ path: 'projects', component: ProjectListingComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'project/:id', component: ProjectEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'projects/new', component: ProjectEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dmps', component: DataManagementPlanListingComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dmp/new', component: DataManagementPlanWizardComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dmp/:id', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dmps/new', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'datasets', component: DatasetListingComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dataset/:id', component: DatasetEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'datasets/new', component: DatasetEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'login', component: MainSignInComponent},
|
||||
|
||||
{ path: 'login', component: LoginComponent},
|
||||
{ path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' },
|
||||
{ path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard]},
|
||||
{ path: '', redirectTo: '/welcome', pathMatch: 'full' },
|
||||
|
|
|
@ -1,78 +1,2 @@
|
|||
<app-navigation></app-navigation>
|
||||
<div class="container">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
<!-- <div>
|
||||
<nav class="navbar navbar-default shadowed">
|
||||
<div class="col-md-5">
|
||||
<div class="nav navbar-nav navbar-left">
|
||||
<li class="dropdown" [ngClass]="{false:'invisible'}[tokenService.isLoggedIn() == true]">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Quick Navigate
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="cursor" (click)="goToDMPs()">My DMPs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="cursor" (click)="goToProjects()">Projects</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-md-3">
|
||||
<h3 class="navbar-title">Data Management Plans Creator</h3>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown" [ngClass]="{true:'invisible'}[loggedInAs == null]">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Quick links
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="#">Action</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Another action</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Something else here</a>
|
||||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
<a href="#">Separated link</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li [ngClass]="{false:'invisible'}[tokenService.isLoggedIn() == true]">
|
||||
<a>{{tokenService.getEmail()}}</a>
|
||||
</li>
|
||||
<li class="cursor" [ngClass]="{false:'invisible'}[tokenService.isLoggedIn() == true]" (click)="logout()">
|
||||
<a>Logout</a>
|
||||
</li>
|
||||
<li class="cursor" [ngClass]="{true:'invisible'}[tokenService.isLoggedIn() == true]" (click)="login()">
|
||||
<a>Login</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<breadcrumb></breadcrumb>
|
||||
</div> -->
|
||||
<!--
|
||||
<router-outlet></router-outlet> -->
|
||||
<router-outlet></router-outlet>
|
|
@ -2,7 +2,6 @@ import { Component, OnInit, ViewEncapsulation} from '@angular/core';
|
|||
import { ServerService } from './services/server.service';
|
||||
import { JsonObjest } from '../app/entities/JsonObject.class';
|
||||
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute, NavigationExtras } from '@angular/router';
|
||||
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
|
||||
import {BreadcrumbModule,MenuItem} from 'primeng/primeng';
|
||||
|
||||
import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
|
||||
|
|
|
@ -50,14 +50,11 @@ import { ConfirmationComponent } from './widgets/confirmation/confirmation.compo
|
|||
|
||||
|
||||
import { EestoreService } from './services/eestore.service';
|
||||
import { GlobalInterceptor } from './services/interceptor';
|
||||
import { PDFService } from './services/transformers/pdf.service';
|
||||
|
||||
import { TabModule } from './tabs/tab.module';
|
||||
import { AngularDraggableModule } from 'angular2-draggable';
|
||||
|
||||
import { GooggleSignInComponent } from './login/googgle-sign-in/googgle-sign-in.component';
|
||||
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
|
||||
import { NguiAutoCompleteModule } from '@ngui/auto-complete';
|
||||
|
||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
|
@ -81,7 +78,6 @@ import { NgDatepickerModule } from 'ng2-datepicker';
|
|||
import { StatusToString } from './pipes/various/status-to-string';
|
||||
import { SidebarModule } from 'ng-sidebar';
|
||||
|
||||
import { Ng4LoadingSpinnerModule } from 'ng4-loading-spinner';
|
||||
import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
|
||||
import { DmpDetailedComponent } from './viewers/dmp-detailed/dmp-detailed.component';
|
||||
import { ProjectDetailedComponent } from './viewers/project-detailed/project-detailed.component';
|
||||
|
@ -112,6 +108,8 @@ import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.comp
|
|||
|
||||
import { FigurecardComponent } from './shared/components/figurecard/figurecard.component';
|
||||
import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.component';
|
||||
import { DataManagementPlanWizardComponent } from './dmp-wizard/dmp-wizard.component';
|
||||
import { LoginComponent } from './login/login.component';
|
||||
|
||||
|
||||
|
||||
|
@ -128,8 +126,7 @@ import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.com
|
|||
TableOfContentsFieldSetComponent,
|
||||
TableOfContentsGroupComponent,
|
||||
TableOfContentsSectionComponent,
|
||||
GooggleSignInComponent,
|
||||
MainSignInComponent,
|
||||
LoginComponent,
|
||||
PageNotFoundComponent,
|
||||
HomepageComponent,
|
||||
ModalComponent,
|
||||
|
@ -154,7 +151,8 @@ import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.com
|
|||
ProjectEditorComponent,
|
||||
DataManagementPlanEditorComponent,
|
||||
FigurecardComponent,
|
||||
DatasetEditorComponent
|
||||
DatasetEditorComponent,
|
||||
DataManagementPlanWizardComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -169,7 +167,6 @@ import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.com
|
|||
AngularDraggableModule,
|
||||
DataTableModule,
|
||||
NgDatepickerModule,
|
||||
Ng4LoadingSpinnerModule,
|
||||
NguiAutoCompleteModule,
|
||||
BreadcrumbModule,
|
||||
ProgressBarModule,
|
||||
|
@ -191,11 +188,7 @@ import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.com
|
|||
BrowserAnimationsModule,
|
||||
MaterialModule
|
||||
],
|
||||
providers: [{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: GlobalInterceptor,
|
||||
multi: true,
|
||||
},
|
||||
providers: [
|
||||
ServerService, VisibilityRulesService, PaginationService, GlobalVariables, AuthGuard,
|
||||
LocalStorageService, RestBase, EestoreService, PDFService,
|
||||
AuthService,DashboardService,DatasetService,
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<div class="data-management-plan-editor">
|
||||
<mat-horizontal-stepper [linear]="isLinear">
|
||||
<mat-step [stepControl]="firstFormGroup">
|
||||
<form [formGroup]="firstFormGroup">
|
||||
<ng-template matStepLabel>Fill out your name</ng-template>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
|
||||
</mat-form-field>
|
||||
<div>
|
||||
<button mat-button matStepperNext>Next</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-step>
|
||||
<mat-step [stepControl]="secondFormGroup">
|
||||
<form [formGroup]="secondFormGroup">
|
||||
<ng-template matStepLabel>Fill out your address</ng-template>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Address" formControlName="secondCtrl" required>
|
||||
</mat-form-field>
|
||||
<div>
|
||||
<button mat-button matStepperPrevious>Back</button>
|
||||
<button mat-button matStepperNext>Next</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-step>
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>Done</ng-template>
|
||||
You are now done.
|
||||
<div>
|
||||
<button mat-button matStepperPrevious>Back</button>
|
||||
</div>
|
||||
</mat-step>
|
||||
</mat-horizontal-stepper>
|
||||
</div>
|
|
@ -0,0 +1,35 @@
|
|||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.table-card .mat-grid-tile {
|
||||
background: rgba(0, 0, 0, 0.32);
|
||||
}
|
||||
|
||||
.data-management-plan-editor {
|
||||
mat-form-field {
|
||||
width: 100%;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.mat-card {
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 16px;
|
||||
}
|
||||
|
||||
.left-button {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.description-area {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
|
||||
import { FormGroup, Validators, FormBuilder } from "@angular/forms";
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-wizard-component',
|
||||
templateUrl: 'dmp-wizard.component.html',
|
||||
styleUrls: ['./dmp-wizard.component.scss'],
|
||||
providers: [DataManagementPlanService],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DataManagementPlanWizardComponent implements AfterViewInit {
|
||||
|
||||
constructor(
|
||||
private dataManagementPlanService: DataManagementPlanService,
|
||||
private formBuilder: FormBuilder
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
isLinear = false;
|
||||
firstFormGroup: FormGroup;
|
||||
secondFormGroup: FormGroup;
|
||||
|
||||
ngOnInit() {
|
||||
this.firstFormGroup = this.formBuilder.group({
|
||||
firstCtrl: ['', Validators.required]
|
||||
});
|
||||
this.secondFormGroup = this.formBuilder.group({
|
||||
secondCtrl: ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
// this.route.params.subscribe((params: Params) => {
|
||||
// const itemId = params['id'];
|
||||
|
||||
// if (itemId != null) {
|
||||
// this.isNew = false;
|
||||
// this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
|
||||
// .subscribe(data => {
|
||||
// this.dataManagementPlan = new JsonSerializer<DataManagementPlanModel>().fromJSONObject(data, DataManagementPlanModel);
|
||||
// this.formGroup = this.dataManagementPlan.buildForm();
|
||||
// });
|
||||
// } else {
|
||||
// this.dataManagementPlan = new DataManagementPlanModel();
|
||||
// setTimeout(() => {
|
||||
// this.formGroup = this.dataManagementPlan.buildForm();
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
public cancel(): void {
|
||||
//this.router.navigate(['/dataManagementPlans']);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
.nomargin{
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
.width-range {
|
||||
max-width: 500px;
|
||||
min-width: 300px;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr align="center">
|
||||
<button id="signinButton" (click)="signIn()">Sign in with Google</button>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
import { AuthService } from '../../services/auth/auth.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable } from '@angular/core';
|
||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
||||
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
declare const gapi: any;
|
||||
|
||||
declare var auth2 :any;
|
||||
|
||||
declare function simple_notifier(type: string, title: string, message:string): any;
|
||||
|
||||
@Component({
|
||||
selector: 'googgle-sign-in',
|
||||
templateUrl: './googgle-sign-in.component.html',
|
||||
styleUrls: ['./googgle-sign-in.component.css']
|
||||
})
|
||||
export class GooggleSignInComponent implements OnInit, Injectable {
|
||||
|
||||
|
||||
constructor(private element: ElementRef, private router : Router,private authService:AuthService,private route:ActivatedRoute,
|
||||
public snackBar: MatSnackBar,public language: TranslateService
|
||||
) { }
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.initiateExternalProviders();
|
||||
}
|
||||
|
||||
initiateExternalProviders(){
|
||||
|
||||
|
||||
|
||||
// if(gapi.auth2 == undefined){
|
||||
|
||||
// gapi.load('auth2', () => {
|
||||
|
||||
// this.auth2 = gapi.auth2.getAuthInstance({
|
||||
// client_id: clientId,
|
||||
// })
|
||||
// });
|
||||
|
||||
// }else{
|
||||
// this.auth2=gapi.auth2.getAuthInstance({
|
||||
// client_id: clientId,
|
||||
// })}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public signIn() {
|
||||
auth2.grantOfflineAccess().then((authResult)=>this.signInCallback(authResult))
|
||||
}
|
||||
|
||||
signInCallback(authResult){
|
||||
if (authResult['code']) {
|
||||
this.authService.login({ticket:authResult['code'],service:"google"}).subscribe(
|
||||
res => this.onLogInSuccess(res),
|
||||
error => this.onLogInError(error)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public onLogInSuccess(logoutMessage: any) {
|
||||
this.route.queryParams.subscribe((params: Params) => {
|
||||
let redirectUrl = params['returnUrl'] ? params['returnUrl'] : '/';
|
||||
this.router.navigate([redirectUrl]);
|
||||
})
|
||||
}
|
||||
|
||||
public onLogInError(errorMessage: string) {
|
||||
console.log(errorMessage);
|
||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||
data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGIN', language: this.language },
|
||||
duration: 3000,
|
||||
extraClasses: ['snackbar-warning']
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<div class="login">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
|
||||
<div class="card col-md-offset-2 col-md-8">
|
||||
<div class="card-header">
|
||||
<h4>Login</h4>
|
||||
<div class="social-btns">
|
||||
<button mat-icon-button id="googleSignInButton">
|
||||
<i class="fa fa-google-plus"></i>
|
||||
</button>
|
||||
<button mat-icon-button>
|
||||
<i class="fa fa-linkedin"></i>
|
||||
</button>
|
||||
<button mat-icon-button>
|
||||
<i class="fa fa-facebook-square"></i>
|
||||
</button>
|
||||
<button mat-icon-button>
|
||||
<i class="fa fa-twitter"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="tip">Or Be Classical</p>
|
||||
<div class="card-form">
|
||||
<div class="form-row">
|
||||
<i class="material-icons">email</i>
|
||||
<mat-input-container color="accent">
|
||||
<input type="text" matInput placeholder="Email address" />
|
||||
</mat-input-container>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<i class="material-icons">lock_outline</i>
|
||||
<mat-input-container color="accent">
|
||||
<input type="password" matInput placeholder="Password" />
|
||||
</mat-input-container>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button mat-button (click)="loginBtn()">LET'S GO</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,101 @@
|
|||
.container{
|
||||
height: 100%;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.card{
|
||||
position: relative;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-top: 90px;
|
||||
top: -90px;
|
||||
-webkit-animation-name: card;
|
||||
-moz-animation-name: card;
|
||||
-o-animation-name: card;
|
||||
animation-name: card;
|
||||
-webkit-animation-duration: 600ms;
|
||||
-moz-animation-duration: 600ms;
|
||||
-o-animation-duration: 600ms;
|
||||
animation-duration: 600ms;
|
||||
-webkit-animation-fill-mode: forwards;
|
||||
-moz-animation-fill-mode: forwards;
|
||||
-o-animation-fill-mode: forwards;
|
||||
animation-fill-mode: forwards;
|
||||
}
|
||||
|
||||
@-webkit-keyframes card {
|
||||
from {top: -40px;}
|
||||
to {top: 0;}
|
||||
}
|
||||
|
||||
@keyframes card {
|
||||
from {top: -40px;}
|
||||
to {top: 0;}
|
||||
}
|
||||
|
||||
.card-header{
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
top: -40px;
|
||||
width: 100%;
|
||||
padding: 25px;
|
||||
border-radius: 3px;
|
||||
background: linear-gradient(60deg, #ec407a, #d81b60);
|
||||
box-shadow: 0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(233, 30, 99, 0.4);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card-header h4{
|
||||
font-weight: 400;
|
||||
color: #fff;
|
||||
margin-bottom: 25px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.social-btns i{
|
||||
font-size: 21px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.social-btns button{
|
||||
margin: 0 8px;
|
||||
}
|
||||
|
||||
.tip{
|
||||
margin-top: -20px;
|
||||
}
|
||||
|
||||
.form-row, .card-form, .mat-input-container{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.card-form{
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.form-row{
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 13px;
|
||||
}
|
||||
|
||||
.form-row i{
|
||||
position: relative;
|
||||
top: -5px;
|
||||
margin-right: 15px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.card-footer{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.card-footer button{
|
||||
color: #e91e63;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
import { HttpClient } from '@angular/common/http';
|
||||
import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable } from '@angular/core';
|
||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { AuthService } from '../services/auth/auth.service';
|
||||
import { SnackBarNotificationComponent } from '../shared/components/notificaiton/snack-bar-notification.component';
|
||||
|
||||
declare const gapi: any;
|
||||
|
||||
@Component({
|
||||
selector: 'login',
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.scss']
|
||||
})
|
||||
export class LoginComponent implements OnInit {
|
||||
|
||||
public auth2: any;
|
||||
|
||||
constructor(private router: Router,
|
||||
public authService: AuthService,
|
||||
public route: ActivatedRoute,
|
||||
public snackBar: MatSnackBar,
|
||||
public language: TranslateService) { }
|
||||
|
||||
ngOnInit() {
|
||||
gapi.load('auth2', () => {
|
||||
this.auth2 = gapi.auth2.init({
|
||||
client_id: '524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com',
|
||||
cookiepolicy: 'single_host_origin',
|
||||
scope: 'profile email'
|
||||
});
|
||||
this.attachGoogleSignin(document.getElementById('googleSignInButton'));
|
||||
});
|
||||
}
|
||||
|
||||
public attachGoogleSignin(element) {
|
||||
this.auth2.attachClickHandler(element, {},
|
||||
(googleUser) => {
|
||||
|
||||
var id_token = googleUser.getAuthResponse().id_token;
|
||||
if (id_token) {
|
||||
this.authService.login({ ticket: id_token, service: "google" }).subscribe(
|
||||
res => this.onLogInSuccess(res),
|
||||
error => this.onLogInError(error)
|
||||
)
|
||||
}
|
||||
|
||||
}, (error) => {
|
||||
alert(JSON.stringify(error, undefined, 2));
|
||||
});
|
||||
}
|
||||
|
||||
public onLogInSuccess(logoutMessage: any) {
|
||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGIN', language: this.language },
|
||||
duration: 3000,
|
||||
extraClasses: ['snackbar-success']
|
||||
});
|
||||
this.route.queryParams.subscribe((params: Params) => {
|
||||
let redirectUrl = params['returnUrl'] ? params['returnUrl'] : '/';
|
||||
this.router.navigate([redirectUrl]);
|
||||
})
|
||||
}
|
||||
|
||||
public onLogInError(errorMessage: string) {
|
||||
console.log(errorMessage);
|
||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||
data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGIN', language: this.language },
|
||||
duration: 3000,
|
||||
extraClasses: ['snackbar-warning']
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
.form-signin
|
||||
{
|
||||
max-width: 330px;
|
||||
padding: 15px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.form-signin .form-signin-heading, .form-signin .checkbox
|
||||
{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.form-signin .checkbox
|
||||
{
|
||||
font-weight: normal;
|
||||
}
|
||||
.form-signin .form-control
|
||||
{
|
||||
position: relative;
|
||||
font-size: 16px;
|
||||
height: auto;
|
||||
padding: 10px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.form-signin .form-control:focus
|
||||
{
|
||||
z-index: 2;
|
||||
}
|
||||
.form-signin input[type="text"]
|
||||
{
|
||||
margin-bottom: -1px;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
.form-signin input[type="password"]
|
||||
{
|
||||
margin-bottom: 10px;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
.account-wall
|
||||
{
|
||||
margin-top: 20px;
|
||||
padding: 40px 0px 20px 0px;
|
||||
background-color: #f7f7f7;
|
||||
-moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.login-title
|
||||
{
|
||||
color: #555;
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
display: block;
|
||||
}
|
||||
.profile-img
|
||||
{
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
margin: 0 auto 10px;
|
||||
display: block;
|
||||
-moz-border-radius: 50%;
|
||||
-webkit-border-radius: 50%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.need-help
|
||||
{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.new-account
|
||||
{
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-4 col-md-offset-4">
|
||||
<h1 class="text-center login-title"></h1>
|
||||
<div class="account-wall">
|
||||
<img class="profile-img" src="/assets/icons/user-icon.png">
|
||||
<form class="form-signin" [formGroup]="nativeLoginForm">
|
||||
<input type="text" class="form-control" [(ngModel)]="creds.username" formControlName="username" placeholder="Username or Email" required autofocus>
|
||||
<input type="password" class="form-control" [(ngModel)]="creds.password" formControlName="password" placeholder="Password" required>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit" (click)="login()">
|
||||
Sign in
|
||||
</button>
|
||||
<label class="checkbox pull-left">
|
||||
<input type="checkbox" value="remember-me">
|
||||
Remember me
|
||||
</label>
|
||||
<a href="#" class="pull-right need-help">Need help? </a><span class="clearfix"></span>
|
||||
</form>
|
||||
|
||||
<!--
|
||||
<p>Form value: {{ nativeLoginForm.value | json }}</p>
|
||||
-->
|
||||
|
||||
<a href="#" class="text-center new-account">Create an account </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-4 col-md-offset-4">
|
||||
<div class="account-wall">
|
||||
<h1 class="text-center login-title"></h1>
|
||||
<h4 class="text-center">Sign in with social</h4>
|
||||
<googgle-sign-in></googgle-sign-in>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {MenuItem} from 'primeng/primeng';
|
||||
declare const gapi: any;
|
||||
|
||||
declare function simple_notifier(type: string, title: string, message:string): any;
|
||||
|
||||
@Component({
|
||||
selector: 'app-main-sign-in',
|
||||
templateUrl: './main-sign-in.component.html',
|
||||
styleUrls: ['./main-sign-in.component.css']
|
||||
})
|
||||
export class MainSignInComponent implements OnInit {
|
||||
|
||||
|
||||
nativeLoginForm : any;
|
||||
|
||||
creds : any = {"username":"","password":""};
|
||||
|
||||
|
||||
constructor( private fb: FormBuilder, private router : Router) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
createForm(){
|
||||
|
||||
this.nativeLoginForm = this.fb.group({
|
||||
username: ['', Validators.required ],
|
||||
password: ['', Validators.required ]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
|
||||
login(){
|
||||
//login using the credentials
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse, HttpErrorResponse} from '@angular/common/http';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
@Injectable()
|
||||
export class GlobalInterceptor implements HttpInterceptor {
|
||||
|
||||
constructor( private router : Router) {}
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
|
||||
return next.handle(req).do((event: HttpEvent<any>) => {
|
||||
/*
|
||||
if (event instanceof HttpResponse) {
|
||||
console.log("response ok");
|
||||
}
|
||||
*/
|
||||
}, (err: any) => {
|
||||
if (err instanceof HttpErrorResponse) {
|
||||
if (err.status === 401) {
|
||||
console.log("Received an unauthorized... redirecting to login page");
|
||||
this.router.navigate(['/login'], { queryParams: { /*returnUrl: this.state.url*/ }});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//return next.handle(req);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ export class RestBase {
|
|||
static get parameters() { return [HttpClient] }
|
||||
|
||||
constructor(public http : HttpClient) {
|
||||
this.xml2jsonOBJ = new X2JS();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,10 +11,8 @@ declare var X2JS: any;
|
|||
@Injectable()
|
||||
export class ServerService {
|
||||
|
||||
xml2jsonOBJ: any;
|
||||
|
||||
constructor(private restBase: RestBase) {
|
||||
this.xml2jsonOBJ = new X2JS();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1 @@
|
|||
|
||||
<div class="jumbotron">
|
||||
<h2>Hello {{ userInfo?.name!=null ? userInfo?.name : userInfo?.email }}</h2>
|
||||
<p>Welcome {{ userInfo?.created != userInfo?.lastloggedin ? "back" : "" }} to the <a href="https://en.wikipedia.org/wiki/Data_management_plan">Data Management Plans</a> composer application. </p>
|
||||
<!--
|
||||
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<!--
|
||||
{{userInfo | json}}
|
||||
-->
|
||||
{{message}}
|
|
@ -23,7 +23,8 @@ import {
|
|||
DateAdapter,
|
||||
MatTooltipModule,
|
||||
MatCheckboxModule,
|
||||
MatTabsModule
|
||||
MatTabsModule,
|
||||
MatStepperModule
|
||||
} from '@angular/material';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { SnackBarNotificationComponent } from '../components/notificaiton/snack-bar-notification.component';
|
||||
|
@ -60,7 +61,8 @@ import { CovalentLayoutModule, CovalentChipsModule, CovalentDialogsModule } from
|
|||
MatTabsModule,
|
||||
CovalentLayoutModule,
|
||||
CovalentChipsModule,
|
||||
CovalentDialogsModule
|
||||
CovalentDialogsModule,
|
||||
MatStepperModule
|
||||
],
|
||||
|
||||
providers: [
|
||||
|
|
|
@ -12,7 +12,6 @@ import { Component } from '@angular/core';
|
|||
</li>
|
||||
</ul>
|
||||
|
||||
<router-outlet></router-outlet>
|
||||
`
|
||||
})
|
||||
export class TabComponent {
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
var clientId = '1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com';
|
||||
var scope = [
|
||||
'profile',
|
||||
'email'
|
||||
].join(' ');
|
||||
|
||||
if(gapi.auth2 == undefined){
|
||||
|
||||
gapi.load('auth2', () => {
|
||||
|
||||
gapi.auth2.init({
|
||||
client_id: clientId,
|
||||
cookiepolicy: 'single_host_origin',
|
||||
scope: scope
|
||||
});
|
||||
|
||||
//RE-Render the button (due to known issues of google-button with angular's lifecycle)
|
||||
gapi.signin2.render('googleBtn');
|
||||
|
||||
//var buttonElement = this.element.nativeElement.querySelector('#googleBtn');
|
||||
//this.attachSignin(buttonElement);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
var sign_out_google = (function() {
|
||||
var auth2 = gapi.auth2.getAuthInstance();
|
||||
auth2.signOut().then(function () {
|
||||
console.log('User signed out from google.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var simple_notifier = (function(type, title, message) {
|
||||
|
||||
setTimeout(function() {
|
||||
$(".alert").remove();
|
||||
}, 11000);
|
||||
|
||||
return notify(type, title, message, null, null, null, null, null, null, null, null, null, null);
|
||||
});
|
||||
|
||||
|
||||
|
||||
function notify(type, title, message, delay, icon, url, target, allow_dismiss, offset_x, offset_y, animate_enter, animate_exit, newest_on_top){
|
||||
|
||||
var options = {};
|
||||
if(icon!=null) options.icon = icon;
|
||||
if(title!=null) options.title = title;
|
||||
if(message!=null) options.message = message;
|
||||
if(url!=null) options.url = url;
|
||||
if(target!=null) options.target = target;
|
||||
|
||||
var settings = {};
|
||||
if(type!=null) settings.type = type;
|
||||
if(allow_dismiss!=null) settings.allow_dismiss = allow_dismiss;
|
||||
settings.delay = 5;
|
||||
if(delay!=null) settings.delay = delay;
|
||||
|
||||
return $.notify(options,settings, delay);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -31,9 +31,7 @@
|
|||
<!-- Nice BS notifications -->
|
||||
<script src="assets/bootstrap-notify.min.js"></script>
|
||||
|
||||
<script src="https://apis.google.com/js/client:platform.js?onload=start" async defer>
|
||||
|
||||
</script>
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
|
||||
<!-- font-awesome css -->
|
||||
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
|
|
Loading…
Reference in New Issue