chore: apply ruff formatting and fix whitespace issues
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -11,15 +11,15 @@
|
||||
<h2 class="text-2xl font-bold mt-4">Processing Authorization</h2>
|
||||
<p class="text-gray-600 mt-2">Please wait while we complete the OneDrive authorization process...</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex justify-center my-6">
|
||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="processing-message" class="text-center text-gray-700">
|
||||
<p>Exchanging authorization code for refresh token...</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="error-container" class="hidden mt-6">
|
||||
<div class="bg-red-50 border-l-4 border-red-400 p-4">
|
||||
<div class="flex">
|
||||
@@ -42,7 +42,7 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="success-container" class="hidden mt-6">
|
||||
<div class="rounded-md bg-green-50 p-4">
|
||||
<div class="flex">
|
||||
@@ -58,26 +58,26 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-6 p-4 bg-gray-100 rounded-md">
|
||||
<h3 class="font-medium text-lg mb-2">Configuration for Worker Nodes</h3>
|
||||
<p class="text-sm text-gray-600 mb-3">
|
||||
Copy these environment variables to configure all worker nodes:
|
||||
</p>
|
||||
|
||||
|
||||
<div class="relative">
|
||||
<pre id="env-vars" class="bg-gray-800 text-green-400 text-sm p-3 rounded overflow-x-auto"><code></code></pre>
|
||||
|
||||
|
||||
<button id="copy-env-vars" class="absolute top-2 right-2 bg-gray-700 hover:bg-gray-600 text-white text-xs py-1 px-2 rounded">
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="text-xs text-gray-500 mt-2">
|
||||
Add these variables to your .env file or environment configuration.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-4 text-center">
|
||||
<a href="/status" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
||||
Go to Status Page
|
||||
@@ -92,27 +92,27 @@
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const code = "{{ code }}";
|
||||
|
||||
|
||||
// Get credentials from session storage (these take precedence over server-provided values)
|
||||
const clientId = sessionStorage.getItem('onedrive_client_id') || "{{ client_id_value }}";
|
||||
const clientSecret = sessionStorage.getItem('onedrive_client_secret') || "{{ client_secret_value }}";
|
||||
const tenantId = sessionStorage.getItem('onedrive_tenant_id') || "{{ tenant_id }}" || "common";
|
||||
const folderPath = sessionStorage.getItem('onedrive_folder_path') || "";
|
||||
|
||||
|
||||
const redirectUri = window.location.origin + "/onedrive-callback";
|
||||
|
||||
|
||||
// Automatically exchange the code for a refresh token
|
||||
if (code) {
|
||||
if (!clientId || !clientSecret) {
|
||||
showError("Missing Client ID or Client Secret. Please go back to the setup page and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
exchangeCode(code, clientId, clientSecret, redirectUri, tenantId, folderPath);
|
||||
} else {
|
||||
showError("No authorization code was found in the URL");
|
||||
}
|
||||
|
||||
|
||||
function exchangeCode(code, clientId, clientSecret, redirectUri, tenantId, folderPath) {
|
||||
const formData = new FormData();
|
||||
formData.append('client_id', clientId);
|
||||
@@ -120,12 +120,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
formData.append('redirect_uri', redirectUri);
|
||||
formData.append('code', code);
|
||||
formData.append('tenant_id', tenantId);
|
||||
|
||||
|
||||
// Show more details in processing message
|
||||
document.getElementById('processing-message').innerHTML =
|
||||
document.getElementById('processing-message').innerHTML =
|
||||
'<p>Exchanging authorization code for refresh token...</p>' +
|
||||
'<p class="text-xs text-gray-500 mt-2">Using tenant: ' + (tenantId || 'common') + '</p>';
|
||||
|
||||
|
||||
fetch('/api/onedrive/exchange-token', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
@@ -143,19 +143,19 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Instead of saving to .env file, update settings in memory
|
||||
const updateFormData = new FormData();
|
||||
updateFormData.append('refresh_token', data.refresh_token);
|
||||
|
||||
|
||||
// Use the values from session storage
|
||||
updateFormData.append('client_id', clientId);
|
||||
updateFormData.append('client_secret', clientSecret);
|
||||
updateFormData.append('tenant_id', tenantId);
|
||||
|
||||
|
||||
if (folderPath) {
|
||||
updateFormData.append('folder_path', folderPath);
|
||||
}
|
||||
|
||||
document.getElementById('processing-message').innerHTML =
|
||||
|
||||
document.getElementById('processing-message').innerHTML =
|
||||
'<p>Updating system settings with new token...</p>';
|
||||
|
||||
|
||||
return fetch('/api/onedrive/update-settings', {
|
||||
method: 'POST',
|
||||
body: updateFormData
|
||||
@@ -169,12 +169,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}).then(() => {
|
||||
// Show the success message and environment variables
|
||||
showSuccess(data.refresh_token, clientId, clientSecret, tenantId, folderPath);
|
||||
|
||||
|
||||
// In 10 seconds, redirect to status page (giving more time to copy)
|
||||
setTimeout(() => {
|
||||
window.location.href = '/status';
|
||||
}, 10000);
|
||||
|
||||
|
||||
// Clean up session storage
|
||||
sessionStorage.removeItem('onedrive_client_id');
|
||||
sessionStorage.removeItem('onedrive_client_secret');
|
||||
@@ -189,23 +189,23 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
showError(error.message);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function showError(message) {
|
||||
document.getElementById('processing-message').classList.add('hidden');
|
||||
document.getElementById('error-container').classList.remove('hidden');
|
||||
document.getElementById('error-message').innerText = message;
|
||||
|
||||
|
||||
// Hide the spinner when showing error
|
||||
document.querySelector('.animate-spin').parentNode.classList.add('hidden');
|
||||
}
|
||||
|
||||
|
||||
function showSuccess(refreshToken, clientId, clientSecret, tenantId, folderPath) {
|
||||
document.getElementById('processing-message').classList.add('hidden');
|
||||
document.getElementById('success-container').classList.remove('hidden');
|
||||
|
||||
|
||||
// Hide the spinner when showing success
|
||||
document.querySelector('.animate-spin').parentNode.classList.add('hidden');
|
||||
|
||||
|
||||
// Update the environment variables pre block with the new token
|
||||
const envVarsCode = document.querySelector('#env-vars code');
|
||||
if (envVarsCode) {
|
||||
@@ -215,7 +215,7 @@ ONEDRIVE_TENANT_ID=${tenantId || 'common'}
|
||||
ONEDRIVE_REFRESH_TOKEN=${refreshToken}
|
||||
ONEDRIVE_FOLDER_PATH=${folderPath || 'Documents/Uploads'}`;
|
||||
}
|
||||
|
||||
|
||||
// Add copy functionality
|
||||
const copyEnvVarsBtn = document.getElementById('copy-env-vars');
|
||||
if (copyEnvVarsBtn) {
|
||||
|
||||
Reference in New Issue
Block a user