UI: Refactoring and add support edge rule chains
This commit is contained in:
parent
92fa873215
commit
86c8ee6bde
@ -32,6 +32,7 @@
|
|||||||
<tb-rule-chain-select
|
<tb-rule-chain-select
|
||||||
fxFlex
|
fxFlex
|
||||||
*ngIf="!isImport"
|
*ngIf="!isImport"
|
||||||
|
[ruleChainType]="ruleChainType"
|
||||||
[disabled]="isDirtyValue"
|
[disabled]="isDirtyValue"
|
||||||
[(ngModel)]="ruleChain.id.id"
|
[(ngModel)]="ruleChain.id.id"
|
||||||
(ngModelChange)="currentRuleChainIdChanged(ruleChain.id?.id)">
|
(ngModelChange)="currentRuleChainIdChanged(ruleChain.id?.id)">
|
||||||
|
|||||||
@ -15,7 +15,9 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AfterViewChecked,
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
@ -90,6 +92,7 @@ import { MatMiniFabButton } from '@angular/material/button';
|
|||||||
import { TbPopoverService } from '@shared/components/popover.service';
|
import { TbPopoverService } from '@shared/components/popover.service';
|
||||||
import { VersionControlComponent } from '@home/components/vc/version-control.component';
|
import { VersionControlComponent } from '@home/components/vc/version-control.component';
|
||||||
import { ComponentClusteringMode } from '@shared/models/component-descriptor.models';
|
import { ComponentClusteringMode } from '@shared/models/component-descriptor.models';
|
||||||
|
import { MatDrawer } from '@angular/material/sidenav';
|
||||||
import Timeout = NodeJS.Timeout;
|
import Timeout = NodeJS.Timeout;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -99,7 +102,7 @@ import Timeout = NodeJS.Timeout;
|
|||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class RuleChainPageComponent extends PageComponent
|
export class RuleChainPageComponent extends PageComponent
|
||||||
implements AfterViewInit, OnInit, OnDestroy, HasDirtyFlag, ISearchableComponent {
|
implements AfterViewInit, OnInit, OnDestroy, HasDirtyFlag, ISearchableComponent, AfterViewChecked {
|
||||||
|
|
||||||
get isDirty(): boolean {
|
get isDirty(): boolean {
|
||||||
return this.isDirtyValue || this.isImport;
|
return this.isDirtyValue || this.isImport;
|
||||||
@ -121,6 +124,8 @@ export class RuleChainPageComponent extends PageComponent
|
|||||||
|
|
||||||
@ViewChild('ruleChainMenuTrigger', {static: true}) ruleChainMenuTrigger: MatMenuTrigger;
|
@ViewChild('ruleChainMenuTrigger', {static: true}) ruleChainMenuTrigger: MatMenuTrigger;
|
||||||
|
|
||||||
|
@ViewChild('drawer') drawer: MatDrawer;
|
||||||
|
|
||||||
eventTypes = EventType;
|
eventTypes = EventType;
|
||||||
|
|
||||||
debugEventTypes = DebugEventType;
|
debugEventTypes = DebugEventType;
|
||||||
@ -265,6 +270,7 @@ export class RuleChainPageComponent extends PageComponent
|
|||||||
private popoverService: TbPopoverService,
|
private popoverService: TbPopoverService,
|
||||||
private renderer: Renderer2,
|
private renderer: Renderer2,
|
||||||
private viewContainerRef: ViewContainerRef,
|
private viewContainerRef: ViewContainerRef,
|
||||||
|
private changeDetector: ChangeDetectorRef,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
public dialogService: DialogService,
|
public dialogService: DialogService,
|
||||||
public fb: UntypedFormBuilder) {
|
public fb: UntypedFormBuilder) {
|
||||||
@ -280,6 +286,10 @@ export class RuleChainPageComponent extends PageComponent
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngAfterViewChecked(){
|
||||||
|
this.changeDetector.detectChanges();
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
fromEvent(this.ruleNodeSearchInputField.nativeElement, 'keyup')
|
fromEvent(this.ruleNodeSearchInputField.nativeElement, 'keyup')
|
||||||
.pipe(
|
.pipe(
|
||||||
@ -299,7 +309,11 @@ export class RuleChainPageComponent extends PageComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentRuleChainIdChanged(ruleChainId: string) {
|
currentRuleChainIdChanged(ruleChainId: string) {
|
||||||
|
if (this.ruleChainType === RuleChainType.CORE) {
|
||||||
this.router.navigateByUrl(`ruleChains/${ruleChainId}`);
|
this.router.navigateByUrl(`ruleChains/${ruleChainId}`);
|
||||||
|
} else {
|
||||||
|
this.router.navigateByUrl(`edgeManagement/ruleChains/${ruleChainId}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearchTextUpdated(searchText: string) {
|
onSearchTextUpdated(searchText: string) {
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
-->
|
-->
|
||||||
<mat-select fxFlex
|
<mat-select fxFlex
|
||||||
|
class="tb-rule-chain-select"
|
||||||
[required]="required"
|
[required]="required"
|
||||||
[disabled]="disabled"
|
[disabled]="disabled"
|
||||||
[(ngModel)]="ruleChainId"
|
[(ngModel)]="ruleChainId"
|
||||||
|
|||||||
@ -17,22 +17,10 @@
|
|||||||
min-width: 52px;
|
min-width: 52px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
.mat-mdc-select {
|
.tb-rule-chain-select {
|
||||||
display: flex;
|
display: flex;
|
||||||
max-width: 300px;
|
|
||||||
height: 48px;
|
height: 48px;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:host ::ng-deep {
|
|
||||||
.mat-mdc-select {
|
|
||||||
.mat-mdc-select-value {
|
|
||||||
max-width: 282px;
|
|
||||||
}
|
|
||||||
.mat-mdc-select-arrow {
|
|
||||||
width: 24px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import { Component, ElementRef, forwardRef, Inject, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
import { Component, forwardRef, Input, OnInit } from '@angular/core';
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { PageLink } from '@shared/models/page/page-link';
|
import { PageLink } from '@shared/models/page/page-link';
|
||||||
@ -22,19 +22,13 @@ import { map, share } from 'rxjs/operators';
|
|||||||
import { PageData } from '@shared/models/page/page-data';
|
import { PageData } from '@shared/models/page/page-data';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppState } from '@app/core/core.state';
|
import { AppState } from '@app/core/core.state';
|
||||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
||||||
import { TooltipPosition } from '@angular/material/tooltip';
|
import { TooltipPosition } from '@angular/material/tooltip';
|
||||||
import { CdkOverlayOrigin, Overlay } from '@angular/cdk/overlay';
|
|
||||||
import { BreakpointObserver } from '@angular/cdk/layout';
|
|
||||||
import { DOCUMENT } from '@angular/common';
|
|
||||||
import { WINDOW } from '@core/services/window.service';
|
|
||||||
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 { RuleChainService } from '@core/http/rule-chain.service';
|
||||||
import { isDefinedAndNotNull } from '@core/utils';
|
import { isDefinedAndNotNull } from '@core/utils';
|
||||||
import { coerceBoolean } from '@shared/decorators/coercion';
|
import { coerceBoolean } from '@shared/decorators/coercion';
|
||||||
import { Direction } from '@shared/models/page/sort-order';
|
import { Direction } from '@shared/models/page/sort-order';
|
||||||
|
|
||||||
// @dynamic
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-rule-chain-select',
|
selector: 'tb-rule-chain-select',
|
||||||
templateUrl: './rule-chain-select.component.html',
|
templateUrl: './rule-chain-select.component.html',
|
||||||
@ -58,33 +52,20 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
|
|||||||
@coerceBoolean()
|
@coerceBoolean()
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
ruleChainType: RuleChainType = RuleChainType.CORE;
|
||||||
|
|
||||||
ruleChains$: Observable<Array<RuleChain>>;
|
ruleChains$: Observable<Array<RuleChain>>;
|
||||||
|
|
||||||
ruleChainId: string | null;
|
ruleChainId: string | null;
|
||||||
|
|
||||||
@ViewChild('ruleChainSelectPanelOrigin') ruleChainSelectPanelOrigin: CdkOverlayOrigin;
|
|
||||||
|
|
||||||
private propagateChange = (v: any) => { };
|
private propagateChange = (v: any) => { };
|
||||||
|
|
||||||
constructor(private store: Store<AppState>,
|
constructor(private store: Store<AppState>,
|
||||||
private ruleChainService: RuleChainService,
|
private ruleChainService: RuleChainService) {
|
||||||
private overlay: Overlay,
|
|
||||||
private breakpointObserver: BreakpointObserver,
|
|
||||||
private viewContainerRef: ViewContainerRef,
|
|
||||||
private nativeElement: ElementRef,
|
|
||||||
@Inject(DOCUMENT) private document: Document,
|
|
||||||
@Inject(WINDOW) private window: Window) {
|
|
||||||
}
|
|
||||||
|
|
||||||
registerOnChange(fn: any): void {
|
|
||||||
this.propagateChange = fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
registerOnTouched(fn: any): void {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
const pageLink = new PageLink(100, 0, null, {
|
const pageLink = new PageLink(100, 0, null, {
|
||||||
property: 'name',
|
property: 'name',
|
||||||
direction: Direction.ASC
|
direction: Direction.ASC
|
||||||
@ -96,6 +77,14 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerOnChange(fn: any): void {
|
||||||
|
this.propagateChange = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerOnTouched(fn: any): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setDisabledState(isDisabled: boolean): void {
|
setDisabledState(isDisabled: boolean): void {
|
||||||
this.disabled = isDisabled;
|
this.disabled = isDisabled;
|
||||||
}
|
}
|
||||||
@ -115,7 +104,7 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getRuleChains(pageLink: PageLink): Observable<PageData<RuleChain>> {
|
private getRuleChains(pageLink: PageLink): Observable<PageData<RuleChain>> {
|
||||||
return this.ruleChainService.getRuleChains(pageLink, RuleChainType.CORE, {ignoreLoading: true});
|
return this.ruleChainService.getRuleChains(pageLink, this.ruleChainType, {ignoreLoading: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user