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 { AlertDialogComponent } from '@shared/components/dialog/alert-dialog.component';
|
||||
import { OAuth2ClientInfo } from '@shared/models/oauth2.models';
|
||||
import { EdgeService } from "@core/http/edge.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
@ -70,7 +70,6 @@ import {
|
||||
import { alarmFields } from '@shared/models/alarm.models';
|
||||
import { EdgeService } from "@core/http/edge.service";
|
||||
import { ruleChainType } from "@shared/models/rule-chain.models";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -91,8 +90,7 @@ export class EntityService {
|
||||
private dashboardService: DashboardService,
|
||||
private entityRelationService: EntityRelationService,
|
||||
private attributeService: AttributeService,
|
||||
private utils: UtilsService,
|
||||
private router: Router
|
||||
private utils: UtilsService
|
||||
) { }
|
||||
|
||||
private getEntityObservable(entityType: EntityType, entityId: string,
|
||||
@ -322,9 +320,10 @@ export class EntityService {
|
||||
break;
|
||||
case EntityType.RULE_CHAIN:
|
||||
pageLink.sortOrder.property = 'name';
|
||||
if (this.router.url.includes('edge')) {
|
||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge, config);
|
||||
if (subType) {
|
||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, subType, config);
|
||||
} else {
|
||||
// safe fallback to default core type
|
||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.core, config);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -230,7 +230,7 @@ export class MenuService {
|
||||
name: 'rulechain.rulechains',
|
||||
type: 'link',
|
||||
path: '/ruleChains',
|
||||
icon: 'settings_ethernet',
|
||||
icon: 'settings_ethernet'
|
||||
},
|
||||
{
|
||||
id: guid(),
|
||||
|
||||
@ -17,14 +17,13 @@
|
||||
import { BaseData, HasId } from '@shared/models/base-data';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
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 { AppState } from '@core/core.state';
|
||||
import { EntityAction } from '@home/models/entity/entity-component.models';
|
||||
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
|
||||
import { PageLink } from '@shared/models/page/page-link';
|
||||
import { deepTrim } from '@core/utils';
|
||||
import { WINDOW } from "@core/services/window.service";
|
||||
|
||||
// @dynamic
|
||||
@Directive()
|
||||
|
||||
@ -24,16 +24,16 @@ import { DebugEventType, Event, EventType } from '@shared/models/event.models';
|
||||
import { TimePageLink } from '@shared/models/page/page-link';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { EntityId } from '@shared/models/id/entity-id';
|
||||
import { EventService } from '@app/core/http/event.service';
|
||||
import { EventTableHeaderComponent } from '@home/components/event/event-table-header.component';
|
||||
import { EventTableHeaderComponent } from '@home/components/event/event-table-header.component';
|
||||
import { EntityTypeResource } from '@shared/models/entity-type.models';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PageData } from '@shared/models/page/page-data';
|
||||
import { Direction } from '@shared/models/page/sort-order';
|
||||
import { DialogService } from '@core/services/dialog.service';
|
||||
import { ContentType } from '@shared/models/constants';
|
||||
import { Direction } from '@shared/models/page/sort-order';
|
||||
import { DialogService } from '@core/services/dialog.service';
|
||||
import { ContentType } from '@shared/models/constants';
|
||||
import {
|
||||
EventContentDialogComponent,
|
||||
EventContentDialogData
|
||||
|
||||
@ -29,6 +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';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-rule-chain-autocomplete',
|
||||
@ -187,8 +188,9 @@ export class RuleChainAutocompleteComponent implements ControlValueAccessor, OnI
|
||||
|
||||
fetchRuleChain(searchText?: string): Observable<Array<BaseData<EntityId>>> {
|
||||
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, null, {ignoreLoading: true});
|
||||
50, ruleChainType.core, {ignoreLoading: true});
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
<tb-rule-node #tbRuleNode
|
||||
[ruleNode]="ruleNode"
|
||||
[ruleChainId]="ruleChainId"
|
||||
[ruleChainType]="ruleChainType"
|
||||
[isEdit]="true"
|
||||
[isAdd]="true"
|
||||
[isReadOnly]="false">
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
<tb-entity-autocomplete required
|
||||
[excludeEntityIds]="[ruleChainId]"
|
||||
[entityType]="entityType.RULE_CHAIN"
|
||||
[entitySubtype]="ruleChainType"
|
||||
formControlName="targetRuleChainId">
|
||||
</tb-entity-autocomplete>
|
||||
<div formGroupName="additionalInfo" fxLayout="column">
|
||||
|
||||
@ -25,6 +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';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-rule-node',
|
||||
@ -41,6 +42,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
||||
@Input()
|
||||
ruleChainId: string;
|
||||
|
||||
@Input()
|
||||
ruleChainType: string;
|
||||
|
||||
@Input()
|
||||
isEdit: boolean;
|
||||
|
||||
@ -147,7 +151,11 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
||||
$event.stopPropagation();
|
||||
}
|
||||
if (this.ruleNode.targetRuleChainId) {
|
||||
this.router.navigateByUrl(`/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
||||
if (this.ruleChainType === ruleChainType.edge) {
|
||||
this.router.navigateByUrl(`/edges/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
||||
} else {
|
||||
this.router.navigateByUrl(`/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,6 +116,7 @@
|
||||
<tb-rule-node #tbRuleNode
|
||||
[ruleNode]="editingRuleNode"
|
||||
[ruleChainId]="ruleChain.id?.id"
|
||||
[ruleChainType]="ruleChainType"
|
||||
[isEdit]="true"
|
||||
[isReadOnly]="false">
|
||||
</tb-rule-node>
|
||||
|
||||
@ -1305,13 +1305,15 @@ export class RuleChainPageComponent extends PageComponent
|
||||
ruleNode.configuration = deepClone(ruleNode.component.configurationDescriptor.nodeDefinition.defaultConfiguration);
|
||||
const ruleChainId = this.ruleChain.id ? this.ruleChain.id.id : null;
|
||||
this.enableHotKeys = false;
|
||||
const ruleChainType = this.ruleChainType;
|
||||
this.dialog.open<AddRuleNodeDialogComponent, AddRuleNodeDialogData,
|
||||
FcRuleNode>(AddRuleNodeDialogComponent, {
|
||||
disableClose: true,
|
||||
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
|
||||
data: {
|
||||
ruleNode,
|
||||
ruleChainId
|
||||
ruleChainId,
|
||||
ruleChainType
|
||||
}
|
||||
}).afterClosed().subscribe(
|
||||
(addedRuleNode) => {
|
||||
@ -1510,6 +1512,7 @@ export class AddRuleNodeLinkDialogComponent extends DialogComponent<AddRuleNodeL
|
||||
export interface AddRuleNodeDialogData {
|
||||
ruleNode: FcRuleNode;
|
||||
ruleChainId: string;
|
||||
ruleChainType: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -1525,6 +1528,7 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo
|
||||
|
||||
ruleNode: FcRuleNode;
|
||||
ruleChainId: string;
|
||||
ruleChainType: string;
|
||||
|
||||
submitted = false;
|
||||
|
||||
@ -1537,6 +1541,7 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo
|
||||
|
||||
this.ruleNode = this.data.ruleNode;
|
||||
this.ruleChainId = this.data.ruleChainId;
|
||||
this.ruleChainType = this.data.ruleChainType;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
@ -216,38 +216,38 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
onAction: ($event, entity) => this.exportRuleChain($event, entity)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (ruleChainScope === 'tenant') {
|
||||
actions.push(
|
||||
{
|
||||
name: this.translate.instant('rulechain.set-root'),
|
||||
icon: 'flag',
|
||||
isEnabled: (entity) => this.isNonRootRuleChain(entity),
|
||||
onAction: ($event, entity) => this.setRootRuleChain($event, entity)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (ruleChainScope === 'edges') {
|
||||
actions.push(
|
||||
{
|
||||
name: this.translate.instant('rulechain.set-edge-template-root-rulechain'),
|
||||
icon: 'flag',
|
||||
isEnabled: (entity) => this.isNonRootRuleChain(entity),
|
||||
onAction: ($event, entity) => this.setEdgeTemplateRootRuleChain($event, entity)
|
||||
},
|
||||
{
|
||||
name: this.translate.instant('rulechain.set-auto-assign-to-edge'),
|
||||
icon: 'bookmark_outline',
|
||||
isEnabled: (entity) => this.isNotAutoAssignToEdgeRuleChain(entity),
|
||||
onAction: ($event, entity) => this.setAutoAssignToEdgeRuleChain($event, entity)
|
||||
},
|
||||
{
|
||||
name: this.translate.instant('rulechain.unset-auto-assign-to-edge'),
|
||||
icon: 'bookmark',
|
||||
isEnabled: (entity) => this.isAutoAssignToEdgeRuleChain(entity),
|
||||
onAction: ($event, entity) => this.unsetAutoAssignToEdgeRuleChain($event, entity)
|
||||
}
|
||||
)
|
||||
if (ruleChainScope === 'tenant') {
|
||||
actions.push(
|
||||
{
|
||||
name: this.translate.instant('rulechain.set-root'),
|
||||
icon: 'flag',
|
||||
isEnabled: (entity) => this.isNonRootRuleChain(entity),
|
||||
onAction: ($event, entity) => this.setRootRuleChain($event, entity)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (ruleChainScope === 'edges') {
|
||||
actions.push(
|
||||
{
|
||||
name: this.translate.instant('rulechain.set-edge-template-root-rulechain'),
|
||||
icon: 'flag',
|
||||
isEnabled: (entity) => this.isNonRootRuleChain(entity),
|
||||
onAction: ($event, entity) => this.setEdgeTemplateRootRuleChain($event, entity)
|
||||
},
|
||||
{
|
||||
name: this.translate.instant('rulechain.set-auto-assign-to-edge'),
|
||||
icon: 'bookmark_outline',
|
||||
isEnabled: (entity) => this.isNotAutoAssignToEdgeRuleChain(entity),
|
||||
onAction: ($event, entity) => this.setAutoAssignToEdgeRuleChain($event, entity)
|
||||
},
|
||||
{
|
||||
name: this.translate.instant('rulechain.unset-auto-assign-to-edge'),
|
||||
icon: 'bookmark',
|
||||
isEnabled: (entity) => this.isAutoAssignToEdgeRuleChain(entity),
|
||||
onAction: ($event, entity) => this.unsetAutoAssignToEdgeRuleChain($event, entity)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
if (ruleChainScope === 'edge') {
|
||||
actions.push(
|
||||
@ -276,7 +276,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
this.importExport.importRuleChain(expectedRuleChainType).subscribe((ruleChainImport) => {
|
||||
if (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) {
|
||||
$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) {
|
||||
@ -294,6 +302,9 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
ruleChain.type = ruleChainType.core;
|
||||
} else if (this.config.componentsData.ruleChainScope == 'edges') {
|
||||
ruleChain.type = ruleChainType.edge;
|
||||
} else {
|
||||
// safe fallback to default core type
|
||||
ruleChain.type = ruleChainType.core;
|
||||
}
|
||||
}
|
||||
return this.ruleChainService.saveRuleChain(ruleChain);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user