Commit ead7ded1 authored by ibuler's avatar ibuler

[Update] 添加树形加载中

parent 946f4110
<div>
<p *ngIf="loading" style="padding: 3px">{{ "Loading"|trans }} ...</p>
<ul id="assetsTree" class="ztree">
{{ "Loading"|trans }} ...
</ul>
<ul id="remoteAppsTree" class="ztree">
......
......@@ -46,6 +46,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
treeFilterSubscription: any;
isLoadTreeAsync: boolean;
filterAssetCancel$: Subject<boolean> = new Subject();
loading = true;
constructor(private _appSvc: AppService,
private _treeFilterSvc: TreeFilterService,
......@@ -103,7 +104,9 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
};
}
this.loading = true;
this._http.getMyGrantedNodes(this.isLoadTreeAsync, refresh).subscribe(resp => {
this.loading = false;
const assetsTree = $.fn.zTree.init($('#assetsTree'), setting, resp);
this.assetsTree = assetsTree;
this.rootNodeAddDom(assetsTree, () => {
......@@ -325,21 +328,22 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
this.assetsTree.removeChildNodes(searchNode[0]);
this.assetsTree.removeNode(searchNode[0]);
}
const treeNodes = this.assetsTree.getNodes();
if (!keyword) {
const treeNodes = this.assetsTree.getNodes();
if (treeNodes.length !== 0) {
this.assetsTree.showNode(treeNodes[0]);
}
return;
}
this.filterAssetCancel$.next(true);
if (treeNodes.length !== 0) {
this.assetsTree.hideNode(treeNodes[0]);
}
this.loading = true;
this._http.getMyGrantedAssets(keyword)
.pipe(takeUntil(this.filterAssetCancel$))
.subscribe(nodes => {
const treeNodes = this.assetsTree.getNodes();
if (treeNodes.length !== 0) {
this.assetsTree.hideNode(treeNodes[0]);
}
this.loading = false;
let name = translate('Search');
const assetsAmount = nodes.length;
name = `${name} (${assetsAmount})`;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment