Implementing UI

This commit is contained in:
Luca Frosini 2019-10-17 15:45:13 +02:00
parent 71b44adbfa
commit e2fe308667
6 changed files with 123 additions and 282 deletions

View File

@ -4,6 +4,6 @@ export interface TypeDefinition {
name: string; name: string;
description: string | null; description: string | null;
abstract: boolean; abstract: boolean;
superClasses?: Set<string>; superClasses?: Array<string>;
properties?: Array<PropertyDefinition>; properties?: Array<PropertyDefinition>;
} }

View File

@ -1,88 +0,0 @@
import { Facet } from './is-model/reference/entities/Facet';
export const list: Array<Facet> = [
{
'@class': 'SoftwareFacet',
header: {
'@class': 'Header',
uuid: 'f0460614-9ffb-4ecd-bf52-d91e8d81d604',
creator: 'luca.frosini',
modifiedBy: 'luca.frosini',
creationTime: '2109-06-29 12:00:00.000 CEST',
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
},
group: 'vre-management',
name: 'whn-manager',
version: '1.3.0'
},
{
'@class': 'SoftwareFacet',
header: {
'@class': 'Header',
uuid: 'f0460614-9ffb-4ecd-bf52-d91e8d81d604',
creator: 'luca.frosini',
modifiedBy: 'luca.frosini',
creationTime: '2109-06-29 12:00:00.000 CEST',
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
},
group: 'vre-management',
name: 'smart-executor',
version: '2.0.0'
},
{
'@class': 'SoftwareFacet',
header: {
'@class': 'Header',
uuid: 'f0460614-9ffb-4ecd-bf52-d91e8d81d604',
creator: 'luca.frosini',
modifiedBy: 'luca.frosini',
creationTime: '2109-06-29 12:00:00.000 CEST',
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
},
group: 'information-system',
name: 'resource-registry',
version: '2.1.0'
},
{
'@class': 'SoftwareFacet',
header: {
'@class': 'Header',
uuid: 'f0460614-9ffb-4ecd-bf52-d91e8d81d604',
creator: 'luca.frosini',
modifiedBy: 'luca.frosini',
creationTime: '2109-06-29 12:00:00.000 CEST',
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
},
group: 'data-publishing',
name: 'gcat',
version: '2.3.0'
},
{
'@class': 'SoftwareFacet',
header: {
'@class': 'Header',
uuid: 'f0460614-9ffb-4ecd-bf52-d91e8d81d604',
creator: 'luca.frosini',
modifiedBy: 'luca.frosini',
creationTime: '2109-06-29 12:00:00.000 CEST',
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
},
group: 'vre-management',
name: 'whn-manager',
version: '1.3.0'
},
{
'@class': 'SoftwareFacet',
header: {
'@class': 'Header',
uuid: 'f0460614-9ffb-4ecd-bf52-d91e8d81d604',
creator: 'luca.frosini',
modifiedBy: 'luca.frosini',
creationTime: '2109-06-29 12:00:00.000 CEST',
lastUpdateTime: '2109-06-29 12:00:00.000 CEST'
},
group: 'vre-management',
name: 'whn-manager',
version: '1.3.0'
}
];

View File

