Commit e2b50d3d authored by ibuler's avatar ibuler

[Update] 修改连接

parent 6e36636a
...@@ -4,7 +4,7 @@ import {BehaviorSubject} from 'rxjs/BehaviorSubject'; ...@@ -4,7 +4,7 @@ import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {AppService, HttpService, LogService, NavService, TreeFilterService} from '../../app.service'; import {AppService, HttpService, LogService, NavService, TreeFilterService} from '../../app.service';
import {connectEvt, i18n} from '../../globals'; import {connectEvt, translate} from '../../globals';
import {TreeNode, ConnectEvt} from '../../model'; import {TreeNode, ConnectEvt} from '../../model';
declare var $: any; declare var $: any;
...@@ -70,12 +70,12 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -70,12 +70,12 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
this.treeFilterSubscription.unsubscribe(); this.treeFilterSubscription.unsubscribe();
} }
onNodeClick(event, treeId, treeNode, clickFlag) { onAssetsNodeClick(event, treeId, treeNode, clickFlag) {
if (treeNode.isParent) { if (treeNode.isParent) {
this.assetsTree.expandNode(treeNode); this.assetsTree.expandNode(treeNode);
} else { } else {
this._http.getUserProfile().subscribe(); this._http.getUserProfile().subscribe();
this.ConnectAsset(treeNode); this.connectAsset(treeNode);
} }
} }
...@@ -87,7 +87,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -87,7 +87,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
initAssetsTree(refresh?: boolean) { initAssetsTree(refresh?: boolean) {
const setting = Object.assign({}, this.setting); const setting = Object.assign({}, this.setting);
setting['callback'] = { setting['callback'] = {
onClick: this.onNodeClick.bind(this), onClick: this.onAssetsNodeClick.bind(this),
onRightClick: this.onRightClick.bind(this) onRightClick: this.onRightClick.bind(this)
}; };
if (this._navSvc.treeLoadAsync) { if (this._navSvc.treeLoadAsync) {
...@@ -112,11 +112,24 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -112,11 +112,24 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
this.remoteAppsTree.destroy(); this.remoteAppsTree.destroy();
this.initRemoteAppsTree(); this.initRemoteAppsTree();
} }
onRemoteAppsNodeClick(event, treeId, treeNode, clickFlag) {
if (treeNode.isParent) {
this.remoteAppsTree.expandNode(treeNode);
} else {
this._http.getUserProfile().subscribe();
this.connectAsset(treeNode);
}
}
initRemoteAppsTree() { initRemoteAppsTree() {
const setting = Object.assign({}, this.setting);
setting['callback'] = {
onClick: this.onRemoteAppsNodeClick.bind(this),
};
this._http.getMyGrantedRemoteApps().subscribe( this._http.getMyGrantedRemoteApps().subscribe(
resp => { resp => {
const tree = $.fn.zTree.init($('#remoteAppsTree'), this.setting, resp); const tree = $.fn.zTree.init($('#remoteAppsTree'), setting, resp);
this.remoteAppsTree = tree; this.remoteAppsTree = tree;
this.rootNodeAddDom(tree, () => { this.rootNodeAddDom(tree, () => {
this.refreshRemoteAppsTree(); this.refreshRemoteAppsTree();
...@@ -136,7 +149,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -136,7 +149,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
this.Data.forEach(t => { this.Data.forEach(t => {
if (login_to === t.id && t.isParent === false) { if (login_to === t.id && t.isParent === false) {
this.hasLoginTo = true; this.hasLoginTo = true;
this.ConnectAsset(t); this.connectAsset(t);
return; return;
} }
}); });
...@@ -144,11 +157,11 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -144,11 +157,11 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
}); });
} }
ConnectAsset(node: TreeNode) { connectAsset(node: TreeNode) {
const evt = new ConnectEvt(node, 'asset'); const evt = new ConnectEvt(node, 'asset');
connectEvt.next(evt); connectEvt.next(evt);
} }
rootNodeAddDom(ztree, callback) { rootNodeAddDom(ztree, callback) {
const tId = ztree.setting.treeId + '_tree_refresh'; const tId = ztree.setting.treeId + '_tree_refresh';
const refreshIcon = '<a id=' + tId + ' class="tree-refresh">' + const refreshIcon = '<a id=' + tId + ' class="tree-refresh">' +
...@@ -214,7 +227,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -214,7 +227,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
connectTerminal() { connectTerminal() {
const host = this.rightClickSelectNode; const host = this.rightClickSelectNode;
this.ConnectAsset(host); this.connectAsset(host);
} }
filterAssets(keyword) { filterAssets(keyword) {
...@@ -293,10 +306,9 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -293,10 +306,9 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
if (treeNodes.length !== 0) { if (treeNodes.length !== 0) {
this.assetsTree.hideNode(treeNodes[0]); this.assetsTree.hideNode(treeNodes[0]);
} }
const newNode = {id: 'search', name: i18n.get('Search'), isParent: true, open: true, zAsync: true}; const newNode = {id: 'search', name: translate('Search'), isParent: true, open: true, zAsync: true};
const parentNode = this.assetsTree.addNodes(null, newNode)[0]; const parentNode = this.assetsTree.addNodes(null, newNode)[0];
parentNode.zAsync = true; parentNode.zAsync = true;
console.log(parentNode);
this.assetsTree.addNodes(parentNode, nodes); this.assetsTree.addNodes(parentNode, nodes);
parentNode.open = true; parentNode.open = true;
}); });
...@@ -337,11 +349,11 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -337,11 +349,11 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
if (!children) { if (!children) {
return []; return [];
} }
let all_children = []; let allChildren = [];
children.forEach((n) => { children.forEach((n) => {
all_children = [...children, ...this.recurseChildren(n)]; allChildren = [...children, ...this.recurseChildren(n)];
}); });
return all_children; return allChildren;
} }
} }
...@@ -32,7 +32,11 @@ export class ElementConnectComponent implements OnInit, OnDestroy { ...@@ -32,7 +32,11 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
connectEvt.asObservable().subscribe(evt => { connectEvt.asObservable().subscribe(evt => {
switch (evt.action) { switch (evt.action) {
case 'asset': { case 'asset': {
this.connectAsset(evt.node); this.Connect(evt.node);
break;
}
case 'sftp': {
this.connectFileManager(evt.node);
break; break;
} }
} }
...@@ -114,7 +118,7 @@ export class ElementConnectComponent implements OnInit, OnDestroy { ...@@ -114,7 +118,7 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
const host = node.meta.asset as Asset; const host = node.meta.asset as Asset;
if (host) { if (host) {
const view = new View(); const view = new View();
view.nick = '[FILE]' + host.hostname; view.nick = '[FILE] ' + host.hostname;
view.connected = true; view.connected = true;
view.editable = false; view.editable = false;
view.closed = false; view.closed = false;
......
...@@ -11,10 +11,6 @@ export class ElementContentComponent implements OnInit { ...@@ -11,10 +11,6 @@ export class ElementContentComponent implements OnInit {
@ViewChild('tabs') tabsRef: ElementRef; @ViewChild('tabs') tabsRef: ElementRef;
static DisconnectAll() { static DisconnectAll() {
// for (let i = 0; i < viewList.List.length; i++) {
// // Todo:
// // ContentComponent.TerminalDisconnect(i);
// }
} }
get tabsWidth() { get tabsWidth() {
......
...@@ -50,3 +50,12 @@ export async function getWsSocket() { ...@@ -50,3 +50,12 @@ export async function getWsSocket() {
} }
export const connectEvt = new BehaviorSubject<ConnectEvt>(new ConnectEvt(null, null)); export const connectEvt = new BehaviorSubject<ConnectEvt>(new ConnectEvt(null, null));
export function translate(value) {
if (i18n.has(value.toLowerCase())) {
return i18n.get(value.toLowerCase());
} else {
return value;
}
}
import {Pipe, PipeTransform} from '@angular/core'; import {Pipe, PipeTransform} from '@angular/core';
import {i18n} from '../globals'; import {translate} from '../globals';
@Pipe({ @Pipe({
name: 'trans' name: 'trans'
...@@ -7,10 +7,6 @@ import {i18n} from '../globals'; ...@@ -7,10 +7,6 @@ import {i18n} from '../globals';
export class TransPipe implements PipeTransform { export class TransPipe implements PipeTransform {
transform(value: any, args?: any): any { transform(value: any, args?: any): any {
if (i18n.has(value.toLowerCase())) { return translate(value);
return i18n.get(value.toLowerCase());
} else {
return value;
}
} }
} }
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