just playing around
This commit is contained in:
parent
c1558c1ca2
commit
d38212fbb3
22
package.json
22
package.json
@ -14,12 +14,18 @@
|
|||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "suvmanager.suv_manager",
|
"command": "mocha.suvmanager.suv_manager",
|
||||||
"title": "Manage SUVs",
|
"title": "Manage SUVs",
|
||||||
"category": "Mocha"
|
"category": "Mocha"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "suvmanager.suv_up",
|
"command": "mocha.suvmanager.suv_show",
|
||||||
|
"title": "Open SUV in Web Browser",
|
||||||
|
"shortTitle": "Show in Web",
|
||||||
|
"category": "Mocha"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mocha.suvmanager.suv_up",
|
||||||
"title": "Launch SUV",
|
"title": "Launch SUV",
|
||||||
"category": "Mocha"
|
"category": "Mocha"
|
||||||
},
|
},
|
||||||
@ -145,6 +151,18 @@
|
|||||||
"when": "view == mocha.suvManager",
|
"when": "view == mocha.suvManager",
|
||||||
"group": "navigation@1"
|
"group": "navigation@1"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"view/item/context": [
|
||||||
|
{
|
||||||
|
"command": "mocha.suvmanager.suv_show",
|
||||||
|
"group": "YourGroup@1",
|
||||||
|
"when": "view == mocha.suvManager"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mocha.suvmanager.suv_up",
|
||||||
|
"group": "YourGroup@2",
|
||||||
|
"when": "view == mocha.suvManager"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
108
src/extension.ts
108
src/extension.ts
@ -25,7 +25,7 @@ export function mkotsuri(suvId : string, tenantName : string, command : string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateModuleExplorerTreeView() {
|
function updateModuleExplorerTreeView() {
|
||||||
/*
|
|
||||||
dpModuleExplorer.items.push(new GenericTreeDataItem("tools", "tools", [
|
dpModuleExplorer.items.push(new GenericTreeDataItem("tools", "tools", [
|
||||||
new GenericTreeDataItem("tools:xpresso", "xpressO", [
|
new GenericTreeDataItem("tools:xpresso", "xpressO", [
|
||||||
new GenericTreeDataItem("tools:xpressO:method", "method", [
|
new GenericTreeDataItem("tools:xpressO:method", "method", [
|
||||||
@ -47,7 +47,7 @@ function updateModuleExplorerTreeView() {
|
|||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
*/
|
return;
|
||||||
|
|
||||||
let suvId : string = "i-0c0398f84acecb702";
|
let suvId : string = "i-0c0398f84acecb702";
|
||||||
let tenantName : string = "super";
|
let tenantName : string = "super";
|
||||||
@ -102,10 +102,29 @@ function recursiveAddItemToTreeView(dp : GenericTreeDataProvider, item : any, pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function launchSuv(name : string)
|
||||||
|
{
|
||||||
|
cp.exec("mocha suv up " + name, (err2: string, stdout2: string, stderr2: string) => {
|
||||||
|
vscode.window.showInformationMessage('Selected SUV ( ' + name + ' ) launched successfully!');
|
||||||
|
});
|
||||||
|
vscode.window.showInformationMessage('Selected SUV ( ' + name + ' ) is launching now!');
|
||||||
|
}
|
||||||
|
|
||||||
|
let outputChannel: vscode.OutputChannel | undefined = undefined;
|
||||||
|
|
||||||
|
export function openWebBrowser(url: vscode.Uri) {
|
||||||
|
|
||||||
|
cp.exec("xdg-open " + url.toString(), (err: string, stdout: string, stderr: string) => {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// This method is called when your extension is activated
|
// This method is called when your extension is activated
|
||||||
// Your extension is activated the very first time the command is executed
|
// Your extension is activated the very first time the command is executed
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
|
||||||
|
outputChannel = vscode.window.createOutputChannel("Mocha");
|
||||||
|
outputChannel.appendLine("Mocha for VSCode activated");
|
||||||
|
|
||||||
let treeDataProvider = new SuvManagerTreeDataProvider();
|
let treeDataProvider = new SuvManagerTreeDataProvider();
|
||||||
treeSuvManager = vscode.window.createTreeView("mocha.suvManager", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": treeDataProvider });
|
treeSuvManager = vscode.window.createTreeView("mocha.suvManager", { "canSelectMany": true, "showCollapseAll": true, "treeDataProvider": treeDataProvider });
|
||||||
treeDataProvider.treeview = treeSuvManager;
|
treeDataProvider.treeview = treeSuvManager;
|
||||||
@ -116,7 +135,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
// dpModuleExplorer.treeview = treeModuleExplorer;
|
// dpModuleExplorer.treeview = treeModuleExplorer;
|
||||||
// treeModuleExplorer.badge = { "value": 1, "tooltip": "1 SUV(s) running" };
|
// treeModuleExplorer.badge = { "value": 1, "tooltip": "1 SUV(s) running" };
|
||||||
|
|
||||||
// updateModuleExplorerTreeView();
|
updateModuleExplorerTreeView();
|
||||||
|
|
||||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||||||
// This line of code will only be executed once when your extension is activated
|
// This line of code will only be executed once when your extension is activated
|
||||||
@ -208,7 +227,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
// The command has been defined in the package.json file
|
// The command has been defined in the package.json file
|
||||||
// Now provide the implementation of the command with registerCommand
|
// Now provide the implementation of the command with registerCommand
|
||||||
// The commandId parameter must match the command field in package.json
|
// The commandId parameter must match the command field in package.json
|
||||||
let cmd_suv_manager = vscode.commands.registerCommand('suvmanager.suv_manager', () => {
|
let cmd_suv_manager = vscode.commands.registerCommand('mocha.suvmanager.suv_manager', () => {
|
||||||
// The code you place here will be executed every time your command is executed
|
// The code you place here will be executed every time your command is executed
|
||||||
// Display a message box to the user
|
// Display a message box to the user
|
||||||
|
|
||||||
@ -216,34 +235,73 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
});
|
});
|
||||||
context.subscriptions.push(cmd_suv_manager);
|
context.subscriptions.push(cmd_suv_manager);
|
||||||
|
|
||||||
let cmd_suv_up = vscode.commands.registerCommand('suvmanager.suv_up', () => {
|
let cmd_suv_show = vscode.commands.registerCommand('mocha.suvmanager.suv_show', (...args) => {
|
||||||
// The code you place here will be executed every time your command is executed
|
if (args.length === 0) {
|
||||||
// Display a message box to the user
|
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) => {
|
||||||
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) =>
|
vscode.window.showInformationMessage(stdout);
|
||||||
{
|
let list = stdout.split(' ');
|
||||||
vscode.window.showInformationMessage(stdout);
|
let list2 = new Array<string>();
|
||||||
let list = stdout.split(' ');
|
list.forEach((element) => {
|
||||||
let list2 = new Array<string>();
|
list2.push(element.trim());
|
||||||
list.forEach( (element) =>
|
});
|
||||||
{
|
|
||||||
list2.push(element.trim());
|
var w = vscode.window.showQuickPick(list2, { "title": "Open SUV in Web Browser", "placeHolder": "Choose an SUV to open" }).then((value) => {
|
||||||
});
|
if (value !== undefined) {
|
||||||
|
openWebBrowser(vscode.Uri.parse("https://" + value + ".privatesuv.com"));
|
||||||
var w = vscode.window.showQuickPick(list2, { "title": "Launch SUV", "placeHolder": "Pick an SUV to launch (e.g. i-012345678)" }).then((value) =>
|
}
|
||||||
{
|
|
||||||
cp.exec("mocha suv up " + value, (err2: string, stdout2: string, stderr2: string) =>
|
|
||||||
{
|
|
||||||
vscode.window.showInformationMessage('Selected SUV ( ' + value + ' ) launched successfully!');
|
|
||||||
});
|
});
|
||||||
vscode.window.showInformationMessage('Selected SUV ( ' + value + ' ) is launching now!');
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let machine : Machine = args[0] as Machine;
|
||||||
|
openWebBrowser(vscode.Uri.parse("https://" + machine.name + ".privatesuv.com"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let cmd_suv_up = vscode.commands.registerCommand('mocha.suvmanager.suv_up', (...args) => {
|
||||||
|
if (args.length === 0) {
|
||||||
|
cp.exec('mocha suv list', (err: string, stdout: string, stderr: string) => {
|
||||||
|
vscode.window.showInformationMessage(stdout);
|
||||||
|
let list = stdout.split(' ');
|
||||||
|
let list2 = new Array<string>();
|
||||||
|
list.forEach((element) => {
|
||||||
|
list2.push(element.trim());
|
||||||
|
});
|
||||||
|
|
||||||
|
var w = vscode.window.showQuickPick(list2, { "title": "Launch SUV", "placeHolder": "Pick an SUV to launch (e.g. i-012345678)" }).then((value) => {
|
||||||
|
if (value !== undefined) {
|
||||||
|
launchSuv(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let machine : Machine = args[0] as Machine;
|
||||||
|
launchSuv(machine.name);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let cmd_suv_new = vscode.commands.registerCommand('mocha.suvmanager.suv_new', () => {
|
let cmd_suv_new = vscode.commands.registerCommand('mocha.suvmanager.suv_new', () => {
|
||||||
|
outputChannel?.appendLine("Provisioning a new persistent SUV...");
|
||||||
|
|
||||||
cp.exec('mocha suv new --unattended', (err: string, stdout: string, stderr: string) =>
|
cp.exec('mocha suv new --unattended', (err: string, stdout: string, stderr: string) =>
|
||||||
{
|
{
|
||||||
vscode.window.showInformationMessage('New SUV provisioned successfully!');
|
if (err == null) {
|
||||||
|
outputChannel?.appendLine("New SUV provisioned successfully!");
|
||||||
|
|
||||||
|
vscode.window.showInformationMessage('New SUV provisioned successfully!');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputChannel?.appendLine(err);
|
||||||
|
vscode.window.showErrorMessage("SUV provisioning failed. Check the error log for details.", "Show Error Log").then((value) => {
|
||||||
|
if (value == "Show Error Log")
|
||||||
|
{
|
||||||
|
outputChannel?.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
treeDataProvider.refresh();
|
treeDataProvider.refresh();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user