@ -1,44 +1,23 @@
<div style="margin-left:5px;"> <div style="margin-left:5px;">
<table class="table table-striped table-bordered" *ngFor="let resourceIdentification of resourceIdentificationList"> <table class="table table-striped table-bordered" *ngFor="let key of resources.keys()">
<thead> <thead>
<tr> <tr>
<th [attr.colspan]="resourceIdentification.mandatoryProperties.size">Resources identifyed by {{resourceIdentification.type}}</th> <th [attr.colspan]="resources.get(key).mandatoryProperties.size+2">Resources identified by {{resources.get(key).type}}</th>
</tr> </tr>
<tr> <tr>
<th scope="col" *ngFor="let property of resourceIdentification.mandatoryProperties">
{{ property.charAt(0).toLocaleUpperCase() + property.substr(1) }}
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let facet of resourceIdentification.instances">
<td *ngFor="let property of resourceIdentification.mandatoryProperties">{{ facet[property] }}</td>
</tr>
</tbody>
</table>
<table class="table table-striped table-bordered" *ngFor="let resourceIdentification of resourcesByIdentificationFacets">
<thead>
<tr>
<th [attr.colspan]="resourceIdentification.mandatoryProperties.size">Resources identifyed by {{resourceIdentification.type}}</th>
</tr>
<tr>
<th>UUID</th>
<th>Resource Type</th> <th>Resource Type</th>
<th scope="col" *ngFor="let property of resourceIdentification.mandatoryProperties"> <th>UUID</th>
<th scope="col" *ngFor="let property of resources.get(key).mandatoryProperties">
{{ property.charAt(0).toLocaleUpperCase() + property.substr(1) }} {{ property.charAt(0).toLocaleUpperCase() + property.substr(1) }}
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let resource of resourceIdentification.resources"> <tr *ngFor="let r of resources.get(key).resources">
<td>{{ resource.header.uuid }}</td> <th>{{ r['@class'] }}</th>
<td>{{ resource['@class'] }}</td> <td>{{ r.header.uuid }}</td>
<td *ngFor="let property of resource.consistsOf[0].target.mandatoryProperties">{{ resource.consistsOf[0].target[property] }}</td> <td *ngFor="let property of resources.get(key).mandatoryProperties">{{ r.consistsOf[0].target[property] }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -1,7 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { IsService } from '../is.service'; import { IsService } from '../is.service';
import { ResourceIdentification, TYPE_PROPERTY_KEY } from './resourceidentification'; import { ResourceIdentification, TYPE_PROPERTY_KEY } from './resourceidentification';
import { Facet } from '../is-model/reference/entities/Facet';
import { Resource } from '../is-model/reference/entities/Resource'; import { Resource } from '../is-model/reference/entities/Resource';
@Component({ @Component({
@ -11,42 +10,12 @@ import { Resource } from '../is-model/reference/entities/Resource';
}) })
export class ResourceListComponent implements OnInit { export class ResourceListComponent implements OnInit {
public resourceIdentificationList: Array<ResourceIdentification>; public resources: Map<string, ResourceIdentification>;
public resourcesByIdentificationFacets: Map<string, ResourceIdentification>;
constructor(private isService: IsService) { } constructor(private isService: IsService) { }
ngOnInit() { ngOnInit() {
// this.isService.getIdentifyingFacets('Service', facets => {this.identifyingFacets = facets;}); this.isService.getResourceInstances('Service', res => { this.resources = this.analyseResources(res); });
this.isService.getIdentifyingFacets('Service', facets => { this.resourceIdentificationList = this.analyseIdentifyingFacets(facets); });
this.isService.getResourceInstances('Service', resources => {
this.resourcesByIdentificationFacets = this.analyseResources(resources);
});
}
analyseIdentifyingFacets(identifyingFacets: Facet[]): Array<ResourceIdentification> {
const map = new Map<string, ResourceIdentification>();
const facets = new Array<ResourceIdentification>();
for (const facet of identifyingFacets) {
const facetType: string = facet[TYPE_PROPERTY_KEY];
let facetList: ResourceIdentification;
if (map.has(facetType)) {
facetList = map.get(facetType);
} else {
facetList = new ResourceIdentification(facetType);
map.set(facetType, facetList);
facets.push(facetList);
}
facetList.addFacet(facet);
}
return facets;
} }
analyseResources(resources: Resource[]): Map<string, ResourceIdentification> { analyseResources(resources: Resource[]): Map<string, ResourceIdentification> {
@ -68,6 +37,7 @@ export class ResourceListComponent implements OnInit {
} }
return map; return map;
} }
} }

View File

