-
+ >
+
+
+
diff --git a/src/app/components/settings/settings.component.spec.ts b/src/app/components/settings/settings.component.spec.ts
index 4b7ecaef..1229b8f7 100644
--- a/src/app/components/settings/settings.component.spec.ts
+++ b/src/app/components/settings/settings.component.spec.ts
@@ -45,7 +45,8 @@ describe('SettingsComponent', () => {
it('should get and save new settings', () => {
const settings = {
'crash_reports': true,
- 'experimental_features': true
+ 'experimental_features': true,
+ 'angular_map': false
};
const getAll = spyOn(settingsService, 'getAll').and.returnValue(settings);
const setAll = spyOn(settingsService, 'setAll');
diff --git a/src/app/services/link.service.ts b/src/app/services/link.service.ts
index 06b262c3..5048cb8c 100644
--- a/src/app/services/link.service.ts
+++ b/src/app/services/link.service.ts
@@ -5,6 +5,8 @@ import 'rxjs/add/operator/map';
import { Server } from "../models/server";
import { HttpServer } from "./http-server.service";
import {Port} from "../models/port";
+import { Link } from '../models/link';
+import { LinkNode } from '../models/link-node';
@Injectable()
export class LinkService {
@@ -33,4 +35,27 @@ export class LinkService {
]});
}
+ updateNodes(
+ server: Server, link: Link, nodes: LinkNode[]) {
+ const requestNodes = nodes.map((linkNode) => {
+ return {
+ node_id: linkNode.node_id,
+ port_number: linkNode.port_number,
+ adapter_number: linkNode.adapter_number,
+ label: {
+ rotation: linkNode.label.rotation,
+ style: linkNode.label.style,
+ text: linkNode.label.text,
+ x: linkNode.label.x,
+ y: linkNode.label.y
+ }
+ }
+ });
+
+ return this.httpServer
+ .put(
+ server,
+ `/projects/${link.project_id}/links/${link.link_id}`,
+ {"nodes": requestNodes});
+ }
}
diff --git a/src/app/services/node.service.spec.ts b/src/app/services/node.service.spec.ts
index 565efe5b..b3b8ff39 100644
--- a/src/app/services/node.service.spec.ts
+++ b/src/app/services/node.service.spec.ts
@@ -10,6 +10,7 @@ import { NodeService } from './node.service';
import { Appliance } from '../models/appliance';
import { Project } from '../models/project';
import { AppTestingModule } from "../testing/app-testing/app-testing.module";
+import { Label } from '../cartography/models/label';
describe('NodeService', () => {
let httpClient: HttpClient;
@@ -102,6 +103,35 @@ describe('NodeService', () => {
});
}));
+ it('should update label of node', inject([NodeService], (service: NodeService) => {
+ const node = new Node();
+ node.project_id = "myproject";
+ node.node_id = "id";
+
+ const label = new Label();
+ label.rotation = 10;
+ label.style = "my style";
+ label.text = "my text";
+ label.x = 10;
+ label.y = 20;
+
+ service.updateLabel(server, node, label).subscribe();
+
+ const req = httpTestingController.expectOne(
+ 'http://127.0.0.1:3080/v2/projects/myproject/nodes/id');
+ expect(req.request.method).toEqual("PUT");
+ expect(req.request.body).toEqual({
+ 'label': {
+ 'rotation': 10,
+ 'style': 'my style',
+ 'text': 'my text',
+ 'x': 10,
+ 'y': 20,
+ }
+ });
+ }));
+
+
it('should update node', inject([NodeService], (service: NodeService) => {
const node = new Node();
node.project_id = "myproject";
diff --git a/src/app/services/node.service.ts b/src/app/services/node.service.ts
index a2c1b80b..28c5a4b7 100644
--- a/src/app/services/node.service.ts
+++ b/src/app/services/node.service.ts
@@ -7,6 +7,7 @@ import 'rxjs/add/operator/map';
import { Server } from "../models/server";
import { HttpServer } from "./http-server.service";
import {Appliance} from "../models/appliance";
+import { Label } from '../cartography/models/label';
@Injectable()
@@ -42,6 +43,19 @@ export class NodeService {
});
}
+ updateLabel(server: Server, node: Node, label: Label): Observable
{
+ return this.httpServer
+ .put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, {
+ 'label': {
+ 'rotation': label.rotation,
+ 'style': label.style,
+ 'text': label.text,
+ 'x': label.x,
+ 'y': label.y
+ }
+ });
+ }
+
update(server: Server, node: Node): Observable {
return this.httpServer
.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, {
diff --git a/src/app/services/settings.service.spec.ts b/src/app/services/settings.service.spec.ts
index 941158f9..ad911a9d 100644
--- a/src/app/services/settings.service.spec.ts
+++ b/src/app/services/settings.service.spec.ts
@@ -53,7 +53,8 @@ describe('SettingsService', () => {
it('should get all values', inject([SettingsService], (service: SettingsService) => {
expect(service.getAll()).toEqual({
'crash_reports': true,
- 'experimental_features': false
+ 'experimental_features': false,
+ 'angular_map': false
});
}));
@@ -65,7 +66,8 @@ describe('SettingsService', () => {
expect(service.getAll()).toEqual({
'crash_reports': false,
- 'experimental_features': false
+ 'experimental_features': false,
+ 'angular_map': false
});
}));
diff --git a/src/app/services/settings.service.ts b/src/app/services/settings.service.ts
index aa74a5af..aca6dea2 100644
--- a/src/app/services/settings.service.ts
+++ b/src/app/services/settings.service.ts
@@ -1,12 +1,12 @@
import { Injectable } from '@angular/core';
import { PersistenceService, StorageType } from "angular-persistence";
-import { Subject } from "rxjs";
import { BehaviorSubject } from "rxjs";
export interface Settings {
crash_reports: boolean;
experimental_features: boolean;
+ angular_map: boolean;
}
@@ -14,7 +14,8 @@ export interface Settings {
export class SettingsService {
static DEFAULTS: Settings = {
'crash_reports': true,
- 'experimental_features': false
+ 'experimental_features': false,
+ 'angular_map': false
};
private settingsSubject: BehaviorSubject;
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index c7e44b00..02712c06 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -1,10 +1,18 @@
-// The file contents for the current environment will overwrite these during build.
-// The build system defaults to the dev environment which uses `environment.ts`, but if you do
-// `ng build --env=prod` then `environment.prod.ts` will be used instead.
-// The list of which env maps to which file can be found in `.angular-cli.json`.
+// This file can be replaced during build by using the `fileReplacements` array.
+// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
+// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false,
electron: false,
githubio: false
};
+
+/*
+ * For easier debugging in development mode, you can import the following file
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
+ *
+ * This import should be commented out in production mode because it will have a negative impact
+ * on performance if an error is thrown.
+ */
+// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
diff --git a/src/main.ts b/src/main.ts
index a9ca1caf..c7b673cf 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -8,4 +8,5 @@ if (environment.production) {
enableProdMode();
}
-platformBrowserDynamic().bootstrapModule(AppModule);
+platformBrowserDynamic().bootstrapModule(AppModule)
+ .catch(err => console.error(err));
diff --git a/src/polyfills.ts b/src/polyfills.ts
index 7831e97b..2d143481 100644
--- a/src/polyfills.ts
+++ b/src/polyfills.ts
@@ -11,7 +11,7 @@
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
- * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
+ * Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
@@ -34,29 +34,47 @@
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';
+/**
+ * If the application will be indexed by Google Search, the following is required.
+ * Googlebot uses a renderer based on Chrome 41.
+ * https://developers.google.com/search/docs/guides/rendering
+ **/
+// import 'core-js/es6/array';
+
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
-/** Evergreen browsers require these. **/
-import 'core-js/es6/reflect';
-import 'core-js/es7/reflect';
-
+/** IE10 and IE11 requires the following for the Reflect API. */
+// import 'core-js/es6/reflect';
/**
- * Required to support Web Animations `@angular/animation`.
- * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
+ * Web Animations `@angular/platform-browser/animations`
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
**/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ */
+ // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
+ // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
+ // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
+
+ /*
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
+ */
+// (window as any).__Zone_enable_cross_context_check = true;
/***************************************************************************************************
- * Zone JS is required by Angular itself.
+ * Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
-
/***************************************************************************************************
* APPLICATION IMPORTS
*/
diff --git a/src/test.ts b/src/test.ts
index cd612eeb..16317897 100644
--- a/src/test.ts
+++ b/src/test.ts
@@ -1,24 +1,14 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
-import 'zone.js/dist/long-stack-trace-zone';
-import 'zone.js/dist/proxy.js';
-import 'zone.js/dist/sync-test';
-import 'zone.js/dist/jasmine-patch';
-import 'zone.js/dist/async-test';
-import 'zone.js/dist/fake-async-test';
+import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
-// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
-declare const __karma__: any;
declare const require: any;
-// Prevent Karma from running prematurely.
-__karma__.loaded = function () {};
-
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
@@ -28,5 +18,3 @@ getTestBed().initTestEnvironment(
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
-// Finally, start Karma to run the tests.
-__karma__.start();
diff --git a/tsconfig.json b/tsconfig.json
index 72d54ded..90f316b6 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,18 +1,21 @@
{
"compileOnSave": false,
"compilerOptions": {
+ "baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
+ "module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
+ "importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
- "es2016",
+ "es2018",
"dom"
],
},
diff --git a/tslint.json b/tslint.json
index b1ed5170..6ddb6b29 100644
--- a/tslint.json
+++ b/tslint.json
@@ -11,10 +11,14 @@
"check-space"
],
"curly": true,
+ "deprecation": {
+ "severity": "warn"
+ },
"eofline": true,
"forin": true,
"import-blacklist": [
- true
+ true,
+ "rxjs/Rx"
],
"import-spacing": true,
"indent": [
@@ -61,11 +65,12 @@
],
"no-misused-new": true,
"no-non-null-assertion": true,
+ "no-redundant-jsdoc": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
- "no-trailing-whitespace": false,
+ "no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
@@ -80,7 +85,7 @@
],
"prefer-const": true,
"quotemark": [
- false,
+ true,
"single"
],
"radix": true,
@@ -102,7 +107,6 @@
"variable-declaration": "nospace"
}
],
- "typeof-compare": true,
"unified-signatures": true,
"variable-name": false,
"whitespace": [
@@ -113,18 +117,7 @@
"check-separator",
"check-type"
],
- "directive-selector": [
- true,
- "attribute",
- "app",
- "camelCase"
- ],
- "component-selector": [
- true,
- "element",
- "app",
- "kebab-case"
- ],
+ "no-output-on-prefix": true,
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
@@ -133,9 +126,6 @@
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
- "directive-class-suffix": true,
- "no-access-missing-member": true,
- "templates-use-public": true,
- "invoke-injectable": true
+ "directive-class-suffix": true
}
}