From b6bbd9290801687a2264ea7b4f8eba4cabd666a4 Mon Sep 17 00:00:00 2001 From: Christophe Chauvot Date: Mon, 21 Aug 2023 11:27:00 +0200 Subject: [PATCH] Feature(#3) - Add support for custom company URL --- README.md | 19 +++++++-------- .../index.html | 23 +++++++++++++++---- .../manifest.json | 2 +- .../shellyControll.html | 8 ++++++- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5247e8d..35da519 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ - `AzurePipeline` is a simple Plugin to view your current Pipeline runs - # Description `AzurePipeline` is a plugin that displays the current status of your Azure Pipeline. @@ -15,13 +13,14 @@ This product was not developed or approved by Azure You have to set the following properties - - Company Name - - Project - - Access Token (with the following rights) - - Build(Read) - - Release(Read) - - Pipeline ID (get it from the URL, called definitionId) - - run Index -> starting at 0 für the current run up to 30 for the 30th run +- Company Name +- Custom URL (optional, default is "https://dev.azure.com/") +- Project +- Access Token (with the following rights) + - Build(Read) + - Release(Read) +- Pipeline ID (get it from the URL, called definitionId) +- run Index -> starting at 0 für the current run up to 30 for the 30th run # Features @@ -31,12 +30,10 @@ You have to set the following properties ![](screenshot.png) - # Installation In the Release folder, you can find the file `com.buzzet.azurepipeline.streamDeckPlugin`. If you double-click this file on your machine, Stream Deck will install the plugin. - # Source code The Sources folder contains the source code of the plugin. diff --git a/Sources/com.buzzet.azurepipeline.sdPlugin/index.html b/Sources/com.buzzet.azurepipeline.sdPlugin/index.html index e47f1cf..663c2b8 100755 --- a/Sources/com.buzzet.azurepipeline.sdPlugin/index.html +++ b/Sources/com.buzzet.azurepipeline.sdPlugin/index.html @@ -26,23 +26,28 @@ var company = ""; var project = ""; var pipelineId = ""; - - if (settings != null && settings.hasOwnProperty('company')) { + var customURL = "https://dev.azure.com/"; + + if (settings != null && settings.hasOwnProperty('company')) { company = settings["company"]; } + if (settings != null && settings.hasOwnProperty('customURL')) { + customURL = settings["customURL"]; + } if (settings != null && settings.hasOwnProperty('project')) { project = settings["project"]; } if (settings != null && settings.hasOwnProperty('pipelineId')) { pipelineId = settings["pipelineId"]; } - this.OpenUrl("https://dev.azure.com/" + company + "/" + project + "/_build?definitionId=" + pipelineId) + this.OpenUrl(customURL + company + "/" + project + "/_build?definitionId=" + pipelineId) }, onWillAppear: async function (context, settings, coordinates) { console.log(settings) var company = ""; var project = ""; + var customURL = "https://dev.azure.com/"; // var repo = ""; var pipelineId = "" var index = 0 @@ -56,6 +61,9 @@ if (settings != null && settings.hasOwnProperty('project')) { project = settings["project"]; } + if (settings != null && settings.hasOwnProperty('customURL')) { + customURL = settings["customURL"]; + } // if (settings != null && settings.hasOwnProperty('repo')) { // repo = settings["repo"]; // } @@ -76,11 +84,11 @@ } headers.append('Authorization', 'Basic' + btoa("abc" + ":" + accessToken)) console.log(settings) - console.log(company, project, pipelineId, index) + console.log(company, customURL, project, pipelineId, index) while (true) { - fetch("http://dev.azure.com/" + company + "/" + project + "/_apis/pipelines/" + pipelineId + "/runs?api-version=6.0-preview.1", { method: 'GET', headers: headers }).then((response) => { + fetch(customURL + company + "/" + project + "/_apis/pipelines/" + pipelineId + "/runs?api-version=6.0-preview.1", { method: 'GET', headers: headers }).then((response) => { return response.json() }).then((data) => { let value = data.value; @@ -216,6 +224,11 @@ var newValue = jsonPayload.setCompany; settingsCache['company'] = newValue } + if (jsonPayload.hasOwnProperty('setCustomURL')) { + + var newValue = jsonPayload.setCustomURL; + settingsCache['customURL'] = newValue + } if (jsonPayload.hasOwnProperty('setProject')) { var newValue = jsonPayload.setProject; diff --git a/Sources/com.buzzet.azurepipeline.sdPlugin/manifest.json b/Sources/com.buzzet.azurepipeline.sdPlugin/manifest.json index 00aaccc..a3bcbe5 100644 --- a/Sources/com.buzzet.azurepipeline.sdPlugin/manifest.json +++ b/Sources/com.buzzet.azurepipeline.sdPlugin/manifest.json @@ -23,7 +23,7 @@ "Icon": "keyIcon", "URL": "https://github.com/Buzzet/streamdeck-azure-pipeline", "PropertyInspectorPath": "shellyControll.html", - "Version": "1.1", + "Version": "1.2", "OS": [ { "Platform": "mac", diff --git a/Sources/com.buzzet.azurepipeline.sdPlugin/shellyControll.html b/Sources/com.buzzet.azurepipeline.sdPlugin/shellyControll.html index a86e753..f1b0fac 100644 --- a/Sources/com.buzzet.azurepipeline.sdPlugin/shellyControll.html +++ b/Sources/com.buzzet.azurepipeline.sdPlugin/shellyControll.html @@ -16,6 +16,12 @@ +
+
Custom URL
+
+ +
+
Project
@@ -57,6 +63,7 @@ } settings = jsonObj.actionInfo.payload.settings; document.getElementById('companyField').value = settings.company || '' + document.getElementById('customURLField').value = settings.customURL || '' document.getElementById('projectField').value = settings.project || '' document.getElementById('accessTokenField').value = settings.accessToken || '' document.getElementById('pipelineIdField').value = settings.pipelineId || '' @@ -74,7 +81,6 @@ $SD.api.sendToPlugin(uuid, pluginAction, payload); } } -