Browse Source

Fix TS warnings. Update RPC shell widgets.

pull/2411/head
Igor Kulikov 7 years ago
parent
commit
ccfebce870
  1. 4
      application/src/main/data/json/system/widget_bundles/control_widgets.json
  2. 20
      ui-ngx/e2e/protractor.conf.js
  3. 20
      ui-ngx/extra-webpack.config.js
  4. 3754
      ui-ngx/package-lock.json
  5. 52
      ui-ngx/package.json
  6. 24
      ui-ngx/proxy.conf.js
  7. 4
      ui-ngx/src/app/app.component.ts
  8. 8
      ui-ngx/src/app/app.module.ts
  9. 4
      ui-ngx/src/app/core/api/data-aggregator.ts
  10. 2
      ui-ngx/src/app/core/auth/auth.actions.ts
  11. 2
      ui-ngx/src/app/core/auth/auth.models.ts
  12. 12
      ui-ngx/src/app/core/auth/auth.service.ts
  13. 208
      ui-ngx/src/app/core/css/css.js
  14. 4
      ui-ngx/src/app/core/http/admin.service.ts
  15. 2
      ui-ngx/src/app/core/http/asset.service.ts
  16. 4
      ui-ngx/src/app/core/http/attribute.service.ts
  17. 6
      ui-ngx/src/app/core/http/audit-log.service.ts
  18. 4
      ui-ngx/src/app/core/http/customer.service.ts
  19. 16
      ui-ngx/src/app/core/http/dashboard.service.ts
  20. 13
      ui-ngx/src/app/core/http/device.service.ts
  21. 4
      ui-ngx/src/app/core/http/entity-relation.service.ts
  22. 15
      ui-ngx/src/app/core/http/entity-view.service.ts
  23. 8
      ui-ngx/src/app/core/http/entity.service.ts
  24. 4
      ui-ngx/src/app/core/http/event.service.ts
  25. 12
      ui-ngx/src/app/core/http/rule-chain.service.ts
  26. 4
      ui-ngx/src/app/core/http/tenant.service.ts
  27. 9
      ui-ngx/src/app/core/http/user.service.ts
  28. 10
      ui-ngx/src/app/core/http/widget.service.ts
  29. 11
      ui-ngx/src/app/core/interceptors/global-http-interceptor.ts
  30. 13
      ui-ngx/src/app/core/services/item-buffer.service.ts
  31. 4
      ui-ngx/src/app/core/services/raf.service.ts
  32. 2
      ui-ngx/src/app/core/utils.ts
  33. 2
      ui-ngx/src/app/modules/home/components/alarm/alarm-table-header.component.html
  34. 1
      ui-ngx/src/app/modules/home/components/alarm/alarm-table-header.component.ts
  35. 2
      ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html
  36. 4
      ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.html
  37. 3
      ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts
  38. 3
      ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.ts
  39. 4
      ui-ngx/src/app/modules/home/components/entity/contact-based.component.ts
  40. 2
      ui-ngx/src/app/modules/home/components/entity/entities-table.component.html
  41. 4
      ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html
  42. 1
      ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts
  43. 2
      ui-ngx/src/app/modules/home/components/event/event-table-config.ts
  44. 4
      ui-ngx/src/app/modules/home/components/import-export/import-dialog.component.ts
  45. 2
      ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts
  46. 4
      ui-ngx/src/app/modules/home/components/relation/relation-table.component.html
  47. 2
      ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.html
  48. 2
      ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html
  49. 6
      ui-ngx/src/app/modules/home/components/widget/dialog/custom-dialog-container.component.ts
  50. 4
      ui-ngx/src/app/modules/home/components/widget/legend-config-panel.component.html
  51. 2
      ui-ngx/src/app/modules/home/components/widget/lib/alarm-status-filter-panel.component.html
  52. 1
      ui-ngx/src/app/modules/home/components/widget/lib/alarm-status-filter-panel.component.ts
  53. 2
      ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.html
  54. 24
      ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts
  55. 12
      ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.component.ts
  56. 10
      ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts
  57. 2
      ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.html
  58. 27
      ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts
  59. 3
      ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.models.ts
  60. 22
      ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts
  61. 180
      ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts
  62. 2
      ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.html
  63. 50
      ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts
  64. 4
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts
  65. 6
      ui-ngx/src/app/modules/home/home.component.html
  66. 2
      ui-ngx/src/app/modules/home/home.component.ts
  67. 10
      ui-ngx/src/app/modules/home/models/dashboard-component.models.ts
  68. 56
      ui-ngx/src/app/modules/home/models/widget-component.models.ts
  69. 4
      ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts
  70. 2
      ui-ngx/src/app/modules/home/pages/dashboard/states/manage-dashboard-states-dialog.component.html
  71. 8
      ui-ngx/src/app/modules/home/pages/dashboard/states/state-controller.component.ts
  72. 1
      ui-ngx/src/app/modules/home/pages/dashboard/states/states-component.directive.ts
  73. 2
      ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.html
  74. 30
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts
  75. 3
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts
  76. 1
      ui-ngx/src/app/modules/home/pages/rulechain/rulenode.component.ts
  77. 2
      ui-ngx/src/app/modules/home/pages/user/add-user-dialog.component.html
  78. 1
      ui-ngx/src/app/modules/home/pages/user/add-user-dialog.component.ts
  79. 10
      ui-ngx/src/app/modules/home/pages/widget/select-widget-type-dialog.component.html
  80. 2
      ui-ngx/src/app/modules/home/pages/widget/widget-editor.component.html
  81. 3
      ui-ngx/src/app/modules/home/pages/widget/widget-library.component.ts
  82. 4
      ui-ngx/src/app/modules/login/login-routing.module.ts
  83. 12
      ui-ngx/src/app/modules/login/pages/login/create-password.component.ts
  84. 7
      ui-ngx/src/app/modules/login/pages/login/login.component.ts
  85. 7
      ui-ngx/src/app/modules/login/pages/login/reset-password-request.component.ts
  86. 10
      ui-ngx/src/app/modules/login/pages/login/reset-password.component.ts
  87. 2
      ui-ngx/src/app/shared/components/breadcrumb.component.ts
  88. 6
      ui-ngx/src/app/shared/components/cheatsheet.component.ts
  89. 2
      ui-ngx/src/app/shared/components/entity/entity-list-select.component.ts
  90. 2
      ui-ngx/src/app/shared/components/entity/entity-select.component.ts
  91. 2
      ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts
  92. 3
      ui-ngx/src/app/shared/components/fab-toolbar.component.ts
  93. 1
      ui-ngx/src/app/shared/components/help.component.ts
  94. 33
      ui-ngx/src/app/shared/components/hotkeys.directive.ts
  95. 2
      ui-ngx/src/app/shared/components/js-func.component.ts
  96. 2
      ui-ngx/src/app/shared/components/json-form/react/json-form-schema-form.tsx
  97. 2
      ui-ngx/src/app/shared/components/mat-chip-draggable.directive.ts
  98. 6
      ui-ngx/src/app/shared/components/nav-tree.component.ts
  99. 4
      ui-ngx/src/app/shared/components/page.component.ts
  100. 2
      ui-ngx/src/app/shared/components/time/timewindow-panel.component.html

4
application/src/main/data/json/system/widget_bundles/control_widgets.json

File diff suppressed because one or more lines are too long

20
ui-ngx/e2e/protractor.conf.js

@ -16,28 +16,28 @@
// Protractor configuration file, see link for more information // Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts // https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter'); const { SpecReporter } = require("jasmine-spec-reporter");
exports.config = { exports.config = {
allScriptsTimeout: 11000, allScriptsTimeout: 11000,
specs: [ specs: [
'./src/**/*.e2e-spec.ts' "./src/**/*.e2e-spec.ts",
], ],
capabilities: { capabilities: {
'browserName': 'chrome' "browserName": "chrome",
}, },
directConnect: true, directConnect: true,
baseUrl: 'http://localhost:4200/', baseUrl: "http://localhost:4200/",
framework: 'jasmine', framework: "jasmine",
jasmineNodeOpts: { jasmineNodeOpts: {
showColors: true, showColors: true,
defaultTimeoutInterval: 30000, defaultTimeoutInterval: 30000,
print: function() {} print: function() {},
}, },
onPrepare() { onPrepare() {
require('ts-node').register({ require("ts-node").register({
project: require('path').join(__dirname, './tsconfig.e2e.json') project: require("path").join(__dirname, "./tsconfig.e2e.json"),
}); });
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
} },
}; };

20
ui-ngx/extra-webpack.config.js

@ -13,23 +13,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
const CompressionPlugin = require('compression-webpack-plugin'); const CompressionPlugin = require("compression-webpack-plugin");
const webpack = require('webpack'); const webpack = require("webpack");
const dirTree = require('directory-tree'); const dirTree = require("directory-tree");
var langs = []; var langs = [];
dirTree('./src/assets/locale/', {extensions:/\.json$/}, (item) => { dirTree("./src/assets/locale/", {extensions: /\.json$/}, (item) => {
/* It is expected what the name of a locale file has the following format: */ /* It is expected what the name of a locale file has the following format: */
/* 'locale.constant-LANG_CODE[_REGION_CODE].json', e.g. locale.constant-es.json or locale.constant-zh_CN.json*/ /* 'locale.constant-LANG_CODE[_REGION_CODE].json', e.g. locale.constant-es.json or locale.constant-zh_CN.json*/
langs.push(item.name.slice(item.name.lastIndexOf('-') + 1, -5)); langs.push(item.name.slice(item.name.lastIndexOf("-") + 1, -5));
}); });
module.exports = { module.exports = {
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
TB_VERSION: JSON.stringify(require('./package.json').version), TB_VERSION: JSON.stringify(require("./package.json").version),
SUPPORTED_LANGS: JSON.stringify(langs) SUPPORTED_LANGS: JSON.stringify(langs),
}), }),
new CompressionPlugin({ new CompressionPlugin({
filename: "[path].gz[query]", filename: "[path].gz[query]",
@ -37,7 +37,7 @@ module.exports = {
test: /\.js$|\.css$|\.html$|\.svg?.+$|\.jpg$|\.ttf?.+$|\.woff?.+$|\.eot?.+$|\.json$/, test: /\.js$|\.css$|\.html$|\.svg?.+$|\.jpg$|\.ttf?.+$|\.woff?.+$|\.eot?.+$|\.json$/,
threshold: 10240, threshold: 10240,
minRatio: 0.8, minRatio: 0.8,
deleteOriginalAssets: false deleteOriginalAssets: false,
}) }),
] ],
}; };

3754
ui-ngx/package-lock.json

File diff suppressed because it is too large

52
ui-ngx/package.json

