From 9d45e3dd4039937f4c32aebed19782ad5e6b6d1c Mon Sep 17 00:00:00 2001 From: William Allen Date: Fri, 25 Sep 2026 12:32:44 -0400 Subject: [PATCH] Compile AngularJS template partials into `legacy.js` The AngularJS template partials are currently loaded separately from the JS bundle, leading to marginally longer initial page load times and a cache-busting system requiring a an auto-generated `version.js` file to be written on every build. This eliminates `version.js` and compiles the template partials into the JS build. I plan to build on this by further separating the frontend build from the backend in the future. --- resources/js/angular/controllers/filters.js | 14 ++++--- resources/js/angular/directives/build.js | 6 ++- resources/js/angular/directives/buildgroup.js | 6 ++- resources/js/angular/directives/daterange.js | 6 ++- resources/js/angular/directives/timeline.js | 5 ++- resources/js/angular/legacy.js | 20 +++++++--- resources/js/angular/views/index.html | 4 +- resources/js/angular/views/queryTests.html | 2 +- resources/js/angular/views/testOverview.html | 2 +- .../js/angular/views/viewSubProjects.html | 2 +- webpack.mix.js | 37 ++++++++++++++----- 11 files changed, 70 insertions(+), 34 deletions(-) diff --git a/resources/js/angular/controllers/filters.js b/resources/js/angular/controllers/filters.js index e28baadc4f..d18af4d0b7 100644 --- a/resources/js/angular/controllers/filters.js +++ b/resources/js/angular/controllers/filters.js @@ -1,3 +1,5 @@ +import filterRowTemplate from '../views/partials/filterRow.html'; +import filterButtonsTemplate from '../views/partials/filterButtons.html'; export function FiltersController($scope, $rootScope, $http, $timeout) { @@ -454,14 +456,14 @@ export function FiltersController($scope, $rootScope, $http, $timeout) { }); } -export const filterRow = ["VERSION", function (VERSION) { +export const filterRow = function () { return { - templateUrl: 'assets/js/angular/views/partials/filterRow.html?id=' + VERSION, + template: filterRowTemplate, }; -}]; +}; -export const filterButtons = ["VERSION", function (VERSION) { +export const filterButtons = function () { return { - templateUrl: 'assets/js/angular/views/partials/filterButtons.html?id=' + VERSION, + template: filterButtonsTemplate, }; -}]; +}; diff --git a/resources/js/angular/directives/build.js b/resources/js/angular/directives/build.js index e839c5f447..5774eab6a8 100644 --- a/resources/js/angular/directives/build.js +++ b/resources/js/angular/directives/build.js @@ -1,5 +1,7 @@ -export function build(VERSION) { +import buildTemplate from '../views/partials/build.html'; + +export function build() { return { - templateUrl: 'assets/js/angular/views/partials/build.html?id=' + VERSION, + template: buildTemplate, } } diff --git a/resources/js/angular/directives/buildgroup.js b/resources/js/angular/directives/buildgroup.js index 21c0e6800d..1e08a5fdc8 100644 --- a/resources/js/angular/directives/buildgroup.js +++ b/resources/js/angular/directives/buildgroup.js @@ -1,5 +1,7 @@ -export function buildgroup(VERSION) { +import buildgroupTemplate from '../views/partials/buildgroup.html'; + +export function buildgroup() { return { - templateUrl: 'assets/js/angular/views/partials/buildgroup.html?id=' + VERSION, + template: buildgroupTemplate, } } diff --git a/resources/js/angular/directives/daterange.js b/resources/js/angular/directives/daterange.js index 43fbbded55..b135d6c1a3 100644 --- a/resources/js/angular/directives/daterange.js +++ b/resources/js/angular/directives/daterange.js @@ -1,7 +1,9 @@ -export function daterange(VERSION) { +import daterangeTemplate from '../views/partials/daterange.html'; + +export function daterange() { return { restrict: 'A', - templateUrl: 'assets/js/angular/views/partials/daterange.html?id=' + VERSION, + template: daterangeTemplate, link: function (scope, element, attrs, ngModelCtrl) { var format = "yy-mm-dd", diff --git a/resources/js/angular/directives/timeline.js b/resources/js/angular/directives/timeline.js index 1a6fa8b02b..55ee177c87 100644 --- a/resources/js/angular/directives/timeline.js +++ b/resources/js/angular/directives/timeline.js @@ -1,5 +1,6 @@ import d3 from 'd3'; import nv from 'nvd3'; +import timelineTemplate from '../views/partials/timeline.html'; var timelineController = function TimelineChartController($http, $scope) { @@ -261,10 +262,10 @@ var timelineController = }; timelineController.$inject = ["$http", "$scope"]; -export function timeline(VERSION) { +export function timeline() { return { restrict: 'A', - templateUrl: 'assets/js/angular/views/partials/timeline.html?id=' + VERSION, + template: timelineTemplate, controller: timelineController }; } diff --git a/resources/js/angular/legacy.js b/resources/js/angular/legacy.js index 933da0667f..bc3356b8b0 100644 --- a/resources/js/angular/legacy.js +++ b/resources/js/angular/legacy.js @@ -23,8 +23,16 @@ const CDash = angular.module('CDash', [ 'ui.bootstrap', ]); -import { VERSION } from '../../../public/assets/js/angular/version.js'; -CDash.constant('VERSION', VERSION); +// filterdataTemplate.html and subProjectTable.html are only ever reached via +// ng-include in server-rendered view HTML (not through Angular DI), so their +// content is pre-loaded into $templateCache under the same path ng-include +// requests, instead of being fetched over HTTP. +import filterdataTemplateHtml from './views/partials/filterdataTemplate.html'; +import subProjectTableHtml from './views/partials/subProjectTable.html'; +CDash.run(["$templateCache", function ($templateCache) { + $templateCache.put('assets/js/angular/views/partials/filterdataTemplate.html', filterdataTemplateHtml); + $templateCache.put('assets/js/angular/views/partials/subProjectTable.html', subProjectTableHtml); +}]); import { ManageSubProjectController, filter_subproject_groups } from "./controllers/manageSubProject"; CDash.controller('ManageSubProjectController', ["$scope", "$http", "apiLoader", ManageSubProjectController]); @@ -86,16 +94,16 @@ import { renderTimer } from './services/renderTimer.js'; CDash.factory('renderTimer', ["$timeout", renderTimer]); import { build } from './directives/build.js'; -CDash.directive('build', ["VERSION", build]); +CDash.directive('build', build); import { timeline } from './directives/timeline.js'; -CDash.directive('timeline', ["VERSION", timeline]); +CDash.directive('timeline', timeline); import { daterange } from './directives/daterange.js'; -CDash.directive('daterange', ["VERSION", daterange]); +CDash.directive('daterange', daterange); import { buildgroup } from './directives/buildgroup.js'; -CDash.directive('buildgroup', ["VERSION", buildgroup]); +CDash.directive('buildgroup', buildgroup); import { autocomplete } from './directives/autocomplete.js'; CDash.directive('autoComplete', ["$parse", autocomplete]); diff --git a/resources/js/angular/views/index.html b/resources/js/angular/views/index.html index 67ead7c320..9593ca3cd6 100644 --- a/resources/js/angular/views/index.html +++ b/resources/js/angular/views/index.html @@ -48,7 +48,7 @@ - + @@ -151,7 +151,7 @@ - +
Query {{cdash.dashboard.projectname}} Tests: {{cdash.builds.le Hide Matching Output
- + diff --git a/resources/js/angular/views/testOverview.html b/resources/js/angular/views/testOverview.html index 8a7045c78b..3c2ea91545 100644 --- a/resources/js/angular/views/testOverview.html +++ b/resources/js/angular/views/testOverview.html @@ -11,7 +11,7 @@ Hide Filters - +