Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #86 from gchq/gh-63-update-schema-builder
Browse files Browse the repository at this point in the history
Gh 63 update schema builder
  • Loading branch information
p013570 committed Apr 3, 2017
2 parents 9bccd9f + 7f8e8a6 commit e5fcf0a
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 41 deletions.
9 changes: 4 additions & 5 deletions schema-builder/schema-builder-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/platform-server": "^4.0.0",
"@angular/router": "^4.0.0",
"@types/lodash": "4.14.58",
"@types/lodash": "4.14.59",
"@types/vis": "4.17.4",
"angular2-prettyjson": "2.0.5",
"angular2-uuid": "1.1.1",
"core-js": "2.4.1",
Expand All @@ -42,9 +43,8 @@
},
"devDependencies": {
"@angular/cli": "^1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/hammerjs": "2.0.34",
"@types/jasmine": "2.5.46",
"@types/jasmine": "2.5.47",
"@types/node": "7.0.12",
"awesome-typescript-loader": "3.1.2",
"codelyzer": "3.0.0-beta.4",
Expand All @@ -57,8 +57,7 @@
"karma-remap-istanbul": "0.6.0",
"protractor": "5.1.1",
"ts-node": "3.0.2",
"tslint": "4.5.1",
"typescript": "2.2.2",
"tslint": "5.0.0",
"webdriver-manager": "12.0.4"
}
}
7 changes: 6 additions & 1 deletion schema-builder/schema-builder-ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ import { Router, ActivatedRoute } from '@angular/router';

import * as _ from 'lodash';

