Adb netzgebiet/add manual rimo import

This commit is contained in:
Luca Haid
2026-01-08 09:38:01 +00:00
parent 36c398126e
commit 6558caf2f3
3 changed files with 329 additions and 3 deletions
+138 -2
View File
@@ -133,6 +133,14 @@ const ADBNetzgebiet = {
</a>
</td>
<td class="col-actions">
<button
v-if="item.netzgebiet.source && item.netzgebiet.source.startsWith('rimo-')"
class="icon-btn"
@click.prevent="handleRimoImportClick(item)"
:title="getImportButtonTitle(item.netzgebiet.id)"
:disabled="getImportButtonDisabled(item.netzgebiet.id)">
<i class="fa-duotone" :class="getImportButtonIcon(item.netzgebiet.id)"></i>
</button>
<button class="icon-btn" @click.prevent="openEditModal(item)" title="Bearbeiten"><i class="fa-duotone fa-pen"></i></button>
<button class="icon-btn" @click.prevent="copyNetzgebiet(item)" title="Kopieren"><i class="fa-duotone fa-copy"></i></button>
<button class="icon-btn" @click.prevent="openHistoryModal(item)" title="Verlauf"><i class="fa-duotone fa-clock-rotate-left"></i></button>
@@ -274,6 +282,25 @@ const ADBNetzgebiet = {
</div>
</div>
</tt-dialog>
<!-- RIMO Import Log Modal -->
<tt-dialog :show="showRimoLogModal" :title="rimoLogTitle" size="large" @close="closeRimoLogModal">
<div v-if="!rimoLogContent && rimoLogStatus === 'running'" class="table-placeholder compact">
<i class="fa-duotone fa-spinner fa-spin"></i>
<span>Lade Log...</span>
</div>
<div v-else-if="!rimoLogContent" class="table-placeholder compact">
<i class="fa-duotone fa-file-lines"></i>
<span>Kein Log vorhanden.</span>
</div>
<pre v-else class="log-view" style="white-space: pre-wrap; word-break: break-all; max-height: 60vh; overflow-y: auto; background: #f5f5f5; padding: 10px; border-radius: 5px;">{{ rimoLogContent }}</pre>
<template #footer>
<div class="footer-status" style="margin-right: auto; font-size: 12px; color: #666;">
Status: <strong :style="{color: rimoLogStatus === 'running' ? 'blue' : (rimoLogStatus === 'cooldown' ? 'orange' : 'green')}">{{ rimoLogStatus }}</strong>
</div>
<button class="ghost-btn" @click="closeRimoLogModal">Schließen</button>
</template>
</tt-dialog>
</div>
`,
@@ -294,6 +321,16 @@ const ADBNetzgebiet = {
historyItems: [],
historyTitle: 'Verlauf',
expandedIds: {},
// RIMO Import
importStatus: {},
showRimoLogModal: false,
rimoLogContent: '',
rimoLogTitle: '',
rimoLogStatus: 'idle',
rimoLogInterval: null,
statusInterval: null,
freigabeLabels: { interest: 'Interest', provision: 'Provision', order: 'Order', reorder: 'Reorder' },
freigabeOptions: [
{ key: 'interest', label: 'Interest' },
@@ -367,12 +404,21 @@ const ADBNetzgebiet = {
filteredNetzgebiete() { if (this.currentPage > this.totalPages) this.currentPage = 1; }
},
async mounted() { await this.fetchNetzgebiete(); },
async mounted() {
await this.fetchNetzgebiete();
this.fetchImportStatus();
this.statusInterval = setInterval(this.fetchImportStatus, 15000); // Poll every 15s
},
beforeDestroy() {
clearInterval(this.statusInterval);
clearInterval(this.rimoLogInterval);
},
methods: {
formatConsentName(name) {
if (name && name.startsWith('Glasfaserprojekt')) {
return name.replace('Glasfaserprojekt', 'Glasfaserprojekt<br>');
return name.replace('Glasfaserprojekt', 'Glasfaserprojekt<br />');
}
return name;
},
@@ -476,6 +522,96 @@ const ADBNetzgebiet = {
} catch { window.notify?.('error', 'Verlauf konnte nicht geladen werden.'); }
finally { this.historyLoading = false; }
},
// RIMO Import Methods
async fetchImportStatus() {
const rimoIds = this.netzgebiete
.filter(item => item.netzgebiet.source && item.netzgebiet.source.startsWith('rimo-'))
.map(item => item.netzgebiet.id);
if (!rimoIds.length) return;
try {
const response = await axios.post(window.TT_CONFIG.GET_RIMO_IMPORT_STATUS_URL, { ids: rimoIds });
if (response.data.success) {
this.importStatus = response.data.data;
}
} catch (error) {
console.error("Could not fetch RIMO import statuses.", error);
}
},
handleRimoImportClick(item) {
const status = this.importStatus[item.netzgebiet.id]?.status || 'idle';
if (status === 'running') {
this.openRimoLogModal(item);
} else if (status === 'cooldown') {
const remaining = this.importStatus[item.netzgebiet.id]?.remaining || 0;
window.notify?.('info', `Bitte warten Sie noch ${Math.ceil(remaining / 60)} Minuten.`);
this.openRimoLogModal(item);
} else {
this.startRimoImport(item);
}
},
getImportButtonTitle(id) {
const status = this.importStatus[id]?.status || 'idle';
if (status === 'running') return 'Import-Log anzeigen';
if (status === 'cooldown') return 'Manueller RIMO-Import (Abkühlphase)';
return 'Manuellen RIMO-Import starten';
},
getImportButtonDisabled(id) {
const status = this.importStatus[id]?.status || 'idle';
return false; // Never truly disabled, just changes action
},
getImportButtonIcon(id) {
const status = this.importStatus[id]?.status || 'idle';
if (status === 'running') return 'fa-spinner fa-spin';
if (status === 'cooldown') return 'fa-hourglass-half';
return 'fa-rocket';
},
async startRimoImport(item) {
try {
const response = await axios.get(window.TT_CONFIG.START_RIMO_IMPORT_URL + '?id=' + item.netzgebiet.id);
if (response.data.success) {
window.notify?.('success', 'RIMO Import gestartet.');
this.importStatus[item.netzgebiet.id] = { status: 'running' };
this.openRimoLogModal(item);
} else {
window.notify?.('error', response.data.message || 'Import konnte nicht gestartet werden.');
}
} catch (error) {
window.notify?.('error', 'Fehler beim Starten des Imports.');
console.error(error);
}
},
openRimoLogModal(item) {
this.rimoLogTitle = `RIMO Import: ${item.netzgebiet.name}`;
this.showRimoLogModal = true;
this.fetchRimoLog(item); // initial fetch
this.rimoLogInterval = setInterval(() => this.fetchRimoLog(item), 3000);
},
closeRimoLogModal() {
this.showRimoLogModal = false;
clearInterval(this.rimoLogInterval);
this.rimoLogContent = '';
this.rimoLogTitle = '';
this.rimoLogStatus = 'idle';
},
async fetchRimoLog(item) {
try {
const response = await axios.get(window.TT_CONFIG.GET_RIMO_IMPORT_LOG_URL + '?id=' + item.netzgebiet.id);
if (response.data.success) {
this.rimoLogContent = response.data.data.log;
this.rimoLogStatus = response.data.data.status;
// If no longer running, stop polling
if (this.rimoLogStatus !== 'running') {
clearInterval(this.rimoLogInterval);
this.fetchImportStatus(); // refresh overall status
}
}
} catch (error) {
console.error('Could not fetch RIMO log.', error);
clearInterval(this.rimoLogInterval);
}
},
translateAction(action) { return { create: 'Erstellt', update: 'Geändert', delete: 'Gelöscht' }[action] || action; },
translateField(field) {
return { name: 'Name', extref: 'ExtRef', source: 'Quelle', source_id: 'Source ID',