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;
description: string | null;
abstract: boolean;
superClasses?: Set<string>;
superClasses?: Array<string>;
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;">
<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>
<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>
<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 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) }}
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let resource of resourceIdentification.resources">
<td>{{ resource.header.uuid }}</td>
<td>{{ resource['@class'] }}</td>
<td *ngFor="let property of resource.consistsOf[0].target.mandatoryProperties">{{ resource.consistsOf[0].target[property] }}</td>
<tr *ngFor="let r of resources.get(key).resources">
<th>{{ r['@class'] }}</th>
<td>{{ r.header.uuid }}</td>
<td *ngFor="let property of resources.get(key).mandatoryProperties">{{ r.consistsOf[0].target[property] }}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,7 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { IsService } from '../is.service';
import { ResourceIdentification, TYPE_PROPERTY_KEY } from './resourceidentification';
import { Facet } from '../is-model/reference/entities/Facet';
import { Resource } from '../is-model/reference/entities/Resource';
@Component({
@ -11,42 +10,12 @@ import { Resource } from '../is-model/reference/entities/Resource';
})
export class ResourceListComponent implements OnInit {
public resourceIdentificationList: Array<ResourceIdentification>;
public resourcesByIdentificationFacets: Map<string, ResourceIdentification>;
public resources: Map<string, ResourceIdentification>;
constructor(private isService: IsService) { }
ngOnInit() {
// this.isService.getIdentifyingFacets('Service', facets => {this.identifyingFacets = facets;});
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;
this.isService.getResourceInstances('Service', res => { this.resources = this.analyseResources(res); });
}
analyseResources(resources: Resource[]): Map<string, ResourceIdentification> {
@ -68,6 +37,7 @@ export class ResourceListComponent implements OnInit {
}
return map;
}
}

View File

@ -1,5 +1,4 @@
import { Resource } from '../is-model/reference/entities/Resource';
import { Facet } from '../is-model/reference/entities/Facet';
export const TYPE_PROPERTY_KEY = '@class';
export const HEADER_PROPERTY_KEY = 'header';
@ -8,9 +7,6 @@ export class ResourceIdentification {
public type: string;
public mandatoryProperties: Set<string>;
public instances: Array<Facet>;
public resources: Array<Resource>;
private first = true;
@ -18,23 +14,7 @@ export class ResourceIdentification {
constructor(type: string) {
this.type = type;
this.mandatoryProperties = new Set<string>();
this.instances = new Array<any>();
}
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);
this.resources = new Array<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[] = [
{
"name": "Resource",
"description": null,
"superClasses": [
"Entity"
name: 'Resource',
description: null,
superClasses: [
'Entity'
],
"properties": [],
"abstract": true
properties: [],
abstract: true
},
{
"name": "Service",
"description": null,
"superClasses": [
"Resource"
name: 'Service',
description: null,
superClasses: [
'Resource'
],
"properties": [],
"abstract": true
properties: [],
abstract: true
},
{
"name": "ConfigurationTemplate",
"description": null,
"superClasses": [
"Resource"
name: 'ConfigurationTemplate',
description: null,
superClasses: [
'Resource'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Dataset",
"description": null,
"superClasses": [
"Resource"
name: 'Dataset',
description: null,
superClasses: [
'Resource'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "ConcreteDataset",
"description": null,
"superClasses": [
"Dataset"
name: 'ConcreteDataset',
description: null,
superClasses: [
'Dataset'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "HostingNode",
"description": null,
"superClasses": [
"Service"
name: 'HostingNode',
description: null,
superClasses: [
'Service'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "VirtualService",
"description": null,
"superClasses": [
"Service"
name: 'VirtualService',
description: null,
superClasses: [
'Service'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "EService",
"description": null,
"superClasses": [
"Service"
name: 'EService',
description: null,
superClasses: [
'Service'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "RunningPlugin",
"description": null,
"superClasses": [
"EService"
name: 'RunningPlugin',
description: null,
superClasses: [
'EService'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Software",
"description": null,
"superClasses": [
"Resource"
name: 'Software',
description: null,
superClasses: [
'Resource'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Schema",
"description": null,
"superClasses": [
"Resource"
name: 'Schema',
description: null,
superClasses: [
'Resource'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Configuration",
"description": null,
"superClasses": [
"ConfigurationTemplate"
name: 'Configuration',
description: null,
superClasses: [
'ConfigurationTemplate'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "LegalBody",
"description": null,
"superClasses": [
"Actor"
name: 'LegalBody',
description: null,
superClasses: [
'Actor'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "VirtualMachine",
"description": null,
"superClasses": [
"Service"
name: 'VirtualMachine',
description: null,
superClasses: [
'Service'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Site",
"description": null,
"superClasses": [
"Resource"
name: 'Site',
description: null,
superClasses: [
'Resource'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Person",
"description": null,
"superClasses": [
"Actor"
name: 'Person',
description: null,
superClasses: [
'Actor'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Plugin",
"description": null,
"superClasses": [
"Software"
name: 'Plugin',
description: null,
superClasses: [
'Software'
],
"properties": [],
"abstract": false
properties: [],
abstract: false
},
{
"name": "Actor",
"description": null,
"superClasses": [
"Resource"
name: 'Actor',
description: null,
superClasses: [
'Resource'
],
"properties": [],
"abstract": true
properties: [],
abstract: true
}
];
];