Rule Chains routing refactored
This commit is contained in:
parent
0336906bf2
commit
ad91c68e11
@ -51,7 +51,6 @@ import {
|
|||||||
AddEntitiesToCustomerDialogData
|
AddEntitiesToCustomerDialogData
|
||||||
} from '../../dialogs/add-entities-to-customer-dialog.component';
|
} from '../../dialogs/add-entities-to-customer-dialog.component';
|
||||||
import { HomeDialogsService } from '@home/dialogs/home-dialogs.service';
|
import { HomeDialogsService } from '@home/dialogs/home-dialogs.service';
|
||||||
|
|
||||||
import { Edge, EdgeInfo } from "@shared/models/edge.models";
|
import { Edge, EdgeInfo } from "@shared/models/edge.models";
|
||||||
import { EdgeService } from "@core/http/edge.service";
|
import { EdgeService } from "@core/http/edge.service";
|
||||||
import { EdgeComponent } from "@home/pages/edge/edge.component";
|
import { EdgeComponent } from "@home/pages/edge/edge.component";
|
||||||
@ -96,19 +95,15 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
|
|||||||
mergeMap((savedEdge) => this.edgeService.getEdge(savedEdge.id.id)
|
mergeMap((savedEdge) => this.edgeService.getEdge(savedEdge.id.id)
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
this.config.onEntityAction = action => this.onEdgeAction(action);
|
this.config.onEntityAction = action => this.onEdgeAction(action);
|
||||||
this.config.detailsReadonly = () => this.config.componentsData.edgeScope === 'customer_user';
|
this.config.detailsReadonly = () => this.config.componentsData.edgeScope === 'customer_user';
|
||||||
|
|
||||||
this.config.headerComponent = EdgeTableHeaderComponent;
|
this.config.headerComponent = EdgeTableHeaderComponent;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> {
|
resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> {
|
||||||
const routeParams = route.params;
|
const routeParams = route.params;
|
||||||
this.config.componentsData = {
|
this.config.componentsData = {
|
||||||
edgeScope: route.data.edgesType,
|
edgeScope: route.data.edgesType
|
||||||
edgeType: ''
|
|
||||||
};
|
};
|
||||||
this.customerId = routeParams.customerId;
|
this.customerId = routeParams.customerId;
|
||||||
return this.store.pipe(select(selectAuthUser), take(1)).pipe(
|
return this.store.pipe(select(selectAuthUser), take(1)).pipe(
|
||||||
@ -166,12 +161,12 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
|
|||||||
configureEntityFunctions(edgeScope: string): void {
|
configureEntityFunctions(edgeScope: string): void {
|
||||||
if (edgeScope === 'tenant') {
|
if (edgeScope === 'tenant') {
|
||||||
this.config.entitiesFetchFunction = pageLink =>
|
this.config.entitiesFetchFunction = pageLink =>
|
||||||
this.edgeService.getTenantEdgeInfos(pageLink, this.config.componentsData.edgeType);
|
this.edgeService.getTenantEdgeInfos(pageLink);
|
||||||
this.config.deleteEntity = id => this.edgeService.deleteEdge(id.id);
|
this.config.deleteEntity = id => this.edgeService.deleteEdge(id.id);
|
||||||
}
|
}
|
||||||
if (edgeScope === 'customer') {
|
if (edgeScope === 'customer') {
|
||||||
this.config.entitiesFetchFunction = pageLink =>
|
this.config.entitiesFetchFunction = pageLink =>
|
||||||
this.edgeService.getCustomerEdgeInfos(this.customerId, pageLink, this.config.componentsData.edgeType);
|
this.edgeService.getCustomerEdgeInfos(this.customerId, pageLink);
|
||||||
this.config.deleteEntity = id => this.edgeService.unassignEdgeFromCustomer(id.id);
|
this.config.deleteEntity = id => this.edgeService.unassignEdgeFromCustomer(id.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,11 +74,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'),
|
new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'),
|
||||||
new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px',
|
new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px',
|
||||||
entity => {
|
entity => {
|
||||||
if (this.config.componentsData.edgeId) {
|
if (isDefined(this.config.componentsData.edgeId)) {
|
||||||
return checkBoxCell((this.edge.rootRuleChainId.id == entity.id.id));
|
return checkBoxCell((this.config.componentsData.edge.rootRuleChainId.id == entity.id.id));
|
||||||
} else {
|
} else {
|
||||||
return checkBoxCell(entity.root);
|
return checkBoxCell(entity.root);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title',
|
this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title',
|
||||||
@ -99,13 +99,14 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
edgeId: routeParams.edgeId
|
edgeId: routeParams.edgeId
|
||||||
};
|
};
|
||||||
if (this.config.componentsData.edgeId) {
|
if (this.config.componentsData.edgeId) {
|
||||||
this.config.entitySelectionEnabled = ruleChain => this.edge.rootRuleChainId.id != ruleChain.id.id;
|
this.config.entitySelectionEnabled = ruleChain => this.config.componentsData.edge.rootRuleChainId.id != ruleChain.id.id;
|
||||||
this.config.deleteEnabled = () => false;
|
this.config.deleteEnabled = () => false;
|
||||||
this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => {
|
this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => {
|
||||||
this.edge = edge;
|
this.config.componentsData.edge = edge;
|
||||||
this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains')
|
this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains');
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
this.config.entitySelectionEnabled = ruleChain => ruleChain && !ruleChain.root;
|
this.config.entitySelectionEnabled = ruleChain => ruleChain && !ruleChain.root;
|
||||||
this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root;
|
this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root;
|
||||||
}
|
}
|
||||||
@ -235,7 +236,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
{
|
{
|
||||||
name: this.translate.instant('edge.unassign-from-edge'),
|
name: this.translate.instant('edge.unassign-from-edge'),
|
||||||
icon: 'portable_wifi_off',
|
icon: 'portable_wifi_off',
|
||||||
isEnabled: (entity) => entity.id.id != this.edge.rootRuleChainId.id,
|
isEnabled: (entity) => entity.id.id != this.config.componentsData.edge.rootRuleChainId.id,
|
||||||
onAction: ($event, entity) => this.unassignFromEdge($event, entity)
|
onAction: ($event, entity) => this.unassignFromEdge($event, entity)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -295,7 +296,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
if (this.config.componentsData.edgeId) {
|
if (this.config.componentsData.edgeId) {
|
||||||
this.edgeService.setRootRuleChain(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
|
this.edgeService.setRootRuleChain(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
|
||||||
(edge) => {
|
(edge) => {
|
||||||
this.edge = edge;
|
this.config.componentsData.edge = edge;
|
||||||
this.config.table.updateData();
|
this.config.table.updateData();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -465,7 +466,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
|
|
||||||
isNonRootRuleChain(ruleChain: RuleChain) {
|
isNonRootRuleChain(ruleChain: RuleChain) {
|
||||||
if (this.config.componentsData.edgeId) {
|
if (this.config.componentsData.edgeId) {
|
||||||
return (isDefined(this.edge.rootRuleChainId) && this.edge.rootRuleChainId != null && this.edge.rootRuleChainId.id != ruleChain.id.id);
|
return (isDefined(this.config.componentsData.edge.rootRuleChainId) && this.config.componentsData.edge.rootRuleChainId != null && this.config.componentsData.edge.rootRuleChainId.id != ruleChain.id.id);
|
||||||
}
|
}
|
||||||
return (isDefined(ruleChain)) && !ruleChain.root;
|
return (isDefined(ruleChain)) && !ruleChain.root;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ export enum DebugEventType {
|
|||||||
DEBUG_RULE_NODE = 'DEBUG_RULE_NODE',
|
DEBUG_RULE_NODE = 'DEBUG_RULE_NODE',
|
||||||
DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN'
|
DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN'
|
||||||
}
|
}
|
||||||
//TODO deaflynx filter CE only event types
|
|
||||||
export enum EdgeEventType {
|
export enum EdgeEventType {
|
||||||
DASHBOARD = "DASHBOARD",
|
DASHBOARD = "DASHBOARD",
|
||||||
ASSET = "ASSET",
|
ASSET = "ASSET",
|
||||||
@ -44,11 +44,6 @@ export enum EdgeEventType {
|
|||||||
USER = "USER",
|
USER = "USER",
|
||||||
CUSTOMER = "CUSTOMER",
|
CUSTOMER = "CUSTOMER",
|
||||||
RELATION = "RELATION",
|
RELATION = "RELATION",
|
||||||
ENTITY_GROUP = "ENTITY_GROUP",
|
|
||||||
SCHEDULER_EVENT = "SCHEDULER_EVENT",
|
|
||||||
WHITE_LABELING = "WHITE_LABELING",
|
|
||||||
LOGIN_WHITE_LABELING = "LOGIN_WHITE_LABELING",
|
|
||||||
CUSTOM_TRANSLATION = "CUSTOM_TRANSLATION",
|
|
||||||
WIDGETS_BUNDLE = "WIDGETS_BUNDLE",
|
WIDGETS_BUNDLE = "WIDGETS_BUNDLE",
|
||||||
WIDGET_TYPE = "WIDGET_TYPE",
|
WIDGET_TYPE = "WIDGET_TYPE",
|
||||||
ADMIN_SETTINGS = "ADMIN_SETTINGS"
|
ADMIN_SETTINGS = "ADMIN_SETTINGS"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user