Initial work for BDC Dashboard (#6646)

This commit is contained in:
Charles Gagnon
2019-08-14 10:17:01 -07:00
committed by GitHub
parent 82c1c57c76
commit 5528a90eaf
11 changed files with 407 additions and 64 deletions

View File

@@ -12,12 +12,15 @@ import { IconPath } from './bigDataCluster/constants';
import { TreeNode } from './bigDataCluster/tree/treeNode';
import { AddControllerDialogModel, AddControllerDialog } from './bigDataCluster/dialog/addControllerDialog';
import { ControllerNode } from './bigDataCluster/tree/controllerTreeNode';
import { BdcDashboard } from './bigDataCluster/dialog/bdcDashboard';
import { BdcDashboardModel } from './bigDataCluster/dialog/bdcDashboardModel';
const localize = nls.loadMessageBundle();
const AddControllerCommand = 'bigDataClusters.command.addController';
const DeleteControllerCommand = 'bigDataClusters.command.deleteController';
const RefreshControllerCommand = 'bigDataClusters.command.refreshController';
const ManageControllerCommand = 'bigDataClusters.command.manageController';
let throttleTimers: { [key: string]: any } = {};
@@ -26,7 +29,7 @@ export function activate(extensionContext: vscode.ExtensionContext) {
let treeDataProvider = new ControllerTreeDataProvider(extensionContext.globalState);
registerTreeDataProvider(treeDataProvider);
registerCommands(treeDataProvider);
registerCommands(extensionContext, treeDataProvider);
}
export function deactivate() {
@@ -36,7 +39,7 @@ function registerTreeDataProvider(treeDataProvider: ControllerTreeDataProvider):
vscode.window.registerTreeDataProvider('sqlBigDataCluster', treeDataProvider);
}
function registerCommands(treeDataProvider: ControllerTreeDataProvider): void {
function registerCommands(context: vscode.ExtensionContext, treeDataProvider: ControllerTreeDataProvider): void {
vscode.commands.registerCommand(AddControllerCommand, (node?: TreeNode) => {
runThrottledAction(AddControllerCommand, () => addBdcController(treeDataProvider, node));
});
@@ -51,6 +54,12 @@ function registerCommands(treeDataProvider: ControllerTreeDataProvider): void {
}
treeDataProvider.notifyNodeChanged(node);
});
vscode.commands.registerCommand(ManageControllerCommand, async (node: ControllerNode) => {
const title: string = `${localize('bdc.dashboard.title', "Big Data Cluster Dashboard -")} ${ControllerNode.toIpAndPort(node.url)} ${localize('bdc.Dash', "-")} ${node.clusterName}`;
const dashboard: BdcDashboard = new BdcDashboard(title, new BdcDashboardModel(node.clusterName, node.url, node.username, node.password), context);
dashboard.showDashboard();
});
}
function addBdcController(treeDataProvider: ControllerTreeDataProvider, node?: TreeNode): void {
@@ -90,8 +99,6 @@ function deleteControllerInternal(treeDataProvider: ControllerTreeDataProvider,
}
}
/**
* Throttles actions to avoid bug where on clicking in tree, action gets called twice
* instead of once. Any right-click action is safe, just the default on-click action in a tree
@@ -106,4 +113,4 @@ function runThrottledAction(id: string, action: () => void) {
}, 150);
}
// else ignore this as we got an identical action in the last 150ms
}
}