diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
new file mode 100644
index 00000000..aa785481
--- /dev/null
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -0,0 +1,56 @@
+const buildCardTemplateSource = jQuery("#build-card-template").html();
+const projectCardTemplateSource = jQuery("#project-card-template").html();
+const refreshFrequency = parseInt(document.querySelector(".pipeline-refresh-frequency").dataset.refreshFrequency, 10);
+
+var buildPipeline = new BuildPipeline(
+buildPipelineViewProxy,
+Handlebars.compile(buildCardTemplateSource),
+Handlebars.compile(projectCardTemplateSource),
+refreshFrequency
+);
+
+
+function initializeBuildCards() {
+ // Find all build data elements
+ document.querySelectorAll('.build-data').forEach(buildElement => {
+
+ const buildId = buildElement.dataset.buildId;
+ const buildData = JSON.parse(buildElement.dataset.buildInfo);
+ const buildStatus = buildElement.dataset.buildStatus;
+ const isManualTrigger = buildElement.dataset.isManualTrigger === 'true';
+ const nextBuildNumber = parseInt(buildElement.dataset.nextBuildNumber, 10);
+ console.log(nextBuildNumber);
+ const dependencyIds = buildElement.dataset.dependencyIds
+ .split(',')
+ .filter(Boolean)
+ .map(id => parseInt(id, 10));
+
+
+ // Generate build card
+ jQuery(buildElement).append(buildPipeline.buildCardTemplate(buildData));
+
+ // add build proxy to proxies for future use-->
+ buildPipeline.buildProxies[buildId] = window[`buildProxy_${buildId}`];
+
+ if (buildStatus === 'BUILDING') {
+ buildPipeline.showProgress(buildId, dependencyIds, nextBuildNumber);
+ }
+
+ if (buildStatus === 'PENDING') {
+ jQuery("table.pipelines").on(`show-status-${buildId}`, function() {
+ if (isManualTrigger) {
+ buildPipeline.updateBuildCard(buildId);
+ } else {
+ buildPipeline.updateNextBuildAndShowProgress(
+ buildId,
+ nextBuildNumber,
+ dependencyIds
+ );
+ }
+ });
+ }
+
+ });
+}
+
+document.addEventListener('DOMContentLoaded', initializeBuildCards);
\ No newline at end of file
diff --git a/src/main/webapp/js/build-pipeline.js b/src/main/webapp/js/build-pipeline.js
index 6ce69423..3d650c9d 100644
--- a/src/main/webapp/js/build-pipeline.js
+++ b/src/main/webapp/js/build-pipeline.js
@@ -26,7 +26,7 @@ BuildPipeline.prototype = {
buildPipeline.updateAllBuildCards(dependencies);
// trigger all dependency tracking
jQuery.each(dependencies, function(){
- jQuery("#pipelines").trigger("show-status-" + this);
+ jQuery("table.pipelines").trigger("show-status-" + this);
});
}
});
From 86b17503e71710c2a0aa8f7127909f7c291ec839 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Sun, 3 Nov 2024 17:04:09 -0500
Subject: [PATCH 2/4] extract inline script bpp.jelly
---
.../hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly | 5 -----
.../buildpipeline/BuildPipelineView/build-pipeline-init.js | 2 +-
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index e7b1ea91..267e61ee 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -34,11 +34,6 @@
-
-
-
-
-
Date: Mon, 4 Nov 2024 16:48:30 -0500
Subject: [PATCH 3/4] fix existing functionality - extract JS
---
.../buildpipeline/BuildPipelineView/bpp.jelly | 5 ++---
.../BuildPipelineView/build-pipeline-init.js | 17 ++++++-----------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index 267e61ee..f3e42b9e 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -130,14 +130,13 @@
-
-
+ data-dependency-ids="${build.getDependencyIds()}"/>
|
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index 734d2cf1..268da39b 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -3,10 +3,10 @@ const projectCardTemplateSource = jQuery("#project-card-template").html();
const refreshFrequency = parseInt(document.querySelector(".pipeline-refresh-frequency").dataset.refreshFrequency, 10);
var buildPipeline = new BuildPipeline(
-buildPipelineViewProxy,
-Handlebars.compile(buildCardTemplateSource),
-Handlebars.compile(projectCardTemplateSource),
-refreshFrequency
+ buildPipelineViewProxy,
+ Handlebars.compile(buildCardTemplateSource),
+ Handlebars.compile(projectCardTemplateSource),
+ refreshFrequency
);
@@ -19,12 +19,7 @@ function initializeBuildCards() {
const buildStatus = buildElement.dataset.buildStatus;
const isManualTrigger = buildElement.dataset.isManualTrigger === 'true';
const nextBuildNumber = parseInt(buildElement.dataset.nextBuildNumber, 10);
- console.log(nextBuildNumber);
- const dependencyIds = buildElement.dataset.dependencyIds
- .split(',')
- .filter(Boolean)
- .map(id => parseInt(id, 10));
-
+ const dependencyIds = JSON.parse(buildElement.dataset.dependencyIds);
// Generate build card
jQuery(buildElement).append(buildPipeline.buildCardTemplate(buildData));
@@ -33,7 +28,7 @@ function initializeBuildCards() {
buildPipeline.buildProxies[buildId] = window[`buildProxy_${buildId}`];
if (buildStatus === 'BUILDING') {
- buildPipeline.showProgress(buildId, dependencyIds, nextBuildNumber);
+ buildPipeline.showProgress(buildId, dependencyIds);
}
if (buildStatus === 'PENDING') {
From 08c66cab0458dc5693da6db178c99140823e64f8 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Mon, 4 Nov 2024 16:49:30 -0500
Subject: [PATCH 4/4] fix existing functionality - extract JS
---
.../buildpipeline/BuildPipelineView/build-pipeline-init.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index 268da39b..2987cde3 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -11,7 +11,6 @@ var buildPipeline = new BuildPipeline(
function initializeBuildCards() {
- // Find all build data elements
document.querySelectorAll('.build-data').forEach(buildElement => {
const buildId = buildElement.dataset.buildId;
|