Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Open run in monitoring view (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
joechung-msft authored Dec 3, 2018
1 parent 71cb49a commit 7275075
Show file tree
Hide file tree
Showing 8 changed files with 506 additions and 13 deletions.
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"onCommand:azureLogicApps.openInPortal",
"onCommand:azureLogicApps.openRunActionInEditor",
"onCommand:azureLogicApps.openRunInEditor",
"onCommand:azureLogicApps.openRunInMonitoringView",
"onCommand:azureLogicApps.openTriggerInEditor",
"onCommand:azureLogicApps.openVersionInDesigner",
"onCommand:azureLogicApps.openVersionInEditor",
Expand Down Expand Up @@ -128,6 +129,11 @@
"command": "azureLogicApps.openRunInEditor",
"title": "%azLogicApps.openInEditor%"
},
{
"category": "Azure Logic Apps",
"command": "azureLogicApps.openRunInMonitoringView",
"title": "%azLogicApps.openRunInMonitoringView%"
},
{
"category": "Azure Logic Apps",
"command": "azureLogicApps.openTriggerInEditor",
Expand Down Expand Up @@ -375,6 +381,11 @@
"group": "1@1",
"when": "view == azureLogicAppsExplorer && viewItem == azLogicAppsWorkflowRun"
},
{
"command": "azureLogicApps.openRunInMonitoringView",
"group": "1@2",
"when": "view == azureLogicAppsExplorer && viewItem == azLogicAppsWorkflowRun"
},
{
"command": "azureLogicApps.resubmitRun",
"group": "1@2",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"azLogicApps.openInDesigner": "Open in Designer",
"azLogicApps.openInEditor": "Open in Editor",
"azLogicApps.openInPortal": "Open in Portal",
"azLogicApps.openRunInMonitoringView": "Open in Monitoring View",
"azLogicApps.promoteVersion": "Promote",
"azLogicApps.refresh": "Refresh",
"azLogicApps.resubmitRun": "Resubmit",
Expand Down
28 changes: 28 additions & 0 deletions src/commands/logic-app/openRunInMonitoringView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from "vscode";
import { AzureTreeDataProvider, IAzureNode } from "vscode-azureextensionui";
import { localize } from "../../localize";
import { LogicAppRunTreeItem } from "../../tree/logic-app/LogicAppRunTreeItem";
import { getAuthorization } from "../../utils/authorizationUtils";
import { getWebviewContent } from "../../utils/logic-app/monitoringViewUtils";

export async function openRunInMonitoringView(tree: AzureTreeDataProvider, node?: IAzureNode): Promise<void> {
if (!node) {
node = await tree.showNodePicker(LogicAppRunTreeItem.contextValue);
}

const title = localize("azLogicApps.monitoringViewTitle", "Monitoring View");
const options: vscode.WebviewOptions & vscode.WebviewPanelOptions = {
enableScripts: true
};
const panel = vscode.window.createWebviewPanel("monitoringView", title, vscode.ViewColumn.Beside, options);
const authorization = await getAuthorization(node.credentials);
const runNode = node as IAzureNode<LogicAppRunTreeItem>;
const { id: runId, location, resourceGroupName, workflowId } = runNode.treeItem;
const { subscriptionId } = runNode;
panel.webview.html = getWebviewContent({ authorization, location, resourceGroupName, runId, subscriptionId, title, workflowId });
}
5 changes: 5 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { openInEditor } from "./commands/logic-app/openInEditor";
import { openInPortal } from "./commands/logic-app/openInPortal";
import { openRunActionInEditor } from "./commands/logic-app/openRunActionInEditor";
import { openRunInEditor } from "./commands/logic-app/openRunInEditor";
import { openRunInMonitoringView } from "./commands/logic-app/openRunInMonitoringView";
import { openTriggerInEditor } from "./commands/logic-app/openTriggerInEditor";
import { openVersionInDesigner } from "./commands/logic-app/openVersionInDesigner";
import { openVersionInEditor } from "./commands/logic-app/openVersionInEditor";
Expand Down Expand Up @@ -110,6 +111,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
await openRunInEditor(tree, node);
});

registerCommand("azureLogicApps.openRunInMonitoringView", async (node?: IAzureNode) => {
await openRunInMonitoringView(tree, node);
});

registerCommand("azureLogicApps.openTriggerInEditor", async (node?: IAzureNode) => {
await openTriggerInEditor(tree, node);
});
Expand Down
8 changes: 8 additions & 0 deletions src/tree/logic-app/LogicAppRunTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export class LogicAppRunTreeItem implements IAzureParentTreeItem {
return this.workflowRun.name!;
}

public get location(): string {
return this.workflow.location!;
}

public get resourceGroupName(): string {
return this.workflow.id!.split("/").slice(-5, -4)[0];
}
Expand All @@ -68,6 +72,10 @@ export class LogicAppRunTreeItem implements IAzureParentTreeItem {
return this.workflowRun.trigger!.name!;
}

public get workflowId(): string {
return this.workflow.id!;
}

public get workflowName(): string {
return this.workflow.name!;
}
Expand Down
14 changes: 2 additions & 12 deletions src/tree/logic-app/LogicAppTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import LogicAppsManagementClient from "azure-arm-logic";
import { Sku, Workflow } from "azure-arm-logic/lib/models";
import { WebResource } from "ms-rest";
import * as request from "request-promise-native";
import { IAzureParentTreeItem, IAzureTreeItem } from "vscode-azureextensionui";
import { localize } from "../../localize";
import { getAuthorization } from "../../utils/authorizationUtils";
import { Callbacks, getCallbacks } from "../../utils/logic-app/callbackUtils";
import { ConnectionReferences, getConnectionReferencesForLogicApp } from "../../utils/logic-app/connectionReferenceUtils";
import { getIconPath } from "../../utils/nodeUtils";
Expand Down Expand Up @@ -138,17 +138,7 @@ export class LogicAppTreeItem implements IAzureParentTreeItem {
delete workflow.properties.tags;
delete workflow.properties.type;

const authorization = await new Promise<string>((resolve, reject) => {
const webResource = new WebResource();
this.client.credentials.signRequest(webResource, (err: Error | undefined): void => {
if (err) {
reject(err);
} else {
resolve(webResource.headers.authorization);
}
});
});

const authorization = await getAuthorization(this.client.credentials);
const uri = `https://management.azure.com/subscriptions/${this.client.subscriptionId}/resourceGroups/${this.resourceGroupName}/providers/Microsoft.Logic/workflows/${this.workflowName}?api-version=${this.client.apiVersion}`;
const options: request.RequestPromiseOptions = {
body: JSON.stringify(workflow),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/logic-app/designerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export function getWebviewContentForDesigner({ authorization, callbacks, definit
const telemetryBaseUrl = options.telemetryBaseUrl || options.baseUrl;
const telemetryVersion = options.telemetryVersion || options.emaApiVersion;
const settings = {
analyticsServiceUri: \`\${telemetryBaseUrl}/providers/Internal.Telemetry/collect?api-version=\${options.telemetryVersion}\`,
analyticsServiceUri: \`\${telemetryBaseUrl}/providers/Internal.Telemetry/collect?api-version=\${telemetryVersion}\`,
getAccessToken: getArmAccessToken
};
Expand Down
Loading

0 comments on commit 7275075

Please sign in to comment.