diff --git a/src/iotHubMessageExplorer.ts b/src/iotHubMessageExplorer.ts index 10d522f..f3a0831 100644 --- a/src/iotHubMessageExplorer.ts +++ b/src/iotHubMessageExplorer.ts @@ -25,7 +25,7 @@ export class IoTHubMessageExplorer extends BaseExplorer { } const deviceConnectionString: string = deviceItem.connectionString; - vscode.window.showInputBox({ prompt: `Enter message to send to ${Constants.IoTHub}` }).then((message: string) => { + vscode.window.showInputBox({ prompt: `Enter message to send to ${Constants.IoTHub}`, ignoreFocusOut: true }).then((message: string) => { if (message !== undefined) { this._outputChannel.show(); try { diff --git a/src/iotHubResourceExplorer.ts b/src/iotHubResourceExplorer.ts index 87c4066..d5f3ddd 100644 --- a/src/iotHubResourceExplorer.ts +++ b/src/iotHubResourceExplorer.ts @@ -184,14 +184,20 @@ export class IoTHubResourceExplorer extends BaseExplorer { } private async generateSasToken(sasTokenFunction: (connectionString: string, expiryInHours: number) => string, connectionString: string, target: string) { - const expiryInHours = await vscode.window.showInputBox({ prompt: `Enter expiration time (hours)`, ignoreFocusOut: true }); - if (expiryInHours && !isNaN(parseFloat(expiryInHours))) { - const sasToken = sasTokenFunction(connectionString, parseFloat(expiryInHours)); - clipboardy.write(sasToken); - this._outputChannel.show(); - this.outputLine("SASToken", `SAS token for [${target}] is generated and copied to clipboard:`); - this._outputChannel.appendLine(sasToken); - } + const expiryInHours = await vscode.window.showInputBox({ + prompt: `Enter expiration time (hours)`, + ignoreFocusOut: true, + validateInput: (value: string) => { + if (!value || isNaN(parseFloat(value))) { + return "Provided expiration time is not a number, enter correct expiration time (hours)."; + } + }}); + + const sasToken = sasTokenFunction(connectionString, parseFloat(expiryInHours)); + clipboardy.write(sasToken); + this._outputChannel.show(); + this.outputLine("SASToken", `SAS token for [${target}] is generated and copied to clipboard:`); + this._outputChannel.appendLine(sasToken); } private async waitForLogin(): Promise {