Browse Source

Merge voba with new rulechain type

pull/3811/head
deaflynx 6 years ago
parent
commit
bbb625c67f
  1. 4
      ui-ngx/src/app/core/http/entity.service.ts
  2. 8
      ui-ngx/src/app/core/http/rule-chain.service.ts
  3. 2
      ui-ngx/src/app/core/services/item-buffer.service.ts
  4. 9
      ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts
  5. 4
      ui-ngx/src/app/modules/home/components/rule-chain/rule-chain-autocomplete.component.ts
  6. 4
      ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts
  7. 6
      ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts
  8. 28
      ui-ngx/src/app/modules/home/pages/edge/edge.component.ts
  9. 79
      ui-ngx/src/app/modules/home/pages/edge/edges-table-config.resolver.ts
  10. 6
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts
  11. 13
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts
  12. 7
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts
  13. 14
      ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts
  14. 4
      ui-ngx/src/app/modules/home/pages/rulechain/rulenode.component.ts
  15. 16
      ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts
  16. 14
      ui-ngx/src/app/shared/components/widgets-bundle-select.component.ts
  17. 4
      ui-ngx/src/app/shared/models/rule-chain.models.ts
  18. 3
      ui-ngx/src/app/shared/models/rule-node.models.ts

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

@ -69,9 +69,9 @@ import {
} from '@shared/models/query/query.models';
import { alarmFields } from '@shared/models/alarm.models';
import { EdgeService } from "@core/http/edge.service";
import { ruleChainType } from "@shared/models/rule-chain.models";
import { Edge } from '@shared/models/edge.models';
import { WINDOW } from "@core/services/window.service";
import { RuleChainType } from "@shared/models/rule-chain.models";
@Injectable({
providedIn: 'root'
@ -327,7 +327,7 @@ export class EntityService {
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, subType, config);
} else {
// safe fallback to default core type
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.core, config);
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, RuleChainType.core, config);
}
break;
case EntityType.DASHBOARD:

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

