Spaces:
Sleeping
Sleeping
Delete static
Browse files- static/app.js +0 -1607
- static/index.html +0 -473
- static/recommended-fit.js +0 -206
- static/score-analysis.js +0 -96
- static/webjars/solverforge/css/solverforge-webui.css +0 -68
- static/webjars/solverforge/img/solverforge-favicon.svg +0 -65
- static/webjars/solverforge/img/solverforge-horizontal-white.svg +0 -66
- static/webjars/solverforge/img/solverforge-horizontal.svg +0 -65
- static/webjars/solverforge/img/solverforge-logo-stacked.svg +0 -73
- static/webjars/solverforge/js/solverforge-webui.js +0 -142
- static/webjars/timefold/css/timefold-webui.css +0 -60
- static/webjars/timefold/img/timefold-favicon.svg +0 -25
- static/webjars/timefold/img/timefold-logo-horizontal-negative.svg +0 -1
- static/webjars/timefold/img/timefold-logo-horizontal-positive.svg +0 -1
- static/webjars/timefold/img/timefold-logo-stacked-positive.svg +0 -1
- static/webjars/timefold/js/timefold-webui.js +0 -142
static/app.js
DELETED
|
@@ -1,1607 +0,0 @@
|
|
| 1 |
-
let autoRefreshIntervalId = null;
|
| 2 |
-
let initialized = false;
|
| 3 |
-
let optimizing = false;
|
| 4 |
-
let demoDataId = null;
|
| 5 |
-
let scheduleId = null;
|
| 6 |
-
let loadedRoutePlan = null;
|
| 7 |
-
let newVisit = null;
|
| 8 |
-
let visitMarker = null;
|
| 9 |
-
let routeGeometries = null; // Cache for encoded polyline geometries
|
| 10 |
-
let useRealRoads = false; // Routing mode toggle state
|
| 11 |
-
const solveButton = $("#solveButton");
|
| 12 |
-
const stopSolvingButton = $("#stopSolvingButton");
|
| 13 |
-
const vehiclesTable = $("#vehicles");
|
| 14 |
-
const analyzeButton = $("#analyzeButton");
|
| 15 |
-
|
| 16 |
-
/**
|
| 17 |
-
* Decode an encoded polyline string into an array of [lat, lng] coordinates.
|
| 18 |
-
* This is the Google polyline encoding algorithm.
|
| 19 |
-
* @param {string} encoded - The encoded polyline string
|
| 20 |
-
* @returns {Array<Array<number>>} Array of [lat, lng] coordinate pairs
|
| 21 |
-
*/
|
| 22 |
-
function decodePolyline(encoded) {
|
| 23 |
-
if (!encoded) return [];
|
| 24 |
-
|
| 25 |
-
const points = [];
|
| 26 |
-
let index = 0;
|
| 27 |
-
let lat = 0;
|
| 28 |
-
let lng = 0;
|
| 29 |
-
|
| 30 |
-
while (index < encoded.length) {
|
| 31 |
-
// Decode latitude
|
| 32 |
-
let shift = 0;
|
| 33 |
-
let result = 0;
|
| 34 |
-
let byte;
|
| 35 |
-
do {
|
| 36 |
-
byte = encoded.charCodeAt(index++) - 63;
|
| 37 |
-
result |= (byte & 0x1f) << shift;
|
| 38 |
-
shift += 5;
|
| 39 |
-
} while (byte >= 0x20);
|
| 40 |
-
const dlat = (result & 1) ? ~(result >> 1) : (result >> 1);
|
| 41 |
-
lat += dlat;
|
| 42 |
-
|
| 43 |
-
// Decode longitude
|
| 44 |
-
shift = 0;
|
| 45 |
-
result = 0;
|
| 46 |
-
do {
|
| 47 |
-
byte = encoded.charCodeAt(index++) - 63;
|
| 48 |
-
result |= (byte & 0x1f) << shift;
|
| 49 |
-
shift += 5;
|
| 50 |
-
} while (byte >= 0x20);
|
| 51 |
-
const dlng = (result & 1) ? ~(result >> 1) : (result >> 1);
|
| 52 |
-
lng += dlng;
|
| 53 |
-
|
| 54 |
-
// Polyline encoding uses precision of 5 decimal places
|
| 55 |
-
points.push([lat / 1e5, lng / 1e5]);
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
return points;
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
/**
|
| 62 |
-
* Fetch route geometries for the current schedule from the backend.
|
| 63 |
-
* @returns {Promise<Object|null>} The geometries object or null if unavailable
|
| 64 |
-
*/
|
| 65 |
-
async function fetchRouteGeometries() {
|
| 66 |
-
if (!scheduleId) return null;
|
| 67 |
-
|
| 68 |
-
try {
|
| 69 |
-
const response = await fetch(`/route-plans/${scheduleId}/geometry`);
|
| 70 |
-
if (response.ok) {
|
| 71 |
-
const data = await response.json();
|
| 72 |
-
return data.geometries || null;
|
| 73 |
-
}
|
| 74 |
-
} catch (e) {
|
| 75 |
-
console.warn('Could not fetch route geometries:', e);
|
| 76 |
-
}
|
| 77 |
-
return null;
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
/*************************************** Loading Overlay Functions **************************************/
|
| 81 |
-
|
| 82 |
-
function showLoadingOverlay(title = "Loading Demo Data", message = "Initializing...") {
|
| 83 |
-
$("#loadingTitle").text(title);
|
| 84 |
-
$("#loadingMessage").text(message);
|
| 85 |
-
$("#loadingProgress").css("width", "0%");
|
| 86 |
-
$("#loadingDetail").text("");
|
| 87 |
-
$("#loadingOverlay").removeClass("hidden");
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
function hideLoadingOverlay() {
|
| 91 |
-
$("#loadingOverlay").addClass("hidden");
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
function updateLoadingProgress(message, percent, detail = "") {
|
| 95 |
-
$("#loadingMessage").text(message);
|
| 96 |
-
$("#loadingProgress").css("width", `${percent}%`);
|
| 97 |
-
$("#loadingDetail").text(detail);
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
/**
|
| 101 |
-
* Load demo data with progress updates via Server-Sent Events.
|
| 102 |
-
* Used when Real Roads mode is enabled.
|
| 103 |
-
*/
|
| 104 |
-
function loadDemoDataWithProgress(demoId) {
|
| 105 |
-
return new Promise((resolve, reject) => {
|
| 106 |
-
const routingMode = useRealRoads ? "real_roads" : "haversine";
|
| 107 |
-
const url = `/demo-data/${demoId}/stream?routing=${routingMode}`;
|
| 108 |
-
|
| 109 |
-
showLoadingOverlay(
|
| 110 |
-
useRealRoads ? "Loading Real Road Data" : "Loading Demo Data",
|
| 111 |
-
"Connecting..."
|
| 112 |
-
);
|
| 113 |
-
|
| 114 |
-
const eventSource = new EventSource(url);
|
| 115 |
-
let solution = null;
|
| 116 |
-
|
| 117 |
-
eventSource.onmessage = function(event) {
|
| 118 |
-
try {
|
| 119 |
-
const data = JSON.parse(event.data);
|
| 120 |
-
|
| 121 |
-
if (data.event === "progress") {
|
| 122 |
-
let statusIcon = "";
|
| 123 |
-
if (data.phase === "network") {
|
| 124 |
-
statusIcon = '<i class="fas fa-download me-2"></i>';
|
| 125 |
-
} else if (data.phase === "routes") {
|
| 126 |
-
statusIcon = '<i class="fas fa-route me-2"></i>';
|
| 127 |
-
} else if (data.phase === "complete") {
|
| 128 |
-
statusIcon = '<i class="fas fa-check-circle me-2 text-success"></i>';
|
| 129 |
-
}
|
| 130 |
-
updateLoadingProgress(data.message, data.percent, data.detail || "");
|
| 131 |
-
} else if (data.event === "complete") {
|
| 132 |
-
solution = data.solution;
|
| 133 |
-
// Store geometries from the response if available
|
| 134 |
-
if (data.geometries) {
|
| 135 |
-
routeGeometries = data.geometries;
|
| 136 |
-
}
|
| 137 |
-
eventSource.close();
|
| 138 |
-
hideLoadingOverlay();
|
| 139 |
-
resolve(solution);
|
| 140 |
-
} else if (data.event === "error") {
|
| 141 |
-
eventSource.close();
|
| 142 |
-
hideLoadingOverlay();
|
| 143 |
-
reject(new Error(data.message));
|
| 144 |
-
}
|
| 145 |
-
} catch (e) {
|
| 146 |
-
console.error("Error parsing SSE event:", e);
|
| 147 |
-
}
|
| 148 |
-
};
|
| 149 |
-
|
| 150 |
-
eventSource.onerror = function(error) {
|
| 151 |
-
eventSource.close();
|
| 152 |
-
hideLoadingOverlay();
|
| 153 |
-
reject(new Error("Connection lost while loading data"));
|
| 154 |
-
};
|
| 155 |
-
});
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
/*************************************** Map constants and variable definitions **************************************/
|
| 159 |
-
|
| 160 |
-
const homeLocationMarkerByIdMap = new Map();
|
| 161 |
-
const visitMarkerByIdMap = new Map();
|
| 162 |
-
|
| 163 |
-
const map = L.map("map", { doubleClickZoom: false }).setView(
|
| 164 |
-
[51.505, -0.09],
|
| 165 |
-
13,
|
| 166 |
-
);
|
| 167 |
-
const visitGroup = L.layerGroup().addTo(map);
|
| 168 |
-
const homeLocationGroup = L.layerGroup().addTo(map);
|
| 169 |
-
const routeGroup = L.layerGroup().addTo(map);
|
| 170 |
-
|
| 171 |
-
/************************************ Time line constants and variable definitions ************************************/
|
| 172 |
-
|
| 173 |
-
let byVehicleTimeline;
|
| 174 |
-
let byVisitTimeline;
|
| 175 |
-
const byVehicleGroupData = new vis.DataSet();
|
| 176 |
-
const byVehicleItemData = new vis.DataSet();
|
| 177 |
-
const byVisitGroupData = new vis.DataSet();
|
| 178 |
-
const byVisitItemData = new vis.DataSet();
|
| 179 |
-
|
| 180 |
-
const byVehicleTimelineOptions = {
|
| 181 |
-
timeAxis: { scale: "hour" },
|
| 182 |
-
orientation: { axis: "top" },
|
| 183 |
-
xss: { disabled: true }, // Items are XSS safe through JQuery
|
| 184 |
-
stack: false,
|
| 185 |
-
stackSubgroups: false,
|
| 186 |
-
zoomMin: 1000 * 60 * 60, // A single hour in milliseconds
|
| 187 |
-
zoomMax: 1000 * 60 * 60 * 24, // A single day in milliseconds
|
| 188 |
-
};
|
| 189 |
-
|
| 190 |
-
const byVisitTimelineOptions = {
|
| 191 |
-
timeAxis: { scale: "hour" },
|
| 192 |
-
orientation: { axis: "top" },
|
| 193 |
-
verticalScroll: true,
|
| 194 |
-
xss: { disabled: true }, // Items are XSS safe through JQuery
|
| 195 |
-
stack: false,
|
| 196 |
-
stackSubgroups: false,
|
| 197 |
-
zoomMin: 1000 * 60 * 60, // A single hour in milliseconds
|
| 198 |
-
zoomMax: 1000 * 60 * 60 * 24, // A single day in milliseconds
|
| 199 |
-
};
|
| 200 |
-
|
| 201 |
-
/************************************ Initialize ************************************/
|
| 202 |
-
|
| 203 |
-
// Vehicle management state
|
| 204 |
-
let addingVehicleMode = false;
|
| 205 |
-
let pickingVehicleLocation = false;
|
| 206 |
-
let tempVehicleMarker = null;
|
| 207 |
-
let vehicleDeparturePicker = null;
|
| 208 |
-
|
| 209 |
-
// Route highlighting state
|
| 210 |
-
let highlightedVehicleId = null;
|
| 211 |
-
let routeNumberMarkers = []; // Markers showing 1, 2, 3... on route stops
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
$(document).ready(function () {
|
| 215 |
-
replaceQuickstartSolverForgeAutoHeaderFooter();
|
| 216 |
-
|
| 217 |
-
// Initialize timelines after DOM is ready with a small delay to ensure Bootstrap tabs are rendered
|
| 218 |
-
setTimeout(function () {
|
| 219 |
-
const byVehiclePanel = document.getElementById("byVehiclePanel");
|
| 220 |
-
const byVisitPanel = document.getElementById("byVisitPanel");
|
| 221 |
-
|
| 222 |
-
if (byVehiclePanel) {
|
| 223 |
-
byVehicleTimeline = new vis.Timeline(
|
| 224 |
-
byVehiclePanel,
|
| 225 |
-
byVehicleItemData,
|
| 226 |
-
byVehicleGroupData,
|
| 227 |
-
byVehicleTimelineOptions,
|
| 228 |
-
);
|
| 229 |
-
}
|
| 230 |
-
|
| 231 |
-
if (byVisitPanel) {
|
| 232 |
-
byVisitTimeline = new vis.Timeline(
|
| 233 |
-
byVisitPanel,
|
| 234 |
-
byVisitItemData,
|
| 235 |
-
byVisitGroupData,
|
| 236 |
-
byVisitTimelineOptions,
|
| 237 |
-
);
|
| 238 |
-
}
|
| 239 |
-
}, 100);
|
| 240 |
-
|
| 241 |
-
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
| 242 |
-
maxZoom: 19,
|
| 243 |
-
attribution:
|
| 244 |
-
'© <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
|
| 245 |
-
}).addTo(map);
|
| 246 |
-
|
| 247 |
-
solveButton.click(solve);
|
| 248 |
-
stopSolvingButton.click(stopSolving);
|
| 249 |
-
analyzeButton.click(analyze);
|
| 250 |
-
refreshSolvingButtons(false);
|
| 251 |
-
|
| 252 |
-
// HACK to allow vis-timeline to work within Bootstrap tabs
|
| 253 |
-
$("#byVehicleTab").on("shown.bs.tab", function (event) {
|
| 254 |
-
if (byVehicleTimeline) {
|
| 255 |
-
byVehicleTimeline.redraw();
|
| 256 |
-
}
|
| 257 |
-
});
|
| 258 |
-
$("#byVisitTab").on("shown.bs.tab", function (event) {
|
| 259 |
-
if (byVisitTimeline) {
|
| 260 |
-
byVisitTimeline.redraw();
|
| 261 |
-
}
|
| 262 |
-
});
|
| 263 |
-
|
| 264 |
-
// Map click handler - context aware
|
| 265 |
-
map.on("click", function (e) {
|
| 266 |
-
if (addingVehicleMode) {
|
| 267 |
-
// Set vehicle home location
|
| 268 |
-
setVehicleHomeLocation(e.latlng.lat, e.latlng.lng);
|
| 269 |
-
} else if (!optimizing) {
|
| 270 |
-
// Add new visit
|
| 271 |
-
visitMarker = L.circleMarker(e.latlng);
|
| 272 |
-
visitMarker.setStyle({ color: "green" });
|
| 273 |
-
visitMarker.addTo(map);
|
| 274 |
-
openRecommendationModal(e.latlng.lat, e.latlng.lng);
|
| 275 |
-
}
|
| 276 |
-
});
|
| 277 |
-
|
| 278 |
-
// Remove visit marker when modal closes
|
| 279 |
-
$("#newVisitModal").on("hidden.bs.modal", function () {
|
| 280 |
-
if (visitMarker) {
|
| 281 |
-
map.removeLayer(visitMarker);
|
| 282 |
-
}
|
| 283 |
-
});
|
| 284 |
-
|
| 285 |
-
// Vehicle management
|
| 286 |
-
$("#addVehicleBtn").click(openAddVehicleModal);
|
| 287 |
-
$("#removeVehicleBtn").click(removeLastVehicle);
|
| 288 |
-
$("#confirmAddVehicle").click(confirmAddVehicle);
|
| 289 |
-
$("#pickLocationBtn").click(pickVehicleLocationOnMap);
|
| 290 |
-
|
| 291 |
-
// Clean up when add vehicle modal closes (only if not picking location)
|
| 292 |
-
$("#addVehicleModal").on("hidden.bs.modal", function () {
|
| 293 |
-
if (!pickingVehicleLocation) {
|
| 294 |
-
addingVehicleMode = false;
|
| 295 |
-
if (tempVehicleMarker) {
|
| 296 |
-
map.removeLayer(tempVehicleMarker);
|
| 297 |
-
tempVehicleMarker = null;
|
| 298 |
-
}
|
| 299 |
-
}
|
| 300 |
-
});
|
| 301 |
-
|
| 302 |
-
// Real Roads toggle handler
|
| 303 |
-
$(document).on('change', '#realRoadRouting', function() {
|
| 304 |
-
useRealRoads = $(this).is(':checked');
|
| 305 |
-
|
| 306 |
-
// If we have a demo dataset loaded, reload it with the new routing mode
|
| 307 |
-
if (demoDataId && !optimizing) {
|
| 308 |
-
scheduleId = null;
|
| 309 |
-
initialized = false;
|
| 310 |
-
homeLocationGroup.clearLayers();
|
| 311 |
-
homeLocationMarkerByIdMap.clear();
|
| 312 |
-
visitGroup.clearLayers();
|
| 313 |
-
visitMarkerByIdMap.clear();
|
| 314 |
-
routeGeometries = null;
|
| 315 |
-
refreshRoutePlan();
|
| 316 |
-
}
|
| 317 |
-
});
|
| 318 |
-
|
| 319 |
-
setupAjax();
|
| 320 |
-
fetchDemoData();
|
| 321 |
-
});
|
| 322 |
-
|
| 323 |
-
/*************************************** Vehicle Management **************************************/
|
| 324 |
-
|
| 325 |
-
function openAddVehicleModal() {
|
| 326 |
-
if (optimizing) {
|
| 327 |
-
alert("Cannot add vehicles while solving. Please stop solving first.");
|
| 328 |
-
return;
|
| 329 |
-
}
|
| 330 |
-
if (!loadedRoutePlan) {
|
| 331 |
-
alert("Please load a dataset first.");
|
| 332 |
-
return;
|
| 333 |
-
}
|
| 334 |
-
|
| 335 |
-
addingVehicleMode = true;
|
| 336 |
-
|
| 337 |
-
// Suggest next vehicle name
|
| 338 |
-
$("#vehicleName").val("").attr("placeholder", `e.g., ${getNextVehicleName()}`);
|
| 339 |
-
|
| 340 |
-
// Set default values based on existing vehicles
|
| 341 |
-
const existingVehicle = loadedRoutePlan.vehicles[0];
|
| 342 |
-
if (existingVehicle) {
|
| 343 |
-
$("#vehicleCapacity").val(existingVehicle.capacity || 25);
|
| 344 |
-
const defaultLat = existingVehicle.homeLocation[0];
|
| 345 |
-
const defaultLng = existingVehicle.homeLocation[1];
|
| 346 |
-
$("#vehicleHomeLat").val(defaultLat.toFixed(6));
|
| 347 |
-
$("#vehicleHomeLng").val(defaultLng.toFixed(6));
|
| 348 |
-
}
|
| 349 |
-
|
| 350 |
-
// Initialize departure time picker
|
| 351 |
-
const tomorrow = JSJoda.LocalDate.now().plusDays(1);
|
| 352 |
-
const defaultDeparture = tomorrow.atTime(JSJoda.LocalTime.of(6, 0));
|
| 353 |
-
|
| 354 |
-
if (vehicleDeparturePicker) {
|
| 355 |
-
vehicleDeparturePicker.destroy();
|
| 356 |
-
}
|
| 357 |
-
vehicleDeparturePicker = flatpickr("#vehicleDepartureTime", {
|
| 358 |
-
enableTime: true,
|
| 359 |
-
dateFormat: "Y-m-d H:i",
|
| 360 |
-
defaultDate: defaultDeparture.format(JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm'))
|
| 361 |
-
});
|
| 362 |
-
|
| 363 |
-
$("#addVehicleModal").modal("show");
|
| 364 |
-
}
|
| 365 |
-
|
| 366 |
-
function pickVehicleLocationOnMap() {
|
| 367 |
-
// Hide modal temporarily while user picks location
|
| 368 |
-
pickingVehicleLocation = true;
|
| 369 |
-
addingVehicleMode = true;
|
| 370 |
-
$("#addVehicleModal").modal("hide");
|
| 371 |
-
|
| 372 |
-
// Show hint on map
|
| 373 |
-
$("#mapHint").html('<i class="fas fa-crosshairs"></i> Click on the map to set vehicle depot location').removeClass("hidden");
|
| 374 |
-
}
|
| 375 |
-
|
| 376 |
-
function setVehicleHomeLocation(lat, lng) {
|
| 377 |
-
$("#vehicleHomeLat").val(lat.toFixed(6));
|
| 378 |
-
$("#vehicleHomeLng").val(lng.toFixed(6));
|
| 379 |
-
$("#vehicleLocationPreview").html(`<i class="fas fa-check text-success"></i> Location set: ${lat.toFixed(4)}, ${lng.toFixed(4)}`);
|
| 380 |
-
|
| 381 |
-
// Show temporary marker
|
| 382 |
-
if (tempVehicleMarker) {
|
| 383 |
-
map.removeLayer(tempVehicleMarker);
|
| 384 |
-
}
|
| 385 |
-
tempVehicleMarker = L.marker([lat, lng], {
|
| 386 |
-
icon: L.divIcon({
|
| 387 |
-
className: 'temp-vehicle-marker',
|
| 388 |
-
html: `<div style="
|
| 389 |
-
background-color: #6366f1;
|
| 390 |
-
border: 3px solid white;
|
| 391 |
-
border-radius: 4px;
|
| 392 |
-
width: 28px;
|
| 393 |
-
height: 28px;
|
| 394 |
-
display: flex;
|
| 395 |
-
align-items: center;
|
| 396 |
-
justify-content: center;
|
| 397 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.4);
|
| 398 |
-
animation: pulse 1s infinite;
|
| 399 |
-
"><i class="fas fa-warehouse" style="color: white; font-size: 12px;"></i></div>`,
|
| 400 |
-
iconSize: [28, 28],
|
| 401 |
-
iconAnchor: [14, 14]
|
| 402 |
-
})
|
| 403 |
-
});
|
| 404 |
-
tempVehicleMarker.addTo(map);
|
| 405 |
-
|
| 406 |
-
// If we were picking location, re-open the modal
|
| 407 |
-
if (pickingVehicleLocation) {
|
| 408 |
-
pickingVehicleLocation = false;
|
| 409 |
-
addingVehicleMode = false;
|
| 410 |
-
$("#addVehicleModal").modal("show");
|
| 411 |
-
// Restore normal map hint
|
| 412 |
-
$("#mapHint").html('<i class="fas fa-mouse-pointer"></i> Click on the map to add a new visit');
|
| 413 |
-
}
|
| 414 |
-
}
|
| 415 |
-
|
| 416 |
-
// Extended phonetic alphabet for generating vehicle names
|
| 417 |
-
const PHONETIC_NAMES = ["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu"];
|
| 418 |
-
|
| 419 |
-
function getNextVehicleName() {
|
| 420 |
-
if (!loadedRoutePlan) return "Alpha";
|
| 421 |
-
const usedNames = new Set(loadedRoutePlan.vehicles.map(v => v.name));
|
| 422 |
-
for (const name of PHONETIC_NAMES) {
|
| 423 |
-
if (!usedNames.has(name)) return name;
|
| 424 |
-
}
|
| 425 |
-
// Fallback if all names used
|
| 426 |
-
return `Vehicle ${loadedRoutePlan.vehicles.length + 1}`;
|
| 427 |
-
}
|
| 428 |
-
|
| 429 |
-
async function confirmAddVehicle() {
|
| 430 |
-
const vehicleName = $("#vehicleName").val().trim() || getNextVehicleName();
|
| 431 |
-
const capacity = parseInt($("#vehicleCapacity").val());
|
| 432 |
-
const lat = parseFloat($("#vehicleHomeLat").val());
|
| 433 |
-
const lng = parseFloat($("#vehicleHomeLng").val());
|
| 434 |
-
const departureTime = $("#vehicleDepartureTime").val();
|
| 435 |
-
|
| 436 |
-
if (!capacity || capacity < 1) {
|
| 437 |
-
alert("Please enter a valid capacity (minimum 1).");
|
| 438 |
-
return;
|
| 439 |
-
}
|
| 440 |
-
if (isNaN(lat) || isNaN(lng)) {
|
| 441 |
-
alert("Please set a valid home location by clicking on the map or entering coordinates.");
|
| 442 |
-
return;
|
| 443 |
-
}
|
| 444 |
-
if (!departureTime) {
|
| 445 |
-
alert("Please set a departure time.");
|
| 446 |
-
return;
|
| 447 |
-
}
|
| 448 |
-
|
| 449 |
-
// Generate new vehicle ID
|
| 450 |
-
const maxId = Math.max(...loadedRoutePlan.vehicles.map(v => parseInt(v.id)), 0);
|
| 451 |
-
const newId = String(maxId + 1);
|
| 452 |
-
|
| 453 |
-
// Format departure time
|
| 454 |
-
const formattedDeparture = JSJoda.LocalDateTime.parse(
|
| 455 |
-
departureTime,
|
| 456 |
-
JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm')
|
| 457 |
-
).format(JSJoda.DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 458 |
-
|
| 459 |
-
// Create new vehicle
|
| 460 |
-
const newVehicle = {
|
| 461 |
-
id: newId,
|
| 462 |
-
name: vehicleName,
|
| 463 |
-
capacity: capacity,
|
| 464 |
-
homeLocation: [lat, lng],
|
| 465 |
-
departureTime: formattedDeparture,
|
| 466 |
-
visits: [],
|
| 467 |
-
totalDemand: 0,
|
| 468 |
-
totalDrivingTimeSeconds: 0,
|
| 469 |
-
arrivalTime: formattedDeparture
|
| 470 |
-
};
|
| 471 |
-
|
| 472 |
-
// Add to solution
|
| 473 |
-
loadedRoutePlan.vehicles.push(newVehicle);
|
| 474 |
-
|
| 475 |
-
// Close modal and refresh
|
| 476 |
-
$("#addVehicleModal").modal("hide");
|
| 477 |
-
addingVehicleMode = false;
|
| 478 |
-
|
| 479 |
-
if (tempVehicleMarker) {
|
| 480 |
-
map.removeLayer(tempVehicleMarker);
|
| 481 |
-
tempVehicleMarker = null;
|
| 482 |
-
}
|
| 483 |
-
|
| 484 |
-
// Refresh display
|
| 485 |
-
await renderRoutes(loadedRoutePlan);
|
| 486 |
-
renderTimelines(loadedRoutePlan);
|
| 487 |
-
|
| 488 |
-
showNotification(`Vehicle "${vehicleName}" added successfully!`, "success");
|
| 489 |
-
}
|
| 490 |
-
|
| 491 |
-
async function removeLastVehicle() {
|
| 492 |
-
if (optimizing) {
|
| 493 |
-
alert("Cannot remove vehicles while solving. Please stop solving first.");
|
| 494 |
-
return;
|
| 495 |
-
}
|
| 496 |
-
if (!loadedRoutePlan || loadedRoutePlan.vehicles.length <= 1) {
|
| 497 |
-
alert("Cannot remove the last vehicle. At least one vehicle is required.");
|
| 498 |
-
return;
|
| 499 |
-
}
|
| 500 |
-
|
| 501 |
-
const lastVehicle = loadedRoutePlan.vehicles[loadedRoutePlan.vehicles.length - 1];
|
| 502 |
-
|
| 503 |
-
if (lastVehicle.visits && lastVehicle.visits.length > 0) {
|
| 504 |
-
if (!confirm(`Vehicle ${lastVehicle.id} has ${lastVehicle.visits.length} assigned visits. These will become unassigned. Continue?`)) {
|
| 505 |
-
return;
|
| 506 |
-
}
|
| 507 |
-
// Unassign visits from the vehicle
|
| 508 |
-
lastVehicle.visits.forEach(visitId => {
|
| 509 |
-
const visit = loadedRoutePlan.visits.find(v => v.id === visitId);
|
| 510 |
-
if (visit) {
|
| 511 |
-
visit.vehicle = null;
|
| 512 |
-
visit.previousVisit = null;
|
| 513 |
-
visit.nextVisit = null;
|
| 514 |
-
visit.arrivalTime = null;
|
| 515 |
-
visit.departureTime = null;
|
| 516 |
-
}
|
| 517 |
-
});
|
| 518 |
-
}
|
| 519 |
-
|
| 520 |
-
// Remove vehicle
|
| 521 |
-
loadedRoutePlan.vehicles.pop();
|
| 522 |
-
|
| 523 |
-
// Remove marker
|
| 524 |
-
const marker = homeLocationMarkerByIdMap.get(lastVehicle.id);
|
| 525 |
-
if (marker) {
|
| 526 |
-
homeLocationGroup.removeLayer(marker);
|
| 527 |
-
homeLocationMarkerByIdMap.delete(lastVehicle.id);
|
| 528 |
-
}
|
| 529 |
-
|
| 530 |
-
// Refresh display
|
| 531 |
-
await renderRoutes(loadedRoutePlan);
|
| 532 |
-
renderTimelines(loadedRoutePlan);
|
| 533 |
-
|
| 534 |
-
showNotification(`Vehicle "${lastVehicle.name || lastVehicle.id}" removed.`, "info");
|
| 535 |
-
}
|
| 536 |
-
|
| 537 |
-
async function removeVehicle(vehicleId) {
|
| 538 |
-
if (optimizing) {
|
| 539 |
-
alert("Cannot remove vehicles while solving. Please stop solving first.");
|
| 540 |
-
return;
|
| 541 |
-
}
|
| 542 |
-
|
| 543 |
-
const vehicleIndex = loadedRoutePlan.vehicles.findIndex(v => v.id === vehicleId);
|
| 544 |
-
if (vehicleIndex === -1) return;
|
| 545 |
-
|
| 546 |
-
if (loadedRoutePlan.vehicles.length <= 1) {
|
| 547 |
-
alert("Cannot remove the last vehicle. At least one vehicle is required.");
|
| 548 |
-
return;
|
| 549 |
-
}
|
| 550 |
-
|
| 551 |
-
const vehicle = loadedRoutePlan.vehicles[vehicleIndex];
|
| 552 |
-
|
| 553 |
-
if (vehicle.visits && vehicle.visits.length > 0) {
|
| 554 |
-
if (!confirm(`Vehicle ${vehicle.id} has ${vehicle.visits.length} assigned visits. These will become unassigned. Continue?`)) {
|
| 555 |
-
return;
|
| 556 |
-
}
|
| 557 |
-
// Unassign visits
|
| 558 |
-
vehicle.visits.forEach(visitId => {
|
| 559 |
-
const visit = loadedRoutePlan.visits.find(v => v.id === visitId);
|
| 560 |
-
if (visit) {
|
| 561 |
-
visit.vehicle = null;
|
| 562 |
-
visit.previousVisit = null;
|
| 563 |
-
visit.nextVisit = null;
|
| 564 |
-
visit.arrivalTime = null;
|
| 565 |
-
visit.departureTime = null;
|
| 566 |
-
}
|
| 567 |
-
});
|
| 568 |
-
}
|
| 569 |
-
|
| 570 |
-
// Remove vehicle
|
| 571 |
-
loadedRoutePlan.vehicles.splice(vehicleIndex, 1);
|
| 572 |
-
|
| 573 |
-
// Remove marker
|
| 574 |
-
const marker = homeLocationMarkerByIdMap.get(vehicleId);
|
| 575 |
-
if (marker) {
|
| 576 |
-
homeLocationGroup.removeLayer(marker);
|
| 577 |
-
homeLocationMarkerByIdMap.delete(vehicleId);
|
| 578 |
-
}
|
| 579 |
-
|
| 580 |
-
// Refresh display
|
| 581 |
-
await renderRoutes(loadedRoutePlan);
|
| 582 |
-
renderTimelines(loadedRoutePlan);
|
| 583 |
-
|
| 584 |
-
showNotification(`Vehicle "${vehicle.name || vehicleId}" removed.`, "info");
|
| 585 |
-
}
|
| 586 |
-
|
| 587 |
-
function showNotification(message, type = "info") {
|
| 588 |
-
const alertClass = type === "success" ? "alert-success" : type === "error" ? "alert-danger" : "alert-info";
|
| 589 |
-
const icon = type === "success" ? "fa-check-circle" : type === "error" ? "fa-exclamation-circle" : "fa-info-circle";
|
| 590 |
-
|
| 591 |
-
const notification = $(`
|
| 592 |
-
<div class="alert ${alertClass} alert-dismissible fade show" role="alert" style="min-width: 300px;">
|
| 593 |
-
<i class="fas ${icon} me-2"></i>${message}
|
| 594 |
-
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
| 595 |
-
</div>
|
| 596 |
-
`);
|
| 597 |
-
|
| 598 |
-
$("#notificationPanel").append(notification);
|
| 599 |
-
|
| 600 |
-
// Auto-dismiss after 3 seconds
|
| 601 |
-
setTimeout(() => {
|
| 602 |
-
notification.alert('close');
|
| 603 |
-
}, 3000);
|
| 604 |
-
}
|
| 605 |
-
|
| 606 |
-
/*************************************** Route Highlighting **************************************/
|
| 607 |
-
|
| 608 |
-
function toggleVehicleHighlight(vehicleId) {
|
| 609 |
-
if (highlightedVehicleId === vehicleId) {
|
| 610 |
-
// Already highlighted - clear it
|
| 611 |
-
clearRouteHighlight();
|
| 612 |
-
} else {
|
| 613 |
-
// Highlight this vehicle's route
|
| 614 |
-
highlightVehicleRoute(vehicleId);
|
| 615 |
-
}
|
| 616 |
-
}
|
| 617 |
-
|
| 618 |
-
function clearRouteHighlight() {
|
| 619 |
-
// Remove number markers
|
| 620 |
-
routeNumberMarkers.forEach(marker => map.removeLayer(marker));
|
| 621 |
-
routeNumberMarkers = [];
|
| 622 |
-
|
| 623 |
-
// Reset all vehicle icons to normal and restore opacity
|
| 624 |
-
if (loadedRoutePlan) {
|
| 625 |
-
loadedRoutePlan.vehicles.forEach(vehicle => {
|
| 626 |
-
const marker = homeLocationMarkerByIdMap.get(vehicle.id);
|
| 627 |
-
if (marker) {
|
| 628 |
-
marker.setIcon(createVehicleHomeIcon(vehicle, false));
|
| 629 |
-
marker.setOpacity(1);
|
| 630 |
-
}
|
| 631 |
-
});
|
| 632 |
-
|
| 633 |
-
// Reset all visit markers to normal and restore opacity
|
| 634 |
-
loadedRoutePlan.visits.forEach(visit => {
|
| 635 |
-
const marker = visitMarkerByIdMap.get(visit.id);
|
| 636 |
-
if (marker) {
|
| 637 |
-
const customerType = getCustomerType(visit);
|
| 638 |
-
const isAssigned = visit.vehicle != null;
|
| 639 |
-
marker.setIcon(createCustomerTypeIcon(customerType, isAssigned, false));
|
| 640 |
-
marker.setOpacity(1);
|
| 641 |
-
}
|
| 642 |
-
});
|
| 643 |
-
}
|
| 644 |
-
|
| 645 |
-
// Reset route lines
|
| 646 |
-
renderRouteLines();
|
| 647 |
-
|
| 648 |
-
// Update vehicle table highlighting
|
| 649 |
-
$("#vehicles tr").removeClass("table-active");
|
| 650 |
-
|
| 651 |
-
highlightedVehicleId = null;
|
| 652 |
-
}
|
| 653 |
-
|
| 654 |
-
function highlightVehicleRoute(vehicleId) {
|
| 655 |
-
// Clear any existing highlight first
|
| 656 |
-
clearRouteHighlight();
|
| 657 |
-
|
| 658 |
-
highlightedVehicleId = vehicleId;
|
| 659 |
-
|
| 660 |
-
if (!loadedRoutePlan) return;
|
| 661 |
-
|
| 662 |
-
const vehicle = loadedRoutePlan.vehicles.find(v => v.id === vehicleId);
|
| 663 |
-
if (!vehicle) return;
|
| 664 |
-
|
| 665 |
-
const vehicleColor = colorByVehicle(vehicle);
|
| 666 |
-
|
| 667 |
-
// Highlight the vehicle's home marker
|
| 668 |
-
const homeMarker = homeLocationMarkerByIdMap.get(vehicleId);
|
| 669 |
-
if (homeMarker) {
|
| 670 |
-
homeMarker.setIcon(createVehicleHomeIcon(vehicle, true));
|
| 671 |
-
}
|
| 672 |
-
|
| 673 |
-
// Dim other vehicles
|
| 674 |
-
loadedRoutePlan.vehicles.forEach(v => {
|
| 675 |
-
if (v.id !== vehicleId) {
|
| 676 |
-
const marker = homeLocationMarkerByIdMap.get(v.id);
|
| 677 |
-
if (marker) {
|
| 678 |
-
marker.setIcon(createVehicleHomeIcon(v, false));
|
| 679 |
-
marker.setOpacity(0.3);
|
| 680 |
-
}
|
| 681 |
-
}
|
| 682 |
-
});
|
| 683 |
-
|
| 684 |
-
// Get visit order for this vehicle
|
| 685 |
-
const visitByIdMap = new Map(loadedRoutePlan.visits.map(v => [v.id, v]));
|
| 686 |
-
const vehicleVisits = vehicle.visits.map(visitId => visitByIdMap.get(visitId)).filter(v => v);
|
| 687 |
-
|
| 688 |
-
// Highlight and number the visits on this route
|
| 689 |
-
let stopNumber = 1;
|
| 690 |
-
vehicleVisits.forEach(visit => {
|
| 691 |
-
const marker = visitMarkerByIdMap.get(visit.id);
|
| 692 |
-
if (marker) {
|
| 693 |
-
const customerType = getCustomerType(visit);
|
| 694 |
-
marker.setIcon(createCustomerTypeIcon(customerType, true, true, vehicleColor));
|
| 695 |
-
marker.setOpacity(1);
|
| 696 |
-
|
| 697 |
-
// Add number marker
|
| 698 |
-
const numberMarker = L.marker(visit.location, {
|
| 699 |
-
icon: createRouteNumberIcon(stopNumber, vehicleColor),
|
| 700 |
-
interactive: false,
|
| 701 |
-
zIndexOffset: 1000
|
| 702 |
-
});
|
| 703 |
-
numberMarker.addTo(map);
|
| 704 |
-
routeNumberMarkers.push(numberMarker);
|
| 705 |
-
stopNumber++;
|
| 706 |
-
}
|
| 707 |
-
});
|
| 708 |
-
|
| 709 |
-
// Dim visits not on this route
|
| 710 |
-
loadedRoutePlan.visits.forEach(visit => {
|
| 711 |
-
if (!vehicle.visits.includes(visit.id)) {
|
| 712 |
-
const marker = visitMarkerByIdMap.get(visit.id);
|
| 713 |
-
if (marker) {
|
| 714 |
-
marker.setOpacity(0.25);
|
| 715 |
-
}
|
| 716 |
-
}
|
| 717 |
-
});
|
| 718 |
-
|
| 719 |
-
// Highlight just this route, dim others
|
| 720 |
-
renderRouteLines(vehicleId);
|
| 721 |
-
|
| 722 |
-
// Highlight the row in the vehicle table
|
| 723 |
-
$("#vehicles tr").removeClass("table-active");
|
| 724 |
-
$(`#vehicle-row-${vehicleId}`).addClass("table-active");
|
| 725 |
-
|
| 726 |
-
// Add start marker (S) at depot
|
| 727 |
-
const startMarker = L.marker(vehicle.homeLocation, {
|
| 728 |
-
icon: createRouteNumberIcon("S", vehicleColor),
|
| 729 |
-
interactive: false,
|
| 730 |
-
zIndexOffset: 1000
|
| 731 |
-
});
|
| 732 |
-
startMarker.addTo(map);
|
| 733 |
-
routeNumberMarkers.push(startMarker);
|
| 734 |
-
}
|
| 735 |
-
|
| 736 |
-
function createRouteNumberIcon(number, color) {
|
| 737 |
-
return L.divIcon({
|
| 738 |
-
className: 'route-number-marker',
|
| 739 |
-
html: `<div style="
|
| 740 |
-
background-color: ${color};
|
| 741 |
-
color: white;
|
| 742 |
-
font-weight: bold;
|
| 743 |
-
font-size: 12px;
|
| 744 |
-
width: 22px;
|
| 745 |
-
height: 22px;
|
| 746 |
-
border-radius: 50%;
|
| 747 |
-
border: 2px solid white;
|
| 748 |
-
display: flex;
|
| 749 |
-
align-items: center;
|
| 750 |
-
justify-content: center;
|
| 751 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.4);
|
| 752 |
-
margin-left: 16px;
|
| 753 |
-
margin-top: -28px;
|
| 754 |
-
">${number}</div>`,
|
| 755 |
-
iconSize: [22, 22],
|
| 756 |
-
iconAnchor: [0, 0]
|
| 757 |
-
});
|
| 758 |
-
}
|
| 759 |
-
|
| 760 |
-
async function renderRouteLines(highlightedId = null) {
|
| 761 |
-
routeGroup.clearLayers();
|
| 762 |
-
|
| 763 |
-
if (!loadedRoutePlan) return;
|
| 764 |
-
|
| 765 |
-
// Fetch geometries during solving (routes change)
|
| 766 |
-
if (scheduleId) {
|
| 767 |
-
routeGeometries = await fetchRouteGeometries();
|
| 768 |
-
}
|
| 769 |
-
|
| 770 |
-
const visitByIdMap = new Map(loadedRoutePlan.visits.map(visit => [visit.id, visit]));
|
| 771 |
-
|
| 772 |
-
for (let vehicle of loadedRoutePlan.vehicles) {
|
| 773 |
-
const homeLocation = vehicle.homeLocation;
|
| 774 |
-
const locations = vehicle.visits.map(visitId => visitByIdMap.get(visitId)?.location).filter(l => l);
|
| 775 |
-
|
| 776 |
-
const isHighlighted = highlightedId === null || vehicle.id === highlightedId;
|
| 777 |
-
const color = colorByVehicle(vehicle);
|
| 778 |
-
const weight = isHighlighted && highlightedId !== null ? 5 : 3;
|
| 779 |
-
const opacity = isHighlighted ? 1 : 0.2;
|
| 780 |
-
|
| 781 |
-
const vehicleGeometry = routeGeometries?.[vehicle.id];
|
| 782 |
-
|
| 783 |
-
if (vehicleGeometry && vehicleGeometry.length > 0) {
|
| 784 |
-
// Draw real road routes using decoded polylines
|
| 785 |
-
for (const encodedSegment of vehicleGeometry) {
|
| 786 |
-
if (encodedSegment) {
|
| 787 |
-
const points = decodePolyline(encodedSegment);
|
| 788 |
-
if (points.length > 0) {
|
| 789 |
-
L.polyline(points, {
|
| 790 |
-
color: color,
|
| 791 |
-
weight: weight,
|
| 792 |
-
opacity: opacity
|
| 793 |
-
}).addTo(routeGroup);
|
| 794 |
-
}
|
| 795 |
-
}
|
| 796 |
-
}
|
| 797 |
-
} else if (locations.length > 0) {
|
| 798 |
-
// Fallback to straight lines if no geometry available
|
| 799 |
-
L.polyline([homeLocation, ...locations, homeLocation], {
|
| 800 |
-
color: color,
|
| 801 |
-
weight: weight,
|
| 802 |
-
opacity: opacity
|
| 803 |
-
}).addTo(routeGroup);
|
| 804 |
-
}
|
| 805 |
-
}
|
| 806 |
-
}
|
| 807 |
-
|
| 808 |
-
function colorByVehicle(vehicle) {
|
| 809 |
-
return vehicle === null ? null : pickColor("vehicle" + vehicle.id);
|
| 810 |
-
}
|
| 811 |
-
|
| 812 |
-
// Customer type definitions matching demo_data.py
|
| 813 |
-
const CUSTOMER_TYPES = {
|
| 814 |
-
RESTAURANT: { label: "Restaurant", icon: "fa-utensils", color: "#f59e0b", windowStart: "06:00", windowEnd: "10:00", minService: 20, maxService: 40 },
|
| 815 |
-
BUSINESS: { label: "Business", icon: "fa-building", color: "#3b82f6", windowStart: "09:00", windowEnd: "17:00", minService: 15, maxService: 30 },
|
| 816 |
-
RESIDENTIAL: { label: "Residential", icon: "fa-home", color: "#10b981", windowStart: "17:00", windowEnd: "20:00", minService: 5, maxService: 10 },
|
| 817 |
-
};
|
| 818 |
-
|
| 819 |
-
function getCustomerType(visit) {
|
| 820 |
-
const startTime = showTimeOnly(visit.minStartTime).toString();
|
| 821 |
-
const endTime = showTimeOnly(visit.maxEndTime).toString();
|
| 822 |
-
|
| 823 |
-
for (const [type, config] of Object.entries(CUSTOMER_TYPES)) {
|
| 824 |
-
if (startTime === config.windowStart && endTime === config.windowEnd) {
|
| 825 |
-
return { type, ...config };
|
| 826 |
-
}
|
| 827 |
-
}
|
| 828 |
-
return { type: "UNKNOWN", label: "Custom", icon: "fa-question", color: "#6b7280", windowStart: startTime, windowEnd: endTime };
|
| 829 |
-
}
|
| 830 |
-
|
| 831 |
-
function formatDrivingTime(drivingTimeInSeconds) {
|
| 832 |
-
return `${Math.floor(drivingTimeInSeconds / 3600)}h ${Math.round((drivingTimeInSeconds % 3600) / 60)}m`;
|
| 833 |
-
}
|
| 834 |
-
|
| 835 |
-
function homeLocationPopupContent(vehicle) {
|
| 836 |
-
const color = colorByVehicle(vehicle);
|
| 837 |
-
const visitCount = vehicle.visits ? vehicle.visits.length : 0;
|
| 838 |
-
const vehicleName = vehicle.name || `Vehicle ${vehicle.id}`;
|
| 839 |
-
return `<div style="min-width: 150px;">
|
| 840 |
-
<h5 style="color: ${color};"><i class="fas fa-truck"></i> ${vehicleName}</h5>
|
| 841 |
-
<p class="mb-1"><strong>Depot Location</strong></p>
|
| 842 |
-
<p class="mb-1"><i class="fas fa-box"></i> Capacity: ${vehicle.capacity}</p>
|
| 843 |
-
<p class="mb-1"><i class="fas fa-route"></i> Visits: ${visitCount}</p>
|
| 844 |
-
<p class="mb-0"><i class="fas fa-clock"></i> Departs: ${showTimeOnly(vehicle.departureTime)}</p>
|
| 845 |
-
</div>`;
|
| 846 |
-
}
|
| 847 |
-
|
| 848 |
-
function visitPopupContent(visit) {
|
| 849 |
-
const customerType = getCustomerType(visit);
|
| 850 |
-
const serviceDurationMinutes = Math.round(visit.serviceDuration / 60);
|
| 851 |
-
const arrival = visit.arrivalTime
|
| 852 |
-
? `<h6>Arrival at ${showTimeOnly(visit.arrivalTime)}.</h6>`
|
| 853 |
-
: "";
|
| 854 |
-
return `<h5><i class="fas ${customerType.icon}" style="color: ${customerType.color}"></i> ${visit.name}</h5>
|
| 855 |
-
<h6><span class="badge" style="background-color: ${customerType.color}">${customerType.label}</span></h6>
|
| 856 |
-
<h6>Cargo: ${visit.demand} units</h6>
|
| 857 |
-
<h6>Service time: ${serviceDurationMinutes} min</h6>
|
| 858 |
-
<h6>Window: ${showTimeOnly(visit.minStartTime)} - ${showTimeOnly(visit.maxEndTime)}</h6>
|
| 859 |
-
${arrival}`;
|
| 860 |
-
}
|
| 861 |
-
|
| 862 |
-
function showTimeOnly(localDateTimeString) {
|
| 863 |
-
return JSJoda.LocalDateTime.parse(localDateTimeString).toLocalTime();
|
| 864 |
-
}
|
| 865 |
-
|
| 866 |
-
function createVehicleHomeIcon(vehicle, isHighlighted = false) {
|
| 867 |
-
const color = colorByVehicle(vehicle);
|
| 868 |
-
const size = isHighlighted ? 36 : 28;
|
| 869 |
-
const fontSize = isHighlighted ? 14 : 11;
|
| 870 |
-
const borderWidth = isHighlighted ? 4 : 3;
|
| 871 |
-
const shadow = isHighlighted
|
| 872 |
-
? `0 0 0 4px ${color}40, 0 4px 8px rgba(0,0,0,0.5)`
|
| 873 |
-
: '0 2px 4px rgba(0,0,0,0.4)';
|
| 874 |
-
|
| 875 |
-
return L.divIcon({
|
| 876 |
-
className: 'vehicle-home-marker',
|
| 877 |
-
html: `<div style="
|
| 878 |
-
background-color: ${color};
|
| 879 |
-
border: ${borderWidth}px solid white;
|
| 880 |
-
border-radius: 50%;
|
| 881 |
-
width: ${size}px;
|
| 882 |
-
height: ${size}px;
|
| 883 |
-
display: flex;
|
| 884 |
-
align-items: center;
|
| 885 |
-
justify-content: center;
|
| 886 |
-
box-shadow: ${shadow};
|
| 887 |
-
transition: all 0.2s ease;
|
| 888 |
-
"><i class="fas fa-truck" style="color: white; font-size: ${fontSize}px;"></i></div>`,
|
| 889 |
-
iconSize: [size, size],
|
| 890 |
-
iconAnchor: [size/2, size/2],
|
| 891 |
-
popupAnchor: [0, -size/2]
|
| 892 |
-
});
|
| 893 |
-
}
|
| 894 |
-
|
| 895 |
-
function getHomeLocationMarker(vehicle) {
|
| 896 |
-
let marker = homeLocationMarkerByIdMap.get(vehicle.id);
|
| 897 |
-
if (marker) {
|
| 898 |
-
marker.setIcon(createVehicleHomeIcon(vehicle));
|
| 899 |
-
return marker;
|
| 900 |
-
}
|
| 901 |
-
marker = L.marker(vehicle.homeLocation, {
|
| 902 |
-
icon: createVehicleHomeIcon(vehicle)
|
| 903 |
-
});
|
| 904 |
-
marker.addTo(homeLocationGroup).bindPopup();
|
| 905 |
-
homeLocationMarkerByIdMap.set(vehicle.id, marker);
|
| 906 |
-
return marker;
|
| 907 |
-
}
|
| 908 |
-
|
| 909 |
-
function createCustomerTypeIcon(customerType, isAssigned = false, isHighlighted = false, highlightColor = null) {
|
| 910 |
-
const borderColor = isHighlighted && highlightColor
|
| 911 |
-
? highlightColor
|
| 912 |
-
: (isAssigned ? customerType.color : '#6b7280');
|
| 913 |
-
const size = isHighlighted ? 38 : 32;
|
| 914 |
-
const fontSize = isHighlighted ? 16 : 14;
|
| 915 |
-
const borderWidth = isHighlighted ? 4 : 3;
|
| 916 |
-
const shadow = isHighlighted
|
| 917 |
-
? `0 0 0 4px ${highlightColor}40, 0 4px 8px rgba(0,0,0,0.4)`
|
| 918 |
-
: '0 2px 4px rgba(0,0,0,0.3)';
|
| 919 |
-
|
| 920 |
-
return L.divIcon({
|
| 921 |
-
className: 'customer-marker',
|
| 922 |
-
html: `<div style="
|
| 923 |
-
background-color: white;
|
| 924 |
-
border: ${borderWidth}px solid ${borderColor};
|
| 925 |
-
border-radius: 50%;
|
| 926 |
-
width: ${size}px;
|
| 927 |
-
height: ${size}px;
|
| 928 |
-
display: flex;
|
| 929 |
-
align-items: center;
|
| 930 |
-
justify-content: center;
|
| 931 |
-
box-shadow: ${shadow};
|
| 932 |
-
transition: all 0.2s ease;
|
| 933 |
-
"><i class="fas ${customerType.icon}" style="color: ${customerType.color}; font-size: ${fontSize}px;"></i></div>`,
|
| 934 |
-
iconSize: [size, size],
|
| 935 |
-
iconAnchor: [size/2, size/2],
|
| 936 |
-
popupAnchor: [0, -size/2]
|
| 937 |
-
});
|
| 938 |
-
}
|
| 939 |
-
|
| 940 |
-
function getVisitMarker(visit) {
|
| 941 |
-
let marker = visitMarkerByIdMap.get(visit.id);
|
| 942 |
-
const customerType = getCustomerType(visit);
|
| 943 |
-
const isAssigned = visit.vehicle != null;
|
| 944 |
-
|
| 945 |
-
if (marker) {
|
| 946 |
-
// Update icon if assignment status changed
|
| 947 |
-
marker.setIcon(createCustomerTypeIcon(customerType, isAssigned));
|
| 948 |
-
return marker;
|
| 949 |
-
}
|
| 950 |
-
|
| 951 |
-
marker = L.marker(visit.location, {
|
| 952 |
-
icon: createCustomerTypeIcon(customerType, isAssigned)
|
| 953 |
-
});
|
| 954 |
-
marker.addTo(visitGroup).bindPopup();
|
| 955 |
-
visitMarkerByIdMap.set(visit.id, marker);
|
| 956 |
-
return marker;
|
| 957 |
-
}
|
| 958 |
-
|
| 959 |
-
async function renderRoutes(solution) {
|
| 960 |
-
if (!initialized) {
|
| 961 |
-
const bounds = [solution.southWestCorner, solution.northEastCorner];
|
| 962 |
-
map.fitBounds(bounds);
|
| 963 |
-
}
|
| 964 |
-
// Vehicles
|
| 965 |
-
vehiclesTable.children().remove();
|
| 966 |
-
const canRemove = solution.vehicles.length > 1;
|
| 967 |
-
solution.vehicles.forEach(function (vehicle) {
|
| 968 |
-
getHomeLocationMarker(vehicle).setPopupContent(
|
| 969 |
-
homeLocationPopupContent(vehicle),
|
| 970 |
-
);
|
| 971 |
-
const { id, capacity, totalDemand, totalDrivingTimeSeconds } = vehicle;
|
| 972 |
-
const percentage = Math.min((totalDemand / capacity) * 100, 100);
|
| 973 |
-
const overCapacity = totalDemand > capacity;
|
| 974 |
-
const color = colorByVehicle(vehicle);
|
| 975 |
-
const progressBarColor = overCapacity ? 'bg-danger' : '';
|
| 976 |
-
const isHighlighted = highlightedVehicleId === id;
|
| 977 |
-
const visitCount = vehicle.visits ? vehicle.visits.length : 0;
|
| 978 |
-
const vehicleName = vehicle.name || `Vehicle ${id}`;
|
| 979 |
-
|
| 980 |
-
vehiclesTable.append(`
|
| 981 |
-
<tr id="vehicle-row-${id}" class="vehicle-row ${isHighlighted ? 'table-active' : ''}" style="cursor: pointer;">
|
| 982 |
-
<td onclick="toggleVehicleHighlight('${id}')">
|
| 983 |
-
<div style="background-color: ${color}; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; ${isHighlighted ? 'box-shadow: 0 0 0 3px ' + color + '40;' : ''}">
|
| 984 |
-
<i class="fas fa-truck" style="color: white; font-size: 0.65rem;"></i>
|
| 985 |
-
</div>
|
| 986 |
-
</td>
|
| 987 |
-
<td onclick="toggleVehicleHighlight('${id}')">
|
| 988 |
-
<strong>${vehicleName}</strong>
|
| 989 |
-
<br><small class="text-muted">${visitCount} stops</small>
|
| 990 |
-
</td>
|
| 991 |
-
<td onclick="toggleVehicleHighlight('${id}')">
|
| 992 |
-
<div class="progress" style="height: 18px;" data-bs-toggle="tooltip" data-bs-placement="left"
|
| 993 |
-
title="Cargo: ${totalDemand} / Capacity: ${capacity}${overCapacity ? ' (OVER CAPACITY!)' : ''}">
|
| 994 |
-
<div class="progress-bar ${progressBarColor}" role="progressbar" style="width: ${percentage}%; font-size: 0.7rem; transition: width 0.3s ease;">
|
| 995 |
-
${totalDemand}/${capacity}
|
| 996 |
-
</div>
|
| 997 |
-
</div>
|
| 998 |
-
</td>
|
| 999 |
-
<td onclick="toggleVehicleHighlight('${id}')" style="font-size: 0.85rem;">
|
| 1000 |
-
${formatDrivingTime(totalDrivingTimeSeconds)}
|
| 1001 |
-
</td>
|
| 1002 |
-
<td>
|
| 1003 |
-
${canRemove ? `<button class="btn btn-sm btn-outline-danger p-0 px-1" onclick="event.stopPropagation(); removeVehicle('${id}')" title="Remove vehicle ${vehicleName}">
|
| 1004 |
-
<i class="fas fa-times" style="font-size: 0.7rem;"></i>
|
| 1005 |
-
</button>` : ''}
|
| 1006 |
-
</td>
|
| 1007 |
-
</tr>`);
|
| 1008 |
-
});
|
| 1009 |
-
// Visits
|
| 1010 |
-
solution.visits.forEach(function (visit) {
|
| 1011 |
-
getVisitMarker(visit).setPopupContent(visitPopupContent(visit));
|
| 1012 |
-
});
|
| 1013 |
-
// Route - use the dedicated function which handles highlighting (await to ensure geometries load)
|
| 1014 |
-
await renderRouteLines(highlightedVehicleId);
|
| 1015 |
-
|
| 1016 |
-
// Summary
|
| 1017 |
-
$("#score").text(solution.score ? `Score: ${solution.score}` : "Score: ?");
|
| 1018 |
-
$("#drivingTime").text(formatDrivingTime(solution.totalDrivingTimeSeconds));
|
| 1019 |
-
}
|
| 1020 |
-
|
| 1021 |
-
function renderTimelines(routePlan) {
|
| 1022 |
-
byVehicleGroupData.clear();
|
| 1023 |
-
byVisitGroupData.clear();
|
| 1024 |
-
byVehicleItemData.clear();
|
| 1025 |
-
byVisitItemData.clear();
|
| 1026 |
-
|
| 1027 |
-
// Build lookup maps for O(1) access
|
| 1028 |
-
const vehicleById = new Map(routePlan.vehicles.map(v => [v.id, v]));
|
| 1029 |
-
const visitById = new Map(routePlan.visits.map(v => [v.id, v]));
|
| 1030 |
-
const visitOrderMap = new Map();
|
| 1031 |
-
|
| 1032 |
-
// Build stop order for each visit
|
| 1033 |
-
routePlan.vehicles.forEach(vehicle => {
|
| 1034 |
-
vehicle.visits.forEach((visitId, index) => {
|
| 1035 |
-
visitOrderMap.set(visitId, index + 1);
|
| 1036 |
-
});
|
| 1037 |
-
});
|
| 1038 |
-
|
| 1039 |
-
// Vehicle groups with names and status summary
|
| 1040 |
-
$.each(routePlan.vehicles, function (index, vehicle) {
|
| 1041 |
-
const vehicleName = vehicle.name || `Vehicle ${vehicle.id}`;
|
| 1042 |
-
const { totalDemand, capacity } = vehicle;
|
| 1043 |
-
const percentage = Math.min((totalDemand / capacity) * 100, 100);
|
| 1044 |
-
const overCapacity = totalDemand > capacity;
|
| 1045 |
-
|
| 1046 |
-
// Count late visits for this vehicle
|
| 1047 |
-
const vehicleVisits = vehicle.visits.map(id => visitById.get(id)).filter(v => v);
|
| 1048 |
-
const lateCount = vehicleVisits.filter(v => {
|
| 1049 |
-
if (!v.departureTime) return false;
|
| 1050 |
-
const departure = JSJoda.LocalDateTime.parse(v.departureTime);
|
| 1051 |
-
const maxEnd = JSJoda.LocalDateTime.parse(v.maxEndTime);
|
| 1052 |
-
return departure.isAfter(maxEnd);
|
| 1053 |
-
}).length;
|
| 1054 |
-
|
| 1055 |
-
const statusIcon = lateCount > 0
|
| 1056 |
-
? `<i class="fas fa-exclamation-triangle timeline-status-late timeline-status-icon" title="${lateCount} late"></i>`
|
| 1057 |
-
: vehicle.visits.length > 0
|
| 1058 |
-
? `<i class="fas fa-check-circle timeline-status-ontime timeline-status-icon" title="All on-time"></i>`
|
| 1059 |
-
: '';
|
| 1060 |
-
|
| 1061 |
-
const progressBarClass = overCapacity ? 'bg-danger' : '';
|
| 1062 |
-
|
| 1063 |
-
const vehicleWithLoad = `
|
| 1064 |
-
<h5 class="card-title mb-1">${vehicleName}${statusIcon}</h5>
|
| 1065 |
-
<div class="progress" style="height: 16px;" title="Cargo: ${totalDemand} / ${capacity}">
|
| 1066 |
-
<div class="progress-bar ${progressBarClass}" role="progressbar" style="width: ${percentage}%">
|
| 1067 |
-
${totalDemand}/${capacity}
|
| 1068 |
-
</div>
|
| 1069 |
-
</div>`;
|
| 1070 |
-
byVehicleGroupData.add({ id: vehicle.id, content: vehicleWithLoad });
|
| 1071 |
-
});
|
| 1072 |
-
|
| 1073 |
-
$.each(routePlan.visits, function (index, visit) {
|
| 1074 |
-
const minStartTime = JSJoda.LocalDateTime.parse(visit.minStartTime);
|
| 1075 |
-
const maxEndTime = JSJoda.LocalDateTime.parse(visit.maxEndTime);
|
| 1076 |
-
const serviceDuration = JSJoda.Duration.ofSeconds(visit.serviceDuration);
|
| 1077 |
-
const customerType = getCustomerType(visit);
|
| 1078 |
-
const stopNumber = visitOrderMap.get(visit.id);
|
| 1079 |
-
|
| 1080 |
-
const visitGroupElement = $(`<div/>`).append(
|
| 1081 |
-
$(`<h5 class="card-title mb-1"/>`).html(
|
| 1082 |
-
`<i class="fas ${customerType.icon}" style="color: ${customerType.color}"></i> ${visit.name}`
|
| 1083 |
-
),
|
| 1084 |
-
).append(
|
| 1085 |
-
$(`<small class="text-muted"/>`).text(customerType.label)
|
| 1086 |
-
);
|
| 1087 |
-
byVisitGroupData.add({
|
| 1088 |
-
id: visit.id,
|
| 1089 |
-
content: visitGroupElement.html(),
|
| 1090 |
-
});
|
| 1091 |
-
|
| 1092 |
-
// Time window per visit.
|
| 1093 |
-
byVisitItemData.add({
|
| 1094 |
-
id: visit.id + "_readyToDue",
|
| 1095 |
-
group: visit.id,
|
| 1096 |
-
start: visit.minStartTime,
|
| 1097 |
-
end: visit.maxEndTime,
|
| 1098 |
-
type: "background",
|
| 1099 |
-
style: "background-color: #8AE23433",
|
| 1100 |
-
});
|
| 1101 |
-
|
| 1102 |
-
if (visit.vehicle == null) {
|
| 1103 |
-
const byJobJobElement = $(`<div/>`).append(
|
| 1104 |
-
$(`<span/>`).html(`<i class="fas fa-exclamation-circle text-danger me-1"></i>Unassigned`),
|
| 1105 |
-
);
|
| 1106 |
-
|
| 1107 |
-
// Unassigned are shown at the beginning of the visit's time window; the length is the service duration.
|
| 1108 |
-
byVisitItemData.add({
|
| 1109 |
-
id: visit.id + "_unassigned",
|
| 1110 |
-
group: visit.id,
|
| 1111 |
-
content: byJobJobElement.html(),
|
| 1112 |
-
start: minStartTime.toString(),
|
| 1113 |
-
end: minStartTime.plus(serviceDuration).toString(),
|
| 1114 |
-
style: "background-color: #EF292999",
|
| 1115 |
-
});
|
| 1116 |
-
} else {
|
| 1117 |
-
const arrivalTime = JSJoda.LocalDateTime.parse(visit.arrivalTime);
|
| 1118 |
-
const beforeReady = arrivalTime.isBefore(minStartTime);
|
| 1119 |
-
const departureTime = JSJoda.LocalDateTime.parse(visit.departureTime);
|
| 1120 |
-
const afterDue = departureTime.isAfter(maxEndTime);
|
| 1121 |
-
|
| 1122 |
-
// Get vehicle info for display
|
| 1123 |
-
const vehicleInfo = vehicleById.get(visit.vehicle);
|
| 1124 |
-
const vehicleName = vehicleInfo ? (vehicleInfo.name || `Vehicle ${visit.vehicle}`) : `Vehicle ${visit.vehicle}`;
|
| 1125 |
-
|
| 1126 |
-
// Stop badge for service segment
|
| 1127 |
-
const stopBadge = stopNumber ? `<span class="timeline-stop-badge">${stopNumber}</span>` : '';
|
| 1128 |
-
|
| 1129 |
-
// Status icon based on timing
|
| 1130 |
-
const statusIcon = afterDue
|
| 1131 |
-
? `<i class="fas fa-exclamation-triangle timeline-status-late timeline-status-icon" title="Late"></i>`
|
| 1132 |
-
: `<i class="fas fa-check timeline-status-ontime timeline-status-icon" title="On-time"></i>`;
|
| 1133 |
-
|
| 1134 |
-
const byVehicleElement = $(`<div/>`)
|
| 1135 |
-
.append($(`<span/>`).html(
|
| 1136 |
-
`${stopBadge}<i class="fas ${customerType.icon}" style="color: ${customerType.color}"></i> ${visit.name}${statusIcon}`
|
| 1137 |
-
));
|
| 1138 |
-
|
| 1139 |
-
const byVisitElement = $(`<div/>`)
|
| 1140 |
-
.append(
|
| 1141 |
-
$(`<span/>`).html(
|
| 1142 |
-
`${stopBadge}${vehicleName}${statusIcon}`
|
| 1143 |
-
),
|
| 1144 |
-
);
|
| 1145 |
-
|
| 1146 |
-
const byVehicleTravelElement = $(`<div/>`).append(
|
| 1147 |
-
$(`<span/>`).html(`<i class="fas fa-route text-warning me-1"></i>Travel`),
|
| 1148 |
-
);
|
| 1149 |
-
|
| 1150 |
-
const previousDeparture = arrivalTime.minusSeconds(
|
| 1151 |
-
visit.drivingTimeSecondsFromPreviousStandstill,
|
| 1152 |
-
);
|
| 1153 |
-
byVehicleItemData.add({
|
| 1154 |
-
id: visit.id + "_travel",
|
| 1155 |
-
group: visit.vehicle,
|
| 1156 |
-
subgroup: visit.vehicle,
|
| 1157 |
-
content: byVehicleTravelElement.html(),
|
| 1158 |
-
start: previousDeparture.toString(),
|
| 1159 |
-
end: visit.arrivalTime,
|
| 1160 |
-
style: "background-color: #f7dd8f90",
|
| 1161 |
-
});
|
| 1162 |
-
|
| 1163 |
-
if (beforeReady) {
|
| 1164 |
-
const byVehicleWaitElement = $(`<div/>`).append(
|
| 1165 |
-
$(`<span/>`).html(`<i class="fas fa-clock timeline-status-early me-1"></i>Wait`),
|
| 1166 |
-
);
|
| 1167 |
-
|
| 1168 |
-
byVehicleItemData.add({
|
| 1169 |
-
id: visit.id + "_wait",
|
| 1170 |
-
group: visit.vehicle,
|
| 1171 |
-
subgroup: visit.vehicle,
|
| 1172 |
-
content: byVehicleWaitElement.html(),
|
| 1173 |
-
start: visit.arrivalTime,
|
| 1174 |
-
end: visit.minStartTime,
|
| 1175 |
-
style: "background-color: #93c5fd80",
|
| 1176 |
-
});
|
| 1177 |
-
}
|
| 1178 |
-
|
| 1179 |
-
let serviceElementBackground = afterDue ? "#EF292999" : "#83C15955";
|
| 1180 |
-
|
| 1181 |
-
byVehicleItemData.add({
|
| 1182 |
-
id: visit.id + "_service",
|
| 1183 |
-
group: visit.vehicle,
|
| 1184 |
-
subgroup: visit.vehicle,
|
| 1185 |
-
content: byVehicleElement.html(),
|
| 1186 |
-
start: visit.startServiceTime,
|
| 1187 |
-
end: visit.departureTime,
|
| 1188 |
-
style: "background-color: " + serviceElementBackground,
|
| 1189 |
-
});
|
| 1190 |
-
byVisitItemData.add({
|
| 1191 |
-
id: visit.id,
|
| 1192 |
-
group: visit.id,
|
| 1193 |
-
content: byVisitElement.html(),
|
| 1194 |
-
start: visit.startServiceTime,
|
| 1195 |
-
end: visit.departureTime,
|
| 1196 |
-
style: "background-color: " + serviceElementBackground,
|
| 1197 |
-
});
|
| 1198 |
-
}
|
| 1199 |
-
});
|
| 1200 |
-
|
| 1201 |
-
$.each(routePlan.vehicles, function (index, vehicle) {
|
| 1202 |
-
if (vehicle.visits.length > 0) {
|
| 1203 |
-
let lastVisit = routePlan.visits
|
| 1204 |
-
.filter(
|
| 1205 |
-
(visit) => visit.id == vehicle.visits[vehicle.visits.length - 1],
|
| 1206 |
-
)
|
| 1207 |
-
.pop();
|
| 1208 |
-
if (lastVisit) {
|
| 1209 |
-
byVehicleItemData.add({
|
| 1210 |
-
id: vehicle.id + "_travelBackToHomeLocation",
|
| 1211 |
-
group: vehicle.id,
|
| 1212 |
-
subgroup: vehicle.id,
|
| 1213 |
-
content: $(`<div/>`)
|
| 1214 |
-
.append($(`<span/>`).html(`<i class="fas fa-home text-secondary me-1"></i>Return`))
|
| 1215 |
-
.html(),
|
| 1216 |
-
start: lastVisit.departureTime,
|
| 1217 |
-
end: vehicle.arrivalTime,
|
| 1218 |
-
style: "background-color: #f7dd8f90",
|
| 1219 |
-
});
|
| 1220 |
-
}
|
| 1221 |
-
}
|
| 1222 |
-
});
|
| 1223 |
-
|
| 1224 |
-
if (!initialized) {
|
| 1225 |
-
if (byVehicleTimeline) {
|
| 1226 |
-
byVehicleTimeline.setWindow(
|
| 1227 |
-
routePlan.startDateTime,
|
| 1228 |
-
routePlan.endDateTime,
|
| 1229 |
-
);
|
| 1230 |
-
}
|
| 1231 |
-
if (byVisitTimeline) {
|
| 1232 |
-
byVisitTimeline.setWindow(routePlan.startDateTime, routePlan.endDateTime);
|
| 1233 |
-
}
|
| 1234 |
-
}
|
| 1235 |
-
}
|
| 1236 |
-
|
| 1237 |
-
function analyze() {
|
| 1238 |
-
// see score-analysis.js
|
| 1239 |
-
analyzeScore(loadedRoutePlan, "/route-plans/analyze");
|
| 1240 |
-
}
|
| 1241 |
-
|
| 1242 |
-
function openRecommendationModal(lat, lng) {
|
| 1243 |
-
if (!('score' in loadedRoutePlan) || optimizing) {
|
| 1244 |
-
map.removeLayer(visitMarker);
|
| 1245 |
-
visitMarker = null;
|
| 1246 |
-
let message = "Please click the Solve button before adding new visits.";
|
| 1247 |
-
if (optimizing) {
|
| 1248 |
-
message = "Please wait for the solving process to finish.";
|
| 1249 |
-
}
|
| 1250 |
-
alert(message);
|
| 1251 |
-
return;
|
| 1252 |
-
}
|
| 1253 |
-
// see recommended-fit.js
|
| 1254 |
-
const visitId = Math.max(...loadedRoutePlan.visits.map(c => parseInt(c.id))) + 1;
|
| 1255 |
-
newVisit = {id: visitId, location: [lat, lng]};
|
| 1256 |
-
addNewVisit(visitId, lat, lng, map, visitMarker);
|
| 1257 |
-
}
|
| 1258 |
-
|
| 1259 |
-
function getRecommendationsModal() {
|
| 1260 |
-
let formValid = true;
|
| 1261 |
-
formValid = validateFormField(newVisit, 'name', '#inputName') && formValid;
|
| 1262 |
-
formValid = validateFormField(newVisit, 'demand', '#inputDemand') && formValid;
|
| 1263 |
-
formValid = validateFormField(newVisit, 'minStartTime', '#inputMinStartTime') && formValid;
|
| 1264 |
-
formValid = validateFormField(newVisit, 'maxEndTime', '#inputMaxStartTime') && formValid;
|
| 1265 |
-
formValid = validateFormField(newVisit, 'serviceDuration', '#inputDuration') && formValid;
|
| 1266 |
-
|
| 1267 |
-
if (formValid) {
|
| 1268 |
-
const updatedMinStartTime = JSJoda.LocalDateTime.parse(
|
| 1269 |
-
newVisit['minStartTime'],
|
| 1270 |
-
JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm')
|
| 1271 |
-
).format(JSJoda.DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 1272 |
-
|
| 1273 |
-
const updatedMaxEndTime = JSJoda.LocalDateTime.parse(
|
| 1274 |
-
newVisit['maxEndTime'],
|
| 1275 |
-
JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm')
|
| 1276 |
-
).format(JSJoda.DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 1277 |
-
|
| 1278 |
-
const updatedVisit = {
|
| 1279 |
-
...newVisit,
|
| 1280 |
-
serviceDuration: parseInt(newVisit['serviceDuration']) * 60, // Convert minutes to seconds
|
| 1281 |
-
minStartTime: updatedMinStartTime,
|
| 1282 |
-
maxEndTime: updatedMaxEndTime
|
| 1283 |
-
};
|
| 1284 |
-
|
| 1285 |
-
let updatedVisitList = [...loadedRoutePlan['visits']];
|
| 1286 |
-
updatedVisitList.push(updatedVisit);
|
| 1287 |
-
let updatedSolution = {...loadedRoutePlan, visits: updatedVisitList};
|
| 1288 |
-
|
| 1289 |
-
// see recommended-fit.js
|
| 1290 |
-
requestRecommendations(updatedVisit.id, updatedSolution, "/route-plans/recommendation");
|
| 1291 |
-
}
|
| 1292 |
-
}
|
| 1293 |
-
|
| 1294 |
-
function validateFormField(target, fieldName, inputName) {
|
| 1295 |
-
target[fieldName] = $(inputName).val();
|
| 1296 |
-
if ($(inputName).val() == "") {
|
| 1297 |
-
$(inputName).addClass("is-invalid");
|
| 1298 |
-
} else {
|
| 1299 |
-
$(inputName).removeClass("is-invalid");
|
| 1300 |
-
}
|
| 1301 |
-
return $(inputName).val() != "";
|
| 1302 |
-
}
|
| 1303 |
-
|
| 1304 |
-
function applyRecommendationModal(recommendations) {
|
| 1305 |
-
let checkedRecommendation = null;
|
| 1306 |
-
recommendations.forEach((recommendation, index) => {
|
| 1307 |
-
if ($('#option' + index).is(":checked")) {
|
| 1308 |
-
checkedRecommendation = recommendations[index];
|
| 1309 |
-
}
|
| 1310 |
-
});
|
| 1311 |
-
|
| 1312 |
-
if (!checkedRecommendation) {
|
| 1313 |
-
alert("Please select a recommendation.");
|
| 1314 |
-
return;
|
| 1315 |
-
}
|
| 1316 |
-
|
| 1317 |
-
const updatedMinStartTime = JSJoda.LocalDateTime.parse(
|
| 1318 |
-
newVisit['minStartTime'],
|
| 1319 |
-
JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm')
|
| 1320 |
-
).format(JSJoda.DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 1321 |
-
|
| 1322 |
-
const updatedMaxEndTime = JSJoda.LocalDateTime.parse(
|
| 1323 |
-
newVisit['maxEndTime'],
|
| 1324 |
-
JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm')
|
| 1325 |
-
).format(JSJoda.DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 1326 |
-
|
| 1327 |
-
const updatedVisit = {
|
| 1328 |
-
...newVisit,
|
| 1329 |
-
serviceDuration: parseInt(newVisit['serviceDuration']) * 60, // Convert minutes to seconds
|
| 1330 |
-
minStartTime: updatedMinStartTime,
|
| 1331 |
-
maxEndTime: updatedMaxEndTime
|
| 1332 |
-
};
|
| 1333 |
-
|
| 1334 |
-
let updatedVisitList = [...loadedRoutePlan['visits']];
|
| 1335 |
-
updatedVisitList.push(updatedVisit);
|
| 1336 |
-
let updatedSolution = {...loadedRoutePlan, visits: updatedVisitList};
|
| 1337 |
-
|
| 1338 |
-
// see recommended-fit.js
|
| 1339 |
-
applyRecommendation(
|
| 1340 |
-
updatedSolution,
|
| 1341 |
-
newVisit.id,
|
| 1342 |
-
checkedRecommendation.proposition.vehicleId,
|
| 1343 |
-
checkedRecommendation.proposition.index,
|
| 1344 |
-
"/route-plans/recommendation/apply"
|
| 1345 |
-
);
|
| 1346 |
-
}
|
| 1347 |
-
|
| 1348 |
-
async function updateSolutionWithNewVisit(newSolution) {
|
| 1349 |
-
loadedRoutePlan = newSolution;
|
| 1350 |
-
await renderRoutes(newSolution);
|
| 1351 |
-
renderTimelines(newSolution);
|
| 1352 |
-
$('#newVisitModal').modal('hide');
|
| 1353 |
-
}
|
| 1354 |
-
|
| 1355 |
-
// TODO: move the general functionality to the webjar.
|
| 1356 |
-
|
| 1357 |
-
function setupAjax() {
|
| 1358 |
-
$.ajaxSetup({
|
| 1359 |
-
headers: {
|
| 1360 |
-
"Content-Type": "application/json",
|
| 1361 |
-
Accept: "application/json,text/plain", // plain text is required by solve() returning UUID of the solver job
|
| 1362 |
-
},
|
| 1363 |
-
});
|
| 1364 |
-
|
| 1365 |
-
// Extend jQuery to support $.put() and $.delete()
|
| 1366 |
-
jQuery.each(["put", "delete"], function (i, method) {
|
| 1367 |
-
jQuery[method] = function (url, data, callback, type) {
|
| 1368 |
-
if (jQuery.isFunction(data)) {
|
| 1369 |
-
type = type || callback;
|
| 1370 |
-
callback = data;
|
| 1371 |
-
data = undefined;
|
| 1372 |
-
}
|
| 1373 |
-
return jQuery.ajax({
|
| 1374 |
-
url: url,
|
| 1375 |
-
type: method,
|
| 1376 |
-
dataType: type,
|
| 1377 |
-
data: data,
|
| 1378 |
-
success: callback,
|
| 1379 |
-
});
|
| 1380 |
-
};
|
| 1381 |
-
});
|
| 1382 |
-
}
|
| 1383 |
-
|
| 1384 |
-
function solve() {
|
| 1385 |
-
// Clear geometry cache - will be refreshed when solution updates
|
| 1386 |
-
routeGeometries = null;
|
| 1387 |
-
|
| 1388 |
-
$.ajax({
|
| 1389 |
-
url: "/route-plans",
|
| 1390 |
-
type: "POST",
|
| 1391 |
-
data: JSON.stringify(loadedRoutePlan),
|
| 1392 |
-
contentType: "application/json",
|
| 1393 |
-
dataType: "text",
|
| 1394 |
-
success: function (data) {
|
| 1395 |
-
scheduleId = data.replace(/"/g, ""); // Remove quotes from UUID
|
| 1396 |
-
refreshSolvingButtons(true);
|
| 1397 |
-
},
|
| 1398 |
-
error: function (xhr, ajaxOptions, thrownError) {
|
| 1399 |
-
showError("Start solving failed.", xhr);
|
| 1400 |
-
refreshSolvingButtons(false);
|
| 1401 |
-
},
|
| 1402 |
-
});
|
| 1403 |
-
}
|
| 1404 |
-
|
| 1405 |
-
function refreshSolvingButtons(solving) {
|
| 1406 |
-
optimizing = solving;
|
| 1407 |
-
if (solving) {
|
| 1408 |
-
$("#solveButton").hide();
|
| 1409 |
-
$("#visitButton").hide();
|
| 1410 |
-
$("#stopSolvingButton").show();
|
| 1411 |
-
$("#solvingSpinner").addClass("active");
|
| 1412 |
-
$("#mapHint").addClass("hidden");
|
| 1413 |
-
if (autoRefreshIntervalId == null) {
|
| 1414 |
-
autoRefreshIntervalId = setInterval(refreshRoutePlan, 2000);
|
| 1415 |
-
}
|
| 1416 |
-
} else {
|
| 1417 |
-
$("#solveButton").show();
|
| 1418 |
-
$("#visitButton").show();
|
| 1419 |
-
$("#stopSolvingButton").hide();
|
| 1420 |
-
$("#solvingSpinner").removeClass("active");
|
| 1421 |
-
$("#mapHint").removeClass("hidden");
|
| 1422 |
-
if (autoRefreshIntervalId != null) {
|
| 1423 |
-
clearInterval(autoRefreshIntervalId);
|
| 1424 |
-
autoRefreshIntervalId = null;
|
| 1425 |
-
}
|
| 1426 |
-
}
|
| 1427 |
-
}
|
| 1428 |
-
|
| 1429 |
-
async function refreshRoutePlan() {
|
| 1430 |
-
let path = "/route-plans/" + scheduleId;
|
| 1431 |
-
let isLoadingDemoData = scheduleId === null;
|
| 1432 |
-
|
| 1433 |
-
if (isLoadingDemoData) {
|
| 1434 |
-
if (demoDataId === null) {
|
| 1435 |
-
alert("Please select a test data set.");
|
| 1436 |
-
return;
|
| 1437 |
-
}
|
| 1438 |
-
|
| 1439 |
-
// Clear geometry cache when loading new demo data
|
| 1440 |
-
routeGeometries = null;
|
| 1441 |
-
|
| 1442 |
-
// Use SSE streaming for demo data loading to show progress
|
| 1443 |
-
try {
|
| 1444 |
-
const routePlan = await loadDemoDataWithProgress(demoDataId);
|
| 1445 |
-
loadedRoutePlan = routePlan;
|
| 1446 |
-
refreshSolvingButtons(
|
| 1447 |
-
routePlan.solverStatus != null &&
|
| 1448 |
-
routePlan.solverStatus !== "NOT_SOLVING",
|
| 1449 |
-
);
|
| 1450 |
-
await renderRoutes(routePlan);
|
| 1451 |
-
renderTimelines(routePlan);
|
| 1452 |
-
initialized = true;
|
| 1453 |
-
} catch (error) {
|
| 1454 |
-
showError("Getting demo data has failed: " + error.message, {});
|
| 1455 |
-
refreshSolvingButtons(false);
|
| 1456 |
-
}
|
| 1457 |
-
return;
|
| 1458 |
-
}
|
| 1459 |
-
|
| 1460 |
-
// Loading existing route plan (during solving)
|
| 1461 |
-
try {
|
| 1462 |
-
const routePlan = await $.getJSON(path);
|
| 1463 |
-
loadedRoutePlan = routePlan;
|
| 1464 |
-
refreshSolvingButtons(
|
| 1465 |
-
routePlan.solverStatus != null &&
|
| 1466 |
-
routePlan.solverStatus !== "NOT_SOLVING",
|
| 1467 |
-
);
|
| 1468 |
-
await renderRoutes(routePlan);
|
| 1469 |
-
renderTimelines(routePlan);
|
| 1470 |
-
initialized = true;
|
| 1471 |
-
} catch (error) {
|
| 1472 |
-
showError("Getting route plan has failed.", error);
|
| 1473 |
-
refreshSolvingButtons(false);
|
| 1474 |
-
}
|
| 1475 |
-
}
|
| 1476 |
-
|
| 1477 |
-
function stopSolving() {
|
| 1478 |
-
$.delete("/route-plans/" + scheduleId, function () {
|
| 1479 |
-
refreshSolvingButtons(false);
|
| 1480 |
-
refreshRoutePlan();
|
| 1481 |
-
}).fail(function (xhr, ajaxOptions, thrownError) {
|
| 1482 |
-
showError("Stop solving failed.", xhr);
|
| 1483 |
-
});
|
| 1484 |
-
}
|
| 1485 |
-
|
| 1486 |
-
function fetchDemoData() {
|
| 1487 |
-
$.get("/demo-data", function (data) {
|
| 1488 |
-
data.forEach(function (item) {
|
| 1489 |
-
$("#testDataButton").append(
|
| 1490 |
-
$(
|
| 1491 |
-
'<a id="' +
|
| 1492 |
-
item +
|
| 1493 |
-
'TestData" class="dropdown-item" href="#">' +
|
| 1494 |
-
item +
|
| 1495 |
-
"</a>",
|
| 1496 |
-
),
|
| 1497 |
-
);
|
| 1498 |
-
|
| 1499 |
-
$("#" + item + "TestData").click(function () {
|
| 1500 |
-
switchDataDropDownItemActive(item);
|
| 1501 |
-
scheduleId = null;
|
| 1502 |
-
demoDataId = item;
|
| 1503 |
-
initialized = false;
|
| 1504 |
-
homeLocationGroup.clearLayers();
|
| 1505 |
-
homeLocationMarkerByIdMap.clear();
|
| 1506 |
-
visitGroup.clearLayers();
|
| 1507 |
-
visitMarkerByIdMap.clear();
|
| 1508 |
-
refreshRoutePlan();
|
| 1509 |
-
});
|
| 1510 |
-
});
|
| 1511 |
-
|
| 1512 |
-
demoDataId = data[0];
|
| 1513 |
-
switchDataDropDownItemActive(demoDataId);
|
| 1514 |
-
|
| 1515 |
-
refreshRoutePlan();
|
| 1516 |
-
}).fail(function (xhr, ajaxOptions, thrownError) {
|
| 1517 |
-
// disable this page as there is no data
|
| 1518 |
-
$("#demo").empty();
|
| 1519 |
-
$("#demo").html(
|
| 1520 |
-
'<h1><p style="justify-content: center">No test data available</p></h1>',
|
| 1521 |
-
);
|
| 1522 |
-
});
|
| 1523 |
-
}
|
| 1524 |
-
|
| 1525 |
-
function switchDataDropDownItemActive(newItem) {
|
| 1526 |
-
activeCssClass = "active";
|
| 1527 |
-
$("#testDataButton > a." + activeCssClass).removeClass(activeCssClass);
|
| 1528 |
-
$("#" + newItem + "TestData").addClass(activeCssClass);
|
| 1529 |
-
}
|
| 1530 |
-
|
| 1531 |
-
function copyTextToClipboard(id) {
|
| 1532 |
-
var text = $("#" + id)
|
| 1533 |
-
.text()
|
| 1534 |
-
.trim();
|
| 1535 |
-
|
| 1536 |
-
var dummy = document.createElement("textarea");
|
| 1537 |
-
document.body.appendChild(dummy);
|
| 1538 |
-
dummy.value = text;
|
| 1539 |
-
dummy.select();
|
| 1540 |
-
document.execCommand("copy");
|
| 1541 |
-
document.body.removeChild(dummy);
|
| 1542 |
-
}
|
| 1543 |
-
|
| 1544 |
-
function replaceQuickstartSolverForgeAutoHeaderFooter() {
|
| 1545 |
-
const solverforgeHeader = $("header#solverforge-auto-header");
|
| 1546 |
-
if (solverforgeHeader != null) {
|
| 1547 |
-
solverforgeHeader.css("background-color", "#ffffff");
|
| 1548 |
-
solverforgeHeader.append(
|
| 1549 |
-
$(`<div class="container-fluid">
|
| 1550 |
-
<nav class="navbar sticky-top navbar-expand-lg shadow-sm mb-3" style="background-color: #ffffff;">
|
| 1551 |
-
<a class="navbar-brand" href="https://www.solverforge.org">
|
| 1552 |
-
<img src="/webjars/solverforge/img/solverforge-horizontal.svg" alt="SolverForge logo" width="400">
|
| 1553 |
-
</a>
|
| 1554 |
-
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
| 1555 |
-
<span class="navbar-toggler-icon"></span>
|
| 1556 |
-
</button>
|
| 1557 |
-
<div class="collapse navbar-collapse" id="navbarNav">
|
| 1558 |
-
<ul class="nav nav-pills">
|
| 1559 |
-
<li class="nav-item active" id="navUIItem">
|
| 1560 |
-
<button class="nav-link active" id="navUI" data-bs-toggle="pill" data-bs-target="#demo" type="button" style="color: #1f2937;">Demo UI</button>
|
| 1561 |
-
</li>
|
| 1562 |
-
<li class="nav-item" id="navRestItem">
|
| 1563 |
-
<button class="nav-link" id="navRest" data-bs-toggle="pill" data-bs-target="#rest" type="button" style="color: #1f2937;">Guide</button>
|
| 1564 |
-
</li>
|
| 1565 |
-
<li class="nav-item" id="navOpenApiItem">
|
| 1566 |
-
<button class="nav-link" id="navOpenApi" data-bs-toggle="pill" data-bs-target="#openapi" type="button" style="color: #1f2937;">REST API</button>
|
| 1567 |
-
</li>
|
| 1568 |
-
</ul>
|
| 1569 |
-
</div>
|
| 1570 |
-
<div class="ms-auto d-flex align-items-center gap-3">
|
| 1571 |
-
<div class="form-check form-switch d-flex align-items-center" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Enable real road routing using OpenStreetMap data. Slower initial load (~5-15s for download), but shows accurate road routes instead of straight lines.">
|
| 1572 |
-
<input class="form-check-input" type="checkbox" id="realRoadRouting" style="width: 2.5em; height: 1.25em; cursor: pointer;">
|
| 1573 |
-
<label class="form-check-label ms-2" for="realRoadRouting" style="white-space: nowrap; cursor: pointer;">
|
| 1574 |
-
<i class="fas fa-road"></i> Real Roads
|
| 1575 |
-
</label>
|
| 1576 |
-
</div>
|
| 1577 |
-
<div class="dropdown">
|
| 1578 |
-
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="background-color: #10b981; color: #ffffff; border-color: #10b981;">
|
| 1579 |
-
Data
|
| 1580 |
-
</button>
|
| 1581 |
-
<div id="testDataButton" class="dropdown-menu" aria-labelledby="dropdownMenuButton"></div>
|
| 1582 |
-
</div>
|
| 1583 |
-
</div>
|
| 1584 |
-
</nav>
|
| 1585 |
-
</div>`),
|
| 1586 |
-
);
|
| 1587 |
-
}
|
| 1588 |
-
|
| 1589 |
-
const solverforgeFooter = $("footer#solverforge-auto-footer");
|
| 1590 |
-
if (solverforgeFooter != null) {
|
| 1591 |
-
solverforgeFooter.append(
|
| 1592 |
-
$(`<footer class="bg-black text-white-50">
|
| 1593 |
-
<div class="container">
|
| 1594 |
-
<div class="hstack gap-3 p-4">
|
| 1595 |
-
<div class="ms-auto"><a class="text-white" href="https://www.solverforge.org">SolverForge</a></div>
|
| 1596 |
-
<div class="vr"></div>
|
| 1597 |
-
<div><a class="text-white" href="https://www.solverforge.org/docs">Documentation</a></div>
|
| 1598 |
-
<div class="vr"></div>
|
| 1599 |
-
<div><a class="text-white" href="https://github.com/SolverForge/solverforge-legacy">Code</a></div>
|
| 1600 |
-
<div class="vr"></div>
|
| 1601 |
-
<div class="me-auto"><a class="text-white" href="mailto:info@solverforge.org">Support</a></div>
|
| 1602 |
-
</div>
|
| 1603 |
-
</div>
|
| 1604 |
-
</footer>`),
|
| 1605 |
-
);
|
| 1606 |
-
}
|
| 1607 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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set=UTF-8">
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
| 7 |
-
<title>Vehicle Routing - SolverForge for Python</title>
|
| 8 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css">
|
| 9 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.css">
|
| 10 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
| 11 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vis-timeline@7.7.2/styles/vis-timeline-graph2d.min.css"
|
| 12 |
-
integrity="sha256-svzNasPg1yR5gvEaRei2jg+n4Pc3sVyMUWeS6xRAh6U=" crossorigin="anonymous">
|
| 13 |
-
<link rel="stylesheet" href="/webjars/solverforge/css/solverforge-webui.css"/>
|
| 14 |
-
<link rel="icon" href="/webjars/solverforge/img/solverforge-favicon.svg" type="image/svg+xml">
|
| 15 |
-
<style>
|
| 16 |
-
/* Customer marker icons */
|
| 17 |
-
.customer-marker, .vehicle-home-marker, .temp-vehicle-marker {
|
| 18 |
-
background: transparent !important;
|
| 19 |
-
border: none !important;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
/* Pulse animation for new vehicle placement */
|
| 23 |
-
@keyframes pulse {
|
| 24 |
-
0% { transform: scale(1); box-shadow: 0 2px 4px rgba(0,0,0,0.4); }
|
| 25 |
-
50% { transform: scale(1.1); box-shadow: 0 4px 8px rgba(99, 102, 241, 0.6); }
|
| 26 |
-
100% { transform: scale(1); box-shadow: 0 2px 4px rgba(0,0,0,0.4); }
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
/* Customer type buttons in modal */
|
| 30 |
-
.customer-type-btn {
|
| 31 |
-
transition: all 0.2s ease;
|
| 32 |
-
padding: 0.75rem 0.5rem;
|
| 33 |
-
}
|
| 34 |
-
.customer-type-btn:hover {
|
| 35 |
-
transform: translateY(-2px);
|
| 36 |
-
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
/* Vehicle table styling */
|
| 40 |
-
#vehicles tr.vehicle-row {
|
| 41 |
-
transition: background-color 0.2s ease;
|
| 42 |
-
}
|
| 43 |
-
#vehicles tr.vehicle-row:hover {
|
| 44 |
-
background-color: rgba(99, 102, 241, 0.1);
|
| 45 |
-
}
|
| 46 |
-
#vehicles tr.vehicle-row.table-active {
|
| 47 |
-
background-color: rgba(99, 102, 241, 0.15) !important;
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
/* Route number markers */
|
| 51 |
-
.route-number-marker {
|
| 52 |
-
background: transparent !important;
|
| 53 |
-
border: none !important;
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
/* Notification panel */
|
| 57 |
-
#notificationPanel {
|
| 58 |
-
z-index: 1050;
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
/* Click hint for vehicle rows */
|
| 62 |
-
#vehicles tr.vehicle-row td:not(:last-child) {
|
| 63 |
-
cursor: pointer;
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
/* Solving spinner */
|
| 67 |
-
#solvingSpinner {
|
| 68 |
-
display: none;
|
| 69 |
-
width: 1.25rem;
|
| 70 |
-
height: 1.25rem;
|
| 71 |
-
border: 2px solid #10b981;
|
| 72 |
-
border-top-color: transparent;
|
| 73 |
-
border-radius: 50%;
|
| 74 |
-
animation: spin 0.75s linear infinite;
|
| 75 |
-
vertical-align: middle;
|
| 76 |
-
}
|
| 77 |
-
#solvingSpinner.active {
|
| 78 |
-
display: inline-block;
|
| 79 |
-
}
|
| 80 |
-
@keyframes spin {
|
| 81 |
-
to { transform: rotate(360deg); }
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
/* Progress bar text should stay horizontal and inside */
|
| 85 |
-
.progress-bar {
|
| 86 |
-
overflow: visible;
|
| 87 |
-
white-space: nowrap;
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
/* Map hint overlay */
|
| 91 |
-
.map-hint {
|
| 92 |
-
position: absolute;
|
| 93 |
-
bottom: 20px;
|
| 94 |
-
left: 50%;
|
| 95 |
-
transform: translateX(-50%);
|
| 96 |
-
background-color: rgba(255, 255, 255, 0.95);
|
| 97 |
-
padding: 8px 16px;
|
| 98 |
-
border-radius: 20px;
|
| 99 |
-
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
| 100 |
-
font-size: 0.9rem;
|
| 101 |
-
color: #374151;
|
| 102 |
-
z-index: 1000;
|
| 103 |
-
pointer-events: none;
|
| 104 |
-
transition: opacity 0.3s ease;
|
| 105 |
-
}
|
| 106 |
-
.map-hint i {
|
| 107 |
-
color: #10b981;
|
| 108 |
-
margin-right: 6px;
|
| 109 |
-
}
|
| 110 |
-
.map-hint.hidden {
|
| 111 |
-
opacity: 0;
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
/* Timeline stop badges */
|
| 115 |
-
.timeline-stop-badge {
|
| 116 |
-
background-color: #6366f1;
|
| 117 |
-
color: white;
|
| 118 |
-
padding: 1px 6px;
|
| 119 |
-
border-radius: 10px;
|
| 120 |
-
font-size: 0.7rem;
|
| 121 |
-
font-weight: bold;
|
| 122 |
-
margin-right: 4px;
|
| 123 |
-
}
|
| 124 |
-
.timeline-status-icon {
|
| 125 |
-
margin-left: 4px;
|
| 126 |
-
font-size: 0.85rem;
|
| 127 |
-
}
|
| 128 |
-
.timeline-status-ontime { color: #10b981; }
|
| 129 |
-
.timeline-status-late { color: #ef4444; }
|
| 130 |
-
.timeline-status-early { color: #3b82f6; }
|
| 131 |
-
.vis-item .vis-item-content {
|
| 132 |
-
font-size: 0.85rem;
|
| 133 |
-
padding: 2px 4px;
|
| 134 |
-
}
|
| 135 |
-
.vis-labelset .vis-label {
|
| 136 |
-
padding: 4px 8px;
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
/* Loading overlay */
|
| 140 |
-
.loading-overlay {
|
| 141 |
-
position: fixed;
|
| 142 |
-
top: 0;
|
| 143 |
-
left: 0;
|
| 144 |
-
right: 0;
|
| 145 |
-
bottom: 0;
|
| 146 |
-
background: rgba(255, 255, 255, 0.95);
|
| 147 |
-
display: flex;
|
| 148 |
-
align-items: center;
|
| 149 |
-
justify-content: center;
|
| 150 |
-
z-index: 2000;
|
| 151 |
-
transition: opacity 0.3s ease;
|
| 152 |
-
}
|
| 153 |
-
.loading-overlay.hidden {
|
| 154 |
-
opacity: 0;
|
| 155 |
-
pointer-events: none;
|
| 156 |
-
}
|
| 157 |
-
.loading-content {
|
| 158 |
-
text-align: center;
|
| 159 |
-
padding: 2rem;
|
| 160 |
-
}
|
| 161 |
-
.loading-spinner {
|
| 162 |
-
width: 60px;
|
| 163 |
-
height: 60px;
|
| 164 |
-
border: 4px solid #e5e7eb;
|
| 165 |
-
border-top-color: #10b981;
|
| 166 |
-
border-radius: 50%;
|
| 167 |
-
animation: spin 1s linear infinite;
|
| 168 |
-
margin: 0 auto 1.5rem;
|
| 169 |
-
}
|
| 170 |
-
@keyframes spin {
|
| 171 |
-
to { transform: rotate(360deg); }
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
/* Real Roads toggle styling */
|
| 175 |
-
#realRoadRouting:checked {
|
| 176 |
-
background-color: #10b981;
|
| 177 |
-
border-color: #10b981;
|
| 178 |
-
}
|
| 179 |
-
</style>
|
| 180 |
-
</head>
|
| 181 |
-
<body>
|
| 182 |
-
|
| 183 |
-
<header id="solverforge-auto-header">
|
| 184 |
-
<!-- Filled in by app.js -->
|
| 185 |
-
</header>
|
| 186 |
-
<div class="tab-content">
|
| 187 |
-
<div id="demo" class="tab-pane fade show active container-fluid">
|
| 188 |
-
<div class="sticky-top d-flex justify-content-center align-items-center">
|
| 189 |
-
<div id="notificationPanel" style="position: absolute; top: .5rem;"></div>
|
| 190 |
-
</div>
|
| 191 |
-
<h1>Vehicle routing with capacity and time windows</h1>
|
| 192 |
-
<p>Generate optimal route plan of a vehicle fleet with limited vehicle capacity and time windows.</p>
|
| 193 |
-
<div class="container-fluid mb-2">
|
| 194 |
-
<div class="row justify-content-start">
|
| 195 |
-
<div class="col-9">
|
| 196 |
-
<ul class="nav nav-pills col" role="tablist">
|
| 197 |
-
<li class="nav-item" role="presentation">
|
| 198 |
-
<button class="nav-link active" id="mapTab" data-bs-toggle="tab" data-bs-target="#mapPanel"
|
| 199 |
-
type="button"
|
| 200 |
-
role="tab" aria-controls="mapPanel" aria-selected="false">Map
|
| 201 |
-
</button>
|
| 202 |
-
</li>
|
| 203 |
-
<li class="nav-item" role="presentation">
|
| 204 |
-
<button class="nav-link" id="byVehicleTab" data-bs-toggle="tab" data-bs-target="#byVehiclePanel"
|
| 205 |
-
type="button" role="tab" aria-controls="byVehiclePanel" aria-selected="false">By vehicle
|
| 206 |
-
</button>
|
| 207 |
-
</li>
|
| 208 |
-
<li class="nav-item" role="presentation">
|
| 209 |
-
<button class="nav-link" id="byVisitTab" data-bs-toggle="tab" data-bs-target="#byVisitPanel"
|
| 210 |
-
type="button" role="tab" aria-controls="byVisitPanel" aria-selected="false">By visit
|
| 211 |
-
</button>
|
| 212 |
-
</li>
|
| 213 |
-
</ul>
|
| 214 |
-
</div>
|
| 215 |
-
<div class="col-3">
|
| 216 |
-
<button id="solveButton" type="button" class="btn btn-success">
|
| 217 |
-
<i class="fas fa-play"></i> Solve
|
| 218 |
-
</button>
|
| 219 |
-
<button id="stopSolvingButton" type="button" class="btn btn-danger p-2">
|
| 220 |
-
<i class="fas fa-stop"></i> Stop solving
|
| 221 |
-
</button>
|
| 222 |
-
<span id="solvingSpinner" class="ms-2"></span>
|
| 223 |
-
<span id="score" class="score ms-2 align-middle fw-bold">Score: ?</span>
|
| 224 |
-
<button id="analyzeButton" type="button" class="ms-2 btn btn-secondary">
|
| 225 |
-
<span class="fas fa-question"></span>
|
| 226 |
-
</button>
|
| 227 |
-
</div>
|
| 228 |
-
</div>
|
| 229 |
-
</div>
|
| 230 |
-
|
| 231 |
-
<div class="tab-content">
|
| 232 |
-
|
| 233 |
-
<div class="tab-pane fade show active" id="mapPanel" role="tabpanel" aria-labelledby="mapTab">
|
| 234 |
-
<div class="row">
|
| 235 |
-
<div class="col-7 col-lg-8 col-xl-9 position-relative">
|
| 236 |
-
<div id="map" style="width: 100%; height: 100vh;"></div>
|
| 237 |
-
<div id="mapHint" class="map-hint">
|
| 238 |
-
<i class="fas fa-mouse-pointer"></i> Click on the map to add a new visit
|
| 239 |
-
</div>
|
| 240 |
-
</div>
|
| 241 |
-
<div class="col-5 col-lg-4 col-xl-3" style="height: 100vh; overflow-y: scroll;">
|
| 242 |
-
<div class="row pt-2 row-cols-1">
|
| 243 |
-
<div class="col">
|
| 244 |
-
<h5>
|
| 245 |
-
Solution summary
|
| 246 |
-
</h5>
|
| 247 |
-
<table class="table">
|
| 248 |
-
<tr>
|
| 249 |
-
<td>Total driving time:</td>
|
| 250 |
-
<td><span id="drivingTime">unknown</span></td>
|
| 251 |
-
</tr>
|
| 252 |
-
</table>
|
| 253 |
-
</div>
|
| 254 |
-
<div class="col mb-3">
|
| 255 |
-
<h5>Time Windows</h5>
|
| 256 |
-
<div class="d-flex flex-column gap-1">
|
| 257 |
-
<div><i class="fas fa-utensils" style="color: #f59e0b; width: 20px;"></i> <strong>Restaurant</strong> <small class="text-muted">06:00-10:00 · 20-40 min</small></div>
|
| 258 |
-
<div><i class="fas fa-building" style="color: #3b82f6; width: 20px;"></i> <strong>Business</strong> <small class="text-muted">09:00-17:00 · 15-30 min</small></div>
|
| 259 |
-
<div><i class="fas fa-home" style="color: #10b981; width: 20px;"></i> <strong>Residential</strong> <small class="text-muted">17:00-20:00 · 5-10 min</small></div>
|
| 260 |
-
</div>
|
| 261 |
-
</div>
|
| 262 |
-
<div class="col">
|
| 263 |
-
<div class="d-flex justify-content-between align-items-center mb-2">
|
| 264 |
-
<div>
|
| 265 |
-
<h5 class="mb-0">Vehicles</h5>
|
| 266 |
-
<small class="text-muted"><i class="fas fa-hand-pointer"></i> Click to highlight route</small>
|
| 267 |
-
</div>
|
| 268 |
-
<div class="btn-group btn-group-sm" role="group" aria-label="Vehicle management">
|
| 269 |
-
<button type="button" class="btn btn-outline-danger" id="removeVehicleBtn" title="Remove last vehicle">
|
| 270 |
-
<i class="fas fa-minus"></i>
|
| 271 |
-
</button>
|
| 272 |
-
<button type="button" class="btn btn-outline-success" id="addVehicleBtn" title="Add new vehicle">
|
| 273 |
-
<i class="fas fa-plus"></i>
|
| 274 |
-
</button>
|
| 275 |
-
</div>
|
| 276 |
-
</div>
|
| 277 |
-
<table class="table-sm w-100">
|
| 278 |
-
<thead>
|
| 279 |
-
<tr>
|
| 280 |
-
<th class="col-1"></th>
|
| 281 |
-
<th class="col-3">Name</th>
|
| 282 |
-
<th class="col-3">
|
| 283 |
-
Cargo
|
| 284 |
-
<i class="fas fa-info-circle" data-bs-toggle="tooltip" data-bs-placement="top"
|
| 285 |
-
data-html="true"
|
| 286 |
-
title="Units to deliver on this route. Each customer requires cargo units (e.g., packages, crates). Bar shows current load vs. vehicle capacity."></i>
|
| 287 |
-
</th>
|
| 288 |
-
<th class="col-2">Drive</th>
|
| 289 |
-
<th class="col-1"></th>
|
| 290 |
-
</tr>
|
| 291 |
-
</thead>
|
| 292 |
-
<tbody id="vehicles"></tbody>
|
| 293 |
-
</table>
|
| 294 |
-
</div>
|
| 295 |
-
</div>
|
| 296 |
-
</div>
|
| 297 |
-
</div>
|
| 298 |
-
</div>
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
<div class="tab-pane fade" id="byVehiclePanel" role="tabpanel" aria-labelledby="byVehicleTab">
|
| 302 |
-
</div>
|
| 303 |
-
<div class="tab-pane fade" id="byVisitPanel" role="tabpanel" aria-labelledby="byVisitTab">
|
| 304 |
-
</div>
|
| 305 |
-
</div>
|
| 306 |
-
</div>
|
| 307 |
-
|
| 308 |
-
<div id="rest" class="tab-pane fade container-fluid">
|
| 309 |
-
<h1>REST API Guide</h1>
|
| 310 |
-
|
| 311 |
-
<h2>Vehicle routing with vehicle capacity and time windows - integration via cURL</h2>
|
| 312 |
-
|
| 313 |
-
<h3>1. Download demo data</h3>
|
| 314 |
-
<pre>
|
| 315 |
-
<button class="btn btn-outline-dark btn-sm float-end"
|
| 316 |
-
onclick="copyTextToClipboard('curl1')">Copy</button>
|
| 317 |
-
<code id="curl1">curl -X GET -H 'Accept:application/json' http://localhost:8080/demo-data/FIRENZE -o sample.json</code>
|
| 318 |
-
</pre>
|
| 319 |
-
|
| 320 |
-
<h3>2. Post the sample data for solving</h3>
|
| 321 |
-
<p>The POST operation returns a <code>jobId</code> that should be used in subsequent commands.</p>
|
| 322 |
-
<pre>
|
| 323 |
-
<button class="btn btn-outline-dark btn-sm float-end"
|
| 324 |
-
onclick="copyTextToClipboard('curl2')">Copy</button>
|
| 325 |
-
<code id="curl2">curl -X POST -H 'Content-Type:application/json' http://localhost:8080/route-plans -d@sample.json</code>
|
| 326 |
-
</pre>
|
| 327 |
-
|
| 328 |
-
<h3>3. Get the current status and score</h3>
|
| 329 |
-
<pre>
|
| 330 |
-
<button class="btn btn-outline-dark btn-sm float-end"
|
| 331 |
-
onclick="copyTextToClipboard('curl3')">Copy</button>
|
| 332 |
-
<code id="curl3">curl -X GET -H 'Accept:application/json' http://localhost:8080/route-plans/{jobId}/status</code>
|
| 333 |
-
</pre>
|
| 334 |
-
|
| 335 |
-
<h3>4. Get the complete route plan</h3>
|
| 336 |
-
<pre>
|
| 337 |
-
<button class="btn btn-outline-dark btn-sm float-end"
|
| 338 |
-
onclick="copyTextToClipboard('curl4')">Copy</button>
|
| 339 |
-
<code id="curl4">curl -X GET -H 'Accept:application/json' http://localhost:8080/route-plans/{jobId}</code>
|
| 340 |
-
</pre>
|
| 341 |
-
|
| 342 |
-
<h3>5. Terminate solving early</h3>
|
| 343 |
-
<pre>
|
| 344 |
-
<button class="btn btn-outline-dark btn-sm float-end"
|
| 345 |
-
onclick="copyTextToClipboard('curl5')">Copy</button>
|
| 346 |
-
<code id="curl5">curl -X DELETE -H 'Accept:application/json' http://localhost:8080/route-plans/{jobId}</code>
|
| 347 |
-
</pre>
|
| 348 |
-
</div>
|
| 349 |
-
|
| 350 |
-
<div id="openapi" class="tab-pane fade container-fluid">
|
| 351 |
-
<h1>REST API Reference</h1>
|
| 352 |
-
<div class="ratio ratio-1x1">
|
| 353 |
-
<!-- "scrolling" attribute is obsolete, but e.g. Chrome does not support "overflow:hidden" -->
|
| 354 |
-
<iframe src="/q/swagger-ui" style="overflow:hidden;" scrolling="no"></iframe>
|
| 355 |
-
</div>
|
| 356 |
-
</div>
|
| 357 |
-
</div>
|
| 358 |
-
<div class="modal fadebd-example-modal-lg" id="scoreAnalysisModal" tabindex="-1" aria-labelledby="scoreAnalysisModalLabel" aria-hidden="true">
|
| 359 |
-
<div class="modal-dialog modal-lg modal-dialog-scrollable">
|
| 360 |
-
<div class="modal-content">
|
| 361 |
-
<div class="modal-header">
|
| 362 |
-
<h1 class="modal-title fs-5" id="scoreAnalysisModalLabel">Score analysis <span id="scoreAnalysisScoreLabel"></span></h1>
|
| 363 |
-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
| 364 |
-
</div>
|
| 365 |
-
<div class="modal-body" id="scoreAnalysisModalContent">
|
| 366 |
-
<!-- Filled in by app.js -->
|
| 367 |
-
</div>
|
| 368 |
-
<div class="modal-footer">
|
| 369 |
-
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
|
| 370 |
-
</div>
|
| 371 |
-
</div>
|
| 372 |
-
</div>
|
| 373 |
-
</div>
|
| 374 |
-
<form id='visitForm' class='needs-validation' novalidate>
|
| 375 |
-
<div class="modal fadebd-example-modal-lg" id="newVisitModal" tabindex="-1"
|
| 376 |
-
aria-labelledby="newVisitModalLabel"
|
| 377 |
-
aria-hidden="true">
|
| 378 |
-
<div class="modal-dialog modal-lg modal-dialog-scrollable">
|
| 379 |
-
<div class="modal-content">
|
| 380 |
-
<div class="modal-header">
|
| 381 |
-
<h1 class="modal-title fs-5" id="newVisitModalLabel">Add New Visit</h1>
|
| 382 |
-
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
| 383 |
-
aria-label="Close"></button>
|
| 384 |
-
</div>
|
| 385 |
-
<div class="modal-body" id="newVisitModalContent">
|
| 386 |
-
<!-- Filled in by app.js -->
|
| 387 |
-
</div>
|
| 388 |
-
<div class="modal-footer" id="newVisitModalFooter">
|
| 389 |
-
</div>
|
| 390 |
-
</div>
|
| 391 |
-
</div>
|
| 392 |
-
</div>
|
| 393 |
-
</form>
|
| 394 |
-
<!-- Add Vehicle Modal -->
|
| 395 |
-
<div class="modal fade" id="addVehicleModal" tabindex="-1" aria-labelledby="addVehicleModalLabel" aria-hidden="true">
|
| 396 |
-
<div class="modal-dialog">
|
| 397 |
-
<div class="modal-content">
|
| 398 |
-
<div class="modal-header">
|
| 399 |
-
<h5 class="modal-title" id="addVehicleModalLabel"><i class="fas fa-truck"></i> Add New Vehicle</h5>
|
| 400 |
-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
| 401 |
-
</div>
|
| 402 |
-
<div class="modal-body">
|
| 403 |
-
<div class="mb-3">
|
| 404 |
-
<label for="vehicleName" class="form-label">Name</label>
|
| 405 |
-
<input type="text" class="form-control" id="vehicleName" placeholder="e.g., Kilo">
|
| 406 |
-
<div class="form-text">Unique name for the vehicle</div>
|
| 407 |
-
</div>
|
| 408 |
-
<div class="mb-3">
|
| 409 |
-
<label for="vehicleCapacity" class="form-label">Capacity</label>
|
| 410 |
-
<input type="number" class="form-control" id="vehicleCapacity" value="25" min="1">
|
| 411 |
-
<div class="form-text">Maximum cargo the vehicle can carry</div>
|
| 412 |
-
</div>
|
| 413 |
-
<div class="mb-3">
|
| 414 |
-
<label for="vehicleDepartureTime" class="form-label">Departure Time</label>
|
| 415 |
-
<input type="text" class="form-control" id="vehicleDepartureTime">
|
| 416 |
-
</div>
|
| 417 |
-
<div class="mb-3">
|
| 418 |
-
<label class="form-label">Home Location</label>
|
| 419 |
-
<div class="d-flex gap-2 mb-2">
|
| 420 |
-
<button type="button" class="btn btn-outline-primary btn-sm" id="pickLocationBtn">
|
| 421 |
-
<i class="fas fa-map-marker-alt"></i> Pick on Map
|
| 422 |
-
</button>
|
| 423 |
-
<span class="text-muted small align-self-center">or enter coordinates:</span>
|
| 424 |
-
</div>
|
| 425 |
-
<div class="row g-2">
|
| 426 |
-
<div class="col-6">
|
| 427 |
-
<input type="number" step="any" class="form-control" id="vehicleHomeLat" placeholder="Latitude">
|
| 428 |
-
</div>
|
| 429 |
-
<div class="col-6">
|
| 430 |
-
<input type="number" step="any" class="form-control" id="vehicleHomeLng" placeholder="Longitude">
|
| 431 |
-
</div>
|
| 432 |
-
</div>
|
| 433 |
-
<div id="vehicleLocationPreview" class="mt-2 text-muted small"></div>
|
| 434 |
-
</div>
|
| 435 |
-
</div>
|
| 436 |
-
<div class="modal-footer">
|
| 437 |
-
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
| 438 |
-
<button type="button" class="btn btn-success" id="confirmAddVehicle"><i class="fas fa-plus"></i> Add Vehicle</button>
|
| 439 |
-
</div>
|
| 440 |
-
</div>
|
| 441 |
-
</div>
|
| 442 |
-
</div>
|
| 443 |
-
|
| 444 |
-
<!-- Loading/Progress Overlay -->
|
| 445 |
-
<div id="loadingOverlay" class="loading-overlay hidden">
|
| 446 |
-
<div class="loading-content">
|
| 447 |
-
<div class="loading-spinner"></div>
|
| 448 |
-
<h5 id="loadingTitle">Loading Demo Data</h5>
|
| 449 |
-
<p id="loadingMessage" class="text-muted mb-2">Initializing...</p>
|
| 450 |
-
<div class="progress" style="width: 300px; height: 8px;">
|
| 451 |
-
<div id="loadingProgress" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%"></div>
|
| 452 |
-
</div>
|
| 453 |
-
<small id="loadingDetail" class="text-muted mt-2 d-block"></small>
|
| 454 |
-
</div>
|
| 455 |
-
</div>
|
| 456 |
-
|
| 457 |
-
<footer id="solverforge-auto-footer"></footer>
|
| 458 |
-
|
| 459 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.13/flatpickr.min.js"></script>
|
| 460 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.13/flatpickr.min.css">
|
| 461 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js"></script>
|
| 462 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
| 463 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.8/umd/popper.min.js"></script>
|
| 464 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js"></script>
|
| 465 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-joda/1.11.0/js-joda.min.js"></script>
|
| 466 |
-
<script src="https://cdn.jsdelivr.net/npm/vis-timeline@7.7.2/standalone/umd/vis-timeline-graph2d.min.js"
|
| 467 |
-
integrity="sha256-Jy2+UO7rZ2Dgik50z3XrrNpnc5+2PAx9MhL2CicodME=" crossorigin="anonymous"></script>
|
| 468 |
-
<script src="/webjars/solverforge/js/solverforge-webui.js"></script>
|
| 469 |
-
<script src="/score-analysis.js"></script>
|
| 470 |
-
<script src="/recommended-fit.js"></script>
|
| 471 |
-
<script src="/app.js"></script>
|
| 472 |
-
</body>
|
| 473 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/recommended-fit.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* Recommended Fit functionality for adding new visits with recommendations.
|
| 3 |
-
*
|
| 4 |
-
* This module provides:
|
| 5 |
-
* - Modal form for adding new visits
|
| 6 |
-
* - Integration with the recommendation API
|
| 7 |
-
* - Application of selected recommendations
|
| 8 |
-
*/
|
| 9 |
-
|
| 10 |
-
// Customer type configurations (must match CUSTOMER_TYPES in app.js and demo_data.py)
|
| 11 |
-
const VISIT_CUSTOMER_TYPES = {
|
| 12 |
-
RESIDENTIAL: { label: "Residential", icon: "fa-home", color: "#10b981", windowStart: "17:00", windowEnd: "20:00", minDemand: 1, maxDemand: 2, minService: 5, maxService: 10 },
|
| 13 |
-
BUSINESS: { label: "Business", icon: "fa-building", color: "#3b82f6", windowStart: "09:00", windowEnd: "17:00", minDemand: 3, maxDemand: 6, minService: 15, maxService: 30 },
|
| 14 |
-
RESTAURANT: { label: "Restaurant", icon: "fa-utensils", color: "#f59e0b", windowStart: "06:00", windowEnd: "10:00", minDemand: 5, maxDemand: 10, minService: 20, maxService: 40 },
|
| 15 |
-
};
|
| 16 |
-
|
| 17 |
-
function addNewVisit(id, lat, lng, map, marker) {
|
| 18 |
-
$('#newVisitModal').modal('show');
|
| 19 |
-
const visitModalContent = $("#newVisitModalContent");
|
| 20 |
-
visitModalContent.children().remove();
|
| 21 |
-
|
| 22 |
-
let visitForm = "";
|
| 23 |
-
|
| 24 |
-
// Customer Type Selection (prominent at the top)
|
| 25 |
-
visitForm += "<div class='form-group mb-3'>" +
|
| 26 |
-
" <label class='form-label fw-bold'>Customer Type</label>" +
|
| 27 |
-
" <div class='row g-2' id='customerTypeButtons'>";
|
| 28 |
-
|
| 29 |
-
Object.entries(VISIT_CUSTOMER_TYPES).forEach(([type, config]) => {
|
| 30 |
-
const isDefault = type === 'RESIDENTIAL';
|
| 31 |
-
visitForm += `
|
| 32 |
-
<div class='col-4'>
|
| 33 |
-
<button type='button' class='btn w-100 customer-type-btn ${isDefault ? 'active' : ''}'
|
| 34 |
-
data-type='${type}'
|
| 35 |
-
style='border: 2px solid ${config.color}; ${isDefault ? `background-color: ${config.color}; color: white;` : `color: ${config.color};`}'>
|
| 36 |
-
<i class='fas ${config.icon}'></i><br>
|
| 37 |
-
<span class='fw-bold'>${config.label}</span><br>
|
| 38 |
-
<small>${config.windowStart}-${config.windowEnd}</small>
|
| 39 |
-
</button>
|
| 40 |
-
</div>`;
|
| 41 |
-
});
|
| 42 |
-
|
| 43 |
-
visitForm += " </div>" +
|
| 44 |
-
"</div>";
|
| 45 |
-
|
| 46 |
-
// Name and Location row
|
| 47 |
-
visitForm += "<div class='form-group mb-3'>" +
|
| 48 |
-
" <div class='row g-2'>" +
|
| 49 |
-
" <div class='col-4'>" +
|
| 50 |
-
" <label for='inputName' class='form-label'>Name</label>" +
|
| 51 |
-
` <input type='text' class='form-control' id='inputName' value='visit${id}' required>` +
|
| 52 |
-
" <div class='invalid-feedback'>Field is required</div>" +
|
| 53 |
-
" </div>" +
|
| 54 |
-
" <div class='col-4'>" +
|
| 55 |
-
" <label for='inputLatitude' class='form-label'>Latitude</label>" +
|
| 56 |
-
` <input type='text' disabled class='form-control' id='inputLatitude' value='${lat.toFixed(6)}'>` +
|
| 57 |
-
" </div>" +
|
| 58 |
-
" <div class='col-4'>" +
|
| 59 |
-
" <label for='inputLongitude' class='form-label'>Longitude</label>" +
|
| 60 |
-
` <input type='text' disabled class='form-control' id='inputLongitude' value='${lng.toFixed(6)}'>` +
|
| 61 |
-
" </div>" +
|
| 62 |
-
" </div>" +
|
| 63 |
-
"</div>";
|
| 64 |
-
|
| 65 |
-
// Cargo and Duration row
|
| 66 |
-
visitForm += "<div class='form-group mb-3'>" +
|
| 67 |
-
" <div class='row g-2'>" +
|
| 68 |
-
" <div class='col-6'>" +
|
| 69 |
-
" <label for='inputDemand' class='form-label'>Cargo (units) <small class='text-muted' id='demandHint'>(1-2 typical)</small></label>" +
|
| 70 |
-
" <input type='number' class='form-control' id='inputDemand' value='1' min='1' required>" +
|
| 71 |
-
" <div class='invalid-feedback'>Field is required</div>" +
|
| 72 |
-
" </div>" +
|
| 73 |
-
" <div class='col-6'>" +
|
| 74 |
-
" <label for='inputDuration' class='form-label'>Service Duration <small class='text-muted' id='durationHint'>(5-10 min typical)</small></label>" +
|
| 75 |
-
" <input type='number' class='form-control' id='inputDuration' value='7' min='1' required>" +
|
| 76 |
-
" <div class='invalid-feedback'>Field is required</div>" +
|
| 77 |
-
" </div>" +
|
| 78 |
-
" </div>" +
|
| 79 |
-
"</div>";
|
| 80 |
-
|
| 81 |
-
// Time window row
|
| 82 |
-
visitForm += "<div class='form-group mb-3'>" +
|
| 83 |
-
" <div class='row g-2'>" +
|
| 84 |
-
" <div class='col-6'>" +
|
| 85 |
-
" <label for='inputMinStartTime' class='form-label'>Time Window Start</label>" +
|
| 86 |
-
" <input class='form-control' id='inputMinStartTime' required>" +
|
| 87 |
-
" <div class='invalid-feedback'>Field is required</div>" +
|
| 88 |
-
" </div>" +
|
| 89 |
-
" <div class='col-6'>" +
|
| 90 |
-
" <label for='inputMaxStartTime' class='form-label'>Time Window End</label>" +
|
| 91 |
-
" <input class='form-control' id='inputMaxStartTime' required>" +
|
| 92 |
-
" <div class='invalid-feedback'>Field is required</div>" +
|
| 93 |
-
" </div>" +
|
| 94 |
-
" </div>" +
|
| 95 |
-
"</div>";
|
| 96 |
-
|
| 97 |
-
visitModalContent.append(visitForm);
|
| 98 |
-
|
| 99 |
-
// Initialize with Residential defaults
|
| 100 |
-
const defaultType = VISIT_CUSTOMER_TYPES.RESIDENTIAL;
|
| 101 |
-
const tomorrow = JSJoda.LocalDate.now().plusDays(1);
|
| 102 |
-
|
| 103 |
-
function parseTimeToDateTime(timeStr) {
|
| 104 |
-
const [hours, minutes] = timeStr.split(':').map(Number);
|
| 105 |
-
return tomorrow.atTime(JSJoda.LocalTime.of(hours, minutes));
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
-
let minStartPicker = flatpickr("#inputMinStartTime", {
|
| 109 |
-
enableTime: true,
|
| 110 |
-
dateFormat: "Y-m-d H:i",
|
| 111 |
-
defaultDate: parseTimeToDateTime(defaultType.windowStart).format(JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm'))
|
| 112 |
-
});
|
| 113 |
-
|
| 114 |
-
let maxEndPicker = flatpickr("#inputMaxStartTime", {
|
| 115 |
-
enableTime: true,
|
| 116 |
-
dateFormat: "Y-m-d H:i",
|
| 117 |
-
defaultDate: parseTimeToDateTime(defaultType.windowEnd).format(JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm'))
|
| 118 |
-
});
|
| 119 |
-
|
| 120 |
-
// Customer type button click handler
|
| 121 |
-
$(".customer-type-btn").click(function() {
|
| 122 |
-
const selectedType = $(this).data('type');
|
| 123 |
-
const config = VISIT_CUSTOMER_TYPES[selectedType];
|
| 124 |
-
|
| 125 |
-
// Update button styles
|
| 126 |
-
$(".customer-type-btn").each(function() {
|
| 127 |
-
const btnType = $(this).data('type');
|
| 128 |
-
const btnConfig = VISIT_CUSTOMER_TYPES[btnType];
|
| 129 |
-
$(this).removeClass('active');
|
| 130 |
-
$(this).css({
|
| 131 |
-
'background-color': 'transparent',
|
| 132 |
-
'color': btnConfig.color
|
| 133 |
-
});
|
| 134 |
-
});
|
| 135 |
-
$(this).addClass('active');
|
| 136 |
-
$(this).css({
|
| 137 |
-
'background-color': config.color,
|
| 138 |
-
'color': 'white'
|
| 139 |
-
});
|
| 140 |
-
|
| 141 |
-
// Update time windows
|
| 142 |
-
minStartPicker.setDate(parseTimeToDateTime(config.windowStart).format(JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm')));
|
| 143 |
-
maxEndPicker.setDate(parseTimeToDateTime(config.windowEnd).format(JSJoda.DateTimeFormatter.ofPattern('yyyy-M-d HH:mm')));
|
| 144 |
-
|
| 145 |
-
// Update demand hint and value
|
| 146 |
-
$("#demandHint").text(`(${config.minDemand}-${config.maxDemand} typical)`);
|
| 147 |
-
$("#inputDemand").val(config.minDemand);
|
| 148 |
-
|
| 149 |
-
// Update service duration hint and value (use midpoint of range)
|
| 150 |
-
const avgService = Math.round((config.minService + config.maxService) / 2);
|
| 151 |
-
$("#durationHint").text(`(${config.minService}-${config.maxService} min typical)`);
|
| 152 |
-
$("#inputDuration").val(avgService);
|
| 153 |
-
});
|
| 154 |
-
|
| 155 |
-
const visitModalFooter = $("#newVisitModalFooter");
|
| 156 |
-
visitModalFooter.children().remove();
|
| 157 |
-
visitModalFooter.append("<button id='recommendationButton' type='button' class='btn btn-success'><i class='fas fa-arrow-right'></i> Get Recommendations</button>");
|
| 158 |
-
$("#recommendationButton").click(getRecommendationsModal);
|
| 159 |
-
}
|
| 160 |
-
|
| 161 |
-
function requestRecommendations(visitId, solution, endpointPath) {
|
| 162 |
-
$.post(endpointPath, JSON.stringify({solution, visitId}), function (recommendations) {
|
| 163 |
-
const visitModalContent = $("#newVisitModalContent");
|
| 164 |
-
visitModalContent.children().remove();
|
| 165 |
-
|
| 166 |
-
if (!recommendations || recommendations.length === 0) {
|
| 167 |
-
visitModalContent.append("<div class='alert alert-warning'>No recommendations available. The recommendation API may not be fully implemented.</div>");
|
| 168 |
-
const visitModalFooter = $("#newVisitModalFooter");
|
| 169 |
-
visitModalFooter.children().remove();
|
| 170 |
-
visitModalFooter.append("<button type='button' class='btn btn-secondary' data-bs-dismiss='modal'>Close</button>");
|
| 171 |
-
return;
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
let visitOptions = "";
|
| 175 |
-
const visit = solution.visits.find(c => c.id === visitId);
|
| 176 |
-
|
| 177 |
-
recommendations.forEach((recommendation, index) => {
|
| 178 |
-
const scoreDiffDisplay = recommendation.scoreDiff || "N/A";
|
| 179 |
-
visitOptions += "<div class='form-check'>" +
|
| 180 |
-
` <input class='form-check-input' type='radio' name='recommendationOptions' id='option${index}' value='option${index}' ${index === 0 ? 'checked=true' : ''}>` +
|
| 181 |
-
` <label class='form-check-label' for='option${index}'>` +
|
| 182 |
-
` Add <b>${visit.name}</b> to vehicle <b>${recommendation.proposition.vehicleId}</b> at position <b>${recommendation.proposition.index + 1}</b> (${scoreDiffDisplay})${index === 0 ? ' - <b>Best Solution</b>': ''}` +
|
| 183 |
-
" </label>" +
|
| 184 |
-
"</div>";
|
| 185 |
-
});
|
| 186 |
-
|
| 187 |
-
visitModalContent.append(visitOptions);
|
| 188 |
-
|
| 189 |
-
const visitModalFooter = $("#newVisitModalFooter");
|
| 190 |
-
visitModalFooter.children().remove();
|
| 191 |
-
visitModalFooter.append("<button id='applyRecommendationButton' type='button' class='btn btn-success'><i class='fas fa-check'></i> Accept</button>");
|
| 192 |
-
$("#applyRecommendationButton").click(_ => applyRecommendationModal(recommendations));
|
| 193 |
-
}).fail(function (xhr, ajaxOptions, thrownError) {
|
| 194 |
-
showError("Recommendations request failed.", xhr);
|
| 195 |
-
$('#newVisitModal').modal('hide');
|
| 196 |
-
});
|
| 197 |
-
}
|
| 198 |
-
|
| 199 |
-
function applyRecommendation(solution, visitId, vehicleId, index, endpointPath) {
|
| 200 |
-
$.post(endpointPath, JSON.stringify({solution, visitId, vehicleId, index}), function (updatedSolution) {
|
| 201 |
-
updateSolutionWithNewVisit(updatedSolution);
|
| 202 |
-
}).fail(function (xhr, ajaxOptions, thrownError) {
|
| 203 |
-
showError("Apply recommendation request failed.", xhr);
|
| 204 |
-
$('#newVisitModal').modal('hide');
|
| 205 |
-
});
|
| 206 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/score-analysis.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
| 1 |
-
function analyzeScore(solution, endpointPath) {
|
| 2 |
-
new bootstrap.Modal("#scoreAnalysisModal").show()
|
| 3 |
-
const scoreAnalysisModalContent = $("#scoreAnalysisModalContent");
|
| 4 |
-
scoreAnalysisModalContent.children().remove();
|
| 5 |
-
scoreAnalysisModalContent.text("");
|
| 6 |
-
|
| 7 |
-
if (solution.score == null) {
|
| 8 |
-
scoreAnalysisModalContent.text("Score not ready for analysis, try to run the solver first or wait until it advances.");
|
| 9 |
-
} else {
|
| 10 |
-
visualizeScoreAnalysis(scoreAnalysisModalContent, solution, endpointPath)
|
| 11 |
-
}
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
function visualizeScoreAnalysis(scoreAnalysisModalContent, solution, endpointPath) {
|
| 15 |
-
$('#scoreAnalysisScoreLabel').text(`(${solution.score})`);
|
| 16 |
-
$.put(endpointPath, JSON.stringify(solution), function (scoreAnalysis) {
|
| 17 |
-
let constraints = scoreAnalysis.constraints;
|
| 18 |
-
constraints.sort(compareConstraintsBySeverity);
|
| 19 |
-
constraints.map(addDerivedScoreAttributes);
|
| 20 |
-
scoreAnalysis.constraints = constraints;
|
| 21 |
-
|
| 22 |
-
const analysisTable = $(`<table class="table"/>`).css({textAlign: 'center'});
|
| 23 |
-
const analysisTHead = $(`<thead/>`).append($(`<tr/>`)
|
| 24 |
-
.append($(`<th></th>`))
|
| 25 |
-
.append($(`<th>Constraint</th>`).css({textAlign: 'left'}))
|
| 26 |
-
.append($(`<th>Type</th>`))
|
| 27 |
-
.append($(`<th># Matches</th>`))
|
| 28 |
-
.append($(`<th>Weight</th>`))
|
| 29 |
-
.append($(`<th>Score</th>`))
|
| 30 |
-
.append($(`<th></th>`)));
|
| 31 |
-
analysisTable.append(analysisTHead);
|
| 32 |
-
const analysisTBody = $(`<tbody/>`)
|
| 33 |
-
$.each(scoreAnalysis.constraints, function (index, constraintAnalysis) {
|
| 34 |
-
visualizeConstraintAnalysis(analysisTBody, index, constraintAnalysis)
|
| 35 |
-
});
|
| 36 |
-
analysisTable.append(analysisTBody);
|
| 37 |
-
scoreAnalysisModalContent.append(analysisTable);
|
| 38 |
-
}).fail(function (xhr, ajaxOptions, thrownError) {
|
| 39 |
-
showError("Score analysis failed.", xhr);
|
| 40 |
-
},
|
| 41 |
-
"text");
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
function compareConstraintsBySeverity(a, b) {
|
| 45 |
-
let aComponents = getScoreComponents(a.score), bComponents = getScoreComponents(b.score);
|
| 46 |
-
if (aComponents.hard < 0 && bComponents.hard > 0) return -1;
|
| 47 |
-
if (aComponents.hard > 0 && bComponents.soft < 0) return 1;
|
| 48 |
-
if (Math.abs(aComponents.hard) > Math.abs(bComponents.hard)) {
|
| 49 |
-
return -1;
|
| 50 |
-
} else {
|
| 51 |
-
if (aComponents.medium < 0 && bComponents.medium > 0) return -1;
|
| 52 |
-
if (aComponents.medium > 0 && bComponents.medium < 0) return 1;
|
| 53 |
-
if (Math.abs(aComponents.medium) > Math.abs(bComponents.medium)) {
|
| 54 |
-
return -1;
|
| 55 |
-
} else {
|
| 56 |
-
if (aComponents.soft < 0 && bComponents.soft > 0) return -1;
|
| 57 |
-
if (aComponents.soft > 0 && bComponents.soft < 0) return 1;
|
| 58 |
-
|
| 59 |
-
return Math.abs(bComponents.soft) - Math.abs(aComponents.soft);
|
| 60 |
-
}
|
| 61 |
-
}
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
function addDerivedScoreAttributes(constraint) {
|
| 65 |
-
let components = getScoreComponents(constraint.weight);
|
| 66 |
-
constraint.type = components.hard != 0 ? 'hard' : (components.medium != 0 ? 'medium' : 'soft');
|
| 67 |
-
constraint.weight = components[constraint.type];
|
| 68 |
-
let scores = getScoreComponents(constraint.score);
|
| 69 |
-
constraint.implicitScore = scores.hard != 0 ? scores.hard : (scores.medium != 0 ? scores.medium : scores.soft);
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
function getScoreComponents(score) {
|
| 73 |
-
let components = {hard: 0, medium: 0, soft: 0};
|
| 74 |
-
|
| 75 |
-
$.each([...score.matchAll(/(-?[0-9]+)(hard|medium|soft)/g)], function (i, parts) {
|
| 76 |
-
components[parts[2]] = parseInt(parts[1], 10);
|
| 77 |
-
});
|
| 78 |
-
|
| 79 |
-
return components;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
function visualizeConstraintAnalysis(analysisTBody, constraintIndex, constraintAnalysis, recommendation = false, recommendationIndex = null) {
|
| 83 |
-
let icon = constraintAnalysis.type == "hard" && constraintAnalysis.implicitScore < 0 ? '<span class="fas fa-exclamation-triangle" style="color: red"></span>' : '';
|
| 84 |
-
if (!icon) icon = constraintAnalysis.weight < 0 && constraintAnalysis.matches.length == 0 ? '<span class="fas fa-check-circle" style="color: green"></span>' : '';
|
| 85 |
-
|
| 86 |
-
let row = $(`<tr/>`);
|
| 87 |
-
row.append($(`<td/>`).html(icon))
|
| 88 |
-
.append($(`<td/>`).text(constraintAnalysis.name).css({textAlign: 'left'}))
|
| 89 |
-
.append($(`<td/>`).text(constraintAnalysis.type))
|
| 90 |
-
.append($(`<td/>`).html(`<b>${constraintAnalysis.matches.length}</b>`))
|
| 91 |
-
.append($(`<td/>`).text(constraintAnalysis.weight))
|
| 92 |
-
.append($(`<td/>`).text(recommendation ? constraintAnalysis.score : constraintAnalysis.implicitScore));
|
| 93 |
-
|
| 94 |
-
analysisTBody.append(row);
|
| 95 |
-
row.append($(`<td/>`));
|
| 96 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/webjars/solverforge/css/solverforge-webui.css
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
:root {
|
| 2 |
-
/* Keep in sync with .navbar height on a large screen. */
|
| 3 |
-
--ts-navbar-height: 109px;
|
| 4 |
-
|
| 5 |
-
--ts-green-1-rgb: #10b981;
|
| 6 |
-
--ts-green-2-rgb: #059669;
|
| 7 |
-
--ts-violet-1-rgb: #3E00FF;
|
| 8 |
-
--ts-violet-2-rgb: #3423A6;
|
| 9 |
-
--ts-violet-3-rgb: #2E1760;
|
| 10 |
-
--ts-violet-4-rgb: #200F4F;
|
| 11 |
-
--ts-violet-5-rgb: #000000; /* TODO FIXME */
|
| 12 |
-
--ts-violet-dark-1-rgb: #b6adfd;
|
| 13 |
-
--ts-violet-dark-2-rgb: #c1bbfd;
|
| 14 |
-
--ts-gray-rgb: #666666;
|
| 15 |
-
--ts-white-rgb: #FFFFFF;
|
| 16 |
-
--ts-light-rgb: #F2F2F2;
|
| 17 |
-
--ts-gray-border: #c5c5c5;
|
| 18 |
-
|
| 19 |
-
--tf-light-rgb-transparent: rgb(242,242,242,0.5); /* #F2F2F2 = rgb(242,242,242) */
|
| 20 |
-
--bs-body-bg: var(--ts-light-rgb); /* link to html bg */
|
| 21 |
-
--bs-link-color: var(--ts-violet-1-rgb);
|
| 22 |
-
--bs-link-hover-color: var(--ts-violet-2-rgb);
|
| 23 |
-
|
| 24 |
-
--bs-navbar-color: var(--ts-white-rgb);
|
| 25 |
-
--bs-navbar-hover-color: var(--ts-white-rgb);
|
| 26 |
-
--bs-nav-link-font-size: 18px;
|
| 27 |
-
--bs-nav-link-font-weight: 400;
|
| 28 |
-
--bs-nav-link-color: var(--ts-white-rgb);
|
| 29 |
-
--ts-nav-link-hover-border-color: var(--ts-violet-1-rgb);
|
| 30 |
-
}
|
| 31 |
-
.btn {
|
| 32 |
-
--bs-btn-border-radius: 1.5rem;
|
| 33 |
-
}
|
| 34 |
-
.btn-primary {
|
| 35 |
-
--bs-btn-bg: var(--ts-violet-1-rgb);
|
| 36 |
-
--bs-btn-border-color: var(--ts-violet-1-rgb);
|
| 37 |
-
--bs-btn-hover-bg: var(--ts-violet-2-rgb);
|
| 38 |
-
--bs-btn-hover-border-color: var(--ts-violet-2-rgb);
|
| 39 |
-
--bs-btn-active-bg: var(--ts-violet-2-rgb);
|
| 40 |
-
--bs-btn-active-border-bg: var(--ts-violet-2-rgb);
|
| 41 |
-
--bs-btn-disabled-bg: var(--ts-violet-1-rgb);
|
| 42 |
-
--bs-btn-disabled-border-color: var(--ts-violet-1-rgb);
|
| 43 |
-
}
|
| 44 |
-
.btn-outline-primary {
|
| 45 |
-
--bs-btn-color: var(--ts-violet-1-rgb);
|
| 46 |
-
--bs-btn-border-color: var(--ts-violet-1-rgb);
|
| 47 |
-
--bs-btn-hover-bg: var(--ts-violet-1-rgb);
|
| 48 |
-
--bs-btn-hover-border-color: var(--ts-violet-1-rgb);
|
| 49 |
-
--bs-btn-active-bg: var(--ts-violet-1-rgb);
|
| 50 |
-
--bs-btn-active-border-color: var(--ts-violet-1-rgb);
|
| 51 |
-
--bs-btn-disabled-color: var(--ts-violet-1-rgb);
|
| 52 |
-
--bs-btn-disabled-border-color: var(--ts-violet-1-rgb);
|
| 53 |
-
}
|
| 54 |
-
.navbar-dark {
|
| 55 |
-
--bs-link-color: var(--ts-violet-dark-1-rgb);
|
| 56 |
-
--bs-link-hover-color: var(--ts-violet-dark-2-rgb);
|
| 57 |
-
--bs-navbar-color: var(--ts-white-rgb);
|
| 58 |
-
--bs-navbar-hover-color: var(--ts-white-rgb);
|
| 59 |
-
}
|
| 60 |
-
.nav-pills {
|
| 61 |
-
--bs-nav-pills-link-active-bg: var(--ts-green-1-rgb);
|
| 62 |
-
}
|
| 63 |
-
.nav-pills .nav-link:hover {
|
| 64 |
-
color: var(--ts-green-1-rgb);
|
| 65 |
-
}
|
| 66 |
-
.nav-pills .nav-link.active:hover {
|
| 67 |
-
color: var(--ts-white-rgb);
|
| 68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/webjars/solverforge/img/solverforge-favicon.svg
DELETED
static/webjars/solverforge/img/solverforge-horizontal-white.svg
DELETED
static/webjars/solverforge/img/solverforge-horizontal.svg
DELETED
static/webjars/solverforge/img/solverforge-logo-stacked.svg
DELETED
static/webjars/solverforge/js/solverforge-webui.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
| 1 |
-
function replaceSolverForgeAutoHeaderFooter() {
|
| 2 |
-
const solverforgeHeader = $("header#solverforge-auto-header");
|
| 3 |
-
if (solverforgeHeader != null) {
|
| 4 |
-
solverforgeHeader.addClass("bg-black")
|
| 5 |
-
solverforgeHeader.append(
|
| 6 |
-
$(`<div class="container-fluid">
|
| 7 |
-
<nav class="navbar sticky-top navbar-expand-lg navbar-dark shadow mb-3">
|
| 8 |
-
<a class="navbar-brand" href="https://www.solverforge.org">
|
| 9 |
-
<img src="/solverforge/img/solverforge-horizontal-white.svg" alt="SolverForge logo" width="200">
|
| 10 |
-
</a>
|
| 11 |
-
</nav>
|
| 12 |
-
</div>`));
|
| 13 |
-
}
|
| 14 |
-
const solverforgeFooter = $("footer#solverforge-auto-footer");
|
| 15 |
-
if (solverforgeFooter != null) {
|
| 16 |
-
solverforgeFooter.append(
|
| 17 |
-
$(`<footer class="bg-black text-white-50">
|
| 18 |
-
<div class="container">
|
| 19 |
-
<div class="hstack gap-3 p-4">
|
| 20 |
-
<div class="ms-auto"><a class="text-white" href="https://www.solverforge.org">SolverForge</a></div>
|
| 21 |
-
<div class="vr"></div>
|
| 22 |
-
<div><a class="text-white" href="https://www.solverforge.org/docs">Documentation</a></div>
|
| 23 |
-
<div class="vr"></div>
|
| 24 |
-
<div><a class="text-white" href="https://github.com/SolverForge/solverforge-legacy">Code</a></div>
|
| 25 |
-
<div class="vr"></div>
|
| 26 |
-
<div class="me-auto"><a class="text-white" href="mailto:info@solverforge.org">Support</a></div>
|
| 27 |
-
</div>
|
| 28 |
-
</div>
|
| 29 |
-
<div id="applicationInfo" class="container text-center"></div>
|
| 30 |
-
</footer>`));
|
| 31 |
-
|
| 32 |
-
applicationInfo();
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
function showSimpleError(title) {
|
| 38 |
-
const notification = $(`<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="min-width: 50rem"/>`)
|
| 39 |
-
.append($(`<div class="toast-header bg-danger">
|
| 40 |
-
<strong class="me-auto text-dark">Error</strong>
|
| 41 |
-
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
| 42 |
-
</div>`))
|
| 43 |
-
.append($(`<div class="toast-body"/>`)
|
| 44 |
-
.append($(`<p/>`).text(title))
|
| 45 |
-
);
|
| 46 |
-
$("#notificationPanel").append(notification);
|
| 47 |
-
notification.toast({delay: 30000});
|
| 48 |
-
notification.toast('show');
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
function showError(title, xhr) {
|
| 52 |
-
var serverErrorMessage = !xhr.responseJSON ? `${xhr.status}: ${xhr.statusText}` : xhr.responseJSON.message;
|
| 53 |
-
var serverErrorCode = !xhr.responseJSON ? `unknown` : xhr.responseJSON.code;
|
| 54 |
-
var serverErrorId = !xhr.responseJSON ? `----` : xhr.responseJSON.id;
|
| 55 |
-
var serverErrorDetails = !xhr.responseJSON ? `no details provided` : xhr.responseJSON.details;
|
| 56 |
-
|
| 57 |
-
if (xhr.responseJSON && !serverErrorMessage) {
|
| 58 |
-
serverErrorMessage = JSON.stringify(xhr.responseJSON);
|
| 59 |
-
serverErrorCode = xhr.statusText + '(' + xhr.status + ')';
|
| 60 |
-
serverErrorId = `----`;
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
console.error(title + "\n" + serverErrorMessage + " : " + serverErrorDetails);
|
| 64 |
-
const notification = $(`<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="min-width: 50rem"/>`)
|
| 65 |
-
.append($(`<div class="toast-header bg-danger">
|
| 66 |
-
<strong class="me-auto text-dark">Error</strong>
|
| 67 |
-
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
| 68 |
-
</div>`))
|
| 69 |
-
.append($(`<div class="toast-body"/>`)
|
| 70 |
-
.append($(`<p/>`).text(title))
|
| 71 |
-
.append($(`<pre/>`)
|
| 72 |
-
.append($(`<code/>`).text(serverErrorMessage + "\n\nCode: " + serverErrorCode + "\nError id: " + serverErrorId))
|
| 73 |
-
)
|
| 74 |
-
);
|
| 75 |
-
$("#notificationPanel").append(notification);
|
| 76 |
-
notification.toast({delay: 30000});
|
| 77 |
-
notification.toast('show');
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
// ****************************************************************************
|
| 81 |
-
// Application info
|
| 82 |
-
// ****************************************************************************
|
| 83 |
-
|
| 84 |
-
function applicationInfo() {
|
| 85 |
-
$.getJSON("info", function (info) {
|
| 86 |
-
$("#applicationInfo").append("<small>" + info.application + " (version: " + info.version + ", built at: " + info.built + ")</small>");
|
| 87 |
-
}).fail(function (xhr, ajaxOptions, thrownError) {
|
| 88 |
-
console.warn("Unable to collect application information");
|
| 89 |
-
});
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
// ****************************************************************************
|
| 93 |
-
// TangoColorFactory
|
| 94 |
-
// ****************************************************************************
|
| 95 |
-
|
| 96 |
-
const SEQUENCE_1 = [0x8AE234, 0xFCE94F, 0x729FCF, 0xE9B96E, 0xAD7FA8];
|
| 97 |
-
const SEQUENCE_2 = [0x73D216, 0xEDD400, 0x3465A4, 0xC17D11, 0x75507B];
|
| 98 |
-
|
| 99 |
-
var colorMap = new Map;
|
| 100 |
-
var nextColorCount = 0;
|
| 101 |
-
|
| 102 |
-
function pickColor(object) {
|
| 103 |
-
let color = colorMap[object];
|
| 104 |
-
if (color !== undefined) {
|
| 105 |
-
return color;
|
| 106 |
-
}
|
| 107 |
-
color = nextColor();
|
| 108 |
-
colorMap[object] = color;
|
| 109 |
-
return color;
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
function nextColor() {
|
| 113 |
-
let color;
|
| 114 |
-
let colorIndex = nextColorCount % SEQUENCE_1.length;
|
| 115 |
-
let shadeIndex = Math.floor(nextColorCount / SEQUENCE_1.length);
|
| 116 |
-
if (shadeIndex === 0) {
|
| 117 |
-
color = SEQUENCE_1[colorIndex];
|
| 118 |
-
} else if (shadeIndex === 1) {
|
| 119 |
-
color = SEQUENCE_2[colorIndex];
|
| 120 |
-
} else {
|
| 121 |
-
shadeIndex -= 3;
|
| 122 |
-
let floorColor = SEQUENCE_2[colorIndex];
|
| 123 |
-
let ceilColor = SEQUENCE_1[colorIndex];
|
| 124 |
-
let base = Math.floor((shadeIndex / 2) + 1);
|
| 125 |
-
let divisor = 2;
|
| 126 |
-
while (base >= divisor) {
|
| 127 |
-
divisor *= 2;
|
| 128 |
-
}
|
| 129 |
-
base = (base * 2) - divisor + 1;
|
| 130 |
-
let shadePercentage = base / divisor;
|
| 131 |
-
color = buildPercentageColor(floorColor, ceilColor, shadePercentage);
|
| 132 |
-
}
|
| 133 |
-
nextColorCount++;
|
| 134 |
-
return "#" + color.toString(16);
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
-
function buildPercentageColor(floorColor, ceilColor, shadePercentage) {
|
| 138 |
-
let red = (floorColor & 0xFF0000) + Math.floor(shadePercentage * ((ceilColor & 0xFF0000) - (floorColor & 0xFF0000))) & 0xFF0000;
|
| 139 |
-
let green = (floorColor & 0x00FF00) + Math.floor(shadePercentage * ((ceilColor & 0x00FF00) - (floorColor & 0x00FF00))) & 0x00FF00;
|
| 140 |
-
let blue = (floorColor & 0x0000FF) + Math.floor(shadePercentage * ((ceilColor & 0x0000FF) - (floorColor & 0x0000FF))) & 0x0000FF;
|
| 141 |
-
return red | green | blue;
|
| 142 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/webjars/timefold/css/timefold-webui.css
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
:root {
|
| 2 |
-
/* Keep in sync with .navbar height on a large screen. */
|
| 3 |
-
--ts-navbar-height: 109px;
|
| 4 |
-
|
| 5 |
-
--ts-violet-1-rgb: #3E00FF;
|
| 6 |
-
--ts-violet-2-rgb: #3423A6;
|
| 7 |
-
--ts-violet-3-rgb: #2E1760;
|
| 8 |
-
--ts-violet-4-rgb: #200F4F;
|
| 9 |
-
--ts-violet-5-rgb: #000000; /* TODO FIXME */
|
| 10 |
-
--ts-violet-dark-1-rgb: #b6adfd;
|
| 11 |
-
--ts-violet-dark-2-rgb: #c1bbfd;
|
| 12 |
-
--ts-gray-rgb: #666666;
|
| 13 |
-
--ts-white-rgb: #FFFFFF;
|
| 14 |
-
--ts-light-rgb: #F2F2F2;
|
| 15 |
-
--ts-gray-border: #c5c5c5;
|
| 16 |
-
|
| 17 |
-
--tf-light-rgb-transparent: rgb(242,242,242,0.5); /* #F2F2F2 = rgb(242,242,242) */
|
| 18 |
-
--bs-body-bg: var(--ts-light-rgb); /* link to html bg */
|
| 19 |
-
--bs-link-color: var(--ts-violet-1-rgb);
|
| 20 |
-
--bs-link-hover-color: var(--ts-violet-2-rgb);
|
| 21 |
-
|
| 22 |
-
--bs-navbar-color: var(--ts-white-rgb);
|
| 23 |
-
--bs-navbar-hover-color: var(--ts-white-rgb);
|
| 24 |
-
--bs-nav-link-font-size: 18px;
|
| 25 |
-
--bs-nav-link-font-weight: 400;
|
| 26 |
-
--bs-nav-link-color: var(--ts-white-rgb);
|
| 27 |
-
--ts-nav-link-hover-border-color: var(--ts-violet-1-rgb);
|
| 28 |
-
}
|
| 29 |
-
.btn {
|
| 30 |
-
--bs-btn-border-radius: 1.5rem;
|
| 31 |
-
}
|
| 32 |
-
.btn-primary {
|
| 33 |
-
--bs-btn-bg: var(--ts-violet-1-rgb);
|
| 34 |
-
--bs-btn-border-color: var(--ts-violet-1-rgb);
|
| 35 |
-
--bs-btn-hover-bg: var(--ts-violet-2-rgb);
|
| 36 |
-
--bs-btn-hover-border-color: var(--ts-violet-2-rgb);
|
| 37 |
-
--bs-btn-active-bg: var(--ts-violet-2-rgb);
|
| 38 |
-
--bs-btn-active-border-bg: var(--ts-violet-2-rgb);
|
| 39 |
-
--bs-btn-disabled-bg: var(--ts-violet-1-rgb);
|
| 40 |
-
--bs-btn-disabled-border-color: var(--ts-violet-1-rgb);
|
| 41 |
-
}
|
| 42 |
-
.btn-outline-primary {
|
| 43 |
-
--bs-btn-color: var(--ts-violet-1-rgb);
|
| 44 |
-
--bs-btn-border-color: var(--ts-violet-1-rgb);
|
| 45 |
-
--bs-btn-hover-bg: var(--ts-violet-1-rgb);
|
| 46 |
-
--bs-btn-hover-border-color: var(--ts-violet-1-rgb);
|
| 47 |
-
--bs-btn-active-bg: var(--ts-violet-1-rgb);
|
| 48 |
-
--bs-btn-active-border-color: var(--ts-violet-1-rgb);
|
| 49 |
-
--bs-btn-disabled-color: var(--ts-violet-1-rgb);
|
| 50 |
-
--bs-btn-disabled-border-color: var(--ts-violet-1-rgb);
|
| 51 |
-
}
|
| 52 |
-
.navbar-dark {
|
| 53 |
-
--bs-link-color: var(--ts-violet-dark-1-rgb);
|
| 54 |
-
--bs-link-hover-color: var(--ts-violet-dark-2-rgb);
|
| 55 |
-
--bs-navbar-color: var(--ts-white-rgb);
|
| 56 |
-
--bs-navbar-hover-color: var(--ts-white-rgb);
|
| 57 |
-
}
|
| 58 |
-
.nav-pills {
|
| 59 |
-
--bs-nav-pills-link-active-bg: var(--ts-violet-1-rgb);
|
| 60 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/webjars/timefold/img/timefold-favicon.svg
DELETED
static/webjars/timefold/img/timefold-logo-horizontal-negative.svg
DELETED
static/webjars/timefold/img/timefold-logo-horizontal-positive.svg
DELETED
static/webjars/timefold/img/timefold-logo-stacked-positive.svg
DELETED
static/webjars/timefold/js/timefold-webui.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
| 1 |
-
function replaceTimefoldAutoHeaderFooter() {
|
| 2 |
-
const timefoldHeader = $("header#timefold-auto-header");
|
| 3 |
-
if (timefoldHeader != null) {
|
| 4 |
-
timefoldHeader.addClass("bg-black")
|
| 5 |
-
timefoldHeader.append(
|
| 6 |
-
$(`<div class="container-fluid">
|
| 7 |
-
<nav class="navbar sticky-top navbar-expand-lg navbar-dark shadow mb-3">
|
| 8 |
-
<a class="navbar-brand" href="https://timefold.ai">
|
| 9 |
-
<img src="/timefold/img/timefold-logo-horizontal-negative.svg" alt="Timefold logo" width="200">
|
| 10 |
-
</a>
|
| 11 |
-
</nav>
|
| 12 |
-
</div>`));
|
| 13 |
-
}
|
| 14 |
-
const timefoldFooter = $("footer#timefold-auto-footer");
|
| 15 |
-
if (timefoldFooter != null) {
|
| 16 |
-
timefoldFooter.append(
|
| 17 |
-
$(`<footer class="bg-black text-white-50">
|
| 18 |
-
<div class="container">
|
| 19 |
-
<div class="hstack gap-3 p-4">
|
| 20 |
-
<div class="ms-auto"><a class="text-white" href="https://timefold.ai">Timefold</a></div>
|
| 21 |
-
<div class="vr"></div>
|
| 22 |
-
<div><a class="text-white" href="https://timefold.ai/docs">Documentation</a></div>
|
| 23 |
-
<div class="vr"></div>
|
| 24 |
-
<div><a class="text-white" href="https://github.com/TimefoldAI/timefold-solver-python">Code</a></div>
|
| 25 |
-
<div class="vr"></div>
|
| 26 |
-
<div class="me-auto"><a class="text-white" href="https://timefold.ai/product/support/">Support</a></div>
|
| 27 |
-
</div>
|
| 28 |
-
</div>
|
| 29 |
-
<div id="applicationInfo" class="container text-center"></div>
|
| 30 |
-
</footer>`));
|
| 31 |
-
|
| 32 |
-
applicationInfo();
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
function showSimpleError(title) {
|
| 38 |
-
const notification = $(`<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="min-width: 50rem"/>`)
|
| 39 |
-
.append($(`<div class="toast-header bg-danger">
|
| 40 |
-
<strong class="me-auto text-dark">Error</strong>
|
| 41 |
-
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
| 42 |
-
</div>`))
|
| 43 |
-
.append($(`<div class="toast-body"/>`)
|
| 44 |
-
.append($(`<p/>`).text(title))
|
| 45 |
-
);
|
| 46 |
-
$("#notificationPanel").append(notification);
|
| 47 |
-
notification.toast({delay: 30000});
|
| 48 |
-
notification.toast('show');
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
function showError(title, xhr) {
|
| 52 |
-
var serverErrorMessage = !xhr.responseJSON ? `${xhr.status}: ${xhr.statusText}` : xhr.responseJSON.message;
|
| 53 |
-
var serverErrorCode = !xhr.responseJSON ? `unknown` : xhr.responseJSON.code;
|
| 54 |
-
var serverErrorId = !xhr.responseJSON ? `----` : xhr.responseJSON.id;
|
| 55 |
-
var serverErrorDetails = !xhr.responseJSON ? `no details provided` : xhr.responseJSON.details;
|
| 56 |
-
|
| 57 |
-
if (xhr.responseJSON && !serverErrorMessage) {
|
| 58 |
-
serverErrorMessage = JSON.stringify(xhr.responseJSON);
|
| 59 |
-
serverErrorCode = xhr.statusText + '(' + xhr.status + ')';
|
| 60 |
-
serverErrorId = `----`;
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
console.error(title + "\n" + serverErrorMessage + " : " + serverErrorDetails);
|
| 64 |
-
const notification = $(`<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="min-width: 50rem"/>`)
|
| 65 |
-
.append($(`<div class="toast-header bg-danger">
|
| 66 |
-
<strong class="me-auto text-dark">Error</strong>
|
| 67 |
-
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
| 68 |
-
</div>`))
|
| 69 |
-
.append($(`<div class="toast-body"/>`)
|
| 70 |
-
.append($(`<p/>`).text(title))
|
| 71 |
-
.append($(`<pre/>`)
|
| 72 |
-
.append($(`<code/>`).text(serverErrorMessage + "\n\nCode: " + serverErrorCode + "\nError id: " + serverErrorId))
|
| 73 |
-
)
|
| 74 |
-
);
|
| 75 |
-
$("#notificationPanel").append(notification);
|
| 76 |
-
notification.toast({delay: 30000});
|
| 77 |
-
notification.toast('show');
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
// ****************************************************************************
|
| 81 |
-
// Application info
|
| 82 |
-
// ****************************************************************************
|
| 83 |
-
|
| 84 |
-
function applicationInfo() {
|
| 85 |
-
$.getJSON("info", function (info) {
|
| 86 |
-
$("#applicationInfo").append("<small>" + info.application + " (version: " + info.version + ", built at: " + info.built + ")</small>");
|
| 87 |
-
}).fail(function (xhr, ajaxOptions, thrownError) {
|
| 88 |
-
console.warn("Unable to collect application information");
|
| 89 |
-
});
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
// ****************************************************************************
|
| 93 |
-
// TangoColorFactory
|
| 94 |
-
// ****************************************************************************
|
| 95 |
-
|
| 96 |
-
const SEQUENCE_1 = [0x8AE234, 0xFCE94F, 0x729FCF, 0xE9B96E, 0xAD7FA8];
|
| 97 |
-
const SEQUENCE_2 = [0x73D216, 0xEDD400, 0x3465A4, 0xC17D11, 0x75507B];
|
| 98 |
-
|
| 99 |
-
var colorMap = new Map;
|
| 100 |
-
var nextColorCount = 0;
|
| 101 |
-
|
| 102 |
-
function pickColor(object) {
|
| 103 |
-
let color = colorMap[object];
|
| 104 |
-
if (color !== undefined) {
|
| 105 |
-
return color;
|
| 106 |
-
}
|
| 107 |
-
color = nextColor();
|
| 108 |
-
colorMap[object] = color;
|
| 109 |
-
return color;
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
function nextColor() {
|
| 113 |
-
let color;
|
| 114 |
-
let colorIndex = nextColorCount % SEQUENCE_1.length;
|
| 115 |
-
let shadeIndex = Math.floor(nextColorCount / SEQUENCE_1.length);
|
| 116 |
-
if (shadeIndex === 0) {
|
| 117 |
-
color = SEQUENCE_1[colorIndex];
|
| 118 |
-
} else if (shadeIndex === 1) {
|
| 119 |
-
color = SEQUENCE_2[colorIndex];
|
| 120 |
-
} else {
|
| 121 |
-
shadeIndex -= 3;
|
| 122 |
-
let floorColor = SEQUENCE_2[colorIndex];
|
| 123 |
-
let ceilColor = SEQUENCE_1[colorIndex];
|
| 124 |
-
let base = Math.floor((shadeIndex / 2) + 1);
|
| 125 |
-
let divisor = 2;
|
| 126 |
-
while (base >= divisor) {
|
| 127 |
-
divisor *= 2;
|
| 128 |
-
}
|
| 129 |
-
base = (base * 2) - divisor + 1;
|
| 130 |
-
let shadePercentage = base / divisor;
|
| 131 |
-
color = buildPercentageColor(floorColor, ceilColor, shadePercentage);
|
| 132 |
-
}
|
| 133 |
-
nextColorCount++;
|
| 134 |
-
return "#" + color.toString(16);
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
-
function buildPercentageColor(floorColor, ceilColor, shadePercentage) {
|
| 138 |
-
let red = (floorColor & 0xFF0000) + Math.floor(shadePercentage * ((ceilColor & 0xFF0000) - (floorColor & 0xFF0000))) & 0xFF0000;
|
| 139 |
-
let green = (floorColor & 0x00FF00) + Math.floor(shadePercentage * ((ceilColor & 0x00FF00) - (floorColor & 0x00FF00))) & 0x00FF00;
|
| 140 |
-
let blue = (floorColor & 0x0000FF) + Math.floor(shadePercentage * ((ceilColor & 0x0000FF) - (floorColor & 0x0000FF))) & 0x0000FF;
|
| 141 |
-
return red | green | blue;
|
| 142 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|