export interface RouteLink {
title: string,
route: string
}

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent implements AfterViewInit {
activeLinkIndex: number;
pages: Array<any> = [
pages: Array<RouteLink> = [
{ title: "Graph", route: "graph" },
{ title: "Properties", route: "properties" },
{ title: "Types", route: "types" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

import { Component, OnInit, Input } from '@angular/core';
import { LocalStorageService } from 'ng2-webstorage';
import { DataSet, Network, Edge } from '@types/vis';
import { NodeEntities } from '../../shared/node-entities.interface';
import { GraphQLType } from '../../shared/graphql-type.interface';
import { FormBuilder } from '@angular/forms';
import * as _ from 'lodash';

Expand All @@ -26,11 +29,11 @@ import * as _ from 'lodash';
providers: [FormBuilder]
})
export class EdgeFormComponent implements OnInit {
_edge: any;
_edges: any;
_nodes: any;
_network: any;
_storedTypes: any;
_edge: Edge;
_edges: DataSet<Edge>;
_nodes: DataSet<NodeEntities>;
_network: Network;
_storedTypes: Array<GraphQLType>;
nodeOptions: any;
form: any;

Expand All @@ -48,7 +51,7 @@ export class EdgeFormComponent implements OnInit {
get nodes() { return this._nodes; }

@Input()
set selectedEdge(selectedEdge: any) {
set selectedEdge(selectedEdge: string) {
this._edge = this._edges.get(selectedEdge);
this.updateForm(this._edge);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import { Component, OnInit, Input } from '@angular/core';
import { LocalStorageService } from 'ng2-webstorage';
import { FormBuilder } from '@angular/forms';
import { DataSet, Network } from '@types/vis';
import { NodeEntities } from '../../shared/node-entities.interface';
import { GraphQLEntity } from '../../shared/graphql-entity.interface';
import { GraphQLType } from '../../shared/graphql-type.interface';
import { UUID } from 'angular2-uuid';
import * as _ from 'lodash';

Expand All @@ -29,10 +33,10 @@ declare var $: any;
providers: [FormBuilder]
})
export class EntityFormComponent implements OnInit {
_node: any;
_nodes: any;
_storedTypes: any;
entities: any;
_node: NodeEntities;
_nodes: DataSet<NodeEntities>;
_storedTypes: Array<GraphQLType>;
entities: Array<GraphQLEntity>;
form: any;

@Input()
Expand All @@ -42,7 +46,7 @@ export class EntityFormComponent implements OnInit {
get nodes() { return this._nodes; }

@Input()
set selectedNode(selectedNode: any) {
set selectedNode(selectedNode: string) {
this._node = this._nodes.get(selectedNode);
this.entities = this._node.entities || [];
this.updateForm(this.entities);
Expand Down
21 changes: 13 additions & 8 deletions schema-builder/schema-builder-ui/src/app/graph/graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,28 @@

import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { DataSet, Network, Node, Edge, Options } from '@types/vis';
import { LocalStorageService } from 'ng2-webstorage';
import * as _ from 'lodash';
declare var vis: any;

export interface DataContainer {
nodes: DataSet<Node>,
edges: DataSet<Edge>
}

@Component({
selector: 'app-graph',
templateUrl: './graph.component.html',
styleUrls: ['./graph.component.css']
})
export class GraphComponent implements OnInit {
nodes: any;
edges: any;
network: any;
nodes: DataSet<Node>;
edges: DataSet<Edge>;
network: Network;
container: any;
events: any;
data: any;
options: any;
data: DataContainer;
options: Options;
selectedNode: Observable<string>;
selectedEdge: Observable<string>;

Expand All @@ -56,7 +61,7 @@ export class GraphComponent implements OnInit {

saveNodes(data, callback) {
if (data.label === 'new') {
data.label = 'node ' + (Object.keys(this.nodes._data).length + 1);
data.label = 'node ' + (this.nodes.get().length + 1);
}
callback(data);
this.storage.store('graphEdges', this.edges);
Expand All @@ -68,7 +73,7 @@ export class GraphComponent implements OnInit {
data.length = 200;
data.arrows = 'to';
if (data.label === undefined) {
data.label = 'edge ' + (Object.keys(this.edges._data).length + 1);
data.label = 'edge ' + (this.edges.get().length + 1);
}
}
callback(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import { Component, OnInit, Input } from '@angular/core';
import { LocalStorageService } from 'ng2-webstorage';
import { DataSet, Network } from '@types/vis';
import { NodeEntities } from '../../shared/node-entities.interface';
import { FormBuilder } from '@angular/forms';
import * as _ from 'lodash';
declare var $: any;
Expand All @@ -27,9 +29,9 @@ declare var $: any;
providers: [FormBuilder]
})
export class NodeFormComponent implements OnInit {
_node: any;
_nodes: any;
_network: any;
_node: NodeEntities;
_nodes: DataSet<NodeEntities>;
_network: Network;
form: any;

@Input()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

import { Component, OnInit } from '@angular/core';
import { LocalStorageService } from 'ng2-webstorage';
import { DataSet, Edge } from '@types/vis';
import { GraphQLType } from '../shared/graphql-type.interface';
import { NodeEntities } from '../shared/node-entities.interface';
import * as _ from 'lodash';

@Component({
Expand All @@ -24,9 +27,9 @@ import * as _ from 'lodash';
styleUrls: ['./properties.component.css']
})
export class PropertiesComponent implements OnInit {
edges: any;
nodes: any;
types: any;
edges: Array<Edge>;
nodes: Array<NodeEntities>;
types: Array<GraphQLType>;

constructor(private storage: LocalStorageService) { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ <h5 style="color:red;" *ngIf="validation && !validation.valid">
<span *ngIf="validation && validation.message">{{validation.message}}</span>
<span *ngIf="!validation || validation.message">Unknown validation error</span>
</h5>
<h5 style="color:red;" *ngIf="errorMessage">
<md-icon>close</md-icon>
<span>{{errorMessage}}</span>
</h5>
</div>
<div fxFlex>
<div fxFlex fxLayout="row">
<div fxFlex class="input-field">
<md-input-container class="full-width">
<input mdInput class="form-control" type="text" name="class" placeholder="Gaffer schema URL: <url>/rest/v1/graph/schema" [(ngModel)]="schemaUrl"
<input mdInput class="form-control" type="text" name="class" placeholder="Gaffer schema URL: <url>/rest/v1/graph/schema" mdTooltip="Gaffer schema URL: <url>/rest/v1/graph/schema" [(ngModel)]="schemaUrl"
(ngModelChange)="schemaUrlChanged()">
</md-input-container>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export class SchemaComponent implements OnInit {
commonTypes: any;
validation: any;

errorMessage: any;
errorMessageURL: any;
successURL: any;
errorMessage: string;
errorMessageURL: string;
successURL: string;

edgesById: any;
edgesByName: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface GraphQLAggregate {
class?: string,
separator?: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { GraphQLProperty } from './graphql-property.interface';

export interface GraphQLEntity {
id: string,
name: string,
properties?: Array<GraphQLProperty>,
editing?: boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface GraphQLProperty {
id: string,
name: string,
type: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { GraphQLAggregate } from './graphql-aggregate.interface';

export interface GraphQLType {
aggregateFunction?: GraphQLAggregate,
serialiserClass?: any,
validateFunctions?: Array<any>,
class?: string,
index?: number,
editing?: boolean,
node?: string,
type: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Node } from '@types/vis';

export interface NodeEntities extends Node {
entities?: Array<any>
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { LocalStorageService } from 'ng2-webstorage';
import { GraphQLType } from '../../shared/graphql-type.interface';
import { GafferService } from '../../services/gaffer.service';
import * as _ from 'lodash';

Expand All @@ -26,19 +27,21 @@ import * as _ from 'lodash';
providers: [GafferService]
})
export class TypeFormComponent implements OnInit {
_type: any;
_type: GraphQLType;
aggregateFields: any;
aggregateFieldsValid: any;
aggregateFieldsDisabled: any;
validationFields: any;
validateFieldsValid: any;
functions: any;
errorMessage: any;
errorMessage: string;

@Input()
set type(type: any) {
this._type = type;
if (!this._type.node && this._type.aggregateFunction !== null && this._type.aggregateFunction !== undefined && this._type.aggregateFunction.class !== 'NULL') {
if (!this._type.node && this._type.aggregateFunction !== null &&
this._type.aggregateFunction !== undefined && this._type.aggregateFunction !== null &&
this._type.aggregateFunction.class !== 'NULL') {
this.aggregateFields = _.cloneDeep(this._type.aggregateFunction);
this.aggregateFields.class = undefined;
this.aggregateFieldsDisabled = false;
Expand Down Expand Up @@ -86,6 +89,7 @@ export class TypeFormComponent implements OnInit {
} else {
this.functions = undefined;
}
this._type.aggregateFunction = {};
}

changeValidations(checked: boolean, validator: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Component, OnInit } from '@angular/core';
import { LocalStorageService } from 'ng2-webstorage';
import { GraphQLType } from '../shared/graphql-type.interface';
import { GafferService } from '../services/gaffer.service';

import * as _ from 'lodash';
Expand All @@ -28,7 +29,7 @@ import * as _ from 'lodash';
})
export class TypesComponent implements OnInit {

types: Array<any>;
types: Array<GraphQLType>;
nodeTypes: Array<any>;
errorMessage: any;

Expand Down
5 changes: 3 additions & 2 deletions schema-builder/schema-builder-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016"
]
"es6"
],
"target": "es6"
}
}

0 comments on commit e5fcf0a

Please sign in to comment.