Rule Chains routing refactored
This commit is contained in:
parent
0336906bf2
commit
ad91c68e11
@ -51,7 +51,6 @@ import {
|
||||
AddEntitiesToCustomerDialogData
|
||||
} from '../../dialogs/add-entities-to-customer-dialog.component';
|
||||
import { HomeDialogsService } from '@home/dialogs/home-dialogs.service';
|
||||
|
||||
import { Edge, EdgeInfo } from "@shared/models/edge.models";
|
||||
import { EdgeService } from "@core/http/edge.service";
|
||||
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)
|
||||
));
|
||||
};
|
||||
|
||||
this.config.onEntityAction = action => this.onEdgeAction(action);
|
||||
this.config.detailsReadonly = () => this.config.componentsData.edgeScope === 'customer_user';
|
||||
|
||||
this.config.headerComponent = EdgeTableHeaderComponent;
|
||||
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> {
|
||||
const routeParams = route.params;
|
||||
this.config.componentsData = {
|
||||
edgeScope: route.data.edgesType,
|
||||
edgeType: ''
|
||||
edgeScope: route.data.edgesType
|
||||
};
|
||||
this.customerId = routeParams.customerId;
|
||||
return this.store.pipe(select(selectAuthUser), take(1)).pipe(
|
||||
@ -166,12 +161,12 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
|
||||
configureEntityFunctions(edgeScope: string): void {
|
||||
if (edgeScope === 'tenant') {
|
||||
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);
|
||||
}
|
||||
if (edgeScope === 'customer') {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'),
|
||||
new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px',
|
||||
entity => {
|
||||
if (this.config.componentsData.edgeId) {
|
||||
return checkBoxCell((this.edge.rootRuleChainId.id == entity.id.id));
|
||||
if (isDefined(this.config.componentsData.edgeId)) {
|
||||
return checkBoxCell((this.config.componentsData.edge.rootRuleChainId.id == entity.id.id));
|
||||
} else {
|
||||
return checkBoxCell(entity.root);
|
||||
}
|
||||
@ -99,13 +99,14 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
edgeId: routeParams.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.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => {
|
||||
this.edge = edge;
|
||||
this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains')
|
||||
this.config.componentsData.edge = edge;
|
||||
this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains');
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.config.entitySelectionEnabled = 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'),
|
||||
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)
|
||||
}
|
||||
)
|
||||
@ -295,7 +296,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
if (this.config.componentsData.edgeId) {
|
||||
this.edgeService.setRootRuleChain(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
|
||||
(edge) => {
|
||||
this.edge = edge;
|
||||
this.config.componentsData.edge = edge;
|
||||
this.config.table.updateData();
|
||||
}
|
||||
)
|
||||
@ -465,7 +466,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
|
||||
isNonRootRuleChain(ruleChain: RuleChain) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ export enum DebugEventType {
|
||||
DEBUG_RULE_NODE = 'DEBUG_RULE_NODE',
|
||||
DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN'
|
||||
}
|
||||
//TODO deaflynx filter CE only event types
|
||||
|
||||
export enum EdgeEventType {
|
||||
DASHBOARD = "DASHBOARD",
|
||||
ASSET = "ASSET",
|
||||
@ -44,11 +44,6 @@ export enum EdgeEventType {
|
||||
USER = "USER",
|
||||
CUSTOMER = "CUSTOMER",
|
||||
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",
|
||||
WIDGET_TYPE = "WIDGET_TYPE",
|
||||
ADMIN_SETTINGS = "ADMIN_SETTINGS"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user