@ -151,12 +151,8 @@ export class RuleChainService {
return this.ruleNodeConfigFactories[directive];
}
public getRuleNodeComponentByClazz(clazz: string): RuleNodeComponentDescriptor {
let mergedRuleNodeComponents: RuleNodeComponentDescriptor[] = [];
this.ruleNodeComponentsMap.forEach((value: Array<RuleNodeComponentDescriptor>, key: RuleChainType) => {
mergedRuleNodeComponents = mergedRuleNodeComponents.concat(value);
});
const found = mergedRuleNodeComponents.filter((component) => component.clazz === clazz);
public getRuleNodeComponentByClazz(ruleChainType: RuleChainType = RuleChainType.core, clazz: string): RuleNodeComponentDescriptor {
const found = this.ruleNodeComponentsMap.get(ruleChainType).filter((component) => component.clazz === clazz);
if (found && found.length) {
return found[0];
} else {

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

@ -331,7 +331,7 @@ export class ItemBufferService {
const deltaX = x - ruleNodes.originX;
const deltaY = y - ruleNodes.originY;
for (const node of ruleNodes.nodes) {
const component = this.ruleChainService.getRuleNodeComponentByClazz(node.componentClazz);
const component = this.ruleChainService.getRuleNodeComponentByClazz(node.ruleChainType, node.componentClazz);
if (component) {
let icon = ruleNodeTypeDescriptors.get(component.type).icon;
let iconUrl: string = null;

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

@ -56,8 +56,7 @@ import {
RuleChain,
RuleChainImport,
RuleChainMetaData,
RuleChainType,
ruleChainType
RuleChainType
} from '@shared/models/rule-chain.models';
import { RuleChainService } from '@core/http/rule-chain.service';
import * as JSZip from 'jszip';
@ -406,9 +405,6 @@ export class ImportExportService {
public importRuleChain(expectedRuleChainType: RuleChainType): Observable<RuleChainImport> {
return this.openImportDialog('rulechain.import', 'rulechain.rulechain-file').pipe(
mergeMap((ruleChainImport: RuleChainImport) => {
if (isUndefined(ruleChainImport.ruleChain.type)) {
ruleChainImport.ruleChain.type = ruleChainType.core;
}
if (!this.validateImportedRuleChain(ruleChainImport)) {
this.store.dispatch(new ActionNotificationShow(
{message: this.translate.instant('rulechain.invalid-rulechain-file-error'),
@ -472,6 +468,9 @@ export class ImportExportService {
|| isUndefined(ruleChainImport.ruleChain.name)) {
return false;
}
if (isUndefined(ruleChainImport.ruleChain.type)) {
ruleChainImport.ruleChain.type = RuleChainType.core;
}
return true;
}

4
ui-ngx/src/app/modules/home/components/rule-chain/rule-chain-autocomplete.component.ts

@ -29,7 +29,7 @@ import { EntityService } from '@core/http/entity.service';
import { TruncatePipe } from '@shared/pipe/truncate.pipe';
import { RuleChainService } from '@core/http/rule-chain.service';
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
import { ruleChainType } from '@app/shared/models/rule-chain.models';
import { RuleChainType } from '@app/shared/models/rule-chain.models';
@Component({
selector: 'tb-rule-chain-autocomplete',
@ -190,7 +190,7 @@ export class RuleChainAutocompleteComponent implements ControlValueAccessor, OnI
this.searchText = searchText;
// voba: at the moment device profiles are not supported by edge, so 'core' hardcoded
return this.entityService.getEntitiesByNameFilter(EntityType.RULE_CHAIN, searchText,
50, ruleChainType.core, {ignoreLoading: true});
50, RuleChainType.core, {ignoreLoading: true});
}
clear() {

4
ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts

@ -30,7 +30,7 @@ import { DashboardService } from '@core/http/dashboard.service';
import { DialogComponent } from '@shared/components/dialog.component';
import { Router } from '@angular/router';
import { RuleChainService } from '@core/http/rule-chain.service';
import { ruleChainType } from '@shared/models/rule-chain.models';
import { RuleChainType } from '@shared/models/rule-chain.models';
export interface AddEntitiesToEdgeDialogData {
edgeId: string;
@ -85,7 +85,7 @@ export class AddEntitiesToEdgeDialogComponent extends
case EntityType.RULE_CHAIN:
this.assignToEdgeTitle = 'rulechain.assign-rulechain-to-edge-title';
this.assignToEdgeText = 'rulechain.assign-rulechain-to-edge-text';
this.subType = ruleChainType.edge;
this.subType = RuleChainType.edge;
break;
case EntityType.ASSET:
this.assignToEdgeTitle = 'asset.assign-asset-to-edge-title';

6
ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts

@ -29,7 +29,7 @@ import { dashboardBreadcumbLabelFunction, DashboardResolver } from '@home/pages/
import { BreadCrumbConfig } from '@shared/components/breadcrumb';
import { RuleChainPageComponent } from '@home/pages/rulechain/rulechain-page.component';
import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
import { ruleChainType } from '@shared/models/rule-chain.models';
import { RuleChainType } from '@shared/models/rule-chain.models';
import {
importRuleChainBreadcumbLabelFunction,
ResolvedRuleChainMetaDataResolver,
@ -189,7 +189,7 @@ const routes: Routes = [
auth: [Authority.TENANT_ADMIN],
title: 'rulechain.edge-rulechain',
import: false,
ruleChainType: ruleChainType.edge
ruleChainType: RuleChainType.edge
},
resolve: {
ruleChain: RuleChainResolver,
@ -210,7 +210,7 @@ const routes: Routes = [
auth: [Authority.TENANT_ADMIN],
title: 'rulechain.edge-rulechain',
import: true,
ruleChainType: ruleChainType.edge
ruleChainType: RuleChainType.edge
},
resolve: {
ruleNodeComponents: RuleNodeComponentsResolver

28
ui-ngx/src/app/modules/home/pages/edge/edge.component.ts

@ -24,7 +24,7 @@ import { EdgeInfo } from '@shared/models/edge.models';
import { TranslateService } from '@ngx-translate/core';
import { NULL_UUID } from '@shared/models/id/has-uuid';
import { ActionNotificationShow } from '@core/notification/notification.actions';
import { guid, isUndefined } from '@core/utils';
import { generateSecret, guid } from '@core/utils';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
import { WINDOW } from '@core/services/window.service';
@ -51,7 +51,7 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
ngOnInit() {
this.edgeScope = this.entitiesTableConfig.componentsData.edgeScope;
this.entityForm.patchValue({
cloudEndpoint:this.window.location.origin
cloudEndpoint: this.window.location.origin
});
super.ngOnInit();
}
@ -76,8 +76,8 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
label: [entity ? entity.label : ''],
cloudEndpoint: [null, [Validators.required]],
edgeLicenseKey: ['', [Validators.required]],
routingKey: this.fb.control({ value: entity ? entity.routingKey : null, disabled: true }),
secret: this.fb.control({ value: entity ? entity.secret : null, disabled: true }),
routingKey: this.fb.control({value: entity ? entity.routingKey : null, disabled: true}),
secret: this.fb.control({value: entity ? entity.secret : null, disabled: true}),
additionalInfo: this.fb.group(
{
description: [entity && entity.additionalInfo ? entity.additionalInfo.description : '']
@ -107,14 +107,14 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
updateFormState() {
super.updateFormState();
this.entityForm.get('routingKey').disable({ emitEvent: false });
this.entityForm.get('secret').disable({ emitEvent: false });
this.entityForm.get('routingKey').disable({emitEvent: false});
this.entityForm.get('secret').disable({emitEvent: false});
}
private checkIsNewEdge(entity: EdgeInfo, form: FormGroup) {
if (entity && !entity.id) {
form.get('routingKey').patchValue(guid(), { emitEvent: false });
form.get('secret').patchValue(this.generateSecret(20), { emitEvent: false });
form.get('routingKey').patchValue(guid(), {emitEvent: false});
form.get('secret').patchValue(generateSecret(20), {emitEvent: false});
}
}
@ -129,18 +129,6 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
}));
}
generateSecret(length): string {
if (isUndefined(length) || length == null) {
length = 1;
}
var l = length > 10 ? 10 : length;
var str = Math.random().toString(36).substr(2, l);
if (str.length >= length) {
return str;
}
return str.concat(this.generateSecret(length - str.length));
}
onEdgeInfoCopied(type: string) {
const message = type === 'key' ? 'edge.edge-key-copied-message'
: 'edge.edge-secret-copied-message';

79
ui-ngx/src/app/modules/home/pages/edge/edges-table-config.resolver.ts

@ -210,31 +210,31 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
name: this.translate.instant('edge.manage-edge-assets'),
icon: 'domain',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeAssets($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ASSET)
},
{
name: this.translate.instant('edge.manage-edge-devices'),
icon: 'devices_other',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeDevices($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DEVICE)
},
{
name: this.translate.instant('edge.manage-edge-entity-views'),
icon: 'view_quilt',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeEntityViews($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ENTITY_VIEW)
},
{
name: this.translate.instant('edge.manage-edge-dashboards'),
icon: 'dashboard',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeDashboards($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DASHBOARD)
},
{
name: this.translate.instant('edge.manage-edge-rulechains'),
icon: 'settings_ethernet',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeRuleChains($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.RULE_CHAIN)
}
);
}
@ -260,25 +260,25 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
name: this.translate.instant('edge.manage-edge-assets'),
icon: 'domain',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeAssets($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ASSET)
},
{
name: this.translate.instant('edge.manage-edge-devices'),
icon: 'devices_other',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeDevices($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DEVICE)
},
{
name: this.translate.instant('edge.manage-edge-entity-views'),
icon: 'view_quilt',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeEntityViews($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ENTITY_VIEW)
},
{
name: this.translate.instant('edge.manage-edge-dashboards'),
icon: 'dashboard',
isEnabled: (entity) => true,
onAction: ($event, entity) => this.openEdgeDashboards($event, entity)
onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DASHBOARD)
}
);
}
@ -392,39 +392,32 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
);
}
openEdgeDashboards($event, edge) {
openEdgeEntitiesByType($event: Event, edge: Edge, entityType: EntityType) {
if ($event) {
$event.stopPropagation();
}
this.router.navigateByUrl(`edges/${edge.id.id}/dashboards`);
}
openEdgeRuleChains($event, edge) {
if ($event) {
$event.stopPropagation();
}
this.router.navigateByUrl(`edges/${edge.id.id}/ruleChains`);
}
openEdgeAssets($event: Event, edge: Edge) {
if ($event) {
$event.stopPropagation();
}
this.router.navigateByUrl(`edges/${edge.id.id}/assets`);
}
openEdgeDevices($event, edge) {
if ($event) {
$event.stopPropagation();
}
this.router.navigateByUrl(`edges/${edge.id.id}/devices`);
}
openEdgeEntityViews($event, edge) {
if ($event) {
$event.stopPropagation();
let suffix: string;
switch (entityType) {
case EntityType.DEVICE:
suffix = 'devices';
break;
case EntityType.ASSET:
suffix = 'assets';
break;
case EntityType.EDGE:
suffix = 'assets';
break;
case EntityType.ENTITY_VIEW:
suffix = 'entityViews';
break;
case EntityType.DASHBOARD:
suffix = 'dashboards';
break;
case EntityType.RULE_CHAIN:
suffix = 'ruleChains';
break;
}
this.router.navigateByUrl(`edges/${edge.id.id}/entityViews`);
this.router.navigateByUrl(`edges/${edge.id.id}/${suffix}`);
}
assignToCustomer($event: Event, edgesIds: Array<EdgeId>) {
@ -537,19 +530,19 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
this.unassignFromCustomer(action.event, action.entity);
return true;
case 'openEdgeAssets':
this.openEdgeAssets(action.event, action.entity);
this.openEdgeEntitiesByType(action.event, action.entity, EntityType.ASSET);
return true;
case 'openEdgeDevices':
this.openEdgeDevices(action.event, action.entity);
this.openEdgeEntitiesByType(action.event, action.entity, EntityType.DEVICE);
return true;
case 'openEdgeEntityViews':
this.openEdgeEntityViews(action.event, action.entity);
this.openEdgeEntitiesByType(action.event, action.entity, EntityType.ENTITY_VIEW);
return true;
case 'openEdgeDashboards':
this.openEdgeDashboards(action.event, action.entity);
this.openEdgeEntitiesByType(action.event, action.entity, EntityType.DASHBOARD);
return true;
case 'openEdgeRuleChains':
this.openEdgeRuleChains(action.event, action.entity);
this.openEdgeEntitiesByType(action.event, action.entity, EntityType.RULE_CHAIN);
return true;
case 'syncEdge':
this.syncEdge(action.event, action.entity);

6
ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts

@ -25,7 +25,7 @@ import { Subscription } from 'rxjs';
import { RuleChainService } from '@core/http/rule-chain.service';
import { RuleNodeConfigComponent } from './rule-node-config.component';
import { Router } from '@angular/router';
import { ruleChainType } from '@app/shared/models/rule-chain.models';
import { RuleChainType } from '@app/shared/models/rule-chain.models';
@Component({
selector: 'tb-rule-node',
@ -43,7 +43,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
ruleChainId: string;
@Input()
ruleChainType: string;
ruleChainType: RuleChainType;
@Input()
isEdit: boolean;
@ -151,7 +151,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
$event.stopPropagation();
}
if (this.ruleNode.targetRuleChainId) {
if (this.ruleChainType === ruleChainType.edge) {
if (this.ruleChainType === RuleChainType.edge) {
this.router.navigateByUrl(`/edges/ruleChains/${this.ruleNode.targetRuleChainId}`);
} else {
this.router.navigateByUrl(`/ruleChains/${this.ruleNode.targetRuleChainId}`);

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

@ -48,8 +48,7 @@ import {
RuleChainConnectionInfo,
RuleChainImport,
RuleChainMetaData,
ruleChainNodeComponent,
ruleChainType
ruleChainNodeComponent, RuleChainType
} from '@shared/models/rule-chain.models';
import { FcItemInfo, FlowchartConstants, NgxFlowchartComponent, UserCallbacks } from 'ngx-flowchart/dist/ngx-flowchart';
import {
@ -120,7 +119,7 @@ export class RuleChainPageComponent extends PageComponent
isDirtyValue: boolean;
isInvalid = false;
ruleChainType: string;
ruleChainType: RuleChainType;
errorTooltips: {[nodeId: string]: JQueryTooltipster.ITooltipsterInstance} = {};
isFullscreen = false;
@ -514,7 +513,7 @@ export class RuleChainPageComponent extends PageComponent
);
const nodes: FcRuleNode[] = [];
this.ruleChainMetaData.nodes.forEach((ruleNode) => {
const component = this.ruleChainService.getRuleNodeComponentByClazz(ruleNode.type);
const component = this.ruleChainService.getRuleNodeComponentByClazz(this.ruleChainType, ruleNode.type);
const descriptor = ruleNodeTypeDescriptors.get(component.type);
let icon = descriptor.icon;
let iconUrl = null;
@ -1287,7 +1286,7 @@ export class RuleChainPageComponent extends PageComponent
if (this.isImport) {
this.isDirtyValue = false;
this.isImport = false;
if (this.ruleChainType !== ruleChainType.edge) {
if (this.ruleChainType !== RuleChainType.edge) {
this.router.navigateByUrl(`ruleChains/${this.ruleChain.id.id}`);
} else {
this.router.navigateByUrl(`edges/ruleChains/${this.ruleChain.id.id}`);
@ -1514,7 +1513,7 @@ export class AddRuleNodeLinkDialogComponent extends DialogComponent<AddRuleNodeL
export interface AddRuleNodeDialogData {
ruleNode: FcRuleNode;
ruleChainId: string;
ruleChainType: string;
ruleChainType: RuleChainType;
}
@Component({
@ -1530,7 +1529,7 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo
ruleNode: FcRuleNode;
ruleChainId: string;
ruleChainType: string;
ruleChainType: RuleChainType;
submitted = false;

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

@ -33,8 +33,7 @@ import { Observable } from 'rxjs';
import { BreadCrumbConfig, BreadCrumbLabelFunction } from '@shared/components/breadcrumb';
import {
ResolvedRuleChainMetaData,
RuleChain,
ruleChainType,
RuleChain, RuleChainType
} from '@shared/models/rule-chain.models';
import { RuleChainService } from '@core/http/rule-chain.service';
import { RuleChainPageComponent } from '@home/pages/rulechain/rulechain-page.component';
@ -145,7 +144,7 @@ const routes: Routes = [
auth: [Authority.TENANT_ADMIN],
title: 'rulechain.rulechain',
import: false,
ruleChainType: ruleChainType.core
ruleChainType: RuleChainType.core
},
resolve: {
ruleChain: RuleChainResolver,
@ -166,7 +165,7 @@ const routes: Routes = [
auth: [Authority.TENANT_ADMIN],
title: 'rulechain.rulechain',
import: true,
ruleChainType: ruleChainType.core
ruleChainType: RuleChainType.core
},
resolve: {
ruleNodeComponents: RuleNodeComponentsResolver

14
ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts

@ -31,7 +31,7 @@ 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 { 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';
@ -272,7 +272,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
if ($event) {
$event.stopPropagation();
}
const expectedRuleChainType = this.config.componentsData.ruleChainScope === 'tenant' ? ruleChainType.core : ruleChainType.edge;
const expectedRuleChainType = this.config.componentsData.ruleChainScope === 'tenant' ? RuleChainType.core : RuleChainType.edge;
this.importExport.importRuleChain(expectedRuleChainType).subscribe((ruleChainImport) => {
if (ruleChainImport) {
this.itembuffer.storeRuleChainImport(ruleChainImport);
@ -299,12 +299,12 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
saveRuleChain(ruleChain: RuleChain) {
if (isUndefined(ruleChain.type)) {
if (this.config.componentsData.ruleChainScope == 'tenant') {
ruleChain.type = ruleChainType.core;
ruleChain.type = RuleChainType.core;
} else if (this.config.componentsData.ruleChainScope == 'edges') {
ruleChain.type = ruleChainType.edge;
ruleChain.type = RuleChainType.edge;
} else {
// safe fallback to default core type
ruleChain.type = ruleChainType.core;
ruleChain.type = RuleChainType.core;
}
}
return this.ruleChainService.saveRuleChain(ruleChain);
@ -550,7 +550,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
}
fetchRuleChains(pageLink: PageLink) {
return this.ruleChainService.getRuleChains(pageLink, ruleChainType.core);
return this.ruleChainService.getRuleChains(pageLink, RuleChainType.core);
}
fetchEdgeRuleChains(pageLink: PageLink) {
@ -558,7 +558,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
mergeMap((ruleChains) => {
this.config.componentsData.autoAssignToEdgeRuleChainIds = [];
ruleChains.map(ruleChain => this.config.componentsData.autoAssignToEdgeRuleChainIds.push(ruleChain.id.id));
return this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge);
return this.ruleChainService.getRuleChains(pageLink, RuleChainType.edge);
})
);
}

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

@ -19,7 +19,7 @@ import { Component, OnInit } from '@angular/core';
import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart';
import { FcRuleNode, RuleNodeType } from '@shared/models/rule-node.models';
import { Router } from '@angular/router';
import { ruleChainType } from '@app/shared/models/rule-chain.models';
import { RuleChainType } from '@app/shared/models/rule-chain.models';
@Component({
// tslint:disable-next-line:component-selector
@ -49,7 +49,7 @@ export class RuleNodeComponent extends FcNodeComponent implements OnInit {
$event.stopPropagation();
}
if (node.targetRuleChainId) {
if (node.ruleChainType === ruleChainType.edge) {
if (node.ruleChainType === RuleChainType.edge) {
this.router.navigateByUrl(`/edges/ruleChains/${node.targetRuleChainId}`);
} else {
this.router.navigateByUrl(`/ruleChains/${node.targetRuleChainId}`);

16
ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts

@ -121,16 +121,14 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
this.config.entitySelectionEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
this.config.detailsReadonly = (widgetsBundle) => !this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
const authState = getCurrentAuthState(this.store);
if (!authState.edgesSupportEnabled) {
this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink).pipe(
map((widgetBundles) => {
this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink).pipe(
map((widgetBundles) => {
if (!authState.edgesSupportEnabled) {
widgetBundles.data = widgetBundles.data.filter(widgetBundle => widgetBundle.alias !== 'edge_widgets');
return widgetBundles;
})
);
} else {
this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink);
}
}
return widgetBundles;
})
);
return this.config;
}

14
ui-ngx/src/app/shared/components/widgets-bundle-select.component.ts

@ -82,6 +82,13 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni
ngOnInit() {
this.widgetsBundles$ = this.getWidgetsBundles().pipe(
map((widgetsBundles) => {
const authState = getCurrentAuthState(this.store);
if (!authState.edgesSupportEnabled) {
widgetsBundles = widgetsBundles.filter(widgetsBundle => widgetsBundle.alias !== 'edge_widgets');
}
return widgetsBundles;
}),
tap((widgetsBundles) => {
this.widgetsBundles = widgetsBundles;
if (this.selectFirstBundle) {
@ -95,13 +102,6 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni
}
}
}),
map((widgetsBundles) => {
const authState = getCurrentAuthState(this.store);
if (!authState.edgesSupportEnabled) {
widgetsBundles = widgetsBundles.filter(widgetsBundle => widgetsBundle.alias !== 'edge_widgets');
}
return widgetsBundles;
}),
share()
);
}

4
ui-ngx/src/app/shared/models/rule-chain.models.ts

@ -113,9 +113,7 @@ export const inputNodeComponent: RuleNodeComponentDescriptor = {
clazz: 'tb.internal.Input'
};
export declare type RuleChainType = 'CORE' | 'EDGE';
export enum ruleChainType {
export enum RuleChainType {
core = 'CORE',
edge = 'EDGE'
}

3
ui-ngx/src/app/shared/models/rule-node.models.ts

@ -25,6 +25,7 @@ import { AfterViewInit, EventEmitter, Inject, OnInit, Directive } from '@angular
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { AbstractControl, FormGroup } from '@angular/forms';
import { RuleChainType } from '@shared/models/rule-chain.models';
export interface RuleNodeConfiguration {
[key: string]: any;
@ -313,7 +314,7 @@ export interface FcRuleNode extends FcRuleNodeType {
error?: string;
highlighted?: boolean;
componentClazz?: string;
ruleChainType?: string;
ruleChainType?: RuleChainType;
}
export interface FcRuleEdge extends FcEdge {

Loading…
Cancel
Save