-
+ >
+
+
+
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
}
}
diff --git a/yarn.lock b/yarn.lock
index 16645d5d..307187ac 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -957,11 +957,6 @@ ansi-html@0.0.7:
resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
integrity sha1-gTWEAhliqenm/QOflA0S9WynhZ4=
-ansi-regex@*:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.0.0.tgz#70de791edf021404c3fd615aa89118ae0432e5a9"
- integrity sha512-iB5Dda8t/UqpPI/IjsejXu5jOGDrzn41wJyljwPH65VCIbk6+1BzFIMJGFwTNrYXT1CrD+B4l19U7awiQ8rk7w==
-
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
@@ -2864,7 +2859,7 @@ debug@^3.0.0, debug@^3.1.0:
dependencies:
ms "^2.1.1"
-debuglog@*, debuglog@^1.0.1:
+debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@@ -4631,7 +4626,7 @@ import-local@^2.0.0:
pkg-dir "^3.0.0"
resolve-cwd "^2.0.0"
-imurmurhash@*, imurmurhash@^0.1.4:
+imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@@ -5648,11 +5643,6 @@ lockfile@~1.0.2:
dependencies:
signal-exit "^3.0.2"
-lodash._baseindexof@*:
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
- integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
-
lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@@ -5661,33 +5651,11 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0"
lodash._root "~3.0.0"
-lodash._bindcallback@*:
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
- integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
-
-lodash._cacheindexof@*:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
- integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
-
-lodash._createcache@*:
- version "3.1.2"
- resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
- integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
- dependencies:
- lodash._getnative "^3.0.0"
-
lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
-lodash._getnative@*, lodash._getnative@^3.0.0:
- version "3.9.1"
- resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
- integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
-
lodash._root@~3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"
@@ -5713,11 +5681,6 @@ lodash.mergewith@^4.6.0:
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"
integrity sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==
-lodash.restparam@*:
- version "3.6.1"
- resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
- integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
-
lodash.tail@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664"
@@ -7722,7 +7685,7 @@ readable-stream@~2.1.5:
string_decoder "~0.10.x"
util-deprecate "~1.0.1"
-readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
+readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
integrity sha1-n6+jfShr5dksuuve4DDcm19AZ0c=
@@ -9457,7 +9420,7 @@ uuid@^3.0.1, uuid@^3.1.0, uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==
-validate-npm-package-license@*, validate-npm-package-license@^3.0.1:
+validate-npm-package-license@^3.0.1:
version "3.0.4"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==