Creation and deletion fixed
This commit is contained in:
parent
54b9206b13
commit
2b93619117
|
@ -3,10 +3,12 @@ package org.gcube.informationsystem.service;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.secret.JWTSecret;
|
||||
|
@ -36,6 +38,8 @@ import org.gcube.informationsystem.types.reference.Type;
|
|||
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.informationsystem.utils.UUIDUtility;
|
||||
import org.gcube.informationsystem.web.rest.FacetDescription;
|
||||
import org.gcube.informationsystem.web.rest.ResourceDescription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -44,6 +48,7 @@ import com.jayway.jsonpath.JsonPath;
|
|||
import com.nimbusds.jose.shaded.json.JSONUtil;
|
||||
|
||||
import net.minidev.json.JSONArray;
|
||||
import net.minidev.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Service class for managing InformationSystem resources.
|
||||
|
@ -330,16 +335,74 @@ public class InformationSystemService {
|
|||
return instancesAsObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//CRUD - 1
|
||||
public void createResourceInstance(String resourceType,String jsonDescription) throws Exception {
|
||||
//Internal representation of the resource
|
||||
public String createResourceInternal(String resourceType,String formData) throws Exception {
|
||||
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create(currentCtx);
|
||||
//String jsonDescription="";
|
||||
publisher.createResource(jsonDescription);
|
||||
//publisher.createResource(new Resource)
|
||||
//NB: non serve UmaToken e context!
|
||||
ArrayList<String> facetNames = new ArrayList<>();
|
||||
ArrayList<String> facetRelations = new ArrayList<>();
|
||||
ArrayList<JSONArray> extraProps = new ArrayList<JSONArray>();
|
||||
JSONArray props = new JSONArray();
|
||||
String sendingJson="";
|
||||
try {
|
||||
facetNames = JsonPath.parse(formData).read("$..facetName");
|
||||
facetRelations = JsonPath.parse(formData).read("$..relationFacet");
|
||||
extraProps = JsonPath.parse(formData).read("$..extraProps");
|
||||
props = JsonPath.parse(formData).read("$..props");
|
||||
ResourceDescription rd = new ResourceDescription();
|
||||
rd = buildSendingJson(resourceType,facetNames,facetRelations,extraProps,props);
|
||||
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
|
||||
sendingJson = ow.writeValueAsString(rd);
|
||||
}catch(Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return sendingJson;
|
||||
}
|
||||
|
||||
|
||||
private ResourceDescription buildSendingJson(String resourceType, ArrayList<String> facetNames, ArrayList<String> relations, ArrayList<JSONArray> extraProps, JSONArray props ) {
|
||||
|
||||
ResourceDescription rd = new ResourceDescription();
|
||||
rd.setType(resourceType);
|
||||
for(int i=0; i<facetNames.size(); i++) {
|
||||
LinkedHashMap targetMap_i = new LinkedHashMap<String, Object>();
|
||||
FacetDescription facet_i = new FacetDescription();
|
||||
facet_i.setType(relations.get(i));
|
||||
LinkedHashMap joProp_i = (LinkedHashMap)props.get(i);
|
||||
joProp_i.put("type", facetNames.get(i));
|
||||
Iterator<String> keyit = (Iterator) joProp_i.keySet().iterator();
|
||||
while(keyit.hasNext()) {
|
||||
String key = keyit.next();
|
||||
targetMap_i.put(key, joProp_i.get(key).toString());
|
||||
}
|
||||
JSONArray extra_joProps_i = (JSONArray)extraProps.get(i);
|
||||
if(extra_joProps_i.size()!=0) {
|
||||
for(int j=0; j<extra_joProps_i.size(); j++) {
|
||||
LinkedHashMap extraProps_ij = (LinkedHashMap)extra_joProps_i.get(j);
|
||||
Iterator<String> it = (Iterator) extraProps_ij.keySet().iterator();
|
||||
while(it.hasNext()) {
|
||||
String key = it.next();
|
||||
targetMap_i.put(extraProps_ij.get("deno").toString(),extraProps_ij.get("val").toString());//to avoid ClassCastException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
facet_i.setTarget(targetMap_i);
|
||||
if(rd.getConsistsOf()==null) {
|
||||
rd.setConsistsOf(new ArrayList<FacetDescription>());
|
||||
}
|
||||
rd.getConsistsOf().add(facet_i);
|
||||
rd.setIsRelatedTo(new ArrayList<String>());
|
||||
}
|
||||
|
||||
return rd;
|
||||
}
|
||||
//CRUD - 1
|
||||
public void createResourceInstance(String jsonDescription) throws Exception {
|
||||
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create(currentCtx);
|
||||
publisher.createResource(jsonDescription);
|
||||
}
|
||||
|
||||
//CRUD - 2
|
||||
|
|
|
@ -12,7 +12,6 @@ public class VirtualServiceDTO {
|
|||
private String id;
|
||||
private String lastMod;
|
||||
private String name;
|
||||
private String version;
|
||||
private String group;
|
||||
private String qualifier;
|
||||
private String version;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||
import org.gcube.informationsystem.service.InformationSystemService;
|
||||
import org.gcube.informationsystem.service.dto.EServiceDTO;
|
||||
import org.gcube.informationsystem.service.dto.HostingNodeDTO;
|
||||
import org.gcube.informationsystem.service.dto.VirtualServiceDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -146,7 +147,26 @@ public class DTOResourceBuilder {
|
|||
break;
|
||||
|
||||
case Constants.RES_TYPE_VSERVICE:
|
||||
dto = new VirtualServiceDTO();
|
||||
try {
|
||||
String uid= JsonPath.parse(resJson).read(UID_QUERY);
|
||||
((VirtualServiceDTO) dto).setId(uid);
|
||||
log.debug("1..."+uid);
|
||||
|
||||
String lastUpd= JsonPath.parse(resJson).read(LAST_UPDATE_QUERY);
|
||||
lastUpd = lastUpd.substring(0,lastUpd.length()-10);
|
||||
((VirtualServiceDTO) dto).setLastMod(lastUpd);
|
||||
log.debug("2..."+lastUpd);
|
||||
|
||||
//Software Facet Fields
|
||||
myLeaves = JsonPath.parse(resJson).read(ES_NGV_QUERY);
|
||||
String name = myLeaves.get(0).get("name").toString();
|
||||
String group = myLeaves.get(0).get("group").toString();
|
||||
String version = myLeaves.get(0).get("version").toString();
|
||||
log.debug("3..."+myLeaves);
|
||||
((VirtualServiceDTO) dto).setVersion(version);
|
||||
((VirtualServiceDTO) dto).setName(name);
|
||||
((VirtualServiceDTO) dto).setGroup(group);
|
||||
|
||||
}catch(Exception e) {
|
||||
log.error("Error while building VirtualServiceDTO from json");
|
||||
|
|
|
@ -128,7 +128,7 @@ public class InformationSystemResource {
|
|||
// e.g. http://localhost:8081/api/is/resourcetype?typeName=HostingNode
|
||||
public ResponseEntity<String> resourceType(@RequestParam String typeName,@RequestParam @Nullable String currentContext) {
|
||||
try {
|
||||
informationSystemService.setUma(createUmaToken(currentContext));
|
||||
|
||||
ResourceTypeDTO dto = informationSystemService.getResourceType(typeName);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sc = objectMapper.writeValueAsString(dto);
|
||||
|
@ -242,100 +242,43 @@ public class InformationSystemResource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//CRUD - 1
|
||||
@PostMapping("/createresource")
|
||||
String createResource(@RequestParam String resourceType, @RequestBody String formData) throws Exception {
|
||||
//NB: non serve UmaToken e context!
|
||||
ArrayList<String> facetNames = new ArrayList<>();
|
||||
ArrayList<String> facetRelations = new ArrayList<>();
|
||||
ArrayList<JSONArray> extraProps = new ArrayList<JSONArray>();
|
||||
JSONArray props = new JSONArray();
|
||||
|
||||
String sendingJson="";
|
||||
String createresource(@RequestParam String resourceType, @RequestBody String formData) throws Exception {
|
||||
/*
|
||||
* ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||
UUIDUtility uuidUtil = new UUIDUtility();
|
||||
return publisher.deleteResource(resourceType, uuidUtil.fromString(uuid));
|
||||
*/
|
||||
String currentContext = SecretManagerProvider.instance.get().getContext();
|
||||
String result = "";
|
||||
informationSystemService.setUma(createUmaToken(currentContext));
|
||||
formData = informationSystemService.createResourceInternal(resourceType, formData);
|
||||
try {
|
||||
|
||||
facetNames = JsonPath.parse(formData).read("$..facetName");
|
||||
facetRelations = JsonPath.parse(formData).read("$..relationFacet");
|
||||
extraProps = JsonPath.parse(formData).read("$..extraProps");
|
||||
props = JsonPath.parse(formData).read("$..props");
|
||||
|
||||
ResourceDescription rd = new ResourceDescription();
|
||||
rd = buildSendingJson(resourceType,facetNames,facetRelations,extraProps,props);
|
||||
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
|
||||
sendingJson = ow.writeValueAsString(rd);
|
||||
//System.out.println(Json.pretty(rd));
|
||||
}catch(Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
// String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||
String uid="";
|
||||
try {
|
||||
uid = publisher.createResource(sendingJson);
|
||||
//String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||
result = publisher.createResource(formData);
|
||||
//result = publisher.create(formData);
|
||||
}catch(Exception e) {
|
||||
log.error("****************");
|
||||
e.printStackTrace();
|
||||
log.error("****************");
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return uid;
|
||||
//TODO: GESTIRE ERRORI!
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//CRUD - 3
|
||||
@PostMapping("/deleteresource")
|
||||
boolean deleteResource(@RequestParam @Nullable String currentContext, @RequestParam String resourceType, @RequestParam String uuid)throws Exception {
|
||||
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||
boolean deleteResource(@RequestParam String resourceType, @RequestBody String uuid)throws Exception {
|
||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||
//TODO: dove setto UMA Token?? (altrimenti error 500)
|
||||
UUIDUtility uuidUtil = new UUIDUtility();
|
||||
return publisher.deleteResource(resourceType, uuidUtil.fromString(uuid));
|
||||
|
||||
//TODO: GESTIRE ERRORI!
|
||||
}
|
||||
|
||||
|
||||
ResourceDescription buildSendingJson(String resourceType, ArrayList<String> facetNames, ArrayList<String> relations, ArrayList<JSONArray> extraProps, JSONArray props ) {
|
||||
|
||||
ResourceDescription rd = new ResourceDescription();
|
||||
rd.setType(resourceType);
|
||||
for(int i=0; i<facetNames.size(); i++) {
|
||||
LinkedHashMap targetMap_i = new LinkedHashMap<String, Object>();
|
||||
FacetDescription facet_i = new FacetDescription();
|
||||
facet_i.setType(relations.get(i));
|
||||
FacetDescription facet_d = new FacetDescription();
|
||||
LinkedHashMap joProp_i = (LinkedHashMap)props.get(i);
|
||||
joProp_i.put("type", facetNames.get(i));
|
||||
Iterator<String> keyit = (Iterator) joProp_i.keySet().iterator();
|
||||
while(keyit.hasNext()) {
|
||||
String key = keyit.next();
|
||||
if(key.equals("optional")) {
|
||||
continue;
|
||||
}
|
||||
targetMap_i.put(key, joProp_i.get(key).toString());
|
||||
}
|
||||
JSONArray extra_joProps_i = (JSONArray)extraProps.get(i);
|
||||
if(extra_joProps_i.size()!=0) {
|
||||
for(int j=0; j<extra_joProps_i.size(); j++) {
|
||||
LinkedHashMap extraProps_ij = (LinkedHashMap)extra_joProps_i.get(j);
|
||||
Iterator<String> it = (Iterator) extraProps_ij.keySet().iterator();
|
||||
while(it.hasNext()) {
|
||||
String key = it.next();
|
||||
targetMap_i.put(extraProps_ij.get("deno").toString(),extraProps_ij.get("val").toString());//to avoid ClassCastException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
facet_i.setTarget(targetMap_i);
|
||||
if(rd.getConsistsOf()==null) {
|
||||
rd.setConsistsOf(new ArrayList<FacetDescription>());
|
||||
}
|
||||
rd.getConsistsOf().add(facet_i);
|
||||
}
|
||||
|
||||
return rd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import lombok.NoArgsConstructor;
|
|||
public class ResourceDescription {
|
||||
String type;
|
||||
ArrayList<FacetDescription> consistsOf;
|
||||
ArrayList<String> isRelatedTo;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import { SpinnercontrolInterceptor } from './shared/spinnercontrol.interceptor';
|
|||
import { ResourceAddComponent } from './resource-add/resource-add.component';
|
||||
import { ResourceDeleteComponent } from './resource-delete/resource-delete.component';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { RemoveResourceComponent } from './remove-resource/remove-resource.component';
|
||||
|
||||
//TODO: PER ORA USIAMO DB IN MEMORY COME MOCK
|
||||
|
||||
|
@ -58,11 +59,11 @@ import { MatDialogModule } from '@angular/material/dialog';
|
|||
providers: [
|
||||
Title,
|
||||
{ provide: LOCALE_ID, useValue: 'en' },
|
||||
{ provide: NgbDateAdapter, useClass: NgbDateDayjsAdapter },
|
||||
{ provide: NgbDateAdapter, useClass: NgbDateDayjsAdapter},
|
||||
{provide:HTTP_INTERCEPTORS,useClass:SpinnercontrolInterceptor, multi: true}
|
||||
],
|
||||
declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent,
|
||||
ResourceDeleteComponent],
|
||||
ResourceDeleteComponent, RemoveResourceComponent],
|
||||
bootstrap: [MainComponent],
|
||||
})
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
</mat-form-field>
|
||||
|
||||
<!-- PROPERTIES -->
|
||||
<!--*ngFor="let propCtrl of getPropsGroup(facetTemplate.key,ind).controls|keyvalue; let k=index;"-->
|
||||
<div formGroupName ="props" >
|
||||
<div *ngFor="let prop of facetTemplate.value.guiProps">
|
||||
<mat-form-field>
|
||||
|
@ -53,15 +52,7 @@
|
|||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div *ngFor="let prop of facetTemplate.value.guiProps">
|
||||
<mat-form-field>
|
||||
<mat-label>{{prop.label}}</mat-label>
|
||||
<input matInput formControlName="prop_{{prop.name}}" id="prop_{{prop.name}}"
|
||||
type="{{prop.type}}"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!-- ADDITIONAL PROPERTIES -->
|
||||
<div formArrayName ="extraProps" style="border: 2px solid rgb(176, 206, 230); padding: 10px; margin: 5px;">
|
||||
<span [style.width.px]="350" [style.font-weight]="900">Custom Properties</span>
|
||||
|
@ -108,14 +99,7 @@
|
|||
<mat-icon>add</mat-icon>Add new </button>
|
||||
</div>
|
||||
|
||||
</div> <!-- chiude la form -->
|
||||
|
||||
<b>Form's Value:</b>
|
||||
{{ myForm.value | json }}
|
||||
<br />
|
||||
<b>Form is Valid ? :</b>
|
||||
{{ myForm.valid }}
|
||||
|
||||
</div> <!-- ends the form -->
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="submit" (click)="onSubmit()">Submit</button>
|
||||
|
|
|
@ -86,6 +86,7 @@ export class FacetComposerComponent implements OnInit {
|
|||
{ value: 'Long'},
|
||||
{ value: 'Float'},
|
||||
{ value: 'Double'},
|
||||
{ value: 'Password'},//Password implica salvare criptato
|
||||
{ value: 'Date'},
|
||||
{ value: 'String'},
|
||||
{ value: 'Binary'},
|
||||
|
@ -133,14 +134,6 @@ export class FacetComposerComponent implements OnInit {
|
|||
})
|
||||
}
|
||||
|
||||
/*
|
||||
getPropsGroup(denoFacet:string):FormGroup{
|
||||
console.debug("òòòòòòòòòòòòòòò");
|
||||
//console.debug((this.getSingleFacetArray(denoFacet)).controls);
|
||||
return this.myForm.get(denoFacet)!.get('props') as FormGroup;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
getPropsGroup(denoFacet:string, index:number):FormGroup{
|
||||
return (this.getSingleFacetArray(denoFacet).controls[index]).get('props') as FormGroup;
|
||||
|
@ -236,61 +229,22 @@ export class FacetComposerComponent implements OnInit {
|
|||
getSingleFacetArray(nameplus:string): FormArray {
|
||||
return this.myForm.controls[nameplus] as FormArray;
|
||||
}
|
||||
|
||||
|
||||
onSubmit() {
|
||||
//TODO: POI VA CAMBIATO
|
||||
this.guiService.createResource(this.titleType, this.testData).subscribe(res => {
|
||||
//TODO: qui ritorna un codice di errore per la form!
|
||||
console.log('ok');
|
||||
}, error => {
|
||||
console.log(JSON.stringify(error));
|
||||
});
|
||||
if(this.myForm.valid){
|
||||
this.guiService.createResource(this.titleType, JSON.stringify(this.myForm.value)).subscribe(res => {
|
||||
this.dialogRef.close(res);
|
||||
}, error => {
|
||||
console.log(JSON.stringify(error));
|
||||
this.dialogRef.close('error');
|
||||
});
|
||||
}else{
|
||||
alert("Data provided is not valid!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
onSubmit2() {
|
||||
const formData = this.testData;
|
||||
const jsonString = JSON.stringify(formData)
|
||||
const tobesaved = {
|
||||
'type':'',
|
||||
'consistsOf':[{}]
|
||||
};
|
||||
|
||||
tobesaved.type=this.titleType;
|
||||
// tobesaved.consistsOf.push
|
||||
//tobesaved.set("consistsOf",array di singlefacet):
|
||||
const inputObj = JSON.parse(jsonString, (key, value) => {
|
||||
const facetObj = new Map();
|
||||
const targetObj = new Map();
|
||||
console.debug('key...'+key);
|
||||
console.debug('value...'+value);
|
||||
if(key==="relationFacet"){
|
||||
facetObj.set('type',value);
|
||||
// this.guiService.createResource(this.titleType, formData);
|
||||
}
|
||||
//targetObj
|
||||
if(key==="facetName"){
|
||||
targetObj.set('type',value);
|
||||
// this.guiService.createResource(this.titleType, formData);
|
||||
}
|
||||
//target
|
||||
if(key==="facetName"){
|
||||
targetObj.set('type',value);
|
||||
// this.guiService.createResource(this.titleType, formData);
|
||||
}
|
||||
if(key.startsWith('prop_')){
|
||||
targetObj.set(key.substring(5,key.length),value);
|
||||
// this.guiService.createResource(this.titleType, formData);
|
||||
}
|
||||
facetObj.set('target',targetObj);
|
||||
tobesaved.consistsOf.push(facetObj);
|
||||
});
|
||||
|
||||
console.debug(tobesaved);
|
||||
|
||||
}
|
||||
|
||||
resetForm() {
|
||||
this.myForm.reset();
|
||||
}
|
||||
|
@ -306,83 +260,9 @@ export class FacetComposerComponent implements OnInit {
|
|||
this.resetForm();
|
||||
this.dialogRef.close({event:'cancel'});
|
||||
}
|
||||
//chiude e basta
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
testData:any= {
|
||||
"SoftwareFacet_IsIdentifiedBy": [
|
||||
{
|
||||
"facetName": "SoftwareFacet",
|
||||
"max": "many",
|
||||
"min": "1",
|
||||
"facetDescription": "SoftwareFacet captures information on any software associated with the resource.",
|
||||
"relationFacet": "IsIdentifiedBy",
|
||||
"isAdded": false,
|
||||
"extraProps": [
|
||||
{
|
||||
"prop_deno": "customname1",
|
||||
"prop_val": "customval1",
|
||||
"prop_tipo": "String"
|
||||
},
|
||||
{
|
||||
"prop_deno": "customname2",
|
||||
"prop_val": "customval2",
|
||||
"prop_tipo": "String"
|
||||
}
|
||||
],
|
||||
"props": {
|
||||
"prop_name": "name1",
|
||||
"prop_optional": true,
|
||||
"prop_group": "group1",
|
||||
"prop_description": "descr1",
|
||||
"prop_version": "version1",
|
||||
"prop_qualifier": "qual1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"facetName": "SoftwareFacet",
|
||||
"max": "many",
|
||||
"min": "1",
|
||||
"facetDescription": "SoftwareFacet captures information on any software associated with the resource.",
|
||||
"relationFacet": "IsIdentifiedBy",
|
||||
"isAdded": true,
|
||||
"extraProps": [
|
||||
{
|
||||
"prop_deno": "customname22",
|
||||
"prop_val": "customval22",
|
||||
"prop_tipo": "String"
|
||||
}
|
||||
],
|
||||
"props": {
|
||||
"prop_name": "name2",
|
||||
"prop_optional": true,
|
||||
"prop_group": "group2",
|
||||
"prop_description": "descr2",
|
||||
"prop_version": "vers2",
|
||||
"prop_qualifier": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"facetName": "SoftwareFacet",
|
||||
"max": "many",
|
||||
"min": "1",
|
||||
"facetDescription": "SoftwareFacet captures information on any software associated with the resource.",
|
||||
"relationFacet": "IsIdentifiedBy",
|
||||
"isAdded": true,
|
||||
"extraProps": [],
|
||||
"props": {
|
||||
"prop_name": "name3",
|
||||
"prop_optional": true,
|
||||
"prop_group": "group3",
|
||||
"prop_description": "",
|
||||
"prop_version": "vers3",
|
||||
"prop_qualifier": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,10 +18,11 @@ export interface ITypeSpecification{
|
|||
providedIn: 'root'
|
||||
})
|
||||
export class FacetComposerService {
|
||||
|
||||
/*
|
||||
httpOptions = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
*/
|
||||
|
||||
constructor(private http: HttpClient, private applicationConfigService: ApplicationConfigService) { }
|
||||
|
||||
|
@ -43,18 +44,27 @@ export class FacetComposerService {
|
|||
|
||||
|
||||
createResource(type:string, body:string): Observable<string> {
|
||||
const headers = new HttpHeaders()
|
||||
.append(
|
||||
'Content-Type',
|
||||
'application/json'
|
||||
);
|
||||
const serviceUrl = this.applicationConfigService.getEndpointFor('api/is/createresource');
|
||||
const params = new HttpParams().append("resourceType",type);
|
||||
return this.http.post<string>(serviceUrl,body,{ headers,params})
|
||||
}
|
||||
|
||||
removeResouce(type:string,id:string):Observable<boolean>{
|
||||
const serviceUrl = this.applicationConfigService.getEndpointFor('api/is/deleteresource');
|
||||
const headers = new HttpHeaders()
|
||||
.append(
|
||||
'Content-Type',
|
||||
'application/json'
|
||||
);
|
||||
//const body=JSON.stringify(myObject);
|
||||
//const params = new HttpParams().append("resourceType",type);
|
||||
//TODO:CAMBIARE QUI
|
||||
const params = new HttpParams().append("resourceType","VirtualService");
|
||||
const params = new HttpParams().append("resourceType",type);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return this.http.post<string>(serviceUrl,body,{ headers,params})
|
||||
}
|
||||
return this.http.post<boolean>(serviceUrl,id,{ headers,params})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,10 +13,95 @@
|
|||
</mat-expansion-panel-header>
|
||||
<p> {{typeSpec.description}} </p>
|
||||
</mat-expansion-panel>
|
||||
|
||||
<div [formGroup]="myForm">
|
||||
|
||||
<div formArrayName="{{facetTemplate.key}}" *ngFor="let facetTemplate of fieldsMap|keyvalue;" >
|
||||
<div [formGroupName] ="ind" *ngFor="let fct of (getSingleFacetArray(facetTemplate.key)).controls; let ind=index;" style="border: 3px solid rgb(72, 157, 202); padding: 10px; margin: 5px;">
|
||||
<mat-form-field appearance="outline" >
|
||||
<input matInput formControlName="facetName" [style.width.px]="350" type="text" [readonly]="true" style="font-size: large; font-weight: 700;" />
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label for="min" >occurr. min</mat-label>
|
||||
<input matInput formControlName="min" id="min" type="text" readonly="true"/>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label for="max" >occurr. max</mat-label>
|
||||
<input matInput formControlName="max" id="max" type="text" readonly="true"/>
|
||||
</mat-form-field>
|
||||
|
||||
<div style="border: 1px solid rgb(202, 202, 202); padding: 10px; margin: 5px;">
|
||||
<textarea matInput formControlName="facetDescription" [readonly]="true">{{facetTemplate.value.description}}</textarea>
|
||||
</div>
|
||||
<mat-form-field>
|
||||
<mat-label for="relationFacet" >relation</mat-label>
|
||||
<mat-select formControlName="relationFacet" id="relationFacet">
|
||||
<mat-option *ngFor="let opt of facetTemplate.value.relationOptions" [value]="opt">
|
||||
{{opt}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<!-- PROPERTIES -->
|
||||
<div formGroupName ="props" >
|
||||
<div *ngFor="let prop of facetTemplate.value.guiProps">
|
||||
<mat-form-field>
|
||||
<mat-label>{{prop.label}}</mat-label>
|
||||
<input matInput formControlName="{{prop.name}}" id="{{prop.name}}"
|
||||
type="{{prop.type}}"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ADDITIONAL PROPERTIES -->
|
||||
<div formArrayName ="extraProps" style="border: 2px solid rgb(176, 206, 230); padding: 10px; margin: 5px;">
|
||||
<span [style.width.px]="350" [style.font-weight]="900">Custom Properties</span>
|
||||
<div [formGroupName] ="i" *ngFor="let x of getExtraPropsArray(facetTemplate.key,ind).controls; let i=index;">
|
||||
<mat-form-field>
|
||||
<mat-label for="deno">name</mat-label>
|
||||
<input matInput formControlName="deno" type="text"/>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label for="val">value</mat-label>
|
||||
<input matInput formControlName="val" type="text"/>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<mat-label for="tipo" >type</mat-label>
|
||||
<mat-select formControlName="tipo" id="tipo">
|
||||
<mat-option *ngFor="let tp of optionTypes" [value]="tp.value" >
|
||||
{{tp.value}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<button mat-stroked-button color="primary" style="margin-left: 12px;"
|
||||
(click)="removeExtraProp(facetTemplate.key,ind,i)" >
|
||||
Remove custom property</button>
|
||||
</div>
|
||||
</div>
|
||||
<button mat-stroked-button color="primary" style="margin-left: 12px; margin-top: 18px;"
|
||||
(click)="addExtraProp(facetTemplate.key,ind)" >
|
||||
Add custom property</button>
|
||||
<!--</div> -->
|
||||
<!-- FINE ADDITIONAL PROPERTIES -->
|
||||
|
||||
<input matInput formControlName="isAdded" style="display: none;"/>
|
||||
|
||||
<div style="padding-top: 20px; padding-bottom: 8px; margin: 5px;">
|
||||
<button mat-icon-button color="primary"
|
||||
[disabled]="facetTemplate.value.min==='1' && !myForm.get([facetTemplate.key,ind,'isAdded'])!.value"
|
||||
(click)="removeFacet(facetTemplate.key,ind)" matTooltip="remove {{facetTemplate.key}}" matTooltipClass="tableTooltip"
|
||||
matTooltipPosition="above"><mat-icon>delete_outline</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
<button mat-flat-button color="primary"
|
||||
(click)="addFacet(facetTemplate.key)" [disabled]="facetTemplate.value.max==='1'">
|
||||
<mat-icon>add</mat-icon>Add new </button>
|
||||
</div>
|
||||
|
||||
</div> <!-- ends the form -->
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="submit" (click)="onSubmit()">Submit</button>
|
||||
<button mat-button (click)="close()">Cancel</button>
|
||||
</mat-dialog-actions>
|
||||
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="submit">Submit</button>
|
||||
<button mat-button (click)="close()">Cancel</button>
|
||||
</mat-dialog-actions>
|
||||
|
|
|
@ -45,18 +45,19 @@ export class FacetEditorComponent implements OnInit {
|
|||
fieldsMap: Map<string, IFacetComposer>;
|
||||
rawjson: string|any;
|
||||
|
||||
optionTypes = [
|
||||
optionTypes = [
|
||||
{ value: 'Boolean'},
|
||||
{ value: 'Integer'},
|
||||
{ value: 'Short'},
|
||||
{ value: 'Long'},
|
||||
{ value: 'Float'},
|
||||
{ value: 'Double'},
|
||||
{ value: 'Password'},//Password implica salvare criptato
|
||||
{ value: 'Date'},
|
||||
{ value: 'String'},
|
||||
{ value: 'Binary'},
|
||||
{ value: 'Byte'}
|
||||
];
|
||||
]
|
||||
|
||||
|
||||
//TODO: PASSARE UID COME STRINGA
|
||||
|
@ -74,8 +75,6 @@ export class FacetEditorComponent implements OnInit {
|
|||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
//TODO: al posto di '' metti titlePath (sembra dare errore)
|
||||
this.dataService.getJsonDetails('',this.titleType,this.uid).subscribe(res => {
|
||||
console.debug("*******RAW OBJECT*********");
|
||||
this.lookoutObject(res);
|
||||
|
@ -104,13 +103,6 @@ export class FacetEditorComponent implements OnInit {
|
|||
|
||||
|
||||
createAndFillForm(rawSource:string, fData:ITypeSpecification):void{
|
||||
/*
|
||||
console.debug("*******RAW STRING*********");
|
||||
console.debug(rawSource);
|
||||
console.debug("****************");
|
||||
*/
|
||||
//const formDataObj = JSON.parse(rawSource);
|
||||
// this.lookoutObject(formDataObj);
|
||||
|
||||
for(let i=0; i<fData.facetSpecs.length; i++){
|
||||
const facetSpec = fData.facetSpecs[i];
|
||||
|
@ -139,6 +131,14 @@ export class FacetEditorComponent implements OnInit {
|
|||
})
|
||||
}
|
||||
|
||||
get props():FormGroup{
|
||||
return this.fb.group({
|
||||
})
|
||||
}
|
||||
|
||||
getPropsGroup(denoFacet:string, index:number):FormGroup{
|
||||
return (this.getSingleFacetArray(denoFacet).controls[index]).get('props') as FormGroup;
|
||||
}
|
||||
getExtraPropsArray(denoFacet:string, index:number):FormArray{
|
||||
return (this.getSingleFacetArray(denoFacet).controls[index]).get('extraProps') as FormArray;
|
||||
}
|
||||
|
@ -173,12 +173,6 @@ export class FacetEditorComponent implements OnInit {
|
|||
const descriptionFc = this.fb.control(item.description);
|
||||
facetFg.addControl('facetDescription', descriptionFc);
|
||||
|
||||
// const relFg: FormGroup = this.fb.group({});
|
||||
|
||||
/*
|
||||
console.debug(item.relationOptions);
|
||||
console.debug('+++++++++++++++++')
|
||||
*/
|
||||
const relationFc = this.fb.control(item.relation);
|
||||
facetFg.addControl('relationFacet', relationFc);
|
||||
//this.itemRelations = item.relationOptions;
|
||||
|
@ -194,7 +188,9 @@ export class FacetEditorComponent implements OnInit {
|
|||
return this.addPropertyControls(facetFg,item.guiProps);
|
||||
}
|
||||
|
||||
addPropertyControls(facetFg:FormGroup, props: IFacetProps[]){
|
||||
addPropertyControls(facetFg:FormGroup, props: IFacetProps[]):FormGroup{
|
||||
const propsFg = this.fb.group({});
|
||||
|
||||
let fc:FormControl;
|
||||
for(let i=0; i<props.length; i++){
|
||||
const prop=props[i];
|
||||
|
@ -220,19 +216,25 @@ export class FacetEditorComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
}
|
||||
facetFg.addControl(prop.name,fc); //formGroup.addControl('controlName', formControl);
|
||||
propsFg.addControl(prop.name,fc); //formGroup.addControl(prop_'controlName', formControl);
|
||||
// facetFg.addControl("prop_"+prop.name,fc); //formGroup.addControl(prop_'controlName', formControl);
|
||||
}
|
||||
facetFg.addControl('props',propsFg);
|
||||
return facetFg;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
if (this.myForm.valid) {
|
||||
const formData = this.myForm.value;
|
||||
// console.log("***** FORMDATA *****");
|
||||
//console.log(formData);
|
||||
//TODO Process formData
|
||||
}
|
||||
}
|
||||
if(this.myForm.valid){
|
||||
this.guiService.createResource(this.titleType, JSON.stringify(this.myForm.value)).subscribe(res => {
|
||||
this.dialogRef.close(res);
|
||||
}, error => {
|
||||
console.log(JSON.stringify(error));
|
||||
this.dialogRef.close('error');
|
||||
});
|
||||
}else{
|
||||
alert("Data provided is not valid!");
|
||||
}
|
||||
}
|
||||
|
||||
getSingleFacetArray(nameplus:string): FormArray {
|
||||
return this.myForm.controls[nameplus] as FormArray;
|
||||
|
@ -243,9 +245,6 @@ export class FacetEditorComponent implements OnInit {
|
|||
this.getSingleFacetArray(deno).removeAt(index);
|
||||
this.typeSpec.facetSpecs.splice(index,1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
resetForm():void {
|
||||
this.myForm.reset();
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
<p>remove-resource works!</p>
|
||||
<h2 mat-dialog-title>Removing {{titleType}} - UUID: {{uid}}</h2>
|
||||
<p>Are you sure?</p>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button (click)="doRemove()">Remove</button>
|
||||
<button mat-button (click)="doCancel()">Cancel</button>
|
||||
</mat-dialog-actions>
|
||||
|
|
|
@ -1,15 +1,41 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
/* eslint-disable @angular-eslint/no-empty-lifecycle-method */
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { FacetComposerService } from 'app/facet-composer/facet-composer.service';
|
||||
import { IContextNode } from 'app/services/i-context-node';
|
||||
import { IResource } from 'app/services/i-resource';
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-remove-resource',
|
||||
templateUrl: './remove-resource.component.html',
|
||||
styleUrls: ['./remove-resource.component.scss']
|
||||
})
|
||||
export class RemoveResourceComponent implements OnInit {
|
||||
export class RemoveResourceComponent /*implements OnInit*/ {
|
||||
|
||||
constructor() { }
|
||||
titleType:string;
|
||||
titlePath:string;
|
||||
uid:string;
|
||||
operationResult:boolean;
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
constructor(private guiService: FacetComposerService,
|
||||
private dialogRef:MatDialogRef<RemoveResourceComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) data: {type: IResource ,context:IContextNode, uid:string}){
|
||||
this.titleType = data.type.name;
|
||||
this.titlePath = data.context.path;
|
||||
this.uid = data.uid;
|
||||
this.operationResult = false;
|
||||
}
|
||||
|
||||
//removeResouce(type:string,id:string):Observable<boolean>{
|
||||
doRemove():void{
|
||||
this.guiService.removeResouce(this.titleType,this.uid).subscribe(res => {
|
||||
this.operationResult = res;
|
||||
this.dialogRef.close(res);
|
||||
});
|
||||
}
|
||||
|
||||
doCancel():void{
|
||||
this.dialogRef.close({event:'cancel'});
|
||||
}
|
||||
}
|
|
@ -23,6 +23,6 @@
|
|||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button (click)="close()">Cancel</button>
|
||||
<button mat-button (click)="doAction()">Save</button>
|
||||
<button mat-button (click)="doAction()"; [mat-dialog-close]="form.data" cdkFocusInitial>Submit</button>
|
||||
</mat-dialog-actions>
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import { IResource } from 'app/services/i-resource';
|
|||
import { IResourceType } from 'app/services/i-resource-type';
|
||||
import { FacetComposerComponent } from 'app/facet-composer/facet-composer.component';
|
||||
import { FacetEditorComponent } from 'app/facet-editor/facet-editor.component';
|
||||
import { RemoveResourceComponent } from 'app/remove-resource/remove-resource.component';
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-table-screen-es',
|
||||
|
@ -191,6 +192,12 @@ export class TableScreenEsComponent implements OnInit, AfterViewInit, OnChanges{
|
|||
this.editDialog.open(FacetEditorComponent,dialogConfig);
|
||||
}
|
||||
|
||||
|
||||
removeItem(uid:string):void{
|
||||
const dialogConfig = new MatDialogConfig();
|
||||
dialogConfig.disableClose = true;
|
||||
dialogConfig.autoFocus = true;
|
||||
dialogConfig.data= {type: this.typeObject, context: this.currentCtx,uid};
|
||||
this.createDialog.open(RemoveResourceComponent,dialogConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="p-3">
|
||||
<div class="p-3">
|
||||
<div class="d-flex flex-row">
|
||||
<mat-form-field class="mb-3 pe-3">
|
||||
<mat-label>Search by Name</mat-label>
|
||||
|
@ -13,12 +13,23 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mat-elevation-z4">
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header color="primary">Name</th>
|
||||
<td mat-cell *matCellDef="let item">{{ item.name }}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="group">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header color="primary">Group</th>
|
||||
<td mat-cell *matCellDef="let item">{{ item.group }}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="version">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header color="primary">Version</th>
|
||||
<td mat-cell *matCellDef="let item">{{ item.version }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="id">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Id</th>
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header color="primary">Id</th>
|
||||
<td mat-cell *matCellDef="let item" >{{ item.id }} </td>
|
||||
</ng-container>
|
||||
|
||||
|
@ -30,20 +41,17 @@
|
|||
<ng-container matColumnDef="actions">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Actions</th>
|
||||
<td mat-cell *matCellDef="let item">
|
||||
<!--<div class="d-flex flex-row py-4">-->
|
||||
<div class="d-flex flex-row">
|
||||
<button mat-button class="action-btn" color="primary" (click)="addTab(this.item.id)" ><mat-icon>visibility</mat-icon></button>
|
||||
<button mat-button class="action-btn" color="primary" (click)="openFacetEditor(this.item.id)"><mat-icon>edit</mat-icon></button>
|
||||
<button mat-button class="action-btn" color="primary"><mat-icon>delete</mat-icon></button>
|
||||
<button mat-button class="action-btn" color="primary" (click)="removeItem(this.item.id)"><mat-icon>delete</mat-icon></button>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- rows visualization -->
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
|
||||
<!-- Rows shown when there is no matching data. -->
|
||||
<tr class="mat-row" *matNoDataRow>
|
||||
<td class="mat-cell" colspan="4">No data matching the filter "{{ input.value }}"</td>
|
||||
</tr>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
||||
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
||||
import {
|
||||
Component,
|
||||
|
@ -27,12 +28,14 @@ import { MatFormFieldControl } from '@angular/material/form-field';
|
|||
import { FacetComposerComponent } from 'app/facet-composer/facet-composer.component';
|
||||
import { FacetEditorComponent } from 'app/facet-editor/facet-editor.component';
|
||||
import { IVirtualService } from 'app/services/i-virtual-service';
|
||||
import { RemoveResourceComponent } from 'app/remove-resource/remove-resource.component';
|
||||
import { GenericInfoComponent } from 'app/generic-info/generic-info.component';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-table-screen-vs',
|
||||
templateUrl: './table-screen-vs.component.html',
|
||||
styleUrls: ['./table-screen-vs.component.scss'],
|
||||
styleUrls: ['../table-screen/table-screen.component.scss'],
|
||||
//NB->dialog form is a provider
|
||||
providers: [{provide:MatFormFieldControl,
|
||||
// useExisting:ResourceAddComponent },
|
||||
|
@ -42,11 +45,11 @@ import { IVirtualService } from 'app/services/i-virtual-service';
|
|||
|
||||
|
||||
export class TableScreenVsComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
displayedColumns: string[] = ['id','lastMod'];
|
||||
displayedColumns: string[] = ['name','group','version','id','lastMod','actions'];
|
||||
dataFromService: IVirtualService[];
|
||||
dataSource = new MatTableDataSource();
|
||||
tableDetail: IVirtualService;
|
||||
dialogAddRef: MatDialogRef<TableScreenVsComponent> |undefined;
|
||||
dialogInfoRef: MatDialogRef<GenericInfoComponent> |undefined;
|
||||
errorMessage = '';
|
||||
|
||||
@Input() currentCtx: IContextNode; //fetching event from parent
|
||||
|
@ -154,6 +157,8 @@ reloadTable():void{
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
closeTab(index: number): void {
|
||||
|
||||
const x = this.chosenIds.indexOf(this.tabs[index].id);
|
||||
|
@ -165,6 +170,11 @@ reloadTable():void{
|
|||
this.tabGroup.selectedIndex = this.tabs.length - 1;
|
||||
//this.chosenIds.indexOf();
|
||||
this.tabs.splice(index, 1);
|
||||
}
|
||||
openDialogDescription(): void {
|
||||
this.dialogInfoRef = this.createDialog.open(GenericInfoComponent, {
|
||||
data: {description: this.typeObject.description}
|
||||
});
|
||||
}
|
||||
|
||||
openFacetComposer(): void {
|
||||
|
@ -172,10 +182,20 @@ reloadTable():void{
|
|||
dialogConfig.disableClose = true;
|
||||
dialogConfig.autoFocus = true;
|
||||
dialogConfig.data= {type: this.typeObject, context: this.currentCtx};
|
||||
this.createDialog.open(FacetComposerComponent,dialogConfig);
|
||||
|
||||
const dialogAddRef = this.createDialog.open(FacetComposerComponent,dialogConfig);
|
||||
dialogAddRef.afterClosed().subscribe( //res is a boolean
|
||||
res=>{
|
||||
if(res!=='error'){ //res di tipo string
|
||||
this.reloadTable();
|
||||
}else{
|
||||
alert('ERROR');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
openFacetEditor(uid: string): void {
|
||||
const dialogConfig = new MatDialogConfig();
|
||||
dialogConfig.disableClose = true;
|
||||
|
@ -184,4 +204,24 @@ reloadTable():void{
|
|||
this.editDialog.open(FacetEditorComponent,dialogConfig);
|
||||
}
|
||||
|
||||
removeItem(uid:string):void{
|
||||
const dialogConfig = new MatDialogConfig();
|
||||
dialogConfig.disableClose = true;
|
||||
dialogConfig.autoFocus = true;
|
||||
dialogConfig.data= {type: this.typeObject, context: this.currentCtx,uid};
|
||||
const dialogRemoveRef = this.createDialog.open(RemoveResourceComponent,dialogConfig);
|
||||
dialogRemoveRef.afterClosed().subscribe( //res is a boolean
|
||||
res=>{if(res){
|
||||
this.reloadTable();
|
||||
}else{
|
||||
alert('ERROR');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue