|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { shortcut, store } from '@core/core'; |
|
|
|
|
import { ButtonGroup, Vertical, CenterAdapt, Label, Layout, Vtape } from 'ui'; |
|
|
|
|
import { ButtonGroup, Vertical, CenterAdapt, Label, Layout, Vtape, LoadingBar } from 'ui'; |
|
|
|
|
import { ListItemXtype } from './list_item/list_item'; |
|
|
|
|
import { ConnectionListModel, ConnectionListModelXtype } from './list.model'; |
|
|
|
|
import { Connection } from '../../../crud/crud.typings'; |
|
|
|
@ -12,6 +12,7 @@ export class ConnectionList extends BI.LoadingPane {
|
|
|
|
|
model: ConnectionListModel['model']; |
|
|
|
|
|
|
|
|
|
groupWidget: any; |
|
|
|
|
loadingBar: any; |
|
|
|
|
|
|
|
|
|
beforeInit(cb: Function) { |
|
|
|
|
this.store.setConnections().then(() => { |
|
|
|
@ -20,13 +21,20 @@ export class ConnectionList extends BI.LoadingPane {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
watch = { |
|
|
|
|
connections() { |
|
|
|
|
connections: () => { |
|
|
|
|
this.groupWidget.populate(this.renderList()); |
|
|
|
|
}, |
|
|
|
|
showItemNum: () => { |
|
|
|
|
this.groupWidget.addItems(this.renderList(this.model.showItemNum - 50)); |
|
|
|
|
BI.size(this.model.connections) > this.model.showItemNum ? |
|
|
|
|
this.loadingBar.setLoaded() : |
|
|
|
|
this.loadingBar.setEnd(); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
if (this.model.connections.length === 0) { |
|
|
|
|
const connectionLength = BI.size(this.model.connections); |
|
|
|
|
if (connectionLength === 0) { |
|
|
|
|
return { |
|
|
|
|
type: CenterAdapt, |
|
|
|
|
items: [ |
|
|
|
@ -54,19 +62,37 @@ export class ConnectionList extends BI.LoadingPane {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
type: ButtonGroup, |
|
|
|
|
layouts: [{ |
|
|
|
|
type: Vertical, |
|
|
|
|
type: Vertical, |
|
|
|
|
items: [{ |
|
|
|
|
type: ButtonGroup, |
|
|
|
|
layouts: [{ |
|
|
|
|
type: Vertical, |
|
|
|
|
}], |
|
|
|
|
items: this.renderList(), |
|
|
|
|
ref: (_ref: any) => { |
|
|
|
|
this.groupWidget = _ref; |
|
|
|
|
}, |
|
|
|
|
}, { |
|
|
|
|
type: LoadingBar, |
|
|
|
|
ref: (_ref: any) => { |
|
|
|
|
this.loadingBar = _ref; |
|
|
|
|
connectionLength > this.model.showItemNum ? |
|
|
|
|
this.loadingBar.setLoaded() : |
|
|
|
|
null; |
|
|
|
|
}, |
|
|
|
|
handler: () => { |
|
|
|
|
this.loadingBar.setLoading(); |
|
|
|
|
this.store.setItemNum(this.model.showItemNum + 50); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
items: this.renderList(), |
|
|
|
|
ref: (_ref: any) => { |
|
|
|
|
this.groupWidget = _ref; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private renderList() { |
|
|
|
|
return this.model.connections.map((item: Connection) => { |
|
|
|
|
private renderList(start = 0) { |
|
|
|
|
const itemNum = Math.min(this.model.connections.length, this.model.showItemNum); |
|
|
|
|
|
|
|
|
|
return this.model.connections.slice(start, itemNum).map((item: Connection) => { |
|
|
|
|
return { |
|
|
|
|
type: ListItemXtype, |
|
|
|
|
name: item.connectionName, |
|
|
|
|