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..2987cde3
--- /dev/null
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -0,0 +1,50 @@
+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() {
+ 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);
+ const dependencyIds = JSON.parse(buildElement.dataset.dependencyIds);
+
+ // 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);
+ }
+
+ 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);
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);
});
}
});
|