@ -1,5 +1,4 @@
import { Resource } from '../is-model/reference/entities/Resource'; import { Resource } from '../is-model/reference/entities/Resource';
import { Facet } from '../is-model/reference/entities/Facet';
export const TYPE_PROPERTY_KEY = '@class'; export const TYPE_PROPERTY_KEY = '@class';
export const HEADER_PROPERTY_KEY = 'header'; export const HEADER_PROPERTY_KEY = 'header';
@ -8,9 +7,6 @@ export class ResourceIdentification {
public type: string; public type: string;
public mandatoryProperties: Set<string>; public mandatoryProperties: Set<string>;
public instances: Array<Facet>;
public resources: Array<Resource>; public resources: Array<Resource>;
private first = true; private first = true;
@ -18,23 +14,7 @@ export class ResourceIdentification {
constructor(type: string) { constructor(type: string) {
this.type = type; this.type = type;
this.mandatoryProperties = new Set<string>(); this.mandatoryProperties = new Set<string>();
this.instances = new Array<any>(); this.resources = new Array<Resource>();
}
public addFacet(facet: Facet) {
if (this.first) {
for (const propertyKey in facet) {
if (propertyKey.localeCompare(TYPE_PROPERTY_KEY) === 0) {
continue;
}
if (propertyKey.localeCompare(HEADER_PROPERTY_KEY) === 0) {
continue;
}
this.mandatoryProperties.add(propertyKey);
}
this.first = false;
}
this.instances.push(facet);
} }
public addResource(resource: Resource) { public addResource(resource: Resource) {

View File

@ -1,166 +1,166 @@
import { TypeDefinition } from './ISType'; import { TypeDefinition } from './is-model/types/TypeDefinition';
export const types: TypeDefinition[] = [ export const types: TypeDefinition[] = [
{ {
"name": "Resource", name: 'Resource',
"description": null, description: null,
"superClasses": [ superClasses: [
"Entity" 'Entity'
], ],
"properties": [], properties: [],
"abstract": true abstract: true
}, },
{ {
"name": "Service", name: 'Service',
"description": null, description: null,
"superClasses": [ superClasses: [
"Resource" 'Resource'
], ],
"properties": [], properties: [],
"abstract": true abstract: true
}, },
{ {
"name": "ConfigurationTemplate", name: 'ConfigurationTemplate',
"description": null, description: null,
"superClasses": [ superClasses: [
"Resource" 'Resource'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Dataset", name: 'Dataset',
"description": null, description: null,
"superClasses": [ superClasses: [
"Resource" 'Resource'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "ConcreteDataset", name: 'ConcreteDataset',
"description": null, description: null,
"superClasses": [ superClasses: [
"Dataset" 'Dataset'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "HostingNode", name: 'HostingNode',
"description": null, description: null,
"superClasses": [ superClasses: [
"Service" 'Service'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "VirtualService", name: 'VirtualService',
"description": null, description: null,
"superClasses": [ superClasses: [
"Service" 'Service'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "EService", name: 'EService',
"description": null, description: null,
"superClasses": [ superClasses: [
"Service" 'Service'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "RunningPlugin", name: 'RunningPlugin',
"description": null, description: null,
"superClasses": [ superClasses: [
"EService" 'EService'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Software", name: 'Software',
"description": null, description: null,
"superClasses": [ superClasses: [
"Resource" 'Resource'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Schema", name: 'Schema',
"description": null, description: null,
"superClasses": [ superClasses: [
"Resource" 'Resource'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Configuration", name: 'Configuration',
"description": null, description: null,
"superClasses": [ superClasses: [
"ConfigurationTemplate" 'ConfigurationTemplate'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "LegalBody", name: 'LegalBody',
"description": null, description: null,
"superClasses": [ superClasses: [
"Actor" 'Actor'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "VirtualMachine", name: 'VirtualMachine',
"description": null, description: null,
"superClasses": [ superClasses: [
"Service" 'Service'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Site", name: 'Site',
"description": null, description: null,
"superClasses": [ superClasses: [
"Resource" 'Resource'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Person", name: 'Person',
"description": null, description: null,
"superClasses": [ superClasses: [
"Actor" 'Actor'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Plugin", name: 'Plugin',
"description": null, description: null,
"superClasses": [ superClasses: [
"Software" 'Software'
], ],
"properties": [], properties: [],
"abstract": false abstract: false
}, },
{ {
"name": "Actor", name: 'Actor',
"description": null, description: null,
"superClasses": [ superClasses: [
"Resource" 'Resource'
], ],
"properties": [], properties: [],
"abstract": true abstract: true
} }
]; ];