diff --git a/ui-ngx/proxy.conf.js b/ui-ngx/proxy.conf.js index 5be6bde1d1..a0881867ca 100644 --- a/ui-ngx/proxy.conf.js +++ b/ui-ngx/proxy.conf.js @@ -14,8 +14,8 @@ * limitations under the License. */ -const forwardUrl = "http://localhost:8080"; -const wsForwardUrl = "ws://localhost:8080"; +const forwardUrl = "http://localhost:8081"; +const wsForwardUrl = "ws://localhost:8081"; const ruleNodeUiforwardUrl = forwardUrl; const PROXY_CONFIG = { diff --git a/ui-ngx/src/app/core/http/rule-chain.service.ts b/ui-ngx/src/app/core/http/rule-chain.service.ts index 5c01902896..e4e5015577 100644 --- a/ui-ngx/src/app/core/http/rule-chain.service.ts +++ b/ui-ngx/src/app/core/http/rule-chain.service.ts @@ -324,9 +324,8 @@ export class RuleChainService { return this.http.get>(`/api/ruleChain/defaultEdgeRuleChains`, defaultHttpOptionsFromConfig(config)); } - public setEdgeRootRuleChain(edgeId: string, ruleChainId: string, config?: RequestConfig): Observable { //TODO deaflynx EdgeInfo vs. Edge check usage - return this.http.post(`/api/edge/${edgeId}/${ruleChainId}/root`, - defaultHttpOptionsFromConfig(config)); + public setEdgeRootRuleChain(edgeId: string, ruleChainId: string, config?: RequestConfig): Observable { + return this.http.post(`/api/edge/${edgeId}/${ruleChainId}/root`, defaultHttpOptionsFromConfig(config)); } } diff --git a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts index 53c70ce0ee..6cd1cf5a54 100644 --- a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts +++ b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts @@ -52,7 +52,13 @@ import { NULL_UUID } from '@shared/models/id/has-uuid'; import { WidgetsBundle } from '@shared/models/widgets-bundle.model'; import { ImportEntitiesResultInfo, ImportEntityData } from '@shared/models/entity.models'; import { RequestConfig } from '@core/http/http-utils'; -import { RuleChain, RuleChainImport, RuleChainMetaData } from '@shared/models/rule-chain.models'; +import { + RuleChain, + RuleChainImport, + RuleChainMetaData, + RuleChainType, + ruleChainType +} from '@shared/models/rule-chain.models'; import { RuleChainService } from '@core/http/rule-chain.service'; import * as JSZip from 'jszip'; import { FiltersInfo } from '@shared/models/query/query.models'; @@ -397,7 +403,7 @@ export class ImportExportService { ); } - public importRuleChain(): Observable { + public importRuleChain(expectedRuleChainType: RuleChainType): Observable { return this.openImportDialog('rulechain.import', 'rulechain.rulechain-file').pipe( mergeMap((ruleChainImport: RuleChainImport) => { if (!this.validateImportedRuleChain(ruleChainImport)) { @@ -405,6 +411,11 @@ export class ImportExportService { {message: this.translate.instant('rulechain.invalid-rulechain-file-error'), type: 'error'})); throw new Error('Invalid rule chain file'); + } else if (ruleChainImport.ruleChain.type !== expectedRuleChainType) { + this.store.dispatch(new ActionNotificationShow( + {message: this.translate.instant('rulechain.invalid-rulechain-type-error', { expectedRuleChainType: expectedRuleChainType }), + type: 'error'})); + throw new Error('Invalid rule chain file'); } else { return this.ruleChainService.resolveRuleChainMetadata(ruleChainImport.metadata).pipe( map((resolvedMetadata) => { @@ -458,6 +469,9 @@ export class ImportExportService { || isUndefined(ruleChainImport.ruleChain.name)) { return false; } + if (isUndefined(ruleChainImport.ruleChain.type)) { + ruleChainImport.ruleChain.type = ruleChainType.core; + } return true; } diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts index fb15089e02..69efc2d7f2 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts @@ -14,39 +14,40 @@ /// limitations under the License. /// -import { Injectable } from '@angular/core'; +import {Injectable} from '@angular/core'; -import {ActivatedRouteSnapshot, Resolve, Route, Router} from '@angular/router'; +import {ActivatedRouteSnapshot, Resolve, Router} from '@angular/router'; import { CellActionDescriptor, checkBoxCell, - DateEntityTableColumn, EntityColumn, + DateEntityTableColumn, + EntityColumn, EntityTableColumn, EntityTableConfig, - GroupActionDescriptor, HeaderActionDescriptor + GroupActionDescriptor, + HeaderActionDescriptor } from '@home/models/entity/entities-table-config.models'; -import { TranslateService } from '@ngx-translate/core'; -import { DatePipe } from '@angular/common'; -import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models'; -import { EntityAction } from '@home/models/entity/entity-component.models'; -import { RuleChain, ruleChainType } from '@shared/models/rule-chain.models'; -import { RuleChainService } from '@core/http/rule-chain.service'; -import { RuleChainComponent } from '@modules/home/pages/rulechain/rulechain.component'; -import { DialogService } from '@core/services/dialog.service'; -import { RuleChainTabsComponent } from '@home/pages/rulechain/rulechain-tabs.component'; -import { ImportExportService } from '@home/components/import-export/import-export.service'; -import { ItemBufferService } from '@core/services/item-buffer.service'; -import { EdgeService } from "@core/http/edge.service"; -import {map, mergeMap} from "rxjs/operators"; -import { forkJoin, Observable } from "rxjs"; +import {TranslateService} from '@ngx-translate/core'; +import {DatePipe} from '@angular/common'; +import {EntityType, entityTypeResources, entityTypeTranslations} from '@shared/models/entity-type.models'; +import {EntityAction} from '@home/models/entity/entity-component.models'; +import {RuleChain, ruleChainType} from '@shared/models/rule-chain.models'; +import {RuleChainService} from '@core/http/rule-chain.service'; +import {RuleChainComponent} from '@modules/home/pages/rulechain/rulechain.component'; +import {DialogService} from '@core/services/dialog.service'; +import {RuleChainTabsComponent} from '@home/pages/rulechain/rulechain-tabs.component'; +import {ImportExportService} from '@home/components/import-export/import-export.service'; +import {ItemBufferService} from '@core/services/item-buffer.service'; +import {EdgeService} from "@core/http/edge.service"; +import {forkJoin, Observable} from "rxjs"; import { AddEntitiesToEdgeDialogComponent, AddEntitiesToEdgeDialogData } from "@home/dialogs/add-entities-to-edge-dialog.component"; -import { MatDialog } from "@angular/material/dialog"; -import { isDefined, isUndefined } from "@core/utils"; -import { PageLink } from "@shared/models/page/page-link"; -import { Edge } from "@shared/models/edge.models"; +import {MatDialog} from "@angular/material/dialog"; +import {isDefined, isUndefined} from "@core/utils"; +import {PageLink} from "@shared/models/page/page-link"; +import {Edge} from "@shared/models/edge.models"; @Injectable() export class RuleChainsTableConfigResolver implements Resolve> { @@ -267,7 +268,8 @@ export class RuleChainsTableConfigResolver implements Resolve { + const expectedRuleChainType = this.config.componentsData.ruleChainScope === 'tenant' ? ruleChainType.core : ruleChainType.edge; + this.importExport.importRuleChain(expectedRuleChainType).subscribe((ruleChainImport) => { if (ruleChainImport) { this.itembuffer.storeRuleChainImport(ruleChainImport); this.router.navigateByUrl(`${this.router.routerState.snapshot.url}/ruleChain/import`);