Code review fixes
This commit is contained in:
parent
90fb9a5f99
commit
685e89ea87
@ -45,7 +45,6 @@ import { ActionNotificationShow } from '@core/notification/notification.actions'
|
|||||||
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
|
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
|
||||||
import { AlertDialogComponent } from '@shared/components/dialog/alert-dialog.component';
|
import { AlertDialogComponent } from '@shared/components/dialog/alert-dialog.component';
|
||||||
import { OAuth2ClientInfo } from '@shared/models/oauth2.models';
|
import { OAuth2ClientInfo } from '@shared/models/oauth2.models';
|
||||||
import { EdgeService } from "@core/http/edge.service";
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
|||||||
@ -70,7 +70,6 @@ import {
|
|||||||
import { alarmFields } from '@shared/models/alarm.models';
|
import { alarmFields } from '@shared/models/alarm.models';
|
||||||
import { EdgeService } from "@core/http/edge.service";
|
import { EdgeService } from "@core/http/edge.service";
|
||||||
import { ruleChainType } from "@shared/models/rule-chain.models";
|
import { ruleChainType } from "@shared/models/rule-chain.models";
|
||||||
import { Router } from "@angular/router";
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -91,8 +90,7 @@ export class EntityService {
|
|||||||
private dashboardService: DashboardService,
|
private dashboardService: DashboardService,
|
||||||
private entityRelationService: EntityRelationService,
|
private entityRelationService: EntityRelationService,
|
||||||
private attributeService: AttributeService,
|
private attributeService: AttributeService,
|
||||||
private utils: UtilsService,
|
private utils: UtilsService
|
||||||
private router: Router
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
private getEntityObservable(entityType: EntityType, entityId: string,
|
private getEntityObservable(entityType: EntityType, entityId: string,
|
||||||
@ -322,9 +320,10 @@ export class EntityService {
|
|||||||
break;
|
break;
|
||||||
case EntityType.RULE_CHAIN:
|
case EntityType.RULE_CHAIN:
|
||||||
pageLink.sortOrder.property = 'name';
|
pageLink.sortOrder.property = 'name';
|
||||||
if (this.router.url.includes('edge')) {
|
if (subType) {
|
||||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge, config);
|
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, subType, config);
|
||||||
} else {
|
} else {
|
||||||
|
// safe fallback to default core type
|
||||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.core, config);
|
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.core, config);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -230,7 +230,7 @@ export class MenuService {
|
|||||||
name: 'rulechain.rulechains',
|
name: 'rulechain.rulechains',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
path: '/ruleChains',
|
path: '/ruleChains',
|
||||||
icon: 'settings_ethernet',
|
icon: 'settings_ethernet'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: guid(),
|
id: guid(),
|
||||||
|
|||||||
@ -17,14 +17,13 @@
|
|||||||
import { BaseData, HasId } from '@shared/models/base-data';
|
import { BaseData, HasId } from '@shared/models/base-data';
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
import { PageComponent } from '@shared/components/page.component';
|
import { PageComponent } from '@shared/components/page.component';
|
||||||
import { Directive, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core';
|
import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppState } from '@core/core.state';
|
import { AppState } from '@core/core.state';
|
||||||
import { EntityAction } from '@home/models/entity/entity-component.models';
|
import { EntityAction } from '@home/models/entity/entity-component.models';
|
||||||
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
|
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
|
||||||
import { PageLink } from '@shared/models/page/page-link';
|
import { PageLink } from '@shared/models/page/page-link';
|
||||||
import { deepTrim } from '@core/utils';
|
import { deepTrim } from '@core/utils';
|
||||||
import { WINDOW } from "@core/services/window.service";
|
|
||||||
|
|
||||||
// @dynamic
|
// @dynamic
|
||||||
@Directive()
|
@Directive()
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import { EntityService } from '@core/http/entity.service';
|
|||||||
import { TruncatePipe } from '@shared/pipe/truncate.pipe';
|
import { TruncatePipe } from '@shared/pipe/truncate.pipe';
|
||||||
import { RuleChainService } from '@core/http/rule-chain.service';
|
import { RuleChainService } from '@core/http/rule-chain.service';
|
||||||
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
||||||
|
import { ruleChainType } from '@app/shared/models/rule-chain.models';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-rule-chain-autocomplete',
|
selector: 'tb-rule-chain-autocomplete',
|
||||||
@ -187,8 +188,9 @@ export class RuleChainAutocompleteComponent implements ControlValueAccessor, OnI
|
|||||||
|
|
||||||
fetchRuleChain(searchText?: string): Observable<Array<BaseData<EntityId>>> {
|
fetchRuleChain(searchText?: string): Observable<Array<BaseData<EntityId>>> {
|
||||||
this.searchText = searchText;
|
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,
|
return this.entityService.getEntitiesByNameFilter(EntityType.RULE_CHAIN, searchText,
|
||||||
50, null, {ignoreLoading: true});
|
50, ruleChainType.core, {ignoreLoading: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
<tb-rule-node #tbRuleNode
|
<tb-rule-node #tbRuleNode
|
||||||
[ruleNode]="ruleNode"
|
[ruleNode]="ruleNode"
|
||||||
[ruleChainId]="ruleChainId"
|
[ruleChainId]="ruleChainId"
|
||||||
|
[ruleChainType]="ruleChainType"
|
||||||
[isEdit]="true"
|
[isEdit]="true"
|
||||||
[isAdd]="true"
|
[isAdd]="true"
|
||||||
[isReadOnly]="false">
|
[isReadOnly]="false">
|
||||||
|
|||||||
@ -53,6 +53,7 @@
|
|||||||
<tb-entity-autocomplete required
|
<tb-entity-autocomplete required
|
||||||
[excludeEntityIds]="[ruleChainId]"
|
[excludeEntityIds]="[ruleChainId]"
|
||||||
[entityType]="entityType.RULE_CHAIN"
|
[entityType]="entityType.RULE_CHAIN"
|
||||||
|
[entitySubtype]="ruleChainType"
|
||||||
formControlName="targetRuleChainId">
|
formControlName="targetRuleChainId">
|
||||||
</tb-entity-autocomplete>
|
</tb-entity-autocomplete>
|
||||||
<div formGroupName="additionalInfo" fxLayout="column">
|
<div formGroupName="additionalInfo" fxLayout="column">
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import { Subscription } from 'rxjs';
|
|||||||
import { RuleChainService } from '@core/http/rule-chain.service';
|
import { RuleChainService } from '@core/http/rule-chain.service';
|
||||||
import { RuleNodeConfigComponent } from './rule-node-config.component';
|
import { RuleNodeConfigComponent } from './rule-node-config.component';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { ruleChainType } from '@app/shared/models/rule-chain.models';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-rule-node',
|
selector: 'tb-rule-node',
|
||||||
@ -41,6 +42,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
|||||||
@Input()
|
@Input()
|
||||||
ruleChainId: string;
|
ruleChainId: string;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
ruleChainType: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
isEdit: boolean;
|
isEdit: boolean;
|
||||||
|
|
||||||
@ -147,7 +151,11 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
if (this.ruleNode.targetRuleChainId) {
|
if (this.ruleNode.targetRuleChainId) {
|
||||||
|
if (this.ruleChainType === ruleChainType.edge) {
|
||||||
|
this.router.navigateByUrl(`/edges/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
||||||
|
} else {
|
||||||
this.router.navigateByUrl(`/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
this.router.navigateByUrl(`/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -116,6 +116,7 @@
|
|||||||
<tb-rule-node #tbRuleNode
|
<tb-rule-node #tbRuleNode
|
||||||
[ruleNode]="editingRuleNode"
|
[ruleNode]="editingRuleNode"
|
||||||
[ruleChainId]="ruleChain.id?.id"
|
[ruleChainId]="ruleChain.id?.id"
|
||||||
|
[ruleChainType]="ruleChainType"
|
||||||
[isEdit]="true"
|
[isEdit]="true"
|
||||||
[isReadOnly]="false">
|
[isReadOnly]="false">
|
||||||
</tb-rule-node>
|
</tb-rule-node>
|
||||||
|
|||||||
@ -1305,13 +1305,15 @@ export class RuleChainPageComponent extends PageComponent
|
|||||||
ruleNode.configuration = deepClone(ruleNode.component.configurationDescriptor.nodeDefinition.defaultConfiguration);
|
ruleNode.configuration = deepClone(ruleNode.component.configurationDescriptor.nodeDefinition.defaultConfiguration);
|
||||||
const ruleChainId = this.ruleChain.id ? this.ruleChain.id.id : null;
|
const ruleChainId = this.ruleChain.id ? this.ruleChain.id.id : null;
|
||||||
this.enableHotKeys = false;
|
this.enableHotKeys = false;
|
||||||
|
const ruleChainType = this.ruleChainType;
|
||||||
this.dialog.open<AddRuleNodeDialogComponent, AddRuleNodeDialogData,
|
this.dialog.open<AddRuleNodeDialogComponent, AddRuleNodeDialogData,
|
||||||
FcRuleNode>(AddRuleNodeDialogComponent, {
|
FcRuleNode>(AddRuleNodeDialogComponent, {
|
||||||
disableClose: true,
|
disableClose: true,
|
||||||
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
|
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
|
||||||
data: {
|
data: {
|
||||||
ruleNode,
|
ruleNode,
|
||||||
ruleChainId
|
ruleChainId,
|
||||||
|
ruleChainType
|
||||||
}
|
}
|
||||||
}).afterClosed().subscribe(
|
}).afterClosed().subscribe(
|
||||||
(addedRuleNode) => {
|
(addedRuleNode) => {
|
||||||
@ -1510,6 +1512,7 @@ export class AddRuleNodeLinkDialogComponent extends DialogComponent<AddRuleNodeL
|
|||||||
export interface AddRuleNodeDialogData {
|
export interface AddRuleNodeDialogData {
|
||||||
ruleNode: FcRuleNode;
|
ruleNode: FcRuleNode;
|
||||||
ruleChainId: string;
|
ruleChainId: string;
|
||||||
|
ruleChainType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -1525,6 +1528,7 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo
|
|||||||
|
|
||||||
ruleNode: FcRuleNode;
|
ruleNode: FcRuleNode;
|
||||||
ruleChainId: string;
|
ruleChainId: string;
|
||||||
|
ruleChainType: string;
|
||||||
|
|
||||||
submitted = false;
|
submitted = false;
|
||||||
|
|
||||||
@ -1537,6 +1541,7 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo
|
|||||||
|
|
||||||
this.ruleNode = this.data.ruleNode;
|
this.ruleNode = this.data.ruleNode;
|
||||||
this.ruleChainId = this.data.ruleChainId;
|
this.ruleChainId = this.data.ruleChainId;
|
||||||
|
this.ruleChainType = this.data.ruleChainType;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@ -216,7 +216,6 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
onAction: ($event, entity) => this.exportRuleChain($event, entity)
|
onAction: ($event, entity) => this.exportRuleChain($event, entity)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
|
||||||
if (ruleChainScope === 'tenant') {
|
if (ruleChainScope === 'tenant') {
|
||||||
actions.push(
|
actions.push(
|
||||||
{
|
{
|
||||||
@ -249,6 +248,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ruleChainScope === 'edge') {
|
if (ruleChainScope === 'edge') {
|
||||||
actions.push(
|
actions.push(
|
||||||
{
|
{
|
||||||
@ -276,7 +276,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
this.importExport.importRuleChain(expectedRuleChainType).subscribe((ruleChainImport) => {
|
this.importExport.importRuleChain(expectedRuleChainType).subscribe((ruleChainImport) => {
|
||||||
if (ruleChainImport) {
|
if (ruleChainImport) {
|
||||||
this.itembuffer.storeRuleChainImport(ruleChainImport);
|
this.itembuffer.storeRuleChainImport(ruleChainImport);
|
||||||
this.router.navigateByUrl(`${this.router.routerState.snapshot.url}/ruleChain/import`);
|
if (this.config.componentsData.ruleChainScope === 'edges') {
|
||||||
|
this.router.navigateByUrl(`edges/ruleChains/ruleChain/import`);
|
||||||
|
} else {
|
||||||
|
this.router.navigateByUrl(`ruleChains/ruleChain/import`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -285,7 +289,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
if ($event) {
|
if ($event) {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
this.router.navigateByUrl(`${this.router.routerState.snapshot.url}/${ruleChain.id.id}`);
|
if (this.config.componentsData.ruleChainScope === 'edges') {
|
||||||
|
this.router.navigateByUrl(`edges/ruleChains/${ruleChain.id.id}`);
|
||||||
|
} else {
|
||||||
|
this.router.navigateByUrl(`ruleChains/${ruleChain.id.id}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveRuleChain(ruleChain: RuleChain) {
|
saveRuleChain(ruleChain: RuleChain) {
|
||||||
@ -294,6 +302,9 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
ruleChain.type = ruleChainType.core;
|
ruleChain.type = ruleChainType.core;
|
||||||
} else if (this.config.componentsData.ruleChainScope == 'edges') {
|
} 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.ruleChainService.saveRuleChain(ruleChain);
|
return this.ruleChainService.saveRuleChain(ruleChain);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user