Skip to content

Commit

Permalink
fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
sdavis3 committed May 31, 2017
1 parent 9032251 commit 5e22369
Show file tree
Hide file tree
Showing 39 changed files with 68,183 additions and 24 deletions.
48 changes: 38 additions & 10 deletions code-coverage1.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<script src="sdk/scripts/VSS.SDK.min.js"></script>
<script src="lib/VSS.SDK.min.js"></script>
<script type="text/javascript">
// Initialize
VSS.init({
explicitNotifyLoaded: true,
usePlatformStyles: true,
Expand All @@ -12,7 +13,7 @@
VSS.require(["TFS/Dashboards/WidgetHelpers", "TFS/Build/RestClient", "TFS/TestManagement/RestClient"],
function (WidgetHelpers, TFS_Build_WebApi, TFS_TestMgmt_WebApi) {
WidgetHelpers.IncludeWidgetStyles();
// TODO: The following line may need VSS.ready() instead. Need to test.

VSS.register("CodeCoverageWidget1", function () {
var projectId = VSS.getWebContext().project.id;
var getBuildBuildInfo = function (widgetSettings) {
Expand All @@ -22,7 +23,7 @@
$("#init-label").show();
$("div.big-count").hide();
$("#percent-label").hide();

return WidgetHelpers.WidgetStatusHelper.Success()
}

Expand All @@ -34,14 +35,23 @@
// Hide build name
$("#build-name").hide();
}

// Output diagnostics info to console
console.log('projectId = ' + projectId);
console.log('settings.buildDefinition = ' + settings.buildDefinition);

// Get most recent successful build details
TFS_Build_WebApi.getClient().getBuilds(projectId, [parseInt(settings.buildDefinition)], null, null, null, null, null, null, "Completed", "Succeeded", null, null, null, 1)
// .getBuilds(project, definitions, queues, buildNumber, minFinishTime, maxFinishTime, requestedFor, reasonFilter, statusFilter, resultFilter, tagFilters, properties, type, top, continuationToken, maxBuildsPerDefinition, deletedFilter, queryOrder, branchName)
TFS_Build_WebApi.getClient().getBuilds(projectId, [parseInt(settings.buildDefinition)], null, null, null, null, null, null, "Completed", "PartiallySucceeded,Succeeded", null, null, null, 1, null, null, null, null, null)
.then(function (query2) {
// Populate dropdown with list of recent builds
$.each(query2, function(key, value) {
var buildId = value.id;
var buildWeb = value._links.web.href
// Evaluate build details of first result
if (query2[0]) {
var buildId = query2[0].id;
var buildWeb = query2[0]._links.web.href

// Output diagnostics info to console
console.log('buildId = ' + buildId);

// Get code coverage summary for most recent build
TFS_TestMgmt_WebApi.getClient().getCodeCoverageSummary(projectId, buildId)
.then(function (query3) {
Expand Down Expand Up @@ -87,12 +97,15 @@
var buildName = query3.build.name;

// Update UI with code coverage percentage
$("div.big-count").hide();
$("#percent-label").hide();

$("div.big-count").text(coveragePct);
$("div.big-count").show();
$("#percent-label").show();
$("#init-label").hide();
$("#build-name").text(buildName);
$("#build-link").prop("href", buildWeb);
$("#build-link").prop("href", buildWeb);
}
else {
// Set display values for no coverage data
Expand All @@ -104,7 +117,16 @@
$("#build-link").removeProp("href");
}
});
});
}
else {
// Set display values for build details
$("div.big-count").hide();
$("#percent-label").hide();
$("#init-label").text("No code coverage details found for this build definition");
$("#init-label").show();
$("#build-name").text("");
$("#build-link").removeProp("href");
};
});

// Get a client to make REST calls to VSTS
Expand All @@ -126,11 +148,17 @@
// Set title
$("h2.title").text(widgetSettings.name);

// Output diagnostics info to console
console.log('event: load');

return getBuildBuildInfo(widgetSettings);
},
reload: function (widgetSettings) {
// Set title
$("h2.title").text(widgetSettings.name);

// Output diagnostics info to console
console.log('event: reload');

return getBuildBuildInfo(widgetSettings);
}
Expand Down
30 changes: 22 additions & 8 deletions configuration.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="sdk/scripts/VSS.SDK.min.js"></script>
<script src="lib/VSS.SDK.min.js"></script>
<script type="text/javascript">
// Initialize
VSS.init({
explicitNotifyLoaded: true,
usePlatformStyles: true,
Expand All @@ -26,8 +27,7 @@
// Retrieve configurations settings
var settings = JSON.parse(widgetSettings.customSettings.data);

TFS_Build_WebApi.getClient().getDefinitions(projectId)
.then(function (query) {
TFS_Build_WebApi.getClient().getDefinitions(projectId).then(function (query) {

// Populate dropdown with list of build definitions
$.each(query, function(key, value) {
Expand Down Expand Up @@ -77,7 +77,6 @@

// If show build name has been previously selected, set the checkbox value
if (settings && settings.checkOptionBuildName == true) {
//console.log('load settings.checkOptionBuildName = ' + settings.checkOptionBuildName);
$checkOptionBuildName.prop('checked', true);
}
// Otherwise, mark the box as unchecked
Expand All @@ -87,12 +86,15 @@

// If a build definition change has been made, prepare to persist the new values
$buildDefinitionDropdown.on("change", function () {
// Output diagnostics info to console
console.log('event: buildDefinitionDropdown.change');

var customSettings = {
data: JSON.stringify({
buildDefinition: $buildDefinitionDropdown.val(),
coverageMeasurement: $coverageMeasurementDropdown.val(),
decimalPlaces: $decimalPlacesDropdown.val(),
checkOptionBuildName: $checkOptionBuildName.prop('checked')
checkOptionBuildName: $checkOptionBuildName.prop('checked')
})
};
var eventName = WidgetHelpers.WidgetEvent.ConfigurationChange;
Expand All @@ -102,6 +104,9 @@

// If a coverage measurement change has been made, prepare to persist the new values
$coverageMeasurementDropdown.on("change", function () {
// Output diagnostics info to console
console.log('event: coverageMeasurementDropdown.change');

var customSettings = {
data: JSON.stringify({
buildDefinition: $buildDefinitionDropdown.val(),
Expand All @@ -117,12 +122,15 @@

// If a decimal places shown change has been made, prepare to persist the new values
$decimalPlacesDropdown.on("change", function () {
// Output diagnostics info to console
console.log('event: decimalPlacesDropdown.change');

var customSettings = {
data: JSON.stringify({
buildDefinition: $buildDefinitionDropdown.val(),
coverageMeasurement: $coverageMeasurementDropdown.val(),
decimalPlaces: $decimalPlacesDropdown.val(),
checkOptionBuildName: $checkOptionBuildName.prop('checked')
checkOptionBuildName: $checkOptionBuildName.prop('checked')
})
};
var eventName = WidgetHelpers.WidgetEvent.ConfigurationChange;
Expand All @@ -132,6 +140,9 @@

// If a show build name change has been made, prepare to persist the new values
$checkOptionBuildName.on("change", function () {
// Output diagnostics info to console
console.log('event: checkOptionBuildName.change');

var customSettings = {
data: JSON.stringify({
buildDefinition: $buildDefinitionDropdown.val(),
Expand All @@ -148,6 +159,9 @@
return WidgetHelpers.WidgetStatusHelper.Success();
},
onSave: function() {
// Output diagnostics info to console
console.log('event: onSave');

// Persist the selected definition
var customSettings = {
data: JSON.stringify({
Expand All @@ -172,7 +186,7 @@
<label>Build definition</label>
<div class="wrapper">
<select id="build-definition-dropdown">
<!--<option value="Shared Queries/Feedback">Shared Queries/Feedback</option>-->
<!--<option value="Shared Queries/Feedback">Shared Queries/Feedback</option>-->
</select>
</div>
</div>
Expand All @@ -197,7 +211,7 @@
<select id="decimal-places-dropdown">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2 (may require resizing widget)</option>
<option value="2">2</option>
</select>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions node_modules/@types/jquery/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5e22369

Please sign in to comment.