From 1af92d8c54d7fb32b5aefecd10c197573956af43 Mon Sep 17 00:00:00 2001 From: Jun Han Date: Mon, 12 Nov 2018 10:16:29 +0800 Subject: [PATCH] Enhancement and support for multi-arch (#201) * [Direct method] Support passing JSON in payload * Add 'Refresh' into context menu of normal device * Support deployment for multi-arch * Add refresh icon inline --- package.json | 33 ++++++++++++++++++++++--------- src/iotEdgeExplorer.ts | 4 ++-- src/iotHubDirectMethodExplorer.ts | 5 ++++- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 34fab44..10019ef 100644 --- a/package.json +++ b/package.json @@ -300,6 +300,11 @@ } ], "view/item/context": [ + { + "command": "azure-iot-toolkit.refresh", + "when": "view == iotHubDevices && viewItem == device", + "group": "inline" + }, { "command": "azure-iot-toolkit.generateCode", "when": "view == iotHubDevices && viewItem == device", @@ -356,10 +361,20 @@ "group": "azure-iot-toolkit@10" }, { - "command": "azure-iot-toolkit.deleteDevice", + "command": "azure-iot-toolkit.refresh", "when": "view == iotHubDevices && viewItem == device", "group": "azure-iot-toolkit@11" }, + { + "command": "azure-iot-toolkit.deleteDevice", + "when": "view == iotHubDevices && viewItem == device", + "group": "azure-iot-toolkit@12" + }, + { + "command": "azure-iot-toolkit.refresh", + "when": "view == iotHubDevices && viewItem == edge", + "group": "inline" + }, { "command": "azure-iot-toolkit.generateCode", "when": "view == iotHubDevices && viewItem == edge", @@ -416,20 +431,20 @@ "group": "azure-iot-toolkit@10" }, { - "command": "azure-iot-toolkit.deleteDevice", + "command": "azure-iot-toolkit.refresh", "when": "view == iotHubDevices && viewItem == edge", "group": "azure-iot-toolkit@11" }, + { + "command": "azure-iot-toolkit.deleteDevice", + "when": "view == iotHubDevices && viewItem == edge", + "group": "azure-iot-toolkit@12" + }, { "command": "azure-iot-toolkit.createDeployment", "when": "view == iotHubDevices && viewItem == edge", "group": "azure-iot-toolkit-edge@0" }, - { - "command": "azure-iot-toolkit.refresh", - "when": "view == iotHubDevices && viewItem == edge", - "group": "azure-iot-toolkit-edge@1" - }, { "command": "azure-iot-toolkit.getModule", "when": " view == iotHubDevices && viewItem == module", @@ -500,12 +515,12 @@ ], "explorer/context": [ { - "when": "resourceFilename == deployment.json", + "when": "resourceFilename =~ /deployment(?!\\.template\\.)(\\.[a-z0-9]+)*(\\.debug)?.json/", "command": "azure-iot-toolkit.createDeployment", "group": "azure-iot-toolkit-edge@0 " }, { - "when": "resourceFilename == deployment.json", + "when": "resourceFilename =~ /deployment(?!\\.template\\.)(\\.[a-z0-9]+)*(\\.debug)?.json/", "command": "azure-iot-toolkit.createDeploymentAtScale", "group": "azure-iot-toolkit-edge@1" } diff --git a/src/iotEdgeExplorer.ts b/src/iotEdgeExplorer.ts index 31e97fb..3f7df82 100644 --- a/src/iotEdgeExplorer.ts +++ b/src/iotEdgeExplorer.ts @@ -140,8 +140,8 @@ export class IoTEdgeExplorer extends BaseExplorer { filePath = filePathUri[0].fsPath; } - if (path.basename(filePath) === "deployment.template.json") { - vscode.window.showWarningMessage("Please select 'deployment.json' under 'config' folder for deployment."); + if (path.basename(filePath) === "deployment.template.json" || path.basename(filePath) === "deployment.template.debug.json" ) { + vscode.window.showWarningMessage("Please select deployment manifest file under 'config' folder for deployment."); return ""; } diff --git a/src/iotHubDirectMethodExplorer.ts b/src/iotHubDirectMethodExplorer.ts index 0902df7..3c157c5 100644 --- a/src/iotHubDirectMethodExplorer.ts +++ b/src/iotHubDirectMethodExplorer.ts @@ -42,7 +42,7 @@ export class IotHubDirectMethodExplorer extends BaseExplorer { } private invokeDirectMethod(iotHubConnectionString: string, deviceId: string, moduleId?: string) { - const target = moduleId ? `[${deviceId}/${moduleId}]` : `[${deviceId}]`; + const target = moduleId ? `[${deviceId}/${moduleId}]` : `[${deviceId}]`; vscode.window.showInputBox({ prompt: `Enter [Method Name] sent to ${target}`, ignoreFocusOut: true }).then((methodName: string) => { if (methodName === undefined) { @@ -52,6 +52,9 @@ export class IotHubDirectMethodExplorer extends BaseExplorer { if (payload === undefined) { return; } + try { + payload = JSON.parse(payload); + } catch (e) { } const methodParams: DeviceMethodParams = { methodName, payload,