165 lines
3.5 KiB
HTML
165 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta http-equiv="Content-Security-Policy" content="connect-src https://nec.clients.septem.pro;">
|
||
<title>SEPTEM Cargo Analytics</title>
|
||
|
||
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
|
||
|
||
<style>
|
||
|
||
body {
|
||
font-family: Segoe UI, sans-serif;
|
||
padding: 20px;
|
||
text-align: center;
|
||
background: #f7f7f7;
|
||
}
|
||
|
||
h3 {
|
||
margin-top: 0;
|
||
}
|
||
|
||
.status {
|
||
margin-top: 15px;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.link {
|
||
word-break: break-all;
|
||
background: #e0e0e0;
|
||
padding: 10px;
|
||
border-radius: 6px;
|
||
margin-top: 10px;
|
||
}
|
||
|
||
.reset-btn {
|
||
margin-top: 25px;
|
||
padding: 12px 22px;
|
||
font-size: 15px;
|
||
background: #0078d4;
|
||
color: white;
|
||
border: none;
|
||
border-radius: 6px;
|
||
cursor: pointer;
|
||
transition: all 0.2s;
|
||
}
|
||
|
||
.reset-btn:hover {
|
||
background: #005fa3;
|
||
}
|
||
|
||
.reset-btn:disabled {
|
||
background: #888;
|
||
cursor: not-allowed;
|
||
}
|
||
|
||
</style>
|
||
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<h3>🚚 SEPTEM Cargo Analytics</h3>
|
||
|
||
<div id="message"></div>
|
||
|
||
<div id="fallbackLink" class="link" style="display:none;"></div>
|
||
|
||
<button id="resetSession" class="reset-btn">
|
||
🔄 Начать новую сессию
|
||
</button>
|
||
|
||
<div id="resetStatus" class="status"></div>
|
||
|
||
<script>
|
||
|
||
const RESULT_URL = "https://nec.clients.septem.pro";
|
||
|
||
Office.onReady(function () {
|
||
|
||
const resetBtn = document.getElementById("resetSession");
|
||
const statusText = document.getElementById("resetStatus");
|
||
|
||
const urlParams = new URLSearchParams(window.location.search);
|
||
const sessionId = urlParams.get('session_id');
|
||
|
||
if (sessionId) {
|
||
|
||
const webUiUrl = `${RESULT_URL}?session_id=${sessionId}`;
|
||
|
||
document.getElementById('message').innerText =
|
||
"Анализ завершён. Открываю браузер...";
|
||
|
||
const newWindow = window.open(webUiUrl, '_blank');
|
||
|
||
if (!newWindow) {
|
||
|
||
document.getElementById('fallbackLink').innerHTML =
|
||
`Если браузер не открылся, <a href="${webUiUrl}" target="_blank">нажмите здесь</a>`;
|
||
|
||
document.getElementById('fallbackLink').style.display = 'block';
|
||
|
||
} else {
|
||
|
||
setTimeout(() => {
|
||
Office.context.ui.close();
|
||
}, 3000);
|
||
|
||
}
|
||
|
||
} else {
|
||
|
||
document.getElementById('message').innerText =
|
||
"Нет данных для анализа.";
|
||
|
||
}
|
||
|
||
/* ----------------------------
|
||
СБРОС СЕССИИ
|
||
---------------------------- */
|
||
|
||
resetBtn.addEventListener("click", function () {
|
||
|
||
resetBtn.disabled = true;
|
||
resetBtn.innerText = "Сбрасываю сессию...";
|
||
|
||
Office.context.roamingSettings.set("cargoSessionId", null);
|
||
|
||
Office.context.roamingSettings.saveAsync(function (result) {
|
||
|
||
if (result.status === Office.AsyncResultStatus.Succeeded) {
|
||
|
||
statusText.innerText =
|
||
"✅ Сессия сброшена. Можно начать новый анализ.";
|
||
|
||
resetBtn.innerText = "✔ Готово";
|
||
|
||
setTimeout(() => {
|
||
Office.context.ui.close();
|
||
}, 2000);
|
||
|
||
}
|
||
|
||
else {
|
||
|
||
statusText.innerText =
|
||
"❌ Ошибка сброса сессии";
|
||
|
||
resetBtn.disabled = false;
|
||
resetBtn.innerText = "🔄 Попробовать снова";
|
||
|
||
}
|
||
|
||
});
|
||
|
||
});
|
||
|
||
});
|
||
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|