diff --git a/package.json b/package.json index 6268bcdb..6e068ca4 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,12 @@ "start:main": "wait-on http-get://localhost:4200/ && npm run build:main:development && electron --nolazy --inspect-brk=9229 .", "start:renderer": "cross-env UCAP_ENV_RUNTIME=ELECTRON ng serve -c renderer-development", "start:browser": "cross-env UCAP_ENV_RUNTIME=BROWSER ng serve -c browser-development -o", - "run": "electron .", "build": "npm-run-all -p build:renderer build:main:production", "build:renderer": "cross-env NODE_ENV=production ng build -c renderer-development --base-href ./", "build:browser": "cross-env UCAP_ENV_RUNTIME=BROWSER ng build -c browser-development", "build:main:development": "cross-env NODE_ENV=development TS_NODE_PROJECT='./config/tsconfig.webpack.json' parallel-webpack --config=config/main.webpack.config.ts", "build:main:production": "cross-env NODE_ENV=production TS_NODE_PROJECT='./config/tsconfig.webpack.json' NODE_OPTIONS='--max_old_space_size=4096' parallel-webpack --config=config/main.webpack.config.ts", + "electron:local": "electron .", "electron:windows": "electron-builder build --windows", "electron:mac": "electron-builder build --mac", "electron:linux": "electron-builder build --linux", diff --git a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html index bb20f3da..73c887e5 100644 --- a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html +++ b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html @@ -23,7 +23,7 @@ diff --git a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts index 553efb6e..35b24202 100644 --- a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts +++ b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts @@ -8,7 +8,8 @@ import { ContentChild, TemplateRef, AfterViewInit, - ChangeDetectorRef + ChangeDetectorRef, + OnDestroy } from '@angular/core'; import { ucapAnimations } from '@ucap-webmessenger/ui'; @@ -25,6 +26,8 @@ import { NGXLogger } from 'ngx-logger'; import { VirtualScrollTreeFlatDataSource } from '@ucap-webmessenger/ui'; import { FlatTreeControl } from '@angular/cdk/tree'; import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; +import { fromEvent, Subject } from 'rxjs'; +import { debounceTime, takeUntil } from 'rxjs/operators'; enum NodeType { None = 'None', @@ -55,7 +58,8 @@ interface FlatNode { styleUrls: ['./expansion-panel.component.scss'], animations: ucapAnimations }) -export class ExpansionPanelComponent implements OnInit, AfterViewInit { +export class ExpansionPanelComponent + implements OnInit, OnDestroy, AfterViewInit { @Input() set myProfileInfo(userInfo: UserInfo) { if (!userInfo) { @@ -156,6 +160,8 @@ export class ExpansionPanelComponent implements OnInit, AfterViewInit { @ViewChild('cvsvGroup', { static: false }) cvsvGroup: CdkVirtualScrollViewport; + private readonly destroySubject = new Subject(); + NodeType = NodeType; profileNodes: GroupNode[] = []; @@ -185,7 +191,7 @@ export class ExpansionPanelComponent implements OnInit, AfterViewInit { countOfChildren: !!node.children && node.children.length > 0 ? node.children.length - : undefined, + : 0, userInfo: node.userInfo, groupDetail: node.groupDetail }; @@ -201,13 +207,23 @@ export class ExpansionPanelComponent implements OnInit, AfterViewInit { ); } - ngOnInit() {} + ngOnInit() { + fromEvent(window, 'resize') + .pipe(debounceTime(10), takeUntil(this.destroySubject)) + .subscribe(() => this.cvsvGroup.checkViewportSize()); + } + + ngOnDestroy(): void { + this.destroySubject.next(); + this.destroySubject.complete(); + } ngAfterViewInit(): void { this.dataSource.cdkVirtualScrollViewport = this.cvsvGroup; } - hasChild = (_: number, node: FlatNode) => node.expandable; + // hasChild = (_: number, node: FlatNode) => node.expandable; + isHeader = (_: number, node: FlatNode) => 0 === node.level; expandMore() { this.groupAccordion.openAll();