';
cable.cable_route_full.forEach((station, index) => {
- let style = { icon: 'fa-sitemap', cssClass: 'station-distributor', color: '#3388ff', typeLabel: 'Verteiler' };
+ let style = {icon: 'fa-sitemap', cssClass: 'station-distributor', color: '#3388ff', typeLabel: 'Verteiler'};
let badgeClass = 'badge-info';
if (station.type === 'pop') {
- style = { icon: 'fa-building', cssClass: 'station-pop', color: '#4caf50', typeLabel: 'POP' };
+ style = {icon: 'fa-building', cssClass: 'station-pop', color: '#4caf50', typeLabel: 'POP'};
badgeClass = 'badge-success';
} else if (station.object_type == 2) { // Schacht
- style = { icon: 'fa-archive', cssClass: 'station-manhole', color: '#ffa726', typeLabel: 'Schacht' };
+ style = {icon: 'fa-archive', cssClass: 'station-manhole', color: '#ffa726', typeLabel: 'Schacht'};
badgeClass = 'badge-warning';
}
@@ -1536,6 +1873,7 @@ function renderCableRouteSchema(cable) {
$station.popover('show');
});
}
+
function showFiberRouteMap(fiberId) {
const mapModalHtml = `
@@ -1575,7 +1913,7 @@ function showFiberRouteMap(fiberId) {
$.ajax({
url: linkGetFiberPath,
method: 'GET',
- data: { fiber_id: fiberId },
+ data: {fiber_id: fiberId},
dataType: 'json',
success: function (response) {
if (response.status === 'OK' && response.result.fiber) {
@@ -1626,8 +1964,7 @@ function findNearestBranchPoint(customerLat, customerLng, allSegments) {
type: 'branch_point'
};
}
- }
- else if (station.type === 'dispatcher' && (station.object_type == 1 || station.object_type == 2 || station.object_type === '1' || station.object_type === '2')) {
+ } else if (station.type === 'dispatcher' && (station.object_type == 1 || station.object_type == 2 || station.object_type === '1' || station.object_type === '2')) {
if (distance < minDispatcherDistance) {
minDispatcherDistance = distance;
nearestDispatcher = {
@@ -1644,8 +1981,7 @@ function findNearestBranchPoint(customerLat, customerLng, allSegments) {
});
if (nearestBranchPoint) {
return nearestBranchPoint;
- }
- else if (nearestDispatcher) {
+ } else if (nearestDispatcher) {
return nearestDispatcher;
}
return null;
@@ -1730,8 +2066,10 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
foundSourceFiber = candidates[0];
}
}
-
+ console.log(foundSourceFiber);
if (foundSourceFiber) {
+ console.log("✅ Gefundene Source-Faser (Rohdaten):", foundSourceFiber);
+ console.log("Verfügbare Keys:", Object.keys(foundSourceFiber));
const correctFiberNr = foundSourceFiber.fiber_nr_cable || foundSourceFiber.fiber_nr;
// console.log("🔧 Hauptkabel-Faser gefunden:", correctFiberNr, foundSourceFiber);
@@ -1744,21 +2082,22 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
bundle_color: foundSourceFiber.bundle_color || foundSourceFiber.bundle_color_name,
bundle_color_hex: foundSourceFiber.bundle_color_hex
};
+ console.log(branchSource);
}
}
}
- if (branchSource) {
- mainFiberNr = branchSource.fiber_nr_cable;
- mainFiberColor = branchSource.fiber_color;
- mainFiberColorHex = branchSource.fiber_color_hex;
- mainBundleNr = branchSource.bundle_nr;
- mainBundleColor = branchSource.bundle_color;
- mainBundleColorHex = branchSource.bundle_color_hex;
- // console.log("✅ Hauptkabel-Daten erfolgreich korrigiert auf Faser:", mainFiberNr);
- } else {
- // console.warn("⚠️ Konnte Quell-Faser nicht ermitteln (Fallback auf End-Faser).");
- }
+ if (branchSource) {
+ mainFiberNr = branchSource.fiber_nr_cable;
+ mainFiberColor = branchSource.fiber_color;
+ mainFiberColorHex = branchSource.fiber_color_hex;
+ mainBundleNr = branchSource.bundle_nr;
+ mainBundleColor = branchSource.bundle_color;
+ mainBundleColorHex = branchSource.bundle_color_hex;
+ // console.log("✅ Hauptkabel-Daten erfolgreich korrigiert auf Faser:", mainFiberNr);
+ } else {
+ // console.warn("⚠️ Konnte Quell-Faser nicht ermitteln (Fallback auf End-Faser).");
+ }
allSegments.push({
name: fiber.cable_info.description,
@@ -1927,6 +2266,7 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
// console.log(`${window.allBranchPoints.length} Abzweigpunkte aus Backend geladen`);
}
const allBounds = L.featureGroup();
+
function getBranchConnectionsAtStation(stationName, currentSegment, allSegs) {
const connections = [];
if (currentSegment.type === 'main' && currentSegment.branch_dropouts) {
@@ -2021,6 +2361,7 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
return connections;
}
+
const drawnStations = new Map();
allSegments.forEach((segment, segmentIndex) => {
@@ -2167,12 +2508,12 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
if (isBranchJunction && !existingStation.isBranchJunction) {
allBounds.removeLayer(existingStation.marker);
allBounds.addLayer(marker);
- drawnStations.set(stationKey, { marker, isBranchJunction });
+ drawnStations.set(stationKey, {marker, isBranchJunction});
} else {
}
} else {
allBounds.addLayer(marker);
- drawnStations.set(stationKey, { marker, isBranchJunction });
+ drawnStations.set(stationKey, {marker, isBranchJunction});
}
if (station.type === 'dispatcher' && station.object_type == 4) {
@@ -2784,7 +3125,7 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
customer_cable_spec: effectiveFiber.customer_cable_spec,
customer_fiber_range: effectiveFiber.customer_fiber_range
};
- customerGps = { lat: dropoutLat, lng: dropoutLng, fallback: true };
+ customerGps = {lat: dropoutLat, lng: dropoutLng, fallback: true};
}
if (customerInfo && customerGps) {
@@ -2961,7 +3302,12 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
allBounds.addLayer(fallbackLabelMarker);
const connectionMarker = L.circleMarker([connectionPoint.lat, connectionPoint.lng], {
- radius: 8, fillColor: '#FFD700', fillOpacity: 0.9, color: '#FF6B6B', weight: 3, opacity: 1
+ radius: 8,
+ fillColor: '#FFD700',
+ fillOpacity: 0.9,
+ color: '#FF6B6B',
+ weight: 3,
+ opacity: 1
}).bindPopup(`
Verbindungspunkt
@@ -3002,7 +3348,7 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
`;
const customerMarker = L.marker([customerLat, customerLng], {
- icon: L.MakiMarkers.icon({ icon: 'home', color: isFallback ? '#ffd700' : '#f0abab', size: 'm' })
+ icon: L.MakiMarkers.icon({icon: 'home', color: isFallback ? '#ffd700' : '#f0abab', size: 'm'})
}).bindPopup(customerPopup);
allBounds.addLayer(customerMarker);
@@ -3016,7 +3362,7 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
allBounds.addTo(map);
if (allBounds.getLayers().length > 0) {
- map.fitBounds(allBounds.getBounds(), { padding: [50, 50] });
+ map.fitBounds(allBounds.getBounds(), {padding: [50, 50]});
}
const MIN_ZOOM_FOR_STATION_LABELS = 15;
@@ -3046,7 +3392,7 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
if (shouldShowCables) {
if (!layer.getTooltip()) {
const labelClass = layer.cableLabelText.includes('Hausanschluss') ||
- layer.options.icon?.options?.className?.includes('customer')
+ layer.options.icon?.options?.className?.includes('customer')
? 'customer-cable-label'
: 'cable-segment-label';
@@ -3063,11 +3409,12 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
}
});
}
+
updateTooltipVisibility();
map.on('zoomend', updateTooltipVisibility);
- const legend = L.control({ position: 'bottomright' });
+ const legend = L.control({position: 'bottomright'});
legend.onAdd = function (map) {
const div = L.DomUtil.create('div', 'info legend');
div.style.backgroundColor = 'white';
@@ -3122,6 +3469,7 @@ function initializeFiberRouteMap(fiber, isLinework = false) {
}, 300);
}
+
function renderFiberPathSchema(fiber, allSegments) {
const schemaContainer = $('#fiber-route-schema');
if (!fiber || allSegments.length === 0) {
@@ -3370,12 +3718,10 @@ function renderFiberPathSchema(fiber, allSegments) {
if (isDuplicate && isSegmentChange) {
// console.log(`⏭️ Branch beginnt an ${station.name} → Station überspringen, aber ${segment.name}-Linie zeichnen`);
previousSegment = segment;
- }
- else if (isDuplicate) {
+ } else if (isDuplicate) {
// console.log(`⏭️ Skipping duplicate within segment: ${station.name}`);
return;
- }
- else {
+ } else {
// console.log(`📍 Drawing station ${station.name}: segment=${segment.name}, isDropout=${isDropoutPoint}`);
const stationInfo = getStationInfo(station, isDropoutPoint, segment, allSegments);
const showTransition = isDropoutPoint && isSegmentChange;
@@ -3579,8 +3925,8 @@ function renderFiberPathSchema(fiber, allSegments) {
});
}
-function renderFiberPathSchemaLinework(fiber, allSegments) {
- const schemaContainer = $('#fiber-route-schema');
+function renderFiberPathSchemaLinework(fiber, allSegments, targetContainer = null) {
+ const schemaContainer = targetContainer ? $(targetContainer) : $('#fiber-route-schema');
if (!fiber || allSegments.length === 0) {
schemaContainer.html('
Keine Daten verfügbar
');
@@ -3841,10 +4187,13 @@ function renderFiberPathSchemaLinework(fiber, allSegments) {
if (!lineColor) lineColor = '#FF0000';
- const lineClass = isBranchLine ? 'schema-line-dashed-horizontal' : 'schema-line-horizontal';
- const lineStyle = isBranchLine
+ const isDashed = nextNode.level > 0;
+
+ const lineClass = isDashed ? 'schema-line-dashed-horizontal' : 'schema-line-horizontal';
+ const lineStyle = isDashed
? `color: ${lineColor};`
: `background-color: ${lineColor}; height: 4px;`;
+ // ÄNDERUNG ENDE
html += `
@@ -3911,11 +4260,22 @@ function renderFiberPathSchemaLinework(fiber, allSegments) {
}
function getLineworkStationStyle(node) {
- if (node.type === 'pop') return { icon: 'fa-building', cssClass: 'station-pop', color: '#4caf50', typeLabel: 'POP' };
- if (node.object_type == 4) return { icon: 'fa-code-branch', cssClass: 'station-branch', color: '#9c27b0', typeLabel: 'Abzweig' };
- if (node.object_type == 2) return { icon: 'fa-archive', cssClass: 'station-manhole', color: '#ffa726', typeLabel: 'Schacht' };
- return { icon: 'fa-sitemap', cssClass: 'station-distributor', color: '#3388ff', typeLabel: 'Verteiler' };
+ if (node.type === 'pop') return {icon: 'fa-building', cssClass: 'station-pop', color: '#4caf50', typeLabel: 'POP'};
+ if (node.object_type == 4) return {
+ icon: 'fa-code-branch',
+ cssClass: 'station-branch',
+ color: '#9c27b0',
+ typeLabel: 'Abzweig'
+ };
+ if (node.object_type == 2) return {
+ icon: 'fa-archive',
+ cssClass: 'station-manhole',
+ color: '#ffa726',
+ typeLabel: 'Schacht'
+ };
+ return {icon: 'fa-sitemap', cssClass: 'station-distributor', color: '#3388ff', typeLabel: 'Verteiler'};
}
+
function getBranchColor(level) {
const colors = [
'#FF6B6B',
@@ -3936,6 +4296,7 @@ function hexToColorName(hex) {
'#9B59B6': 'Violett',
'#E91E63': 'Pink',
'#3388ff': 'Blau',
+ '#0070C0': 'Blau',
'#FF0000': 'Rot',
'#00FF00': 'Grün',
'#0000FF': 'Blau',
@@ -4005,6 +4366,7 @@ function findTargetFiberAtLevel(branchPath, targetLevel, currentLevel = 1) {
return null;
}
+
function findCableForCustomerConnection(customerLat, customerLng, cables) {
const tolerance = 0.00001;
@@ -4033,6 +4395,7 @@ function findCableForCustomerConnection(customerLat, customerLng, cables) {
return null;
}
+
$('body').on('click', '#toggle-fiber-view', function () {
const btn = $(this);
const cableName = btn.data('cable-name');
@@ -4052,7 +4415,7 @@ $('body').on('click', '#toggle-fiber-view', function () {
loadFiberPlanCableDetails(cableName, fiberStart, fiberEnd);
}
});
-$(document).ready(function() {
+$(document).ready(function () {
$('body').on('click', '#fiber-details-table .view-fiber-path', function (e) {
e.preventDefault();
e.stopPropagation();
@@ -4079,4 +4442,367 @@ $(document).ready(function() {
const cableName = $(this).data('cable-name');
showCableRouteMap(cableId, cableName);
});
-});
\ No newline at end of file
+});
+function openFiberSelectionModal(homeId) {
+ $('#fiberRouteMapModal').modal('show');
+ const modalHeader = $('#fiberRouteMapModal .modal-header');
+
+ // Container für Dropdown und Button erstellen
+ if ($('#fiber-select-container').length === 0) {
+ const controlsHtml = `
+
+
+
+
+
+
+ `;
+ modalHeader.find('.modal-title').after(controlsHtml);
+ }
+
+ // Spinner anzeigen
+ $('#fiber-route-map').html('
');
+ $('#fiber-route-schema').empty();
+
+ $.ajax({
+ url: linkGetAllFiberPathsForHome,
+ method: 'GET',
+ data: { home_id: homeId },
+ dataType: 'json',
+ success: function (response) {
+ if (response.status === 'OK' && response.result.paths && response.result.paths.length > 0) {
+ const paths = response.result.paths;
+ const count = paths.length;
+
+ modalHeader.find('.modal-title').html(`
+
${homeId}
+
${count} Fasern
+ `);
+
+ populateFiberDropdown(paths, homeId);
+
+ // --- KLICK-EVENT FÜR DEN "ALLE" BUTTON ---
+ $('#btn-show-all-details').off('click').on('click', function() {
+ renderAllDetailedSchemas(paths);
+ });
+
+ } else {
+ $('#fiber-route-map').html('
Keine Fasern gefunden.
');
+ }
+ },
+ error: function () {
+ $('#fiber-route-map').html('
Fehler beim Laden.
');
+ }
+ });
+}
+
+function populateFiberDropdown(paths, homeId) {
+ const selector = $('#fiber-path-selector');
+
+ // Falls Select2 schon existiert, zerstören um sauber neu zu bauen
+ if (selector.data('select2')) {
+ selector.select2('destroy');
+ }
+
+ selector.empty();
+
+ paths.forEach((path, index) => {
+ const f = path.fiber;
+
+ // Farben und Texte vorbereiten
+ const fHex = f.fiber_color_hex || '#cccccc';
+ const fName = f.fiber_color || '';
+ const bHex = f.bundle_color_hex || '#cccccc';
+ const bNr = f.bundle_nr || '';
+
+ // Wir speichern die Infos in Data-Attributen für den Formatter
+ const option = $('