@ -25,24 +25,24 @@
"@angular/router": "~8.2.14", "@angular/router": "~8.2.14",
"@auth0/angular-jwt": "^3.0.1", "@auth0/angular-jwt": "^3.0.1",
"@date-io/date-fns": "^1.3.13", "@date-io/date-fns": "^1.3.13",
"@flowjs/flow.js": "^2.13.2", "@flowjs/flow.js": "^2.14.0",
"@flowjs/ngx-flow": "^0.4.3", "@flowjs/ngx-flow": "^0.4.3",
"@mat-datetimepicker/core": "^2.0.1", "@mat-datetimepicker/core": "^2.0.1",
"@material-ui/core": "^4.7.2", "@material-ui/core": "^4.9.1",
"@material-ui/icons": "^4.5.1", "@material-ui/icons": "^4.9.1",
"@material-ui/pickers": "^3.2.8", "@material-ui/pickers": "^3.2.10",
"@ngrx/effects": "^8.5.2", "@ngrx/effects": "^8.6.0",
"@ngrx/store": "^8.5.2", "@ngrx/store": "^8.6.0",
"@ngrx/store-devtools": "^8.5.2", "@ngrx/store-devtools": "^8.6.0",
"@ngx-share/core": "^7.1.4", "@ngx-share/core": "^7.1.4",
"@ngx-translate/core": "^11.0.1", "@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0", "@ngx-translate/http-loader": "^4.0.0",
"ace-builds": "^1.4.7", "ace-builds": "^1.4.8",
"angular-gridster2": "^8.2.0", "angular-gridster2": "^8.3.0",
"angular2-hotkeys": "^2.1.5", "angular2-hotkeys": "^2.1.5",
"base64-js": "^1.3.1", "base64-js": "^1.3.1",
"compass-sass-mixins": "^0.12.7", "compass-sass-mixins": "^0.12.7",
"core-js": "^3.5.0", "core-js": "^3.6.4",
"date-fns": "2.8.1", "date-fns": "2.8.1",
"deep-equal": "^1.1.1", "deep-equal": "^1.1.1",
"flot": "git://github.com/thingsboard/flot.git#0.9-work", "flot": "git://github.com/thingsboard/flot.git#0.9-work",
@ -51,8 +51,8 @@
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"javascript-detect-element-resize": "^0.5.3", "javascript-detect-element-resize": "^0.5.3",
"jquery": "^3.4.1", "jquery": "^3.4.1",
"jquery.terminal": "^2.9.0", "jquery.terminal": "^1.5.0",
"js-beautify": "^1.10.2", "js-beautify": "^1.10.3",
"json-schema-defaults": "^0.4.0", "json-schema-defaults": "^0.4.0",
"jstree": "^3.3.8", "jstree": "^3.3.8",
"jstree-bootstrap-theme": "^1.0.1", "jstree-bootstrap-theme": "^1.0.1",
@ -67,15 +67,15 @@
"objectpath": "^1.2.2", "objectpath": "^1.2.2",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"raphael": "^2.3.0", "raphael": "^2.3.0",
"rc-select": "^9.2.1", "rc-select": "^9.2.3",
"react": "^16.12.0", "react": "^16.12.0",
"react-ace": "^8.0.0", "react-ace": "^8.0.0",
"react-dom": "^16.12.0", "react-dom": "^16.12.0",
"react-dropzone": "^10.2.1", "react-dropzone": "^10.2.1",
"reactcss": "^1.2.3", "reactcss": "^1.2.3",
"rxjs": "~6.5.3", "rxjs": "^6.5.4",
"schema-inspector": "^1.6.8", "schema-inspector": "^1.6.9",
"screenfull": "^5.0.0", "screenfull": "^5.0.1",
"split.js": "^1.5.11", "split.js": "^1.5.11",
"systemjs": "0.21.5", "systemjs": "0.21.5",
"tinycolor2": "^1.4.1", "tinycolor2": "^1.4.1",
@ -87,24 +87,24 @@
}, },
"devDependencies": { "devDependencies": {
"@angular-builders/custom-webpack": "^8.4.1", "@angular-builders/custom-webpack": "^8.4.1",
"@angular-devkit/build-angular": "^0.803.20", "@angular-devkit/build-angular": "^0.803.24",
"@angular/cli": "~8.3.20", "@angular/cli": "^8.3.24",
"@angular/compiler-cli": "~8.2.14", "@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14", "@angular/language-service": "~8.2.14",
"@types/flot": "0.0.31", "@types/flot": "0.0.31",
"@types/jasmine": "~3.5.0", "@types/jasmine": "^3.5.2",
"@types/jasminewd2": "~2.0.8", "@types/jasminewd2": "~2.0.8",
"@types/jquery": "^3.3.31", "@types/jquery": "^3.3.31",
"@types/js-beautify": "^1.8.1", "@types/js-beautify": "^1.8.1",
"@types/jstree": "^3.3.39", "@types/jstree": "^3.3.39",
"@types/node": "~12.12.17", "@types/node": "^12.12.26",
"@types/raphael": "^2.1.30", "@types/raphael": "^2.1.30",
"@types/react": "^16.9.16", "@types/react": "^16.9.19",
"@types/react-dom": "^16.9.4", "@types/react-dom": "^16.9.5",
"@types/tinycolor2": "^1.4.2", "@types/tinycolor2": "^1.4.2",
"@types/tooltipster": "0.0.29", "@types/tooltipster": "0.0.29",
"codelyzer": "~5.2.0", "codelyzer": "^5.2.1",
"compression-webpack-plugin": "^3.0.1", "compression-webpack-plugin": "^3.1.0",
"directory-tree": "^2.2.4", "directory-tree": "^2.2.4",
"jasmine-core": "~3.5.0", "jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",
@ -112,9 +112,9 @@
"karma-chrome-launcher": "~3.1.0", "karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.1", "karma-coverage-istanbul-reporter": "~2.1.1",
"karma-jasmine": "~2.0.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2", "karma-jasmine-html-reporter": "^1.5.2",
"ngrx-store-freeze": "^0.2.4", "ngrx-store-freeze": "^0.2.4",
"protractor": "~5.4.2", "protractor": "^5.4.3",
"ts-node": "~8.5.4", "ts-node": "~8.5.4",
"tslint": "~5.20.1", "tslint": "~5.20.1",
"typescript": "~3.5.3" "typescript": "~3.5.3"

24
ui-ngx/proxy.conf.js

@ -14,22 +14,22 @@
* limitations under the License. * limitations under the License.
*/ */
const ruleNodeUiforwardHost = 'localhost'; const ruleNodeUiforwardHost = "localhost";
const ruleNodeUiforwardPort = 8080; const ruleNodeUiforwardPort = 8080;
const PROXY_CONFIG = { const PROXY_CONFIG = {
'/api': { "/api": {
'target': 'http://localhost:8080', "target": "http://localhost:8080",
'secure': false "secure": false,
}, },
'/static/rulenode': { "/static/rulenode": {
'target': `http://${ruleNodeUiforwardHost}:${ruleNodeUiforwardPort}`, "target": `http://${ruleNodeUiforwardHost}:${ruleNodeUiforwardPort}`,
'secure': false "secure": false,
}, },
'/api/ws': { "/api/ws": {
'target': 'ws://localhost:8080', "target": "ws://localhost:8080",
'ws': true "ws": true,
} },
} };
module.exports = PROXY_CONFIG; module.exports = PROXY_CONFIG;

4
ui-ngx/src/app/app.component.ts

@ -20,8 +20,8 @@ import { environment as env } from '@env/environment';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { select, Store } from '@ngrx/store'; import { select, Store } from '@ngrx/store';
import { AppState } from './core/core.state'; import { AppState } from '@core/core.state';
import { LocalStorageService } from './core/local-storage/local-storage.service'; import { LocalStorageService } from '@core/local-storage/local-storage.service';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { MatIconRegistry } from '@angular/material'; import { MatIconRegistry } from '@angular/material';
import { combineLatest } from 'rxjs'; import { combineLatest } from 'rxjs';

8
ui-ngx/src/app/app.module.ts

@ -19,12 +19,12 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { CoreModule } from './core/core.module'; import { CoreModule } from '@core/core.module';
import { LoginModule } from './modules/login/login.module'; import { LoginModule } from '@modules/login/login.module';
import { HomeModule } from './modules/home/home.module'; import { HomeModule } from '@home/home.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { DashboardRoutingModule } from './modules/dashboard/dashboard-routing.module'; import { DashboardRoutingModule } from '@modules/dashboard/dashboard-routing.module';
@NgModule({ @NgModule({
declarations: [ declarations: [

4
ui-ngx/src/app/core/api/data-aggregator.ts

@ -65,7 +65,7 @@ export class DataAggregator {
private dataBuffer: SubscriptionData = {}; private dataBuffer: SubscriptionData = {};
private data: SubscriptionData; private data: SubscriptionData;
private lastPrevKvPairData: {[key: string]: [number, any]}; private readonly lastPrevKvPairData: {[key: string]: [number, any]};
private aggregationMap: AggregationMap; private aggregationMap: AggregationMap;
@ -74,7 +74,7 @@ export class DataAggregator {
private noAggregation = this.aggregationType === AggregationType.NONE; private noAggregation = this.aggregationType === AggregationType.NONE;
private aggregationTimeout = Math.max(this.interval, 1000); private aggregationTimeout = Math.max(this.interval, 1000);
private aggFunction: AggFunction; private readonly aggFunction: AggFunction;
private intervalTimeoutHandle: Timeout; private intervalTimeoutHandle: Timeout;
private intervalScheduledTime: number; private intervalScheduledTime: number;

2
ui-ngx/src/app/core/auth/auth.actions.ts

@ -15,7 +15,7 @@
/// ///
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { AuthUser, User } from '../../shared/models/user.model'; import { User } from '@shared/models/user.model';
import { AuthPayload } from '@core/auth/auth.models'; import { AuthPayload } from '@core/auth/auth.models';
export enum AuthActionTypes { export enum AuthActionTypes {

2
ui-ngx/src/app/core/auth/auth.models.ts

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { AuthUser, User } from '../../shared/models/user.model'; import { AuthUser, User } from '@shared/models/user.model';
export interface AuthPayload { export interface AuthPayload {
authUser: AuthUser; authUser: AuthUser;

12
ui-ngx/src/app/core/auth/auth.service.ts

@ -18,19 +18,19 @@ import { Injectable, NgZone } from '@angular/core';
import { JwtHelperService } from '@auth0/angular-jwt'; import { JwtHelperService } from '@auth0/angular-jwt';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { combineLatest, forkJoin, Observable, of, throwError } from 'rxjs'; import { forkJoin, Observable, of, throwError } from 'rxjs';
import { catchError, distinctUntilChanged, filter, map, mergeMap, skip, tap } from 'rxjs/operators'; import { catchError, map, mergeMap, tap } from 'rxjs/operators';
import { LoginRequest, LoginResponse, PublicLoginRequest } from '../../shared/models/login.models'; import { LoginRequest, LoginResponse, PublicLoginRequest } from '@shared/models/login.models';
import { ActivatedRoute, Router, UrlTree } from '@angular/router'; import { ActivatedRoute, Router, UrlTree } from '@angular/router';
import { defaultHttpOptions } from '../http/http-utils'; import { defaultHttpOptions } from '../http/http-utils';
import { ReplaySubject } from 'rxjs/internal/ReplaySubject'; import { ReplaySubject } from 'rxjs/internal/ReplaySubject';
import { UserService } from '../http/user.service'; import { UserService } from '../http/user.service';
import { select, Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '../core.state'; import { AppState } from '../core.state';
import { ActionAuthAuthenticated, ActionAuthLoadUser, ActionAuthUnauthenticated } from './auth.actions'; import { ActionAuthAuthenticated, ActionAuthLoadUser, ActionAuthUnauthenticated } from './auth.actions';
import { getCurrentAuthState, getCurrentAuthUser, selectIsAuthenticated, selectIsUserLoaded } from './auth.selectors'; import { getCurrentAuthState, getCurrentAuthUser } from './auth.selectors';
import { Authority } from '../../shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
import { ActionSettingsChangeLanguage } from '@app/core/settings/settings.actions'; import { ActionSettingsChangeLanguage } from '@app/core/settings/settings.actions';
import { AuthPayload, AuthState } from '@core/auth/auth.models'; import { AuthPayload, AuthState } from '@core/auth/auth.models';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';

208
ui-ngx/src/app/core/css/css.js

@ -17,17 +17,17 @@
/* jshint unused:false */ /* jshint unused:false */
/* global base64_decode, CSSWizardView, window, console, jQuery */ /* global base64_decode, CSSWizardView, window, console, jQuery */
var fi = function () { var fi = function() {
this.cssImportStatements = []; this.cssImportStatements = [];
this.cssKeyframeStatements = []; this.cssKeyframeStatements = [];
this.cssRegex = new RegExp('([\\s\\S]*?){([\\s\\S]*?)}', 'gi'); this.cssRegex = new RegExp("([\\s\\S]*?){([\\s\\S]*?)}", "gi");
this.cssMediaQueryRegex = '((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})'; this.cssMediaQueryRegex = "((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})";
this.cssKeyframeRegex = '((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})'; this.cssKeyframeRegex = "((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})";
this.combinedCSSRegex = '((\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})'; //to match css & media queries together this.combinedCSSRegex = "((\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})"; //to match css & media queries together
this.cssCommentsRegex = '(\\/\\*[\\s\\S]*?\\*\\/)'; this.cssCommentsRegex = "(\\/\\*[\\s\\S]*?\\*\\/)";
this.cssImportStatementRegex = new RegExp('@import .*?;', 'gi'); this.cssImportStatementRegex = new RegExp("@import .*?;", "gi");
}; };
/* /*
@ -37,10 +37,10 @@ var fi = function () {
@return cleanedCSS contains no css comments @return cleanedCSS contains no css comments
*/ */
fi.prototype.stripComments = function (cssString) { fi.prototype.stripComments = function(cssString) {
var regex = new RegExp(this.cssCommentsRegex, 'gi'); var regex = new RegExp(this.cssCommentsRegex, "gi");
return cssString.replace(regex, ''); return cssString.replace(regex, "");
}; };
/* /*
@ -52,7 +52,7 @@ fi.prototype.stripComments = function (cssString) {
@return object css @return object css
*/ */
fi.prototype.parseCSS = function (source) { fi.prototype.parseCSS = function(source) {
if (source === undefined) { if (source === undefined) {
return []; return [];
@ -69,17 +69,17 @@ fi.prototype.parseCSS = function (source) {
if (imports !== null) { if (imports !== null) {
this.cssImportStatements.push(imports[0]); this.cssImportStatements.push(imports[0]);
css.push({ css.push({
selector: '@imports', selector: "@imports",
type: 'imports', type: "imports",
styles: imports[0] styles: imports[0],
}); });
} else { } else {
break; break;
} }
} }
source = source.replace(this.cssImportStatementRegex, ''); source = source.replace(this.cssImportStatementRegex, "");
//get keyframe statements //get keyframe statements
var keyframesRegex = new RegExp(this.cssKeyframeRegex, 'gi'); var keyframesRegex = new RegExp(this.cssKeyframeRegex, "gi");
var arr; var arr;
while (true) { while (true) {
arr = keyframesRegex.exec(source); arr = keyframesRegex.exec(source);
@ -87,44 +87,44 @@ fi.prototype.parseCSS = function (source) {
break; break;
} }
css.push({ css.push({
selector: '@keyframes', selector: "@keyframes",
type: 'keyframes', type: "keyframes",
styles: arr[0] styles: arr[0],
}); });
} }
source = source.replace(keyframesRegex, ''); source = source.replace(keyframesRegex, "");
//unified regex //unified regex
var unified = new RegExp(this.combinedCSSRegex, 'gi'); var unified = new RegExp(this.combinedCSSRegex, "gi");
while (true) { while (true) {
arr = unified.exec(source); arr = unified.exec(source);
if (arr === null) { if (arr === null) {
break; break;
} }
var selector = ''; var selector = "";
if (arr[2] === undefined) { if (arr[2] === undefined) {
selector = arr[5].split('\r\n').join('\n').trim(); selector = arr[5].split("\r\n").join("\n").trim();
} else { } else {
selector = arr[2].split('\r\n').join('\n').trim(); selector = arr[2].split("\r\n").join("\n").trim();
} }
/* /*
fetch comments and associate it with current selector fetch comments and associate it with current selector
*/ */
var commentsRegex = new RegExp(this.cssCommentsRegex, 'gi'); var commentsRegex = new RegExp(this.cssCommentsRegex, "gi");
var comments = commentsRegex.exec(selector); var comments = commentsRegex.exec(selector);
if (comments !== null) { if (comments !== null) {
selector = selector.replace(commentsRegex, '').trim(); selector = selector.replace(commentsRegex, "").trim();
} }
//determine the type //determine the type
if (selector.indexOf('@media') !== -1) { if (selector.indexOf("@media") !== -1) {
//we have a media query //we have a media query
var cssObject = { var cssObject = {
selector: selector, selector: selector,
type: 'media', type: "media",
subStyles: this.parseCSS(arr[3] + '\n}') //recursively parse media query inner css subStyles: this.parseCSS(arr[3] + "\n}"), //recursively parse media query inner css
}; };
if (comments !== null) { if (comments !== null) {
cssObject.comments = comments[0]; cssObject.comments = comments[0];
@ -135,10 +135,10 @@ fi.prototype.parseCSS = function (source) {
var rules = this.parseRules(arr[6]); var rules = this.parseRules(arr[6]);
var style = { var style = {
selector: selector, selector: selector,
rules: rules rules: rules,
}; };
if (selector === '@font-face') { if (selector === "@font-face") {
style.type = 'font-face'; style.type = "font-face";
} }
if (comments !== null) { if (comments !== null) {
style.comments = comments[0]; style.comments = comments[0];
@ -157,9 +157,9 @@ fi.prototype.parseCSS = function (source) {
@param rules, css directive string example @param rules, css directive string example
\n\ncolor:white;\n font-size:18px;\n \n\ncolor:white;\n font-size:18px;\n
*/ */
fi.prototype.parseRules = function (rules) { fi.prototype.parseRules = function(rules) {
//convert all windows style line endings to unix style line endings //convert all windows style line endings to unix style line endings
rules = rules.split('\r\n').join('\n'); rules = rules.split("\r\n").join("\n");
var ret = []; var ret = [];
// Split all rules but keep semicolon for base64 url data // Split all rules but keep semicolon for base64 url data
@ -171,11 +171,11 @@ fi.prototype.parseRules = function (rules) {
//determine if line is a valid css directive, ie color:white; //determine if line is a valid css directive, ie color:white;
line = line.trim(); line = line.trim();
if (line.indexOf(':') !== -1) { if (line.indexOf(":") !== -1) {
//line contains : //line contains :
line = line.split(':'); line = line.split(":");
var cssDirective = line[0].trim(); var cssDirective = line[0].trim();
var cssValue = line.slice(1).join(':').trim(); var cssValue = line.slice(1).join(":").trim();
//more checks //more checks
if (cssDirective.length < 1 || cssValue.length < 1) { if (cssDirective.length < 1 || cssValue.length < 1) {
@ -186,19 +186,19 @@ fi.prototype.parseRules = function (rules) {
//push rule //push rule
ret.push({ ret.push({
directive: cssDirective, directive: cssDirective,
value: cssValue value: cssValue,
}); });
} else { } else {
//if there is no ':', but what if it was mis splitted value which starts with base64 //if there is no ':', but what if it was mis splitted value which starts with base64
if (line.trim().substr(0, 7) == 'base64,') { //hack :) if (line.trim().substr(0, 7) == "base64,") { //hack :)
ret[ret.length - 1].value += line.trim(); ret[ret.length - 1].value += line.trim();
} else { } else {
//add rule, even if it is defective //add rule, even if it is defective
if (line.length > 0) { if (line.length > 0) {
ret.push({ ret.push({
directive: '', directive: "",
value: line, value: line,
defective: true defective: true,
}); });
} }
} }
@ -211,7 +211,7 @@ fi.prototype.parseRules = function (rules) {
just returns the rule having given directive just returns the rule having given directive
if not found returns false; if not found returns false;
*/ */
fi.prototype.findCorrespondingRule = function (rules, directive, value) { fi.prototype.findCorrespondingRule = function(rules, directive, value) {
if (value === undefined) { if (value === undefined) {
value = false; value = false;
} }
@ -231,7 +231,7 @@ fi.prototype.findCorrespondingRule = function (rules, directive, value) {
Finds styles that have given selector, compress them, Finds styles that have given selector, compress them,
and returns them and returns them
*/ */
fi.prototype.findBySelector = function (cssObjectArray, selector, contains) { fi.prototype.findBySelector = function(cssObjectArray, selector, contains) {
if (contains === undefined) { if (contains === undefined) {
contains = false; contains = false;
} }
@ -263,7 +263,7 @@ fi.prototype.findBySelector = function (cssObjectArray, selector, contains) {
/* /*
deletes cssObjects having given selector, and returns new array deletes cssObjects having given selector, and returns new array
*/ */
fi.prototype.deleteBySelector = function (cssObjectArray, selector) { fi.prototype.deleteBySelector = function(cssObjectArray, selector) {
var ret = []; var ret = [];
for (var i = 0; i < cssObjectArray.length; i++) { for (var i = 0; i < cssObjectArray.length; i++) {
if (cssObjectArray[i].selector !== selector) { if (cssObjectArray[i].selector !== selector) {
@ -277,7 +277,7 @@ fi.prototype.deleteBySelector = function (cssObjectArray, selector) {
Compresses given cssObjectArray and tries to minimize Compresses given cssObjectArray and tries to minimize
selector redundence. selector redundence.
*/ */
fi.prototype.compressCSS = function (cssObjectArray) { fi.prototype.compressCSS = function(cssObjectArray) {
var compressed = []; var compressed = [];
var done = {}; var done = {};
for (var i = 0; i < cssObjectArray.length; i++) { for (var i = 0; i < cssObjectArray.length; i++) {
@ -315,19 +315,19 @@ fi.prototype.compressCSS = function (cssObjectArray) {
@return diff css object contains changed values in css1 in regards to css2 see test input output in /test/data/css.js @return diff css object contains changed values in css1 in regards to css2 see test input output in /test/data/css.js
*/ */
fi.prototype.cssDiff = function (css1, css2) { fi.prototype.cssDiff = function(css1, css2) {
if (css1.selector !== css2.selector) { if (css1.selector !== css2.selector) {
return false; return false;
} }
//if one of them is media query return false, because diff function can not operate on media queries //if one of them is media query return false, because diff function can not operate on media queries
if ((css1.type === 'media' || css2.type === 'media')) { if ((css1.type === "media" || css2.type === "media")) {
return false; return false;
} }
var diff = { var diff = {
selector: css1.selector, selector: css1.selector,
rules: [] rules: [],
}; };
var rule1, rule2; var rule1, rule2;
for (var i = 0; i < css1.rules.length; i++) { for (var i = 0; i < css1.rules.length; i++) {
@ -352,12 +352,11 @@ fi.prototype.cssDiff = function (css1, css2) {
rule1 = this.findCorrespondingRule(css1.rules, rule2.directive); rule1 = this.findCorrespondingRule(css1.rules, rule2.directive);
if (rule1 === false) { if (rule1 === false) {
//rule1 is a new rule //rule1 is a new rule
rule2.type = 'DELETED'; //mark it as a deleted rule, so that other merge operations could be true rule2.type = "DELETED"; //mark it as a deleted rule, so that other merge operations could be true
diff.rules.push(rule2); diff.rules.push(rule2);
} }
} }
if (diff.rules.length === 0) { if (diff.rules.length === 0) {
return false; return false;
} }
@ -373,18 +372,17 @@ fi.prototype.cssDiff = function (css1, css2) {
@param reverse, [optional], if given true, first parameter will be traversed on reversed order @param reverse, [optional], if given true, first parameter will be traversed on reversed order
effectively giving priority to the styles in newArray effectively giving priority to the styles in newArray
*/ */
fi.prototype.intelligentMerge = function (cssObjectArray, newArray, reverse) { fi.prototype.intelligentMerge = function(cssObjectArray, newArray, reverse) {
if (reverse === undefined) { if (reverse === undefined) {
reverse = false; reverse = false;
} }
for (var i = 0; i < newArray.length; i++) { for (var i = 0; i < newArray.length; i++) {
this.intelligentCSSPush(cssObjectArray, newArray[i], reverse); this.intelligentCSSPush(cssObjectArray, newArray[i], reverse);
} }
for (i = 0; i < cssObjectArray.length; i++) { for (i = 0; i < cssObjectArray.length; i++) {
var cobj = cssObjectArray[i]; var cobj = cssObjectArray[i];
if (cobj.type === 'media' || (cobj.type === 'keyframes')) { if (cobj.type === "media" || (cobj.type === "keyframes")) {
continue; continue;
} }
cobj.rules = this.compactRules(cobj.rules); cobj.rules = this.compactRules(cobj.rules);
@ -400,7 +398,7 @@ fi.prototype.intelligentMerge = function (cssObjectArray, newArray, reverse) {
@param reverse [optional] default is false, if given, cssObjectArray will be reversly traversed @param reverse [optional] default is false, if given, cssObjectArray will be reversly traversed
resulting more priority in minimalObject's styles resulting more priority in minimalObject's styles
*/ */
fi.prototype.intelligentCSSPush = function (cssObjectArray, minimalObject, reverse) { fi.prototype.intelligentCSSPush = function(cssObjectArray, minimalObject, reverse) {
var pushSelector = minimalObject.selector; var pushSelector = minimalObject.selector;
//find correct selector if not found just push minimalObject into cssObject //find correct selector if not found just push minimalObject into cssObject
var cssObject = false; var cssObject = false;
@ -428,15 +426,15 @@ fi.prototype.intelligentCSSPush = function (cssObjectArray, minimalObject, rever
if (cssObject === false) { if (cssObject === false) {
cssObjectArray.push(minimalObject); //just push, because cssSelector is new cssObjectArray.push(minimalObject); //just push, because cssSelector is new
} else { } else {
if (minimalObject.type !== 'media') { if (minimalObject.type !== "media") {
for (var ii = 0; ii < minimalObject.rules.length; ii++) { for (var ii = 0; ii < minimalObject.rules.length; ii++) {
var rule = minimalObject.rules[ii]; var rule = minimalObject.rules[ii];
//find rule inside cssObject //find rule inside cssObject
var oldRule = this.findCorrespondingRule(cssObject.rules, rule.directive); var oldRule = this.findCorrespondingRule(cssObject.rules, rule.directive);
if (oldRule === false) { if (oldRule === false) {
cssObject.rules.push(rule); cssObject.rules.push(rule);
} else if (rule.type == 'DELETED') { } else if (rule.type == "DELETED") {
oldRule.type = 'DELETED'; oldRule.type = "DELETED";
} else { } else {
//rule found just update value //rule found just update value
@ -457,10 +455,10 @@ fi.prototype.intelligentCSSPush = function (cssObjectArray, minimalObject, rever
@returns rules array, compacted by deleting all unneccessary rules @returns rules array, compacted by deleting all unneccessary rules
*/ */
fi.prototype.compactRules = function (rules) { fi.prototype.compactRules = function(rules) {
var newRules = []; var newRules = [];
for (var i = 0; i < rules.length; i++) { for (var i = 0; i < rules.length; i++) {
if (rules[i].type !== 'DELETED') { if (rules[i].type !== "DELETED") {
newRules.push(rules[i]); newRules.push(rules[i]);
} }
} }
@ -471,18 +469,18 @@ fi.prototype.compactRules = function (rules) {
@param [optional] cssBase, if given computes cssString from cssObject array @param [optional] cssBase, if given computes cssString from cssObject array
*/ */
fi.prototype.getCSSForEditor = function (cssBase, depth) { fi.prototype.getCSSForEditor = function(cssBase, depth) {
if (depth === undefined) { if (depth === undefined) {
depth = 0; depth = 0;
} }
var ret = ''; var ret = "";
if (cssBase === undefined) { if (cssBase === undefined) {
cssBase = this.css; cssBase = this.css;
} }
//append imports //append imports
for (var i = 0; i < cssBase.length; i++) { for (var i = 0; i < cssBase.length; i++) {
if (cssBase[i].type == 'imports') { if (cssBase[i].type == "imports") {
ret += cssBase[i].styles + '\n\n'; ret += cssBase[i].styles + "\n\n";
} }
} }
for (i = 0; i < cssBase.length; i++) { for (i = 0; i < cssBase.length; i++) {
@ -492,34 +490,34 @@ fi.prototype.getCSSForEditor = function (cssBase, depth) {
} }
var comments = ""; var comments = "";
if (tmp.comments !== undefined) { if (tmp.comments !== undefined) {
comments = tmp.comments + '\n'; comments = tmp.comments + "\n";
} }
if (tmp.type == 'media') { //also put media queries to output if (tmp.type == "media") { //also put media queries to output
ret += comments + tmp.selector + '{\n'; ret += comments + tmp.selector + "{\n";
ret += this.getCSSForEditor(tmp.subStyles, depth + 1); ret += this.getCSSForEditor(tmp.subStyles, depth + 1);
ret += '}\n\n'; ret += "}\n\n";
} else if (tmp.type !== 'keyframes' && tmp.type !== 'imports') { } else if (tmp.type !== "keyframes" && tmp.type !== "imports") {
ret += this.getSpaces(depth) + comments + tmp.selector + ' {\n'; ret += this.getSpaces(depth) + comments + tmp.selector + " {\n";
ret += this.getCSSOfRules(tmp.rules, depth + 1); ret += this.getCSSOfRules(tmp.rules, depth + 1);
ret += this.getSpaces(depth) + '}\n\n'; ret += this.getSpaces(depth) + "}\n\n";
} }
} }
//append keyFrames //append keyFrames
for (i = 0; i < cssBase.length; i++) { for (i = 0; i < cssBase.length; i++) {
if (cssBase[i].type == 'keyframes') { if (cssBase[i].type == "keyframes") {
ret += cssBase[i].styles + '\n\n'; ret += cssBase[i].styles + "\n\n";
} }
} }
return ret; return ret;
}; };
fi.prototype.getImports = function (cssObjectArray) { fi.prototype.getImports = function(cssObjectArray) {
var imps = []; var imps = [];
for (var i = 0; i < cssObjectArray.length; i++) { for (var i = 0; i < cssObjectArray.length; i++) {
if (cssObjectArray[i].type == 'imports') { if (cssObjectArray[i].type == "imports") {
imps.push(cssObjectArray[i].styles); imps.push(cssObjectArray[i].styles);
} }
} }
@ -529,30 +527,30 @@ fi.prototype.getImports = function (cssObjectArray) {
given rules array, returns visually formatted css string given rules array, returns visually formatted css string
to be used inside editor to be used inside editor
*/ */
fi.prototype.getCSSOfRules = function (rules, depth) { fi.prototype.getCSSOfRules = function(rules, depth) {
var ret = ''; var ret = "";
for (var i = 0; i < rules.length; i++) { for (var i = 0; i < rules.length; i++) {
if (rules[i] === undefined) { if (rules[i] === undefined) {
continue; continue;
} }
if (rules[i].defective === undefined) { if (rules[i].defective === undefined) {
ret += this.getSpaces(depth) + rules[i].directive + ' : ' + rules[i].value + ';\n'; ret += this.getSpaces(depth) + rules[i].directive + " : " + rules[i].value + ";\n";
} else { } else {
ret += this.getSpaces(depth) + rules[i].value + ';\n'; ret += this.getSpaces(depth) + rules[i].value + ";\n";
} }
} }
return ret || '\n'; return ret || "\n";
}; };
/* /*
A very simple helper function returns number of spaces appended in a single string, A very simple helper function returns number of spaces appended in a single string,
the number depends input parameter, namely input*2 the number depends input parameter, namely input*2
*/ */
fi.prototype.getSpaces = function (num) { fi.prototype.getSpaces = function(num) {
var ret = ''; var ret = "";
for (var i = 0; i < num * 4; i++) { for (var i = 0; i < num * 4; i++) {
ret += ' '; ret += " ";
} }
return ret; return ret;
}; };
@ -563,14 +561,14 @@ fi.prototype.getSpaces = function (num) {
@returns css string in which this.cssPreviewNamespace prepended @returns css string in which this.cssPreviewNamespace prepended
*/ */
fi.prototype.applyNamespacing = function (css, forcedNamespace) { fi.prototype.applyNamespacing = function(css, forcedNamespace) {
var cssObjectArray = css; var cssObjectArray = css;
var namespaceClass = '.' + this.cssPreviewNamespace; var namespaceClass = "." + this.cssPreviewNamespace;
if (forcedNamespace !== undefined) { if (forcedNamespace !== undefined) {
namespaceClass = forcedNamespace; namespaceClass = forcedNamespace;
} }
if (typeof css === 'string') { if (typeof css === "string") {
cssObjectArray = this.parseCSS(css); cssObjectArray = this.parseCSS(css);
} }
@ -578,21 +576,21 @@ fi.prototype.applyNamespacing = function (css, forcedNamespace) {
var obj = cssObjectArray[i]; var obj = cssObjectArray[i];
//bypass namespacing for @font-face @keyframes @import //bypass namespacing for @font-face @keyframes @import
if (obj.selector.indexOf('@font-face') > -1 || obj.selector.indexOf('keyframes') > -1 || obj.selector.indexOf('@import') > -1 || obj.selector.indexOf('.form-all') > -1 || obj.selector.indexOf('#stage') > -1) { if (obj.selector.indexOf("@font-face") > -1 || obj.selector.indexOf("keyframes") > -1 || obj.selector.indexOf("@import") > -1 || obj.selector.indexOf(".form-all") > -1 || obj.selector.indexOf("#stage") > -1) {
continue; continue;
} }
if (obj.type !== 'media') { if (obj.type !== "media") {
var selector = obj.selector.split(','); var selector = obj.selector.split(",");
var newSelector = []; var newSelector = [];
for (var j = 0; j < selector.length; j++) { for (var j = 0; j < selector.length; j++) {
if (selector[j].indexOf('.supernova') === -1) { //do not apply namespacing to selectors including supernova if (selector[j].indexOf(".supernova") === -1) { //do not apply namespacing to selectors including supernova
newSelector.push(namespaceClass + ' ' + selector[j]); newSelector.push(namespaceClass + " " + selector[j]);
} else { } else {
newSelector.push(selector[j]); newSelector.push(selector[j]);
} }
} }
obj.selector = newSelector.join(','); obj.selector = newSelector.join(",");
} else { } else {
obj.subStyles = this.applyNamespacing(obj.subStyles, forcedNamespace); //handle media queries as well obj.subStyles = this.applyNamespacing(obj.subStyles, forcedNamespace); //handle media queries as well
} }
@ -605,26 +603,26 @@ fi.prototype.applyNamespacing = function (css, forcedNamespace) {
given css string or object array, clears possible namespacing from given css string or object array, clears possible namespacing from
all of the selectors inside the css all of the selectors inside the css
*/ */
fi.prototype.clearNamespacing = function (css, returnObj) { fi.prototype.clearNamespacing = function(css, returnObj) {
if (returnObj === undefined) { if (returnObj === undefined) {
returnObj = false; returnObj = false;
} }
var cssObjectArray = css; var cssObjectArray = css;
var namespaceClass = '.' + this.cssPreviewNamespace; var namespaceClass = "." + this.cssPreviewNamespace;
if (typeof css === 'string') { if (typeof css === "string") {
cssObjectArray = this.parseCSS(css); cssObjectArray = this.parseCSS(css);
} }
for (var i = 0; i < cssObjectArray.length; i++) { for (var i = 0; i < cssObjectArray.length; i++) {
var obj = cssObjectArray[i]; var obj = cssObjectArray[i];
if (obj.type !== 'media') { if (obj.type !== "media") {
var selector = obj.selector.split(','); var selector = obj.selector.split(",");
var newSelector = []; var newSelector = [];
for (var j = 0; j < selector.length; j++) { for (var j = 0; j < selector.length; j++) {
newSelector.push(selector[j].split(namespaceClass + ' ').join('')); newSelector.push(selector[j].split(namespaceClass + " ").join(""));
} }
obj.selector = newSelector.join(','); obj.selector = newSelector.join(",");
} else { } else {
obj.subStyles = this.clearNamespacing(obj.subStyles, true); //handle media queries as well obj.subStyles = this.clearNamespacing(obj.subStyles, true); //handle media queries as well
} }
@ -641,17 +639,17 @@ fi.prototype.clearNamespacing = function (css, returnObj) {
creates a new style tag (also destroys the previous one) creates a new style tag (also destroys the previous one)
and injects given css string into that css tag and injects given css string into that css tag
*/ */
fi.prototype.createStyleElement = function (id, css, format) { fi.prototype.createStyleElement = function(id, css, format) {
if (format === undefined) { if (format === undefined) {
format = false; format = false;
} }
if (this.testMode === false && format !== 'nonamespace') { if (this.testMode === false && format !== "nonamespace") {
//apply namespacing classes //apply namespacing classes
css = this.applyNamespacing(css); css = this.applyNamespacing(css);
} }
if (typeof css != 'string') { if (typeof css != "string") {
css = this.getCSSForEditor(css); css = this.getCSSForEditor(css);
} }
//apply formatting for css //apply formatting for css
@ -660,7 +658,7 @@ fi.prototype.createStyleElement = function (id, css, format) {
} }
if (this.testMode !== false) { if (this.testMode !== false) {
return this.testMode('create style #' + id, css); //if test mode, just pass result to callback return this.testMode("create style #" + id, css); //if test mode, just pass result to callback
} }
var __el = document.getElementById(id); var __el = document.getElementById(id);
@ -668,11 +666,11 @@ fi.prototype.createStyleElement = function (id, css, format) {
__el.parentNode.removeChild(__el); __el.parentNode.removeChild(__el);
} }
var head = document.head || document.getElementsByTagName('head')[0], var head = document.head || document.getElementsByTagName("head")[0],
style = document.createElement('style'); style = document.createElement("style");
style.id = id; style.id = id;
style.type = 'text/css'; style.type = "text/css";
head.appendChild(style); head.appendChild(style);

4
ui-ngx/src/app/core/http/admin.service.ts

@ -15,8 +15,8 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { AdminSettings, MailServerSettings, SecuritySettings, UpdateMessage } from '@shared/models/settings.models'; import { AdminSettings, MailServerSettings, SecuritySettings, UpdateMessage } from '@shared/models/settings.models';

2
ui-ngx/src/app/core/http/asset.service.ts

@ -16,7 +16,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';

4
ui-ngx/src/app/core/http/attribute.service.ts

@ -15,8 +15,8 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { forkJoin, Observable, of } from 'rxjs/index'; import { forkJoin, Observable, of } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { EntityId } from '@shared/models/id/entity-id'; import { EntityId } from '@shared/models/id/entity-id';
import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetry.models'; import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetry.models';

6
ui-ngx/src/app/core/http/audit-log.service.ts

@ -15,10 +15,10 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink, TimePageLink } from '@shared/models/page/page-link'; import { TimePageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import { AuditLog } from '@shared/models/audit-log.models'; import { AuditLog } from '@shared/models/audit-log.models';
import { EntityId } from '@shared/models/id/entity-id'; import { EntityId } from '@shared/models/id/entity-id';

4
ui-ngx/src/app/core/http/customer.service.ts

@ -15,8 +15,8 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';

16
ui-ngx/src/app/core/http/dashboard.service.ts

@ -14,15 +14,15 @@
/// limitations under the License. /// limitations under the License.
/// ///
import {Inject, Injectable} from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable, ReplaySubject, Subject } from 'rxjs/index'; import { Observable } from 'rxjs';
import {HttpClient} from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import {PageLink} from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import {PageData} from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import {Dashboard, DashboardInfo} from '@shared/models/dashboard.models'; import { Dashboard, DashboardInfo } from '@shared/models/dashboard.models';
import {WINDOW} from '@core/services/window.service'; import { WINDOW } from '@core/services/window.service';
import { ActivationEnd, NavigationEnd, Router } from '@angular/router'; import { NavigationEnd, Router } from '@angular/router';
import { filter, map, publishReplay, refCount } from 'rxjs/operators'; import { filter, map, publishReplay, refCount } from 'rxjs/operators';
// @dynamic // @dynamic

13
ui-ngx/src/app/core/http/device.service.ts

@ -15,17 +15,14 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable, Subject, ReplaySubject } from 'rxjs/index'; import { Observable, ReplaySubject } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import { Tenant } from '@shared/models/tenant.model'; import { Device, DeviceCredentials, DeviceInfo, DeviceSearchQuery } from '@app/shared/models/device.models';
import {DashboardInfo, Dashboard} from '@shared/models/dashboard.models'; import { EntitySubtype } from '@app/shared/models/entity-type.models';
import {map} from 'rxjs/operators'; import { AuthService } from '@core/auth/auth.service';
import { DeviceInfo, Device, DeviceCredentials, DeviceSearchQuery } from '@app/shared/models/device.models';
import {EntitySubtype} from '@app/shared/models/entity-type.models';
import {AuthService} from '../auth/auth.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'

4
ui-ngx/src/app/core/http/entity-relation.service.ts

@ -15,8 +15,8 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { EntityRelation, EntityRelationInfo, EntityRelationsQuery } from '@shared/models/relation.models'; import { EntityRelation, EntityRelationInfo, EntityRelationsQuery } from '@shared/models/relation.models';
import { EntityId } from '@app/shared/models/id/entity-id'; import { EntityId } from '@app/shared/models/id/entity-id';

15
ui-ngx/src/app/core/http/entity-view.service.ts

@ -14,15 +14,14 @@
/// limitations under the License. /// limitations under the License.
/// ///
import {Injectable} from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import {Observable} from 'rxjs/index'; import { Observable } from 'rxjs';
import {HttpClient} from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import {PageLink} from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import {PageData} from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import {EntitySubtype} from '@app/shared/models/entity-type.models'; import { EntitySubtype } from '@app/shared/models/entity-type.models';
import { EntityView, EntityViewInfo, EntityViewSearchQuery } from '@app/shared/models/entity-view.models'; import { EntityView, EntityViewInfo, EntityViewSearchQuery } from '@app/shared/models/entity-view.models';
import { Asset, AssetSearchQuery } from '@shared/models/asset.models';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'

8
ui-ngx/src/app/core/http/entity.service.ts

@ -15,7 +15,7 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { EMPTY, forkJoin, Observable, of, throwError } from 'rxjs/index'; import { EMPTY, forkJoin, Observable, of, throwError } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { AliasEntityType, EntityType } from '@shared/models/entity-type.models'; import { AliasEntityType, EntityType } from '@shared/models/entity-type.models';
@ -28,7 +28,7 @@ import { UserService } from './user.service';
import { DashboardService } from '@core/http/dashboard.service'; import { DashboardService } from '@core/http/dashboard.service';
import { Direction } from '@shared/models/page/sort-order'; import { Direction } from '@shared/models/page/sort-order';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import { getCurrentAuthUser } from '../auth/auth.selectors'; import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { Authority } from '@shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
@ -44,7 +44,7 @@ import { AliasInfo, StateParams, SubscriptionInfo } from '@core/api/widget-api.m
import { Datasource, DatasourceType, KeyInfo } from '@app/shared/models/widget.models'; import { Datasource, DatasourceType, KeyInfo } from '@app/shared/models/widget.models';
import { UtilsService } from '@core/services/utils.service'; import { UtilsService } from '@core/services/utils.service';
import { AliasFilterType, EntityAlias, EntityAliasFilter, EntityAliasFilterResult } from '@shared/models/alias.models'; import { AliasFilterType, EntityAlias, EntityAliasFilter, EntityAliasFilterResult } from '@shared/models/alias.models';
import { EntityInfo, ImportEntityData, ImportEntitiesResultInfo } from '@shared/models/entity.models'; import { EntityInfo, ImportEntitiesResultInfo, ImportEntityData } from '@shared/models/entity.models';
import { import {
EntityRelationInfo, EntityRelationInfo,
EntityRelationsQuery, EntityRelationsQuery,
@ -52,7 +52,7 @@ import {
EntitySearchQuery EntitySearchQuery
} from '@shared/models/relation.models'; } from '@shared/models/relation.models';
import { EntityRelationService } from '@core/http/entity-relation.service'; import { EntityRelationService } from '@core/http/entity-relation.service';
import { isDefined } from '../utils'; import { isDefined } from '@core/utils';
import { Asset, AssetSearchQuery } from '@shared/models/asset.models'; import { Asset, AssetSearchQuery } from '@shared/models/asset.models';
import { Device, DeviceCredentialsType, DeviceSearchQuery } from '@shared/models/device.models'; import { Device, DeviceCredentialsType, DeviceSearchQuery } from '@shared/models/device.models';
import { EntityViewSearchQuery } from '@shared/models/entity-view.models'; import { EntityViewSearchQuery } from '@shared/models/entity-view.models';

4
ui-ngx/src/app/core/http/event.service.ts

@ -15,8 +15,8 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { TimePageLink } from '@shared/models/page/page-link'; import { TimePageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';

12
ui-ngx/src/app/core/http/rule-chain.service.ts

@ -16,22 +16,26 @@
import { ComponentFactory, Injectable } from '@angular/core'; import { ComponentFactory, Injectable } from '@angular/core';
import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { forkJoin, Observable, of } from 'rxjs/index'; import { forkJoin, Observable, of } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import { import {
ResolvedRuleChainMetaData, ResolvedRuleChainMetaData,
RuleChain, RuleChainConnectionInfo, RuleChain,
RuleChainConnectionInfo,
RuleChainMetaData, RuleChainMetaData,
ruleChainNodeComponent, ruleChainNodeComponent,
ruleNodeTypeComponentTypes, unknownNodeComponent ruleNodeTypeComponentTypes,
unknownNodeComponent
} from '@shared/models/rule-chain.models'; } from '@shared/models/rule-chain.models';
import { ComponentDescriptorService } from './component-descriptor.service'; import { ComponentDescriptorService } from './component-descriptor.service';
import { import {
IRuleNodeConfigurationComponent, IRuleNodeConfigurationComponent,
LinkLabel, LinkLabel,
RuleNodeComponentDescriptor, TestScriptInputParams, TestScriptResult RuleNodeComponentDescriptor,
TestScriptInputParams,
TestScriptResult
} from '@app/shared/models/rule-node.models'; } from '@app/shared/models/rule-node.models';
import { ResourcesService } from '../services/resources.service'; import { ResourcesService } from '../services/resources.service';
import { catchError, map, mergeMap } from 'rxjs/operators'; import { catchError, map, mergeMap } from 'rxjs/operators';

4
ui-ngx/src/app/core/http/tenant.service.ts

@ -15,8 +15,8 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';

9
ui-ngx/src/app/core/http/user.service.ts

@ -15,11 +15,10 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { User } from '../../shared/models/user.model'; import { User } from '@shared/models/user.model';
import { Observable } from 'rxjs/index'; import { Observable } from 'rxjs';
import { HttpClient, HttpResponse } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { AdminSettings } from '@shared/models/settings.models';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';

10
ui-ngx/src/app/core/http/widget.service.ts

@ -15,18 +15,18 @@
/// ///
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { defaultHttpOptions, defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils';
import { Observable, Subject, of, ReplaySubject } from 'rxjs/index'; import { Observable, of, ReplaySubject, Subject } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import { WidgetsBundle } from '@shared/models/widgets-bundle.model'; import { WidgetsBundle } from '@shared/models/widgets-bundle.model';
import { Widget, WidgetType, widgetType, WidgetTypeData, widgetTypesData } from '@shared/models/widget.models'; import { Widget, WidgetType, widgetType, widgetTypesData } from '@shared/models/widget.models';
import { UtilsService } from '@core/services/utils.service'; import { UtilsService } from '@core/services/utils.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ResourcesService } from '../services/resources.service'; import { ResourcesService } from '../services/resources.service';
import { toWidgetInfo, WidgetInfo, toWidgetType } from '@app/modules/home/models/widget-component.models'; import { toWidgetInfo, toWidgetType, WidgetInfo } from '@app/modules/home/models/widget-component.models';
import { map, tap, mergeMap, filter } from 'rxjs/operators'; import { filter, map, mergeMap, tap } from 'rxjs/operators';
import { WidgetTypeId } from '@shared/models/id/widget-type-id'; import { WidgetTypeId } from '@shared/models/id/widget-type-id';
import { NULL_UUID } from '@shared/models/id/has-uuid'; import { NULL_UUID } from '@shared/models/id/has-uuid';
import { ActivationEnd, Router } from '@angular/router'; import { ActivationEnd, Router } from '@angular/router';

11
ui-ngx/src/app/core/interceptors/global-http-interceptor.ts

@ -24,15 +24,15 @@ import {
} from '@angular/common/http'; } from '@angular/common/http';
import { Observable } from 'rxjs/internal/Observable'; import { Observable } from 'rxjs/internal/Observable';
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { AuthService } from '../auth/auth.service'; import { AuthService } from '@core/auth/auth.service';
import { Constants } from '../../shared/models/constants'; import { Constants } from '@shared/models/constants';
import { InterceptorHttpParams } from './interceptor-http-params'; import { InterceptorHttpParams } from './interceptor-http-params';
import {catchError, delay, switchMap, tap, map, mergeMap} from 'rxjs/operators'; import { catchError, delay, mergeMap, switchMap, tap } from 'rxjs/operators';
import { throwError } from 'rxjs/internal/observable/throwError'; import { throwError } from 'rxjs/internal/observable/throwError';
import { of } from 'rxjs/internal/observable/of'; import { of } from 'rxjs/internal/observable/of';
import { InterceptorConfig } from './interceptor-config'; import { InterceptorConfig } from './interceptor-config';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '../core.state'; import { AppState } from '@core/core.state';
import { ActionLoadFinish, ActionLoadStart } from './load.actions'; import { ActionLoadFinish, ActionLoadStart } from './load.actions';
import { ActionNotificationShow } from '@app/core/notification/notification.actions'; import { ActionNotificationShow } from '@app/core/notification/notification.actions';
import { DialogService } from '@core/services/dialog.service'; import { DialogService } from '@core/services/dialog.service';
@ -127,7 +127,8 @@ export class GlobalHttpInterceptor implements HttpInterceptor {
const resendRequest = config.resendRequest; const resendRequest = config.resendRequest;
const errorCode = errorResponse.error ? errorResponse.error.errorCode : null; const errorCode = errorResponse.error ? errorResponse.error.errorCode : null;
if (errorResponse.error && errorResponse.error.refreshTokenPending || errorResponse.status === 401) { if (errorResponse.error && errorResponse.error.refreshTokenPending || errorResponse.status === 401) {
if (errorResponse.error && errorResponse.error.refreshTokenPending || errorCode && errorCode === Constants.serverErrorCode.jwtTokenExpired) { if (errorResponse.error && errorResponse.error.refreshTokenPending ||
errorCode && errorCode === Constants.serverErrorCode.jwtTokenExpired) {
return this.refreshTokenAndRetry(req, next); return this.refreshTokenAndRetry(req, next);
} else if (errorCode !== Constants.serverErrorCode.credentialsExpired) { } else if (errorCode !== Constants.serverErrorCode.credentialsExpired) {
unhandled = true; unhandled = true;

13
ui-ngx/src/app/core/services/item-buffer.service.ts

@ -240,7 +240,10 @@ export class ItemBufferService {
nodes: [], nodes: [],
connections: [] connections: []
}; };
let top = -1, left = -1, bottom = -1, right = -1; let top = -1;
let left = -1;
let bottom = -1;
let right = -1;
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
const origNode = nodes[i]; const origNode = nodes[i];
const node: FcRuleNode = { const node: FcRuleNode = {
@ -253,7 +256,7 @@ export class ItemBufferService {
y: origNode.y, y: origNode.y,
name: origNode.name, name: origNode.name,
componentClazz: origNode.component.clazz, componentClazz: origNode.component.clazz,
} };
if (origNode.targetRuleChainId) { if (origNode.targetRuleChainId) {
node.targetRuleChainId = origNode.targetRuleChainId; node.targetRuleChainId = origNode.targetRuleChainId;
} }
@ -261,7 +264,7 @@ export class ItemBufferService {
node.error = origNode.error; node.error = origNode.error;
} }
ruleNodes.nodes.push(node); ruleNodes.nodes.push(node);
if (i==0) { if (i === 0) {
top = node.y; top = node.y;
left = node.x; left = node.x;
bottom = node.y + 50; bottom = node.y + 50;
@ -273,8 +276,8 @@ export class ItemBufferService {
right = Math.max(right, node.x + 170); right = Math.max(right, node.x + 170);
} }
} }
ruleNodes.originX = left + (right-left)/2; ruleNodes.originX = left + (right - left) / 2;
ruleNodes.originY = top + (bottom-top)/2; ruleNodes.originY = top + (bottom - top) / 2;
connections.forEach(connection => { connections.forEach(connection => {
ruleNodes.connections.push(connection); ruleNodes.connections.push(connection);
}); });

4
ui-ngx/src/app/core/services/raf.service.ts

@ -26,8 +26,8 @@ export type CancelAnimationFrame = () => void;
}) })
export class RafService { export class RafService {
private rafFunction: (frameCallback: () => void) => CancelAnimationFrame; private readonly rafFunction: (frameCallback: () => void) => CancelAnimationFrame;
private rafSupported: boolean; private readonly rafSupported: boolean;
constructor( constructor(
@Inject(WINDOW) private window: Window, @Inject(WINDOW) private window: Window,

2
ui-ngx/src/app/core/utils.ts

@ -400,5 +400,5 @@ export function snakeCase(name: string, separator: string): string {
} }
export function getDescendantProp(obj: any, path: string): any { export function getDescendantProp(obj: any, path: string): any {
return path.split('.').reduce((acc, part) => acc && acc[part], obj) return path.split('.').reduce((acc, part) => acc && acc[part], obj);
} }

2
ui-ngx/src/app/modules/home/components/alarm/alarm-table-header.component.html

@ -21,7 +21,7 @@
<mat-select matInput [ngModel]="alarmTableConfig.searchStatus" <mat-select matInput [ngModel]="alarmTableConfig.searchStatus"
(ngModelChange)="searchStatusChanged($event)"> (ngModelChange)="searchStatusChanged($event)">
<mat-option *ngFor="let status of alarmSearchStatusTypes" [value]="status"> <mat-option *ngFor="let status of alarmSearchStatusTypes" [value]="status">
{{ alarmSearchStatusTranslationsMap.get(status) | translate }} {{ alarmSearchStatusTranslationsMap.get(alarmSearchStatusEnum[status]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

1
ui-ngx/src/app/modules/home/components/alarm/alarm-table-header.component.ts

@ -31,6 +31,7 @@ export class AlarmTableHeaderComponent extends EntityTableHeaderComponent<AlarmI
alarmSearchStatusTranslationsMap = alarmSearchStatusTranslations; alarmSearchStatusTranslationsMap = alarmSearchStatusTranslations;
alarmSearchStatusTypes = Object.keys(AlarmSearchStatus); alarmSearchStatusTypes = Object.keys(AlarmSearchStatus);
alarmSearchStatusEnum = AlarmSearchStatus;
get alarmTableConfig(): AlarmTableConfig { get alarmTableConfig(): AlarmTableConfig {
return this.entitiesTableConfig as AlarmTableConfig; return this.entitiesTableConfig as AlarmTableConfig;

2
ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html

@ -15,7 +15,7 @@
limitations under the License. limitations under the License.
--> -->
<form #attributeForm="ngForm" [formGroup]="attributeFormGroup" (ngSubmit)="add()" style="min-width: 400px;"> <form [formGroup]="attributeFormGroup" (ngSubmit)="add()" style="min-width: 400px;">
<mat-toolbar fxLayout="row" color="primary"> <mat-toolbar fxLayout="row" color="primary">
<h2>{{ 'attribute.add' | translate }}</h2> <h2>{{ 'attribute.add' | translate }}</h2>
<span fxFlex></span> <span fxFlex></span>

4
ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.html

@ -26,7 +26,7 @@
matInput [ngModel]="attributeScope" matInput [ngModel]="attributeScope"
(ngModelChange)="attributeScopeChanged($event)"> (ngModelChange)="attributeScopeChanged($event)">
<mat-option *ngFor="let scope of attributeScopes" [value]="scope"> <mat-option *ngFor="let scope of attributeScopes" [value]="scope">
{{ telemetryTypeTranslationsMap.get(scope) | translate }} {{ telemetryTypeTranslationsMap.get(toTelemetryTypeFunc(scope)) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
@ -135,7 +135,7 @@
</mat-toolbar> </mat-toolbar>
<div fxFlex class="table-container" [fxShow]="mode !== 'widget'"> <div fxFlex class="table-container" [fxShow]="mode !== 'widget'">
<mat-table [dataSource]="dataSource" <mat-table [dataSource]="dataSource"
matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="(pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
<ng-container matColumnDef="select" sticky> <ng-container matColumnDef="select" sticky>
<mat-header-cell *matHeaderCellDef> <mat-header-cell *matHeaderCellDef>
<mat-checkbox (change)="$event ? dataSource.masterToggle() : null" <mat-checkbox (change)="$event ? dataSource.masterToggle() : null"

3
ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts

@ -45,7 +45,7 @@ import {
isClientSideTelemetryType, isClientSideTelemetryType,
LatestTelemetry, LatestTelemetry,
TelemetryType, TelemetryType,
telemetryTypeTranslations telemetryTypeTranslations, toTelemetryType
} from '@shared/models/telemetry/telemetry.models'; } from '@shared/models/telemetry/telemetry.models';
import { AttributeDatasource } from '@home/models/datasource/attribute-datasource'; import { AttributeDatasource } from '@home/models/datasource/attribute-datasource';
import { AttributeService } from '@app/core/http/attribute.service'; import { AttributeService } from '@app/core/http/attribute.service';
@ -98,6 +98,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
attributeScopes: Array<string> = []; attributeScopes: Array<string> = [];
attributeScope: TelemetryType; attributeScope: TelemetryType;
toTelemetryTypeFunc = toTelemetryType;
displayedColumns = ['select', 'lastUpdateTs', 'key', 'value']; displayedColumns = ['select', 'lastUpdateTs', 'key', 'value'];
pageLink: PageLink; pageLink: PageLink;

3
ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.ts

@ -36,7 +36,8 @@ import { Router } from '@angular/router';
providers: [{provide: ErrorStateMatcher, useExisting: AddEntityDialogComponent}], providers: [{provide: ErrorStateMatcher, useExisting: AddEntityDialogComponent}],
styleUrls: ['./add-entity-dialog.component.scss'] styleUrls: ['./add-entity-dialog.component.scss']
}) })
export class AddEntityDialogComponent extends DialogComponent<AddEntityDialogComponent, BaseData<HasId>> implements OnInit, ErrorStateMatcher { export class AddEntityDialogComponent extends
DialogComponent<AddEntityDialogComponent, BaseData<HasId>> implements OnInit, ErrorStateMatcher {
entityComponent: EntityComponent<BaseData<HasId>>; entityComponent: EntityComponent<BaseData<HasId>>;
detailsForm: NgForm; detailsForm: NgForm;

4
ui-ngx/src/app/modules/home/components/entity/contact-based.component.ts

@ -25,8 +25,8 @@ import {EntityComponent} from './entity.component';
export abstract class ContactBasedComponent<T extends ContactBased<HasId>> extends EntityComponent<T> implements AfterViewInit { export abstract class ContactBasedComponent<T extends ContactBased<HasId>> extends EntityComponent<T> implements AfterViewInit {
constructor(protected store: Store<AppState>, protected constructor(protected store: Store<AppState>,
protected fb: FormBuilder) { protected fb: FormBuilder) {
super(store); super(store);
} }

2
ui-ngx/src/app/modules/home/components/entity/entities-table.component.html

@ -136,7 +136,7 @@
</mat-toolbar> </mat-toolbar>
<div fxFlex class="table-container"> <div fxFlex class="table-container">
<mat-table [dataSource]="dataSource" [trackBy]="trackByEntityId" <mat-table [dataSource]="dataSource" [trackBy]="trackByEntityId"
matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="(pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
<ng-container matColumnDef="select" sticky> <ng-container matColumnDef="select" sticky>
<mat-header-cell *matHeaderCellDef> <mat-header-cell *matHeaderCellDef>
<mat-checkbox (change)="$event ? dataSource.masterToggle() : null" <mat-checkbox (change)="$event ? dataSource.masterToggle() : null"

4
ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html

@ -138,7 +138,7 @@
<mat-label translate>relation.direction</mat-label> <mat-label translate>relation.direction</mat-label>
<mat-select required matInput formControlName="direction"> <mat-select required matInput formControlName="direction">
<mat-option *ngFor="let type of directionTypes" [value]="type"> <mat-option *ngFor="let type of directionTypes" [value]="type">
{{ directionTypeTranslations.get(type) | translate }} {{ directionTypeTranslations.get(directionTypeEnum[type]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
@ -196,7 +196,7 @@
<mat-label translate>relation.direction</mat-label> <mat-label translate>relation.direction</mat-label>
<mat-select required matInput formControlName="direction"> <mat-select required matInput formControlName="direction">
<mat-option *ngFor="let type of directionTypes" [value]="type"> <mat-option *ngFor="let type of directionTypes" [value]="type">
{{ directionTypeTranslations.get(type) | translate }} {{ directionTypeTranslations.get(directionTypeEnum[type]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

1
ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts

@ -62,6 +62,7 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit {
directionTypes = Object.keys(EntitySearchDirection); directionTypes = Object.keys(EntitySearchDirection);
directionTypeTranslations = entitySearchDirectionTranslations; directionTypeTranslations = entitySearchDirectionTranslations;
directionTypeEnum = EntitySearchDirection;
private propagateChange = null; private propagateChange = null;

2
ui-ngx/src/app/modules/home/components/event/event-table-config.ts

@ -191,7 +191,7 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
}), }),
entity => entity.body.msgType), entity => entity.body.msgType),
new EntityTableColumn<Event>('relationType', 'event.relation-type', '100px', new EntityTableColumn<Event>('relationType', 'event.relation-type', '100px',
(entity) => entity.body.relationType, entity => ({padding: '0 12px 0 0',}),false, key => ({ (entity) => entity.body.relationType, entity => ({padding: '0 12px 0 0', }), false, key => ({
padding: '0 12px 0 0' padding: '0 12px 0 0'
})), })),
new EntityActionTableColumn<Event>('data', 'event.data', new EntityActionTableColumn<Event>('data', 'event.data',

4
ui-ngx/src/app/modules/home/components/import-export/import-dialog.component.ts

@ -51,7 +51,7 @@ export interface ImportDialogData {
providers: [{provide: ErrorStateMatcher, useExisting: ImportDialogComponent}], providers: [{provide: ErrorStateMatcher, useExisting: ImportDialogComponent}],
styleUrls: [] styleUrls: []
}) })
export class ImportDialogComponent extends DialogComponent<ImportDialogComponent, any> export class ImportDialogComponent extends DialogComponent<ImportDialogComponent>
implements OnInit, ErrorStateMatcher { implements OnInit, ErrorStateMatcher {
importTitle: string; importTitle: string;
@ -65,7 +65,7 @@ export class ImportDialogComponent extends DialogComponent<ImportDialogComponent
protected router: Router, protected router: Router,
@Inject(MAT_DIALOG_DATA) public data: ImportDialogData, @Inject(MAT_DIALOG_DATA) public data: ImportDialogData,
@SkipSelf() private errorStateMatcher: ErrorStateMatcher, @SkipSelf() private errorStateMatcher: ErrorStateMatcher,
public dialogRef: MatDialogRef<ImportDialogComponent, any>, public dialogRef: MatDialogRef<ImportDialogComponent>,
private fb: FormBuilder) { private fb: FormBuilder) {
super(store, router, dialogRef); super(store, router, dialogRef);
this.importTitle = data.importTitle; this.importTitle = data.importTitle;

2
ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts

@ -426,7 +426,7 @@ export class ImportExportService {
private prepareRuleChainMetaData(ruleChainMetaData: RuleChainMetaData) { private prepareRuleChainMetaData(ruleChainMetaData: RuleChainMetaData) {
delete ruleChainMetaData.ruleChainId; delete ruleChainMetaData.ruleChainId;
for (let i = 0; i < ruleChainMetaData.nodes.length; i++) { for (let i = 0; i < ruleChainMetaData.nodes.length; i++) {
var node = ruleChainMetaData.nodes[i]; const node = ruleChainMetaData.nodes[i];
delete node.ruleChainId; delete node.ruleChainId;
ruleChainMetaData.nodes[i] = this.prepareExport(node); ruleChainMetaData.nodes[i] = this.prepareExport(node);
} }

4
ui-ngx/src/app/modules/home/components/relation/relation-table.component.html

@ -26,7 +26,7 @@
<mat-select matInput [ngModel]="direction" <mat-select matInput [ngModel]="direction"
(ngModelChange)="directionChanged($event)"> (ngModelChange)="directionChanged($event)">
<mat-option *ngFor="let type of directionTypes" [value]="type"> <mat-option *ngFor="let type of directionTypes" [value]="type">
{{ directionTypeTranslations.get(type) | translate }} {{ directionTypeTranslations.get(directions[type]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
@ -85,7 +85,7 @@
</mat-toolbar> </mat-toolbar>
<div fxFlex class="table-container"> <div fxFlex class="table-container">
<mat-table [dataSource]="dataSource" <mat-table [dataSource]="dataSource"
matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="(pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
<ng-container matColumnDef="select" sticky> <ng-container matColumnDef="select" sticky>
<mat-header-cell *matHeaderCellDef> <mat-header-cell *matHeaderCellDef>
<mat-checkbox (change)="$event ? dataSource.masterToggle() : null" <mat-checkbox (change)="$event ? dataSource.masterToggle() : null"

2
ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.html

@ -60,7 +60,7 @@
</mat-toolbar> </mat-toolbar>
<div fxFlex class="table-container"> <div fxFlex class="table-container">
<mat-table [dataSource]="dataSource" <mat-table [dataSource]="dataSource"
matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="(pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
<ng-container matColumnDef="actionSourceName"> <ng-container matColumnDef="actionSourceName">
<mat-header-cell *matHeaderCellDef mat-sort-header> {{ 'widget-config.action-source' | translate }} </mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header> {{ 'widget-config.action-source' | translate }} </mat-header-cell>
<mat-cell *matCellDef="let action"> <mat-cell *matCellDef="let action">

2
ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html

@ -58,7 +58,7 @@
<mat-label translate>widget-config.action-type</mat-label> <mat-label translate>widget-config.action-type</mat-label>
<mat-select required matInput formControlName="type"> <mat-select required matInput formControlName="type">
<mat-option *ngFor="let actionType of widgetActionTypes" [value]="actionType"> <mat-option *ngFor="let actionType of widgetActionTypes" [value]="actionType">
{{ widgetActionTypeTranslations.get(actionType) | translate }} {{ widgetActionTypeTranslations.get(widgetActionType[actionType]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="widgetActionFormGroup.get('type').hasError('required')"> <mat-error *ngIf="widgetActionFormGroup.get('type').hasError('required')">

6
ui-ngx/src/app/modules/home/components/widget/dialog/custom-dialog-container.component.ts

@ -46,14 +46,14 @@ export interface CustomDialogContainerData {
selector: 'tb-custom-dialog-container-component', selector: 'tb-custom-dialog-container-component',
template: '' template: ''
}) })
export class CustomDialogContainerComponent extends DialogComponent<CustomDialogContainerComponent, any> implements OnDestroy { export class CustomDialogContainerComponent extends DialogComponent<CustomDialogContainerComponent> implements OnDestroy {
private customComponentRef: ComponentRef<CustomDialogComponent>; private readonly customComponentRef: ComponentRef<CustomDialogComponent>;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
protected router: Router, protected router: Router,
public viewContainerRef: ViewContainerRef, public viewContainerRef: ViewContainerRef,
public dialogRef: MatDialogRef<CustomDialogContainerComponent, any>, public dialogRef: MatDialogRef<CustomDialogContainerComponent>,
@Inject(MAT_DIALOG_DATA) public data: CustomDialogContainerData) { @Inject(MAT_DIALOG_DATA) public data: CustomDialogContainerData) {
super(store, router, dialogRef); super(store, router, dialogRef);
let customDialogData: CustomDialogData = { let customDialogData: CustomDialogData = {

4
ui-ngx/src/app/modules/home/components/widget/legend-config-panel.component.html

@ -24,7 +24,7 @@
<mat-label translate>legend.direction</mat-label> <mat-label translate>legend.direction</mat-label>
<mat-select matInput formControlName="direction" style="min-width: 150px;"> <mat-select matInput formControlName="direction" style="min-width: 150px;">
<mat-option *ngFor="let direction of legendDirections" [value]="direction"> <mat-option *ngFor="let direction of legendDirections" [value]="direction">
{{ legendDirectionTranslations.get(direction) | translate }} {{ legendDirectionTranslations.get(legendDirection[direction]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
@ -34,7 +34,7 @@
<mat-option *ngFor="let pos of legendPositions" [value]="pos" <mat-option *ngFor="let pos of legendPositions" [value]="pos"
[disabled]="legendConfigForm.get('direction').value === legendDirection.row && [disabled]="legendConfigForm.get('direction').value === legendDirection.row &&
(pos === legendPosition.left || pos === legendPosition.right)"> (pos === legendPosition.left || pos === legendPosition.right)">
{{ legendPositionTranslations.get(pos) | translate }} {{ legendPositionTranslations.get(legendPosition[pos]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

2
ui-ngx/src/app/modules/home/components/widget/lib/alarm-status-filter-panel.component.html

@ -19,7 +19,7 @@
<label class="tb-title" translate>alarm.alarm-status-filter</label> <label class="tb-title" translate>alarm.alarm-status-filter</label>
<mat-radio-group [(ngModel)]="subscription.alarmSearchStatus" fxLayout="column" fxLayoutGap="16px"> <mat-radio-group [(ngModel)]="subscription.alarmSearchStatus" fxLayout="column" fxLayoutGap="16px">
<mat-radio-button *ngFor="let searchStatus of alarmSearchStatuses" [value]="searchStatus" color="primary"> <mat-radio-button *ngFor="let searchStatus of alarmSearchStatuses" [value]="searchStatus" color="primary">
{{ alarmSearchStatusTranslationMap.get(searchStatus) | translate }} {{ alarmSearchStatusTranslationMap.get(alarmSearchStatusEnum[searchStatus]) | translate }}
</mat-radio-button> </mat-radio-button>
</mat-radio-group> </mat-radio-group>
</div> </div>

1
ui-ngx/src/app/modules/home/components/widget/lib/alarm-status-filter-panel.component.ts

@ -35,6 +35,7 @@ export class AlarmStatusFilterPanelComponent {
alarmSearchStatuses = Object.keys(AlarmSearchStatus); alarmSearchStatuses = Object.keys(AlarmSearchStatus);
alarmSearchStatusTranslationMap = alarmSearchStatusTranslations; alarmSearchStatusTranslationMap = alarmSearchStatusTranslations;
alarmSearchStatusEnum = AlarmSearchStatus;
constructor(@Inject(ALARM_STATUS_FILTER_PANEL_DATA) public data: AlarmStatusFilterPanelData) { constructor(@Inject(ALARM_STATUS_FILTER_PANEL_DATA) public data: AlarmStatusFilterPanelData) {
this.subscription = this.data.subscription; this.subscription = this.data.subscription;

2
ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.html

@ -62,7 +62,7 @@
</mat-toolbar> </mat-toolbar>
<div fxFlex class="table-container"> <div fxFlex class="table-container">
<mat-table [dataSource]="alarmsDatasource" <mat-table [dataSource]="alarmsDatasource"
matSort [matSortActive]="sortOrderProperty" [matSortDirection]="(pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="sortOrderProperty" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
<ng-container matColumnDef="select" sticky> <ng-container matColumnDef="select" sticky>
<mat-header-cell *matHeaderCellDef style="width: 30px;"> <mat-header-cell *matHeaderCellDef style="width: 30px;">
<mat-checkbox (change)="$event ? alarmsDatasource.masterToggle() : null" <mat-checkbox (change)="$event ? alarmsDatasource.masterToggle() : null"

24
ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts

@ -100,9 +100,6 @@ interface AlarmsTableWidgetSettings extends TableWidgetSettings {
allowClear: boolean; allowClear: boolean;
} }
interface AlarmsTableDataKeySettings extends TableWidgetDataKeySettings {
}
interface AlarmWidgetActionDescriptor extends WidgetActionDescriptor { interface AlarmWidgetActionDescriptor extends WidgetActionDescriptor {
details?: boolean; details?: boolean;
acknowledge?: boolean; acknowledge?: boolean;
@ -301,7 +298,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
if (isDefined(pageSize) && isNumber(pageSize) && pageSize > 0) { if (isDefined(pageSize) && isNumber(pageSize) && pageSize > 0) {
this.defaultPageSize = pageSize; this.defaultPageSize = pageSize;
} }
this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize*2, this.defaultPageSize*3]; this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3];
this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY;
const cssString = constructTableCssString(this.widgetConfig); const cssString = constructTableCssString(this.widgetConfig);
@ -320,11 +317,11 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
} }
if (this.alarmSource) { if (this.alarmSource) {
this.alarmSource.dataKeys.forEach((_dataKey) => { this.alarmSource.dataKeys.forEach((alarmDataKey) => {
const dataKey: EntityColumn = deepClone(_dataKey) as EntityColumn; const dataKey: EntityColumn = deepClone(alarmDataKey) as EntityColumn;
dataKey.title = this.utils.customTranslation(dataKey.label, dataKey.label); dataKey.title = this.utils.customTranslation(dataKey.label, dataKey.label);
dataKey.def = 'def' + this.columns.length; dataKey.def = 'def' + this.columns.length;
const keySettings: AlarmsTableDataKeySettings = dataKey.settings; const keySettings: TableWidgetDataKeySettings = dataKey.settings;
this.stylesInfo[dataKey.def] = getCellStyleInfo(keySettings); this.stylesInfo[dataKey.def] = getCellStyleInfo(keySettings);
this.contentsInfo[dataKey.def] = getCellContentInfo(keySettings, 'value, alarm, ctx'); this.contentsInfo[dataKey.def] = getCellContentInfo(keySettings, 'value, alarm, ctx');
@ -383,7 +380,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
title: column.title, title: column.title,
def: column.def, def: column.def,
display: this.displayedColumns.indexOf(column.def) > -1 display: this.displayedColumns.indexOf(column.def) > -1
} };
}); });
const injectionTokens = new WeakMap<any, any>([ const injectionTokens = new WeakMap<any, any>([
@ -481,7 +478,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
const columnWidth = this.columnWidth[key.def]; const columnWidth = this.columnWidth[key.def];
return { return {
width: columnWidth width: columnWidth
} };
} }
public cellStyle(alarm: AlarmInfo, key: EntityColumn): any { public cellStyle(alarm: AlarmInfo, key: EntityColumn): any {
@ -629,7 +626,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
} }
if (this.alarmsDatasource.selection.hasValue()) { if (this.alarmsDatasource.selection.hasValue()) {
const alarms = this.alarmsDatasource.selection.selected.filter( const alarms = this.alarmsDatasource.selection.selected.filter(
(alarm) => { return alarm.id.id !== NULL_UUID } (alarm) => alarm.id.id !== NULL_UUID
); );
if (alarms.length) { if (alarms.length) {
const title = this.translate.instant('alarm.aknowledge-alarms-title', {count: alarms.length}); const title = this.translate.instant('alarm.aknowledge-alarms-title', {count: alarms.length});
@ -685,7 +682,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
} }
if (this.alarmsDatasource.selection.hasValue()) { if (this.alarmsDatasource.selection.hasValue()) {
const alarms = this.alarmsDatasource.selection.selected.filter( const alarms = this.alarmsDatasource.selection.selected.filter(
(alarm) => { return alarm.id.id !== NULL_UUID } (alarm) => alarm.id.id !== NULL_UUID
); );
if (alarms.length) { if (alarms.length) {
const title = this.translate.instant('alarm.clear-alarms-title', {count: alarms.length}); const title = this.translate.instant('alarm.clear-alarms-title', {count: alarms.length});
@ -725,8 +722,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
return this.translate.instant(alarmStatusTranslations.get(value)); return this.translate.instant(alarmStatusTranslations.get(value));
} else if (alarmField.value === alarmFields.originatorType.value) { } else if (alarmField.value === alarmFields.originatorType.value) {
return this.translate.instant(entityTypeTranslations.get(value).type); return this.translate.instant(entityTypeTranslations.get(value).type);
} } else {
else {
return value; return value;
} }
} else { } else {
@ -741,7 +737,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
if (isDefined(value)) { if (isDefined(value)) {
const alarmField = alarmFields[key.name]; const alarmField = alarmFields[key.name];
if (alarmField) { if (alarmField) {
if (alarmField.value == alarmFields.severity.value) { if (alarmField.value === alarmFields.severity.value) {
return { return {
fontWeight: 'bold', fontWeight: 'bold',
color: alarmSeverityColors.get(value) color: alarmSeverityColors.get(value)

12
ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.component.ts

@ -227,7 +227,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
if (datasource.nodeId) { if (datasource.nodeId) {
const node = this.nodesMap[datasource.nodeId]; const node = this.nodesMap[datasource.nodeId];
const key = datasourceData.dataKey.label; const key = datasourceData.dataKey.label;
let value = undefined; let value;
if (datasourceData.data && datasourceData.data.length) { if (datasourceData.data && datasourceData.data.length) {
value = datasourceData.data[0][1]; value = datasourceData.data[0][1];
} }
@ -292,7 +292,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
cb([]); cb([]);
} }
} }
}; }
public onNodeSelected: NodeSelectedCallback = (node, event) => { public onNodeSelected: NodeSelectedCallback = (node, event) => {
let nodeId; let nodeId;
@ -311,7 +311,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
} }
} }
} }
}; }
public onNodesInserted: NodesInsertedCallback = (nodes, parent) => { public onNodesInserted: NodesInsertedCallback = (nodes, parent) => {
if (nodes) { if (nodes) {
@ -323,7 +323,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
} }
}); });
} }
}; }
public searchCallback: NodeSearchCallback = (searchText, node) => { public searchCallback: NodeSearchCallback = (searchText, node) => {
const theNode = this.nodesMap[node.id]; const theNode = this.nodesMap[node.id];
@ -331,7 +331,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
return theNode.data.searchText.includes(searchText.toLowerCase()); return theNode.data.searchText.includes(searchText.toLowerCase());
} }
return false; return false;
}; }
private updateNodeStyle(node: HierarchyNavTreeNode) { private updateNodeStyle(node: HierarchyNavTreeNode) {
const newText = this.prepareNodeText(node); const newText = this.prepareNodeText(node);
@ -404,7 +404,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
map(entity => { map(entity => {
if (entity !== null) { if (entity !== null) {
const node: HierarchyNavTreeNode = { const node: HierarchyNavTreeNode = {
id: (++this.nodeIdCounter)+'' id: (++this.nodeIdCounter) + ''
}; };
this.nodesMap[node.id] = node; this.nodesMap[node.id] = node;
datasource.nodeId = node.id; datasource.nodeId = node.id;

10
ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts

@ -44,7 +44,7 @@ export interface HierarchyNavTreeNode extends NavTreeNode {
datasource: HierarchyNodeDatasource; datasource: HierarchyNodeDatasource;
nodeCtx: HierarchyNodeContext; nodeCtx: HierarchyNodeContext;
searchText?: string; searchText?: string;
} };
} }
export interface HierarchyNodeDatasource extends Datasource { export interface HierarchyNodeDatasource extends Datasource {
@ -64,7 +64,7 @@ export type NodeOpenedFunction = (nodeCtx: HierarchyNodeContext) => boolean;
export type NodeHasChildrenFunction = (nodeCtx: HierarchyNodeContext) => boolean; export type NodeHasChildrenFunction = (nodeCtx: HierarchyNodeContext) => boolean;
export type NodesSortFunction = (nodeCtx1: HierarchyNodeContext, nodeCtx2: HierarchyNodeContext) => number; export type NodesSortFunction = (nodeCtx1: HierarchyNodeContext, nodeCtx2: HierarchyNodeContext) => number;
export function loadNodeCtxFunction<F extends Function>(functionBody: string, argNames: string, ...args: any[]): F { export function loadNodeCtxFunction<F extends (...args: any[]) => any>(functionBody: string, argNames: string, ...args: any[]): F {
let nodeCtxFunction: F = null; let nodeCtxFunction: F = null;
if (isDefined(functionBody) && functionBody.length) { if (isDefined(functionBody) && functionBody.length) {
try { try {
@ -81,11 +81,11 @@ export function loadNodeCtxFunction<F extends Function>(functionBody: string, ar
} }
export function materialIconHtml(materialIcon: string): string { export function materialIconHtml(materialIcon: string): string {
return '<mat-icon class="node-icon material-icons" role="img" aria-hidden="false">'+materialIcon+'</mat-icon>'; return '<mat-icon class="node-icon material-icons" role="img" aria-hidden="false">' + materialIcon + '</mat-icon>';
} }
export function iconUrlHtml(iconUrl: string): string { export function iconUrlHtml(iconUrl: string): string {
return '<div class="node-icon" style="background-image: url('+iconUrl+');">&nbsp;</div>'; return '<div class="node-icon" style="background-image: url(' + iconUrl + ');">&nbsp;</div>';
} }
export const defaultNodeRelationQueryFunction: NodeRelationQueryFunction = nodeCtx => { export const defaultNodeRelationQueryFunction: NodeRelationQueryFunction = nodeCtx => {
@ -100,7 +100,7 @@ export const defaultNodeRelationQueryFunction: NodeRelationQueryFunction = nodeC
}, },
filters: [ filters: [
{ {
relationType: "Contains", relationType: 'Contains',
entityTypes: [] entityTypes: []
} }
] ]

2
ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.html

@ -39,7 +39,7 @@
</mat-toolbar> </mat-toolbar>
<div fxFlex class="table-container"> <div fxFlex class="table-container">
<mat-table [dataSource]="entityDatasource" <mat-table [dataSource]="entityDatasource"
matSort [matSortActive]="sortOrderProperty" [matSortDirection]="(pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="sortOrderProperty" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
<ng-container [matColumnDef]="column.def" *ngFor="let column of columns; trackBy: trackByColumnDef;"> <ng-container [matColumnDef]="column.def" *ngFor="let column of columns; trackBy: trackByColumnDef;">
<mat-header-cell [ngStyle]="headerStyle(column)" *matHeaderCellDef mat-sort-header> {{ column.title }} </mat-header-cell> <mat-header-cell [ngStyle]="headerStyle(column)" *matHeaderCellDef mat-sort-header> {{ column.title }} </mat-header-cell>
<mat-cell *matCellDef="let entity;" <mat-cell *matCellDef="let entity;"

27
ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts

@ -85,9 +85,6 @@ interface EntitiesTableWidgetSettings extends TableWidgetSettings {
displayEntityType: boolean; displayEntityType: boolean;
} }
interface EntitiesTableDataKeySettings extends TableWidgetDataKeySettings {
}
@Component({ @Component({
selector: 'tb-entities-table-widget', selector: 'tb-entities-table-widget',
templateUrl: './entities-table-widget.component.html', templateUrl: './entities-table-widget.component.html',
@ -221,7 +218,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
if (isDefined(pageSize) && isNumber(pageSize) && pageSize > 0) { if (isDefined(pageSize) && isNumber(pageSize) && pageSize > 0) {
this.defaultPageSize = pageSize; this.defaultPageSize = pageSize;
} }
this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize*2, this.defaultPageSize*3]; this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3];
this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY;
const cssString = constructTableCssString(this.widgetConfig); const cssString = constructTableCssString(this.widgetConfig);
@ -253,13 +250,13 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
title: entityNameColumnTitle title: entityNameColumnTitle
} as EntityColumn } as EntityColumn
); );
this.contentsInfo['entityName'] = { this.contentsInfo.entityName = {
useCellContentFunction: false useCellContentFunction: false
}; };
this.stylesInfo['entityName'] = { this.stylesInfo.entityName = {
useCellStyleFunction: false useCellStyleFunction: false
}; };
this.columnWidth['entityName'] = '0px'; this.columnWidth.entityName = '0px';
} }
if (displayEntityType) { if (displayEntityType) {
this.columns.push( this.columns.push(
@ -270,13 +267,13 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
title: this.translate.instant('entity.entity-type'), title: this.translate.instant('entity.entity-type'),
} as EntityColumn } as EntityColumn
); );
this.contentsInfo['entityType'] = { this.contentsInfo.entityType = {
useCellContentFunction: false useCellContentFunction: false
}; };
this.stylesInfo['entityType'] = { this.stylesInfo.entityType = {
useCellStyleFunction: false useCellStyleFunction: false
}; };
this.columnWidth['entityType'] = '0px'; this.columnWidth.entityType = '0px';
} }
const dataKeys: Array<DataKey> = []; const dataKeys: Array<DataKey> = [];
@ -284,8 +281,8 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
const datasource = this.subscription.datasources[0]; const datasource = this.subscription.datasources[0];
if (datasource) { if (datasource) {
datasource.dataKeys.forEach((_dataKey) => { datasource.dataKeys.forEach((entityDataKey) => {
const dataKey: EntityColumn = deepClone(_dataKey) as EntityColumn; const dataKey: EntityColumn = deepClone(entityDataKey) as EntityColumn;
if (dataKey.type === DataKeyType.function) { if (dataKey.type === DataKeyType.function) {
dataKey.name = dataKey.label; dataKey.name = dataKey.label;
} }
@ -293,7 +290,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
dataKey.title = this.utils.customTranslation(dataKey.label, dataKey.label); dataKey.title = this.utils.customTranslation(dataKey.label, dataKey.label);
dataKey.def = 'def' + this.columns.length; dataKey.def = 'def' + this.columns.length;
const keySettings: EntitiesTableDataKeySettings = dataKey.settings; const keySettings: TableWidgetDataKeySettings = dataKey.settings;
this.stylesInfo[dataKey.def] = getCellStyleInfo(keySettings); this.stylesInfo[dataKey.def] = getCellStyleInfo(keySettings);
this.contentsInfo[dataKey.def] = getCellContentInfo(keySettings, 'value, entity, ctx'); this.contentsInfo[dataKey.def] = getCellContentInfo(keySettings, 'value, entity, ctx');
@ -345,7 +342,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
title: column.title, title: column.title,
def: column.def, def: column.def,
display: this.displayedColumns.indexOf(column.def) > -1 display: this.displayedColumns.indexOf(column.def) > -1
} };
}); });
const injectionTokens = new WeakMap<any, any>([ const injectionTokens = new WeakMap<any, any>([
@ -407,7 +404,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
const columnWidth = this.columnWidth[key.def]; const columnWidth = this.columnWidth[key.def];
return { return {
width: columnWidth width: columnWidth
} };
} }
public cellStyle(entity: EntityData, key: EntityColumn): any { public cellStyle(entity: EntityData, key: EntityColumn): any {

3
ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.models.ts

@ -398,8 +398,7 @@ export function flotSettingsSchema(chartType: ChartType): JsonSettingsSchema {
return schema; return schema;
} }
export const flotPieSettingsSchema: JsonSettingsSchema = export const flotPieSettingsSchema: JsonSettingsSchema = {
{
schema: { schema: {
type: 'object', type: 'object',
title: 'Settings', title: 'Settings',

22
ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts

@ -51,23 +51,23 @@ export class TbFlot {
private settings: TbFlotSettings; private settings: TbFlotSettings;
private tooltip: JQuery<any>; private readonly tooltip: JQuery<any>;
private yAxisTickFormatter: TbFlotTicksFormatterFunction; private readonly yAxisTickFormatter: TbFlotTicksFormatterFunction;
private ticksFormatterFunction: TbFlotTicksFormatterFunction; private ticksFormatterFunction: TbFlotTicksFormatterFunction;
private yaxis: TbFlotAxisOptions; private readonly yaxis: TbFlotAxisOptions;
private yaxes: Array<TbFlotAxisOptions>; private yaxes: Array<TbFlotAxisOptions>;
private options: JQueryPlotOptions; private readonly options: JQueryPlotOptions;
private subscription: IWidgetSubscription; private subscription: IWidgetSubscription;
private $element: JQuery<any>; private $element: JQuery<any>;
private trackUnits: string; private readonly trackUnits: string;
private trackDecimals: number; private readonly trackDecimals: number;
private tooltipIndividual: boolean; private readonly tooltipIndividual: boolean;
private tooltipCumulative: boolean; private readonly tooltipCumulative: boolean;
private defaultBarWidth: number; private readonly defaultBarWidth: number;
private plotInited = false; private plotInited = false;
private plot: JQueryPlot; private plot: JQueryPlot;
@ -85,7 +85,7 @@ export class TbFlot {
private mouseupHandler = this.onFlotMouseUp.bind(this); private mouseupHandler = this.onFlotMouseUp.bind(this);
private mouseleaveHandler = this.onFlotMouseLeave.bind(this); private mouseleaveHandler = this.onFlotMouseLeave.bind(this);
private animatedPie: boolean; private readonly animatedPie: boolean;
private pieDataAnimationDuration: number; private pieDataAnimationDuration: number;
private pieData: DatasourceData[]; private pieData: DatasourceData[];
private pieRenderedData: any[]; private pieRenderedData: any[];
@ -110,7 +110,7 @@ export class TbFlot {
return flotDatakeySettingsSchema(defaultShowLines); return flotDatakeySettingsSchema(defaultShowLines);
} }
constructor(private ctx: WidgetContext, private chartType: ChartType) { constructor(private ctx: WidgetContext, private readonly chartType: ChartType) {
this.chartType = this.chartType || 'line'; this.chartType = this.chartType || 'line';
this.settings = ctx.settings as TbFlotSettings; this.settings = ctx.settings as TbFlotSettings;
this.tooltip = $('#flot-series-tooltip'); this.tooltip = $('#flot-series-tooltip');

180
ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts

@ -56,21 +56,25 @@ export interface DisplayColumn {
display: boolean; display: boolean;
} }
export type CellContentFunction = (...args: any[]) => string;
export interface CellContentInfo { export interface CellContentInfo {
useCellContentFunction: boolean; useCellContentFunction: boolean;
cellContentFunction?: Function; cellContentFunction?: CellContentFunction;
units?: string; units?: string;
decimals?: number; decimals?: number;
} }
export type CellStyleFunction = (value: any) => any;
export interface CellStyleInfo { export interface CellStyleInfo {
useCellStyleFunction: boolean; useCellStyleFunction: boolean;
cellStyleFunction?: Function; cellStyleFunction?: CellStyleFunction;
} }
export function findColumnProperty(searchProperty: string, searchValue: string, columnProperty: string, columns: EntityColumn[]): string { export function findColumnProperty(searchProperty: string, searchValue: string, columnProperty: string, columns: EntityColumn[]): string {
let res = searchValue; let res = searchValue;
const column = columns.find(column => column[searchProperty] === searchValue); const column = columns.find(theColumn => theColumn[searchProperty] === searchValue);
if (column) { if (column) {
res = column[columnProperty]; res = column[columnProperty];
} }
@ -107,13 +111,13 @@ export function getAlarmValue(alarm: AlarmInfo, key: EntityColumn) {
} }
export function getCellStyleInfo(keySettings: TableWidgetDataKeySettings): CellStyleInfo { export function getCellStyleInfo(keySettings: TableWidgetDataKeySettings): CellStyleInfo {
let cellStyleFunction: Function = null; let cellStyleFunction: CellStyleFunction = null;
let useCellStyleFunction = false; let useCellStyleFunction = false;
if (keySettings.useCellStyleFunction === true) { if (keySettings.useCellStyleFunction === true) {
if (isDefined(keySettings.cellStyleFunction) && keySettings.cellStyleFunction.length > 0) { if (isDefined(keySettings.cellStyleFunction) && keySettings.cellStyleFunction.length > 0) {
try { try {
cellStyleFunction = new Function('value', keySettings.cellStyleFunction); cellStyleFunction = new Function('value', keySettings.cellStyleFunction) as CellStyleFunction;
useCellStyleFunction = true; useCellStyleFunction = true;
} catch (e) { } catch (e) {
cellStyleFunction = null; cellStyleFunction = null;
@ -128,13 +132,13 @@ export function getCellStyleInfo(keySettings: TableWidgetDataKeySettings): CellS
} }
export function getCellContentInfo(keySettings: TableWidgetDataKeySettings, ...args: string[]): CellContentInfo { export function getCellContentInfo(keySettings: TableWidgetDataKeySettings, ...args: string[]): CellContentInfo {
let cellContentFunction: Function = null; let cellContentFunction: CellContentFunction = null;
let useCellContentFunction = false; let useCellContentFunction = false;
if (keySettings.useCellContentFunction === true) { if (keySettings.useCellContentFunction === true) {
if (isDefined(keySettings.cellContentFunction) && keySettings.cellContentFunction.length > 0) { if (isDefined(keySettings.cellContentFunction) && keySettings.cellContentFunction.length > 0) {
try { try {
cellContentFunction = new Function(...args, keySettings.cellContentFunction); cellContentFunction = new Function(...args, keySettings.cellContentFunction) as CellContentFunction;
useCellContentFunction = true; useCellContentFunction = true;
} catch (e) { } catch (e) {
cellContentFunction = null; cellContentFunction = null;
@ -173,94 +177,94 @@ export function constructTableCssString(widgetConfig: WidgetConfig): string {
const cssString = const cssString =
'.mat-input-element::placeholder {\n' + '.mat-input-element::placeholder {\n' +
' color: ' + mdDarkSecondary + ';\n'+ ' color: ' + mdDarkSecondary + ';\n' +
'}\n' + '}\n' +
'.mat-input-element::-moz-placeholder {\n' + '.mat-input-element::-moz-placeholder {\n' +
' color: ' + mdDarkSecondary + ';\n'+ ' color: ' + mdDarkSecondary + ';\n' +
'}\n' + '}\n' +
'.mat-input-element::-webkit-input-placeholder {\n' + '.mat-input-element::-webkit-input-placeholder {\n' +
' color: ' + mdDarkSecondary + ';\n'+ ' color: ' + mdDarkSecondary + ';\n' +
'}\n' + '}\n' +
'.mat-input-element:-ms-input-placeholder {\n' + '.mat-input-element:-ms-input-placeholder {\n' +
' color: ' + mdDarkSecondary + ';\n'+ ' color: ' + mdDarkSecondary + ';\n' +
'}\n' +
'mat-toolbar.mat-table-toolbar {\n' +
'color: ' + mdDark + ';\n' +
'}\n' +
'mat-toolbar.mat-table-toolbar:not([color="primary"]) button.mat-icon-button mat-icon {\n' +
'color: ' + mdDarkSecondary + ';\n' +
'}\n' +
'.mat-tab-label {\n' +
'color: ' + mdDark + ';\n' +
'}\n' +
'.mat-tab-header-pagination-chevron {\n' +
'border-color: ' + mdDark + ';\n' +
'}\n' +
'.mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {\n' +
'border-color: ' + mdDarkDisabled2 + ';\n' +
'}\n' +
'.mat-table .mat-header-row {\n' +
'background-color: ' + origBackgroundColor + ';\n' +
'}\n' +
'.mat-table .mat-header-cell {\n' +
'color: ' + mdDarkSecondary + ';\n' +
'}\n' +
'.mat-table .mat-header-cell .mat-sort-header-arrow {\n' +
'color: ' + mdDarkDisabled + ';\n' +
'}\n' +
'.mat-table .mat-cell, .mat-table .mat-header-cell {\n' +
'border-bottom-color: ' + mdDarkDivider + ';\n' +
'}\n' +
'.mat-table .mat-cell .mat-checkbox-frame, .mat-table .mat-header-cell .mat-checkbox-frame {\n' +
'border-color: ' + mdDarkSecondary + ';\n' +
'}\n' +
'.mat-table .mat-row .mat-cell.mat-table-sticky {\n' +
'transition: background-color .2s;\n' +
'}\n' +
'.mat-table .mat-row.tb-current-entity {\n' +
'background-color: ' + currentEntityColor + ';\n' +
'}\n' +
'.mat-table .mat-row.tb-current-entity .mat-cell.mat-table-sticky {\n' +
'background-color: ' + currentEntityStickyColor + ';\n' +
'}\n' +
'.mat-table .mat-row:hover:not(.tb-current-entity) {\n' +
'background-color: ' + hoverColor + ';\n' +
'}\n' +
'.mat-table .mat-row:hover:not(.tb-current-entity) .mat-cell.mat-table-sticky {\n' +
'background-color: ' + hoverStickyColor + ';\n' +
'}\n' +
'.mat-table .mat-row.mat-row-select.mat-selected:not(.tb-current-entity) {\n' +
'background-color: ' + selectedColor + ';\n' +
'}\n' +
'.mat-table .mat-row.mat-row-select.mat-selected:not(.tb-current-entity) .mat-cell.mat-table-sticky {\n' +
'background-color: ' + selectedStickyColor + ';\n' +
'}\n' +
'.mat-table .mat-row .mat-cell.mat-table-sticky, .mat-table .mat-header-cell.mat-table-sticky {\n' +
'background-color: ' + origBackgroundColor + ';\n' +
'}\n' +
'.mat-table .mat-cell {\n' +
'color: ' + mdDark + ';\n' +
'}\n' +
'.mat-table .mat-cell button.mat-icon-button mat-icon {\n' +
'color: ' + mdDarkSecondary + ';\n' +
'}\n' +
'.mat-table .mat-cell button.mat-icon-button[disabled][disabled] mat-icon {\n' +
'color: ' + mdDarkDisabled + ';\n' +
'}\n' +
'.mat-divider {\n' +
'border-top-color: ' + mdDarkDivider + ';\n' +
'}\n' +
'.mat-paginator {\n' +
'color: ' + mdDarkSecondary + ';\n' +
'}\n' +
'.mat-paginator button.mat-icon-button {\n' +
'color: ' + mdDarkSecondary + ';\n' +
'}\n' +
'.mat-paginator button.mat-icon-button[disabled][disabled] {\n' +
'color: ' + mdDarkDisabled + ';\n' +
'}\n' + '}\n' +
'mat-toolbar.mat-table-toolbar {\n'+ '.mat-paginator .mat-select-value {\n' +
'color: ' + mdDark + ';\n'+ 'color: ' + mdDarkSecondary + ';\n' +
'}\n'+
'mat-toolbar.mat-table-toolbar:not([color="primary"]) button.mat-icon-button mat-icon {\n'+
'color: ' + mdDarkSecondary + ';\n'+
'}\n'+
'.mat-tab-label {\n'+
'color: ' + mdDark + ';\n'+
'}\n'+
'.mat-tab-header-pagination-chevron {\n'+
'border-color: ' + mdDark + ';\n'+
'}\n'+
'.mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {\n'+
'border-color: ' + mdDarkDisabled2 + ';\n'+
'}\n'+
'.mat-table .mat-header-row {\n'+
'background-color: ' + origBackgroundColor + ';\n'+
'}\n'+
'.mat-table .mat-header-cell {\n'+
'color: ' + mdDarkSecondary + ';\n'+
'}\n'+
'.mat-table .mat-header-cell .mat-sort-header-arrow {\n'+
'color: ' + mdDarkDisabled + ';\n'+
'}\n'+
'.mat-table .mat-cell, .mat-table .mat-header-cell {\n'+
'border-bottom-color: '+mdDarkDivider+';\n'+
'}\n'+
'.mat-table .mat-cell .mat-checkbox-frame, .mat-table .mat-header-cell .mat-checkbox-frame {\n'+
'border-color: '+mdDarkSecondary+';\n'+
'}\n'+
'.mat-table .mat-row .mat-cell.mat-table-sticky {\n'+
'transition: background-color .2s;\n'+
'}\n'+
'.mat-table .mat-row.tb-current-entity {\n'+
'background-color: ' + currentEntityColor + ';\n'+
'}\n'+
'.mat-table .mat-row.tb-current-entity .mat-cell.mat-table-sticky {\n'+
'background-color: ' + currentEntityStickyColor + ';\n'+
'}\n'+
'.mat-table .mat-row:hover:not(.tb-current-entity) {\n'+
'background-color: ' + hoverColor + ';\n'+
'}\n'+
'.mat-table .mat-row:hover:not(.tb-current-entity) .mat-cell.mat-table-sticky {\n'+
'background-color: ' + hoverStickyColor + ';\n'+
'}\n'+
'.mat-table .mat-row.mat-row-select.mat-selected:not(.tb-current-entity) {\n'+
'background-color: ' + selectedColor + ';\n'+
'}\n'+
'.mat-table .mat-row.mat-row-select.mat-selected:not(.tb-current-entity) .mat-cell.mat-table-sticky {\n'+
'background-color: ' + selectedStickyColor + ';\n'+
'}\n'+
'.mat-table .mat-row .mat-cell.mat-table-sticky, .mat-table .mat-header-cell.mat-table-sticky {\n'+
'background-color: ' + origBackgroundColor + ';\n'+
'}\n'+
'.mat-table .mat-cell {\n'+
'color: ' + mdDark + ';\n'+
'}\n'+
'.mat-table .mat-cell button.mat-icon-button mat-icon {\n'+
'color: ' + mdDarkSecondary + ';\n'+
'}\n'+
'.mat-table .mat-cell button.mat-icon-button[disabled][disabled] mat-icon {\n'+
'color: ' + mdDarkDisabled + ';\n'+
'}\n'+
'.mat-divider {\n'+
'border-top-color: ' + mdDarkDivider + ';\n'+
'}\n'+
'.mat-paginator {\n'+
'color: ' + mdDarkSecondary + ';\n'+
'}\n'+
'.mat-paginator button.mat-icon-button {\n'+
'color: ' + mdDarkSecondary + ';\n'+
'}\n'+
'.mat-paginator button.mat-icon-button[disabled][disabled] {\n'+
'color: ' + mdDarkDisabled + ';\n'+
'}\n'+
'.mat-paginator .mat-select-value {\n'+
'color: ' + mdDarkSecondary + ';\n'+
'}'; '}';
return cssString; return cssString;
} }

2
ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.html

@ -42,7 +42,7 @@
<mat-tab *ngFor="let source of sources" label="{{ source.datasource.name }}"> <mat-tab *ngFor="let source of sources" label="{{ source.datasource.name }}">
<div fxFlex class="table-container"> <div fxFlex class="table-container">
<mat-table [dataSource]="source.timeseriesDatasource" [trackBy]="trackByRowIndex" <mat-table [dataSource]="source.timeseriesDatasource" [trackBy]="trackByRowIndex"
matSort [matSortActive]="source.pageLink.sortOrder.property" [matSortDirection]="(source.pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="source.pageLink.sortOrder.property" [matSortDirection]="source.pageLink.sortDirection()" matSortDisableClear>
<ng-container *ngIf="showTimestamp" [matColumnDef]="'0'"> <ng-container *ngIf="showTimestamp" [matColumnDef]="'0'">
<mat-header-cell *matHeaderCellDef mat-sort-header>Timestamp</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header>Timestamp</mat-header-cell>
<mat-cell *matCellDef="let row;" <mat-cell *matCellDef="let row;"

50
ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts

@ -72,9 +72,6 @@ interface TimeseriesTableWidgetSettings {
hideEmptyLines: boolean; hideEmptyLines: boolean;
} }
interface TimeseriesTableDataKeySettings extends TableWidgetDataKeySettings {
}
interface TimeseriesRow { interface TimeseriesRow {
[col: number]: any; [col: number]: any;
formattedTs: string; formattedTs: string;
@ -94,10 +91,10 @@ interface TimeseriesTableSource {
pageLink: PageLink; pageLink: PageLink;
displayedColumns: string[]; displayedColumns: string[];
timeseriesDatasource: TimeseriesDatasource; timeseriesDatasource: TimeseriesDatasource;
header: TimeseriesHeader[], header: TimeseriesHeader[];
stylesInfo: CellStyleInfo[], stylesInfo: CellStyleInfo[];
contentsInfo: CellContentInfo[], contentsInfo: CellContentInfo[];
rowDataTemplate: {[key: string]: any} rowDataTemplate: {[key: string]: any};
} }
@Component({ @Component({
@ -223,13 +220,13 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
if (isDefined(pageSize) && isNumber(pageSize) && pageSize > 0) { if (isDefined(pageSize) && isNumber(pageSize) && pageSize > 0) {
this.defaultPageSize = pageSize; this.defaultPageSize = pageSize;
} }
this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize*2, this.defaultPageSize*3]; this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3];
let cssString = constructTableCssString(this.widgetConfig); let cssString = constructTableCssString(this.widgetConfig);
const origBackgroundColor = this.widgetConfig.backgroundColor || 'rgb(255, 255, 255)'; const origBackgroundColor = this.widgetConfig.backgroundColor || 'rgb(255, 255, 255)';
cssString += '.tb-table-widget mat-toolbar.mat-table-toolbar:not([color=primary]) {\n'+ cssString += '.tb-table-widget mat-toolbar.mat-table-toolbar:not([color=primary]) {\n' +
'background-color: ' + origBackgroundColor + ' !important;\n'+ 'background-color: ' + origBackgroundColor + ' !important;\n' +
'}\n'; '}\n';
const cssParser = new cssjs(); const cssParser = new cssjs();
@ -262,13 +259,13 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
source.stylesInfo = []; source.stylesInfo = [];
source.contentsInfo = []; source.contentsInfo = [];
source.rowDataTemplate = {}; source.rowDataTemplate = {};
source.rowDataTemplate['Timestamp'] = null; source.rowDataTemplate.Timestamp = null;
if (this.showTimestamp) { if (this.showTimestamp) {
source.displayedColumns.push('0'); source.displayedColumns.push('0');
} }
for (let a = 0; a < datasource.dataKeys.length; a++ ) { for (let a = 0; a < datasource.dataKeys.length; a++ ) {
const dataKey = datasource.dataKeys[a]; const dataKey = datasource.dataKeys[a];
const keySettings: TimeseriesTableDataKeySettings = dataKey.settings; const keySettings: TableWidgetDataKeySettings = dataKey.settings;
const index = a + 1; const index = a + 1;
source.header.push({ source.header.push({
index, index,
@ -371,14 +368,14 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
return header.index; return header.index;
} }
public trackByRowIndex(index: number, row: TimeseriesRow) { public trackByRowIndex(index: number) {
return index; return index;
} }
public cellStyle(source: TimeseriesTableSource, index: number, value: any): any { public cellStyle(source: TimeseriesTableSource, index: number, value: any): any {
let style: any = {}; let style: any = {};
if (index > 0) { if (index > 0) {
const styleInfo = source.stylesInfo[index-1]; const styleInfo = source.stylesInfo[index - 1];
if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) { if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) {
try { try {
style = styleInfo.cellStyleFunction(value); style = styleInfo.cellStyleFunction(value);
@ -394,16 +391,15 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
if (index === 0) { if (index === 0) {
return row.formattedTs; return row.formattedTs;
} else { } else {
let content = ''; let content;
const contentInfo = source.contentsInfo[index-1]; const contentInfo = source.contentsInfo[index - 1];
if (contentInfo.useCellContentFunction && contentInfo.cellContentFunction) { if (contentInfo.useCellContentFunction && contentInfo.cellContentFunction) {
try { try {
const rowData = source.rowDataTemplate; const rowData = source.rowDataTemplate;
rowData['Timestamp'] = row[0]; rowData.Timestamp = row[0];
for (let h=0; h < source.header.length; h++) { source.header.forEach((headerInfo) => {
const headerInfo = source.header[h];
rowData[headerInfo.dataKey.name] = row[headerInfo.index]; rowData[headerInfo.dataKey.name] = row[headerInfo.index];
} });
content = contentInfo.cellContentFunction(value, rowData, this.ctx); content = contentInfo.cellContentFunction(value, rowData, this.ctx);
} catch (e) { } catch (e) {
content = '' + value; content = '' + value;
@ -498,8 +494,7 @@ class TimeseriesDatasource implements DataSource<TimeseriesRow> {
const rowsMap: {[timestamp: number]: TimeseriesRow} = {}; const rowsMap: {[timestamp: number]: TimeseriesRow} = {};
for (let d = 0; d < data.length; d++) { for (let d = 0; d < data.length; d++) {
const columnData = data[d].data; const columnData = data[d].data;
for (let i = 0; i < columnData.length; i++) { columnData.forEach((cellData) => {
const cellData = columnData[i];
const timestamp = cellData[0]; const timestamp = cellData[0];
let row = rowsMap[timestamp]; let row = rowsMap[timestamp];
if (!row) { if (!row) {
@ -508,20 +503,21 @@ class TimeseriesDatasource implements DataSource<TimeseriesRow> {
}; };
row[0] = timestamp; row[0] = timestamp;
for (let c = 0; c < data.length; c++) { for (let c = 0; c < data.length; c++) {
row[c+1] = undefined; row[c + 1] = undefined;
} }
rowsMap[timestamp] = row; rowsMap[timestamp] = row;
} }
row[d+1] = cellData[1]; row[d + 1] = cellData[1];
} });
} }
const rows: TimeseriesRow[] = []; const rows: TimeseriesRow[] = [];
for (const t of Object.keys(rowsMap)) { for (const t of Object.keys(rowsMap)) {
if (this.hideEmptyLines) { if (this.hideEmptyLines) {
let hideLine = true; let hideLine = true;
for (let _c = 0; (_c < data.length) && hideLine; _c++) { for (let c = 0; (c < data.length) && hideLine; c++) {
if (rowsMap[t][_c+1]) if (rowsMap[t][c + 1]) {
hideLine = false; hideLine = false;
}
} }
if (!hideLine) { if (!hideLine) {
rows.push(rowsMap[t]); rows.push(rowsMap[t]);

4
ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts

@ -58,7 +58,7 @@ import { MatDialog } from '@angular/material/dialog';
import { EntityService } from '@core/http/entity.service'; import { EntityService } from '@core/http/entity.service';
import { JsonFormComponentData } from '@shared/components/json-form/json-form-component.models'; import { JsonFormComponentData } from '@shared/components/json-form/json-form-component.models';
import { WidgetActionsData } from './action/manage-widget-actions.component.models'; import { WidgetActionsData } from './action/manage-widget-actions.component.models';
import { Dashboard } from '@shared/models/dashboard.models'; import { Dashboard, DashboardState } from '@shared/models/dashboard.models';
const emptySettingsSchema = { const emptySettingsSchema = {
type: 'object', type: 'object',
@ -107,7 +107,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
functionsOnly: boolean; functionsOnly: boolean;
@Input() @Input()
dashboardStates: Array<string>; dashboardStates: {[id: string]: DashboardState };
@Input() disabled: boolean; @Input() disabled: boolean;

6
ui-ngx/src/app/modules/home/home.component.html

@ -50,9 +50,9 @@
(click)="closeSearch()"> (click)="closeSearch()">
<mat-icon class="material-icons">arrow_back</mat-icon> <mat-icon class="material-icons">arrow_back</mat-icon>
</button> </button>
<div [fxShow]="!displaySearchMode()" <tb-breadcrumb [fxShow]="!displaySearchMode()"
fxFlex tb-breadcrumb [activeComponent]="activeComponent" class="mat-toolbar-tools"> fxFlex [activeComponent]="activeComponent" class="mat-toolbar-tools">
</div> </tb-breadcrumb>
<div [fxShow]="displaySearchMode()" fxFlex fxLayout="row" class="tb-dark"> <div [fxShow]="displaySearchMode()" fxFlex fxLayout="row" class="tb-dark">
<mat-form-field fxFlex floatLabel="always"> <mat-form-field fxFlex floatLabel="always">
<mat-label></mat-label> <mat-label></mat-label>

2
ui-ngx/src/app/modules/home/home.component.ts

@ -50,7 +50,7 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni
activeComponent: any; activeComponent: any;
searchableComponent: ISearchableComponent; searchableComponent: ISearchableComponent;
sidenavMode = 'side'; sidenavMode: 'over' | 'push' | 'side' = 'side';
sidenavOpened = true; sidenavOpened = true;
logo = require('../../../assets/logo_title_white.svg'); logo = require('../../../assets/logo_title_white.svg');

10
ui-ngx/src/app/modules/home/models/dashboard-component.models.ts

@ -134,11 +134,10 @@ export class DashboardWidgets implements Iterable<DashboardWidget> {
} }
if (widgetLayoutChange !== null) { if (widgetLayoutChange !== null) {
widgetLayoutChange.forEachChangedItem((changed) => { widgetLayoutChange.forEachChangedItem((changed) => {
let operation = updateRecords.find((record) => record.widgetId === changed.key); const operation = updateRecords.find((record) => record.widgetId === changed.key);
if (!operation) { if (!operation) {
let index = this.dashboardWidgets.findIndex((dashboardWidget) => dashboardWidget.widgetId === changed.key); const widget = this.dashboardWidgets.find((dashboardWidget) => dashboardWidget.widgetId === changed.key);
if (index > -1) { if (widget) {
const widget = this.dashboardWidgets[index];
updateRecords.push({ updateRecords.push({
widget: widget.widget, widget: widget.widget,
widgetId: changed.key, widgetId: changed.key,
@ -167,7 +166,8 @@ export class DashboardWidgets implements Iterable<DashboardWidget> {
index = this.dashboardWidgets.findIndex((dashboardWidget) => dashboardWidget.widgetId === record.widgetId); index = this.dashboardWidgets.findIndex((dashboardWidget) => dashboardWidget.widgetId === record.widgetId);
if (index > -1) { if (index > -1) {
const prevDashboardWidget = this.dashboardWidgets[index]; const prevDashboardWidget = this.dashboardWidgets[index];
if (!deepEqual(prevDashboardWidget.widget, record.widget) || !deepEqual(prevDashboardWidget.widgetLayout, record.widgetLayout)) { if (!deepEqual(prevDashboardWidget.widget, record.widget) ||
!deepEqual(prevDashboardWidget.widgetLayout, record.widgetLayout)) {
this.dashboardWidgets[index] = new DashboardWidget(this.dashboard, record.widget, record.widgetLayout); this.dashboardWidgets[index] = new DashboardWidget(this.dashboard, record.widget, record.widgetLayout);
this.dashboardWidgets[index].highlighted = prevDashboardWidget.highlighted; this.dashboardWidgets[index].highlighted = prevDashboardWidget.highlighted;
this.dashboardWidgets[index].selected = prevDashboardWidget.selected; this.dashboardWidgets[index].selected = prevDashboardWidget.selected;

56
ui-ngx/src/app/modules/home/models/widget-component.models.ts

@ -108,36 +108,10 @@ export class WidgetContext {
} }
set changeDetector(cd: ChangeDetectorRef) { set changeDetector(cd: ChangeDetectorRef) {
this._changeDetector = cd; this.changeDetectorValue = cd;
} }
private _changeDetector: ChangeDetectorRef; private changeDetectorValue: ChangeDetectorRef;
detectChanges(updateWidgetParams: boolean = false) {
if (!this.destroyed) {
if (updateWidgetParams) {
this.dashboardWidget.updateWidgetParams();
}
this._changeDetector.detectChanges();
}
}
updateWidgetParams() {
if (!this.destroyed) {
setTimeout(() => {
this.dashboardWidget.updateWidgetParams();
}, 0);
}
}
reset() {
this.destroyed = false;
this.hideTitlePanel = false;
this.widgetTitleTemplate = undefined;
this.widgetTitle = undefined;
this.customHeaderActions = undefined;
this.widgetActions = undefined;
}
inited = false; inited = false;
destroyed = false; destroyed = false;
@ -209,6 +183,32 @@ export class WidgetContext {
$injector?: Injector; $injector?: Injector;
ngZone?: NgZone; ngZone?: NgZone;
detectChanges(updateWidgetParams: boolean = false) {
if (!this.destroyed) {
if (updateWidgetParams) {
this.dashboardWidget.updateWidgetParams();
}
this.changeDetectorValue.detectChanges();
}
}
updateWidgetParams() {
if (!this.destroyed) {
setTimeout(() => {
this.dashboardWidget.updateWidgetParams();
}, 0);
}
}
reset() {
this.destroyed = false;
this.hideTitlePanel = false;
this.widgetTitleTemplate = undefined;
this.widgetTitle = undefined;
this.customHeaderActions = undefined;
this.widgetActions = undefined;
}
} }
export interface IDynamicWidgetComponent { export interface IDynamicWidgetComponent {

4
ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts

@ -20,8 +20,8 @@ import { Routes, RouterModule } from '@angular/router';
import { MailServerComponent } from '@modules/home/pages/admin/mail-server.component'; import { MailServerComponent } from '@modules/home/pages/admin/mail-server.component';
import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard'; import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
import { Authority } from '@shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
import {GeneralSettingsComponent} from "@modules/home/pages/admin/general-settings.component"; import {GeneralSettingsComponent} from '@modules/home/pages/admin/general-settings.component';
import {SecuritySettingsComponent} from "@modules/home/pages/admin/security-settings.component"; import {SecuritySettingsComponent} from '@modules/home/pages/admin/security-settings.component';
const routes: Routes = [ const routes: Routes = [
{ {

2
ui-ngx/src/app/modules/home/pages/dashboard/states/manage-dashboard-states-dialog.component.html

@ -76,7 +76,7 @@
</mat-toolbar> </mat-toolbar>
<div class="table-container"> <div class="table-container">
<mat-table [dataSource]="dataSource" <mat-table [dataSource]="dataSource"
matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="(pageLink.sortOrder.direction + '').toLowerCase()" matSortDisableClear> matSort [matSortActive]="pageLink.sortOrder.property" [matSortDirection]="pageLink.sortDirection()" matSortDisableClear>
<ng-container matColumnDef="name"> <ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header> {{ 'dashboard.state-name' | translate }} </mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header> {{ 'dashboard.state-name' | translate }} </mat-header-cell>
<mat-cell *matCellDef="let state"> <mat-cell *matCellDef="let state">

8
ui-ngx/src/app/modules/home/pages/dashboard/states/state-controller.component.ts

@ -89,10 +89,10 @@ export abstract class StateControllerComponent implements IStateControllerCompon
private inited = false; private inited = false;
constructor(protected router: Router, protected constructor(protected router: Router,
protected route: ActivatedRoute, protected route: ActivatedRoute,
protected ngZone: NgZone, protected ngZone: NgZone,
protected statesControllerService: StatesControllerService) { protected statesControllerService: StatesControllerService) {
} }
ngOnInit(): void { ngOnInit(): void {

1
ui-ngx/src/app/modules/home/pages/dashboard/states/states-component.directive.ts

@ -34,6 +34,7 @@ import { IStateController } from '@core/api/widget-api.models';
import { IStateControllerComponent } from '@home/pages/dashboard/states/state-controller.models'; import { IStateControllerComponent } from '@home/pages/dashboard/states/state-controller.models';
@Directive({ @Directive({
// tslint:disable-next-line:directive-selector
selector: 'tb-states-component' selector: 'tb-states-component'
}) })
export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges { export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {

2
ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.html

@ -35,7 +35,7 @@
<mat-select matInput formControlName="credentialsType" <mat-select matInput formControlName="credentialsType"
(ngModelChange)="credentialsTypeChanged()"> (ngModelChange)="credentialsTypeChanged()">
<mat-option *ngFor="let credentialsType of credentialsTypes" [value]="credentialsType"> <mat-option *ngFor="let credentialsType of credentialsTypes" [value]="credentialsType">
{{ credentialTypeNamesMap.get(credentialsType) }} {{ credentialTypeNamesMap.get(deviceCredentialsType[credentialsType]) }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

30
ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts

@ -817,7 +817,7 @@ export class RuleChainPageComponent extends PageComponent
menuItems: [] menuItems: []
}; };
const sourceNode: FcRuleNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(edge.source); const sourceNode: FcRuleNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(edge.source);
if (sourceNode.component.type != RuleNodeType.INPUT) { if (sourceNode.component.type !== RuleNodeType.INPUT) {
contextInfo.menuItems.push( contextInfo.menuItems.push(
{ {
action: () => { action: () => {
@ -900,14 +900,14 @@ export class RuleChainPageComponent extends PageComponent
edges.forEach((edge) => { edges.forEach((edge) => {
const sourceNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(edge.source); const sourceNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(edge.source);
const destNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(edge.destination); const destNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(edge.destination);
const isInputSource = sourceNode.component.type == RuleNodeType.INPUT; const isInputSource = sourceNode.component.type === RuleNodeType.INPUT;
const fromIndex = nodes.indexOf(sourceNode); const fromIndex = nodes.indexOf(sourceNode);
const toIndex = nodes.indexOf(destNode); const toIndex = nodes.indexOf(destNode);
if ( (isInputSource || fromIndex > -1) && toIndex > -1 ) { if ( (isInputSource || fromIndex > -1) && toIndex > -1 ) {
const connection: RuleNodeConnection = { const connection: RuleNodeConnection = {
isInputSource: isInputSource, isInputSource,
fromIndex: fromIndex, fromIndex,
toIndex: toIndex, toIndex,
label: edge.label, label: edge.label,
labels: edge.labels labels: edge.labels
}; };
@ -929,8 +929,8 @@ export class RuleChainPageComponent extends PageComponent
const scrollParent = canvas.parent(); const scrollParent = canvas.parent();
const scrollTop = scrollParent.scrollTop(); const scrollTop = scrollParent.scrollTop();
const scrollLeft = scrollParent.scrollLeft(); const scrollLeft = scrollParent.scrollLeft();
x = scrollLeft + scrollParent.width()/2; x = scrollLeft + scrollParent.width() / 2;
y = scrollTop + scrollParent.height()/2; y = scrollTop + scrollParent.height() / 2;
} }
const ruleNodes = this.itembuffer.pasteRuleNodes(x, y); const ruleNodes = this.itembuffer.pasteRuleNodes(x, y);
if (ruleNodes) { if (ruleNodes) {
@ -972,19 +972,21 @@ export class RuleChainPageComponent extends PageComponent
this.ruleChainCanvas.modelService.edges.delete(found); this.ruleChainCanvas.modelService.edges.delete(found);
} }
} else { } else {
const sourceConnectors = this.ruleChainCanvas.modelService.nodes.getConnectorsByType(sourceNode, FlowchartConstants.rightConnectorType); const sourceConnectors = this.ruleChainCanvas.modelService.nodes
.getConnectorsByType(sourceNode, FlowchartConstants.rightConnectorType);
if (sourceConnectors && sourceConnectors.length) { if (sourceConnectors && sourceConnectors.length) {
source = sourceConnectors[0].id; source = sourceConnectors[0].id;
} }
} }
const destConnectors = this.ruleChainCanvas.modelService.nodes.getConnectorsByType(destNode, FlowchartConstants.leftConnectorType); const destConnectors = this.ruleChainCanvas.modelService.nodes
.getConnectorsByType(destNode, FlowchartConstants.leftConnectorType);
if (destConnectors && destConnectors.length) { if (destConnectors && destConnectors.length) {
destination = destConnectors[0].id; destination = destConnectors[0].id;
} }
if (source && destination) { if (source && destination) {
const edge: FcRuleEdge = { const edge: FcRuleEdge = {
source: source, source,
destination: destination, destination,
label: connection.label, label: connection.label,
labels: connection.labels labels: connection.labels
}; };
@ -1203,7 +1205,7 @@ export class RuleChainPageComponent extends PageComponent
nodes.push(node); nodes.push(node);
} }
}); });
const firstNodeEdge = this.ruleChainModel.edges.find((edge) => edge.source === this.inputConnectorId+''); const firstNodeEdge = this.ruleChainModel.edges.find((edge) => edge.source === this.inputConnectorId + '');
if (firstNodeEdge) { if (firstNodeEdge) {
const firstNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(firstNodeEdge.destination); const firstNode = this.ruleChainCanvas.modelService.nodes.getNodeByConnectorId(firstNodeEdge.destination);
ruleChainMetaData.firstNodeIndex = nodes.indexOf(firstNode); ruleChainMetaData.firstNodeIndex = nodes.indexOf(firstNode);
@ -1241,8 +1243,8 @@ export class RuleChainPageComponent extends PageComponent
} }
} }
}); });
this.ruleChainService.saveAndGetResolvedRuleChainMetadata(ruleChainMetaData).subscribe((ruleChainMetaData) => { this.ruleChainService.saveAndGetResolvedRuleChainMetadata(ruleChainMetaData).subscribe((savedRuleChainMetaData) => {
this.ruleChainMetaData = ruleChainMetaData; this.ruleChainMetaData = savedRuleChainMetaData;
if (this.isImport) { if (this.isImport) {
this.isDirtyValue = false; this.isDirtyValue = false;
this.isImport = false; this.isImport = false;

3
ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts

@ -113,7 +113,8 @@ export class RuleChainImportGuard implements CanActivate {
private router: Router) { private router: Router) {
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):
Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if (this.itembuffer.hasRuleChainImport()) { if (this.itembuffer.hasRuleChainImport()) {
return true; return true;
} else { } else {

1
ui-ngx/src/app/modules/home/pages/rulechain/rulenode.component.ts

@ -19,6 +19,7 @@ import { Component, OnInit } from '@angular/core';
import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart'; import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart';
@Component({ @Component({
// tslint:disable-next-line:component-selector
selector: 'rule-node', selector: 'rule-node',
templateUrl: './rulenode.component.html', templateUrl: './rulenode.component.html',
styleUrls: ['./rulenode.component.scss'] styleUrls: ['./rulenode.component.scss']

2
ui-ngx/src/app/modules/home/pages/user/add-user-dialog.component.html

@ -35,7 +35,7 @@
<mat-label translate>user.activation-method</mat-label> <mat-label translate>user.activation-method</mat-label>
<mat-select matInput [ngModelOptions]="{standalone: true}" [(ngModel)]="activationMethod"> <mat-select matInput [ngModelOptions]="{standalone: true}" [(ngModel)]="activationMethod">
<mat-option *ngFor="let activationMethod of activationMethods" [value]="activationMethod"> <mat-option *ngFor="let activationMethod of activationMethods" [value]="activationMethod">
{{ activationMethodTranslations.get(activationMethod) | translate }} {{ activationMethodTranslations.get(activationMethodEnum[activationMethod]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

1
ui-ngx/src/app/modules/home/pages/user/add-user-dialog.component.ts

@ -50,6 +50,7 @@ export class AddUserDialogComponent extends DialogComponent<AddUserDialogCompone
user: User; user: User;
activationMethods = Object.keys(ActivationMethod); activationMethods = Object.keys(ActivationMethod);
activationMethodEnum = ActivationMethod;
activationMethodTranslations = activationMethodTranslations; activationMethodTranslations = activationMethodTranslations;

10
ui-ngx/src/app/modules/home/pages/widget/select-widget-type-dialog.component.html

@ -33,15 +33,15 @@
<div fxLayout="column" fxLayoutGap="16px" fxLayout.gt-sm="row" fxLayoutAlign="center center"> <div fxLayout="column" fxLayoutGap="16px" fxLayout.gt-sm="row" fxLayoutAlign="center center">
<button *ngFor="let type of allWidgetTypes;" class="tb-card-button" mat-button mat-raised-button color="primary" <button *ngFor="let type of allWidgetTypes;" class="tb-card-button" mat-button mat-raised-button color="primary"
type="button" type="button"
(click)="typeSelected(type)"> (click)="typeSelected(widgetTypes[type])">
<mat-icon *ngIf="!widgetTypesDataMap.get(type).isMdiIcon; else mdiIconBlock" class="tb-mat-96"> <mat-icon *ngIf="!widgetTypesDataMap.get(widgetTypes[type]).isMdiIcon; else mdiIconBlock" class="tb-mat-96">
{{ widgetTypesDataMap.get(type).icon }} {{ widgetTypesDataMap.get(widgetTypes[type]).icon }}
</mat-icon> </mat-icon>
<ng-template #mdiIconBlock> <ng-template #mdiIconBlock>
<mat-icon class="tb-mat-96" [svgIcon]="widgetTypesDataMap.get(type).icon"> <mat-icon class="tb-mat-96" [svgIcon]="widgetTypesDataMap.get(widgetTypes[type]).icon">
</mat-icon> </mat-icon>
</ng-template> </ng-template>
<span translate>{{ widgetTypesDataMap.get(type).name }}</span> <span translate>{{ widgetTypesDataMap.get(widgetTypes[type]).name }}</span>
</button> </button>
</div> </div>
</fieldset> </fieldset>

2
ui-ngx/src/app/modules/home/pages/widget/widget-editor.component.html

@ -29,7 +29,7 @@
<mat-select [disabled]="isReadOnly" matInput placeholder="{{ 'widget.type' | translate }}" <mat-select [disabled]="isReadOnly" matInput placeholder="{{ 'widget.type' | translate }}"
[(ngModel)]="widget.type" (ngModelChange)="widetTypeChanged()"> [(ngModel)]="widget.type" (ngModelChange)="widetTypeChanged()">
<mat-option *ngFor="let type of allWidgetTypes" [value]="type"> <mat-option *ngFor="let type of allWidgetTypes" [value]="type">
{{ widgetTypesDataMap.get(type).name | translate }} {{ widgetTypesDataMap.get(widgetTypes[type]).name | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

3
ui-ngx/src/app/modules/home/pages/widget/widget-library.component.ts

@ -88,7 +88,8 @@ export class WidgetLibraryComponent extends PageComponent implements OnInit {
getStateParams(): StateParams { getStateParams(): StateParams {
return {}; return {};
} }
} as IStateController}, } as IStateController;
},
{}); {});
@ViewChild('dashboard', {static: true}) dashboard: IDashboardComponent; @ViewChild('dashboard', {static: true}) dashboard: IDashboardComponent;

4
ui-ngx/src/app/modules/login/login-routing.module.ts

@ -15,10 +15,10 @@
/// ///
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { LoginComponent } from './pages/login/login.component'; import { LoginComponent } from './pages/login/login.component';
import { AuthGuard } from '../../core/guards/auth.guard'; import { AuthGuard } from '@core/guards/auth.guard';
import { ResetPasswordRequestComponent } from '@modules/login/pages/login/reset-password-request.component'; import { ResetPasswordRequestComponent } from '@modules/login/pages/login/reset-password-request.component';
import { ResetPasswordComponent } from '@modules/login/pages/login/reset-password.component'; import { ResetPasswordComponent } from '@modules/login/pages/login/reset-password.component';
import { CreatePasswordComponent } from '@modules/login/pages/login/create-password.component'; import { CreatePasswordComponent } from '@modules/login/pages/login/create-password.component';

12
ui-ngx/src/app/modules/login/pages/login/create-password.component.ts

@ -15,17 +15,15 @@
/// ///
import { Component, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { AuthService } from '../../../../core/auth/auth.service'; import { AuthService } from '@core/auth/auth.service';
import { LoginRequest } from '../../../../shared/models/login.models';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '../../../../core/core.state'; import { AppState } from '@core/core.state';
import { PageComponent } from '../../../../shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { ActionNotificationShow } from '@core/notification/notification.actions'; import { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Observable, Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
@Component({ @Component({
selector: 'tb-create-password', selector: 'tb-create-password',

7
ui-ngx/src/app/modules/login/pages/login/login.component.ts

@ -15,11 +15,10 @@
/// ///
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../../../core/auth/auth.service'; import { AuthService } from '@core/auth/auth.service';
import { LoginRequest } from '../../../../shared/models/login.models';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '../../../../core/core.state'; import { AppState } from '@core/core.state';
import { PageComponent } from '../../../../shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { Constants } from '@shared/models/constants'; import { Constants } from '@shared/models/constants';

7
ui-ngx/src/app/modules/login/pages/login/reset-password-request.component.ts

@ -15,11 +15,10 @@
/// ///
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../../../core/auth/auth.service'; import { AuthService } from '@core/auth/auth.service';
import { LoginRequest } from '../../../../shared/models/login.models';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '../../../../core/core.state'; import { AppState } from '@core/core.state';
import { PageComponent } from '../../../../shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { ActionNotificationShow } from '@core/notification/notification.actions'; import { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';

10
ui-ngx/src/app/modules/login/pages/login/reset-password.component.ts

@ -15,17 +15,15 @@
/// ///
import { Component, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { AuthService } from '../../../../core/auth/auth.service'; import { AuthService } from '@core/auth/auth.service';
import { LoginRequest } from '../../../../shared/models/login.models';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '../../../../core/core.state'; import { AppState } from '@core/core.state';
import { PageComponent } from '../../../../shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { ActionNotificationShow } from '@core/notification/notification.actions'; import { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Observable, Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
@Component({ @Component({
selector: 'tb-reset-password', selector: 'tb-reset-password',

2
ui-ngx/src/app/shared/components/breadcrumb.component.ts

@ -22,7 +22,7 @@ import { distinctUntilChanged, filter, map } from 'rxjs/operators';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@Component({ @Component({
selector: '[tb-breadcrumb]', selector: 'tb-breadcrumb',
templateUrl: './breadcrumb.component.html', templateUrl: './breadcrumb.component.html',
styleUrls: ['./breadcrumb.component.scss'] styleUrls: ['./breadcrumb.component.scss']
}) })

6
ui-ngx/src/app/shared/components/cheatsheet.component.ts

@ -128,7 +128,7 @@ import { Hotkey, HotkeysService } from 'angular2-hotkeys';
export class TbCheatSheetComponent implements OnInit, OnDestroy { export class TbCheatSheetComponent implements OnInit, OnDestroy {
helpVisible = false; helpVisible = false;
@Input() title: string = 'Keyboard Shortcuts:'; @Input() title = 'Keyboard Shortcuts:';
@Input() @Input()
hotkeys: Hotkey[]; hotkeys: Hotkey[];
@ -137,9 +137,9 @@ export class TbCheatSheetComponent implements OnInit, OnDestroy {
private mousetrap: MousetrapInstance; private mousetrap: MousetrapInstance;
constructor(private _elementRef: ElementRef, constructor(private elementRef: ElementRef,
private hotkeysService: HotkeysService) { private hotkeysService: HotkeysService) {
this.mousetrap = new Mousetrap(this._elementRef.nativeElement); this.mousetrap = new Mousetrap(this.elementRef.nativeElement);
this.mousetrap.bind('?', (event: KeyboardEvent, combo: string) => { this.mousetrap.bind('?', (event: KeyboardEvent, combo: string) => {
this.toggleCheatSheet(); this.toggleCheatSheet();
}); });

2
ui-ngx/src/app/shared/components/entity/entity-list-select.component.ts

@ -66,7 +66,7 @@ export class EntityListSelectComponent implements ControlValueAccessor, OnInit,
displayEntityTypeSelect: boolean; displayEntityTypeSelect: boolean;
private defaultEntityType: EntityType | AliasEntityType = null; private readonly defaultEntityType: EntityType | AliasEntityType = null;
private propagateChange = (v: any) => { }; private propagateChange = (v: any) => { };

2
ui-ngx/src/app/shared/components/entity/entity-select.component.ts

@ -60,7 +60,7 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte
displayEntityTypeSelect: boolean; displayEntityTypeSelect: boolean;
private defaultEntityType: EntityType | AliasEntityType = null; private readonly defaultEntityType: EntityType | AliasEntityType = null;
private propagateChange = (v: any) => { }; private propagateChange = (v: any) => { };

2
ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts

@ -21,7 +21,7 @@ import {AppState} from '@app/core/core.state';
import {TranslateService} from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import {AliasEntityType, EntityType, entityTypeTranslations} from '@app/shared/models/entity-type.models'; import {AliasEntityType, EntityType, entityTypeTranslations} from '@app/shared/models/entity-type.models';
import {EntityService} from '@core/http/entity.service'; import {EntityService} from '@core/http/entity.service';
import {coerceBooleanProperty} from "@angular/cdk/coercion"; import {coerceBooleanProperty} from '@angular/cdk/coercion';
@Component({ @Component({
selector: 'tb-entity-type-select', selector: 'tb-entity-type-select',

3
ui-ngx/src/app/shared/components/fab-toolbar.component.ts

@ -38,6 +38,7 @@ class MatFabToolbarBase {
const MatFabToolbarMixinBase: CanColorCtor & typeof MatFabToolbarBase = mixinColor(MatFabToolbarBase); const MatFabToolbarMixinBase: CanColorCtor & typeof MatFabToolbarBase = mixinColor(MatFabToolbarBase);
@Directive({ @Directive({
// tslint:disable-next-line:directive-selector
selector: 'mat-fab-trigger' selector: 'mat-fab-trigger'
}) })
export class FabTriggerDirective { export class FabTriggerDirective {
@ -48,6 +49,7 @@ export class FabTriggerDirective {
} }
@Directive({ @Directive({
// tslint:disable-next-line:directive-selector
selector: 'mat-fab-actions' selector: 'mat-fab-actions'
}) })
export class FabActionsDirective implements OnInit { export class FabActionsDirective implements OnInit {
@ -65,6 +67,7 @@ export class FabActionsDirective implements OnInit {
// @dynamic // @dynamic
@Component({ @Component({
// tslint:disable-next-line:component-selector
selector: 'mat-fab-toolbar', selector: 'mat-fab-toolbar',
templateUrl: './fab-toolbar.component.html', templateUrl: './fab-toolbar.component.html',
styleUrls: ['./fab-toolbar.component.scss'], styleUrls: ['./fab-toolbar.component.scss'],

1
ui-ngx/src/app/shared/components/help.component.ts

@ -18,6 +18,7 @@ import { Component, Input } from '@angular/core';
import { HelpLinks } from '@shared/models/constants'; import { HelpLinks } from '@shared/models/constants';
@Component({ @Component({
// tslint:disable-next-line:component-selector
selector: '[tb-help]', selector: '[tb-help]',
templateUrl: './help.component.html' templateUrl: './help.component.html'
}) })

33
ui-ngx/src/app/shared/components/hotkeys.directive.ts

@ -29,21 +29,21 @@ export class TbHotkeysDirective implements OnInit, OnDestroy {
private mousetrap: MousetrapInstance; private mousetrap: MousetrapInstance;
private hotkeysList: Hotkey[] = []; private hotkeysList: Hotkey[] = [];
private _preventIn = ['INPUT', 'SELECT', 'TEXTAREA']; private preventIn = ['INPUT', 'SELECT', 'TEXTAREA'];
constructor(private _elementRef: ElementRef) { constructor(private elementRef: ElementRef) {
this.mousetrap = new Mousetrap(this._elementRef.nativeElement); this.mousetrap = new Mousetrap(this.elementRef.nativeElement);
(this._elementRef.nativeElement as HTMLElement).tabIndex = -1; (this.elementRef.nativeElement as HTMLElement).tabIndex = -1;
(this._elementRef.nativeElement as HTMLElement).style.outline = '0'; (this.elementRef.nativeElement as HTMLElement).style.outline = '0';
} }
ngOnInit() { ngOnInit() {
for (let hotkey of this.hotkeys) { for (const hotkey of this.hotkeys) {
this.hotkeysList.push(hotkey); this.hotkeysList.push(hotkey);
this.bindEvent(hotkey); this.bindEvent(hotkey);
} }
if (this.cheatSheet) { if (this.cheatSheet) {
let hotkeyObj: Hotkey = new Hotkey( const hotkeyObj: Hotkey = new Hotkey(
'?', '?',
(event: KeyboardEvent) => { (event: KeyboardEvent) => {
this.cheatSheet.toggleCheatSheet(); this.cheatSheet.toggleCheatSheet();
@ -59,26 +59,27 @@ export class TbHotkeysDirective implements OnInit, OnDestroy {
} }
private bindEvent(hotkey: Hotkey): void { private bindEvent(hotkey: Hotkey): void {
this.mousetrap.bind((<Hotkey>hotkey).combo, (event: KeyboardEvent, combo: string) => { this.mousetrap.bind((hotkey as Hotkey).combo, (event: KeyboardEvent, combo: string) => {
let shouldExecute = true; let shouldExecute = true;
if(event) { if (event) {
let target: HTMLElement = <HTMLElement>(event.target || event.srcElement); const target: HTMLElement = (event.target || event.srcElement) as HTMLElement;
let nodeName: string = target.nodeName.toUpperCase(); const nodeName: string = target.nodeName.toUpperCase();
if((' ' + target.className + ' ').indexOf(' mousetrap ') > -1) { if ((' ' + target.className + ' ').indexOf(' mousetrap ') > -1) {
shouldExecute = true; shouldExecute = true;
} else if(this._preventIn.indexOf(nodeName) > -1 && (<Hotkey>hotkey).allowIn.map(allow => allow.toUpperCase()).indexOf(nodeName) === -1) { } else if (this.preventIn.indexOf(nodeName) > -1 && (hotkey as Hotkey).
allowIn.map(allow => allow.toUpperCase()).indexOf(nodeName) === -1) {
shouldExecute = false; shouldExecute = false;
} }
} }
if(shouldExecute) { if (shouldExecute) {
return (<Hotkey>hotkey).callback.apply(this, [event, combo]); return (hotkey as Hotkey).callback.apply(this, [event, combo]);
} }
}); });
} }
ngOnDestroy() { ngOnDestroy() {
for (let hotkey of this.hotkeysList) { for (const hotkey of this.hotkeysList) {
this.mousetrap.unbind(hotkey.combo); this.mousetrap.unbind(hotkey.combo);
} }
} }

2
ui-ngx/src/app/shared/components/js-func.component.ts

@ -66,7 +66,7 @@ export class JsFuncComponent implements OnInit, OnDestroy, ControlValueAccessor,
@Input() functionArgs: Array<string>; @Input() functionArgs: Array<string>;
@Input() validationArgs: Array<string>; @Input() validationArgs: Array<any>;
@Input() resultType: string; @Input() resultType: string;

2
ui-ngx/src/app/shared/components/json-form/react/json-form-schema-form.tsx

@ -41,7 +41,7 @@ const tinycolor = tinycolor_;
class ThingsboardSchemaForm extends React.Component<JsonFormProps, any> { class ThingsboardSchemaForm extends React.Component<JsonFormProps, any> {
private hasConditions: boolean; private hasConditions: boolean;
private mapper: {[type: string]: any}; private readonly mapper: {[type: string]: any};
constructor(props) { constructor(props) {
super(props); super(props);

2
ui-ngx/src/app/shared/components/mat-chip-draggable.directive.ts

@ -98,7 +98,7 @@ let globalDraggingChipListId = null;
class DraggableChip { class DraggableChip {
private chipElement: HTMLElement; private chipElement: HTMLElement;
private handle: HTMLElement; private readonly handle: HTMLElement;
private dragging = false; private dragging = false;
private counter = 0; private counter = 0;

6
ui-ngx/src/app/shared/components/nav-tree.component.ts

@ -103,10 +103,10 @@ export class NavTreeComponent implements OnInit {
private initTree() { private initTree() {
const loadNodes: LoadNodesCallback = (node, cb) => { const loadNodes: LoadNodesCallback = (node, cb) => {
const outCb = (_nodes: NavTreeNode[]) => { const outCb = (nodes: NavTreeNode[]) => {
const copied: NavTreeNode[] = []; const copied: NavTreeNode[] = [];
if (_nodes) { if (nodes) {
_nodes.forEach((n) => { nodes.forEach((n) => {
copied.push(deepClone(n, ['data'])); copied.push(deepClone(n, ['data']));
}); });
} }

4
ui-ngx/src/app/shared/components/page.component.ts

@ -16,9 +16,9 @@
import { OnDestroy } from '@angular/core'; import { OnDestroy } from '@angular/core';
import { select, Store } from '@ngrx/store'; import { select, Store } from '@ngrx/store';
import { AppState } from '../../core/core.state'; import { AppState } from '@core/core.state';
import { Observable, Subscription } from 'rxjs'; import { Observable, Subscription } from 'rxjs';
import { selectIsLoading } from '../../core/interceptors/load.selectors'; import { selectIsLoading } from '@core/interceptors/load.selectors';
import { delay, share } from 'rxjs/operators'; import { delay, share } from 'rxjs/operators';
import { AbstractControl } from '@angular/forms'; import { AbstractControl } from '@angular/forms';

2
ui-ngx/src/app/shared/components/time/timewindow-panel.component.html

@ -63,7 +63,7 @@
<mat-label translate>aggregation.function</mat-label> <mat-label translate>aggregation.function</mat-label>
<mat-select matInput formControlName="type" style="min-width: 150px;"> <mat-select matInput formControlName="type" style="min-width: 150px;">
<mat-option *ngFor="let aggregation of aggregations" [value]="aggregation"> <mat-option *ngFor="let aggregation of aggregations" [value]="aggregation">
{{ aggregationTypesTranslations.get(aggregation) | translate }} {{ aggregationTypesTranslations.get(aggregationTypes[aggregation]) | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save