-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add color picker for number widgets (#40)
* Added support for choosing a color in the 1x1 widget * Add background color option to the number widgets
- Loading branch information
Showing
9 changed files
with
139 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,61 @@ | ||
async function loadWidget(widgetSettings, organization, projectName) { | ||
consoleLog(`WidgetSettings inside loadWidget: ${JSON.stringify(widgetSettings)}`); | ||
consoleLog(`Running for organization [${organization}], projectName [${projectName}]`); | ||
consoleLog(`WidgetSettings inside loadWidget: ${JSON.stringify(widgetSettings)}`) | ||
consoleLog(`Running for organization [${organization}], projectName [${projectName}]`) | ||
|
||
// data contains a stringified json object, so we need to make a json object from it | ||
const data = JSON.parse(widgetSettings.customSettings.data); | ||
const data = JSON.parse(widgetSettings.customSettings.data) | ||
|
||
// init with default values | ||
let alerts = { | ||
dependencyAlerts: 0, | ||
secretAlerts: 0, | ||
codeAlerts: 0 | ||
}; | ||
let linkBase = 'https://dev.azure.com'; | ||
} | ||
let linkBase = 'https://dev.azure.com' | ||
|
||
if (data && data.repo) { | ||
const repoName = data.repo; | ||
const repoId = data.repoId; | ||
consoleLog('loaded repoName from widgetSettings: ' + repoName); | ||
const repoName = data.repo | ||
const repoId = data.repoId | ||
consoleLog('loaded repoName from widgetSettings: ' + repoName) | ||
|
||
// set the tile | ||
var title = $('h2.ghazdo-title'); | ||
title.text(`Security Alerts for ${repoName}`); | ||
title.attr('title', repoName); | ||
alerts = (await getAlerts(organization, projectName, repoId)).values; | ||
consoleLog('alerts: ' + JSON.stringify(alerts)); | ||
var title = $('h2.ghazdo-title') | ||
title.text(`Security Alerts for ${repoName}`) | ||
title.attr('title', repoName) | ||
alerts = (await getAlerts(organization, projectName, repoId)).values | ||
consoleLog('alerts: ' + JSON.stringify(alerts)) | ||
|
||
// GHAS is only available on the SaaS version, so we can hardcode the domain | ||
linkBase = `https://dev.azure.com/${organization}/${projectName}/_git/${repoName}/alerts`; | ||
linkBase = `https://dev.azure.com/${organization}/${projectName}/_git/${repoName}/alerts` | ||
|
||
// set the color | ||
const color = data.color ? data.color : '#68217a' // default to purple | ||
const widget = document.getElementById('GHAzDo-widget') | ||
widget.style.backgroundColor = `${color}` | ||
} | ||
else { | ||
consoleLog('configuration is needed first, opening with empty values'); | ||
// set the tile to indicate config is needed | ||
var title = $('h2.ghazdo-title'); | ||
title.text(`Configure the widget to get Security Alerts`); | ||
var title = $('h2.ghazdo-title') | ||
title.text(`Configure the widget to get Security Alerts`) | ||
} | ||
|
||
// set the alert counts | ||
var dependencyAlertCount = $('p.dependencyAlertCount'); | ||
dependencyAlertCount.text(alerts.dependencyAlerts); | ||
const dependencyLinkValue = `${linkBase}?_t=dependencies`; | ||
const dependencyLink = $('a.dependency-link'); | ||
dependencyLink.attr('href', dependencyLinkValue); | ||
|
||
var secretAlertCount = $('p.secretAlertCount'); | ||
secretAlertCount.text(alerts.secretAlerts); | ||
const secretLinkValue = `${linkBase}?_t=secrets`; | ||
const secretLink = $('a.secret-link'); | ||
secretLink.attr('href', secretLinkValue); | ||
|
||
var codeAlertCount = $('p.codeAlertCount'); | ||
codeAlertCount.text(alerts.codeAlerts); | ||
const codeLinkValue = `${linkBase}?_t=codescanning`; | ||
const codeLink = $('a.code-link'); | ||
codeLink.attr('href', codeLinkValue); | ||
var dependencyAlertCount = $('p.dependencyAlertCount') | ||
dependencyAlertCount.text(alerts.dependencyAlerts) | ||
const dependencyLinkValue = `${linkBase}?_t=dependencies` | ||
const dependencyLink = $('a.dependency-link') | ||
dependencyLink.attr('href', dependencyLinkValue) | ||
|
||
var secretAlertCount = $('p.secretAlertCount') | ||
secretAlertCount.text(alerts.secretAlerts) | ||
const secretLinkValue = `${linkBase}?_t=secrets` | ||
const secretLink = $('a.secret-link') | ||
secretLink.attr('href', secretLinkValue) | ||
|
||
var codeAlertCount = $('p.codeAlertCount') | ||
codeAlertCount.text(alerts.codeAlerts) | ||
const codeLinkValue = `${linkBase}?_t=codescanning` | ||
const codeLink = $('a.code-link') | ||
codeLink.attr('href', codeLinkValue) | ||
} |