mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Put 'loading' text while loading the saved controllers in Big Data Cluster extension (#6375)
This commit is contained in:
@@ -13,7 +13,8 @@ export enum BdcItemType {
|
|||||||
folder = 'bigDataClusters.itemType.folderNode',
|
folder = 'bigDataClusters.itemType.folderNode',
|
||||||
sqlMaster = 'bigDataClusters.itemType.sqlMasterNode',
|
sqlMaster = 'bigDataClusters.itemType.sqlMasterNode',
|
||||||
EndPoint = 'bigDataClusters.itemType.endPointNode',
|
EndPoint = 'bigDataClusters.itemType.endPointNode',
|
||||||
addController = 'bigDataClusters.itemType.addControllerNode'
|
addController = 'bigDataClusters.itemType.addControllerNode',
|
||||||
|
loadingController = 'bigDataClusters.itemType.loadingControllerNode'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class IconPath {
|
export class IconPath {
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ import * as vscode from 'vscode';
|
|||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import { TreeNode } from './treeNode';
|
import { TreeNode } from './treeNode';
|
||||||
import { IControllerTreeChangeHandler } from './controllerTreeChangeHandler';
|
import { IControllerTreeChangeHandler } from './controllerTreeChangeHandler';
|
||||||
import { AddControllerNode } from './addControllerTreeNode';
|
import { AddControllerNode } from './addControllerNode';
|
||||||
import { ControllerRootNode, ControllerNode } from './controllerTreeNode';
|
import { ControllerRootNode, ControllerNode } from './controllerTreeNode';
|
||||||
import { IEndPoint } from '../controller/clusterControllerApi';
|
import { IEndPoint } from '../controller/clusterControllerApi';
|
||||||
import { showErrorMessage } from '../utils';
|
import { showErrorMessage } from '../utils';
|
||||||
|
import { LoadingControllerNode } from './loadingControllerNode';
|
||||||
|
|
||||||
const CredentialNamespace = 'clusterControllerCredentials';
|
const CredentialNamespace = 'clusterControllerCredentials';
|
||||||
|
|
||||||
@@ -32,7 +33,6 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
|||||||
|
|
||||||
constructor(private memento: vscode.Memento) {
|
constructor(private memento: vscode.Memento) {
|
||||||
this.root = new ControllerRootNode(this);
|
this.root = new ControllerRootNode(this);
|
||||||
this.loadSavedControllers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getChildren(element?: TreeNode): Promise<TreeNode[]> {
|
public async getChildren(element?: TreeNode): Promise<TreeNode[]> {
|
||||||
@@ -42,15 +42,20 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
|||||||
|
|
||||||
if (this.root.hasChildren) {
|
if (this.root.hasChildren) {
|
||||||
return this.root.getChildren();
|
return this.root.getChildren();
|
||||||
} else {
|
|
||||||
return [new AddControllerNode()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.loadSavedControllers();
|
||||||
|
return [new LoadingControllerNode()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTreeItem(element: TreeNode): vscode.TreeItem | Thenable<vscode.TreeItem> {
|
public getTreeItem(element: TreeNode): vscode.TreeItem | Thenable<vscode.TreeItem> {
|
||||||
return element.getTreeItem();
|
return element.getTreeItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public notifyNodeChanged(node?: TreeNode): void {
|
||||||
|
this._onDidChangeTreeData.fire(node);
|
||||||
|
}
|
||||||
|
|
||||||
public addController(
|
public addController(
|
||||||
url: string,
|
url: string,
|
||||||
username: string,
|
username: string,
|
||||||
@@ -58,6 +63,7 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
|||||||
rememberPassword: boolean,
|
rememberPassword: boolean,
|
||||||
masterInstance?: IEndPoint
|
masterInstance?: IEndPoint
|
||||||
): void {
|
): void {
|
||||||
|
this.removeNonControllerNodes();
|
||||||
this.root.addControllerNode(url, username, password, rememberPassword, masterInstance);
|
this.root.addControllerNode(url, username, password, rememberPassword, masterInstance);
|
||||||
this.notifyNodeChanged();
|
this.notifyNodeChanged();
|
||||||
}
|
}
|
||||||
@@ -70,14 +76,42 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
|||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public notifyNodeChanged(node?: TreeNode): void {
|
private removeNonControllerNodes(): void {
|
||||||
this._onDidChangeTreeData.fire(node);
|
this.removePlaceholderNodes();
|
||||||
|
this.removeDefectiveControllerNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async loadSavedControllers(): Promise<void> {
|
private removePlaceholderNodes(): void {
|
||||||
|
let nodes = this.root.children;
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
for (let i = 0; i < nodes.length; ++i) {
|
||||||
|
if (nodes[i] instanceof AddControllerNode ||
|
||||||
|
nodes[i] instanceof LoadingControllerNode
|
||||||
|
) {
|
||||||
|
nodes.splice(i--, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeDefectiveControllerNodes(): void {
|
||||||
|
let nodes = this.root.children;
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
for (let i = 0; i < nodes.length; ++i) {
|
||||||
|
if (nodes[i] instanceof ControllerNode) {
|
||||||
|
let controller = nodes[i] as ControllerNode;
|
||||||
|
if (!controller.url || !controller.id) {
|
||||||
|
nodes.splice(i--, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async loadSavedControllers(): Promise<void> {
|
||||||
|
this.root.clearChildren();
|
||||||
let controllers: IControllerInfoSlim[] = this.memento.get('controllers');
|
let controllers: IControllerInfoSlim[] = this.memento.get('controllers');
|
||||||
if (controllers) {
|
if (controllers) {
|
||||||
this.root.clearChildren();
|
|
||||||
for (let c of controllers) {
|
for (let c of controllers) {
|
||||||
let password = undefined;
|
let password = undefined;
|
||||||
if (c.rememberPassword) {
|
if (c.rememberPassword) {
|
||||||
@@ -88,8 +122,14 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
|||||||
undefined, this.root, this, undefined
|
undefined, this.root, this, undefined
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
this.notifyNodeChanged();
|
this.removeDefectiveControllerNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.root.hasChildren) {
|
||||||
|
this.root.addChild(new AddControllerNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.notifyNodeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async saveControllers(): Promise<void> {
|
public async saveControllers(): Promise<void> {
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import * as nls from 'vscode-nls';
|
||||||
|
import * as azdata from 'azdata';
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
import { TreeNode } from './treeNode';
|
||||||
|
import { BdcItemType } from '../constants';
|
||||||
|
|
||||||
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
|
export class LoadingControllerNode extends TreeNode {
|
||||||
|
private readonly nodeType: string;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(localize('textLoadingWithDots', "Loading..."));
|
||||||
|
this.nodeType = BdcItemType.loadingController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getChildren(): Promise<TreeNode[]> {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getTreeItem(): vscode.TreeItem {
|
||||||
|
let item = new vscode.TreeItem(this.label, vscode.TreeItemCollapsibleState.None);
|
||||||
|
item.contextValue = this.nodeType;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNodeInfo(): azdata.NodeInfo {
|
||||||
|
return {
|
||||||
|
label: this.label,
|
||||||
|
isLeaf: this.isLeaf,
|
||||||
|
errorMessage: undefined,
|
||||||
|
metadata: undefined,
|
||||||
|
nodePath: this.nodePath,
|
||||||
|
nodeStatus: undefined,
|
||||||
|
nodeType: this.nodeType,
|
||||||
|
iconType: this.nodeType,
|
||||||
|
nodeSubType: undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user