Hide OAuth reconnect instructions once already connected
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 25s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 25s
Settings always showed the full "how to connect" steps and code-paste form for oauth2 mode regardless of connection status, which read as broken even when the token was live and polling successfully. Collapse it behind a "Reconnect" toggle once connected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
ba070e0ad5
commit
5ffd91a643
1 changed files with 16 additions and 0 deletions
|
|
@ -27,6 +27,7 @@
|
|||
</p>
|
||||
{% elif isolarcloud_auth_mode == "oauth2" %}
|
||||
<p id="isolarcloud-status" class="muted">Checking connection status…</p>
|
||||
<button type="button" id="oauth-reconnect-toggle" style="display:none;">Reconnect / use a different account</button>
|
||||
<div id="oauth-connect-block">
|
||||
<p class="muted">
|
||||
1. Open the authorization link below in your own browser, log in with your iSolarCloud account, and approve access.<br>
|
||||
|
|
@ -254,6 +255,18 @@ async function checkIsolarcloudStatus() {
|
|||
el.textContent = status.connected
|
||||
? 'Connected -- a valid token is cached.'
|
||||
: 'Not connected yet.';
|
||||
|
||||
// Only oauth2 mode has the connect-block/reconnect-toggle pair.
|
||||
const connectBlock = document.getElementById('oauth-connect-block');
|
||||
const reconnectToggle = document.getElementById('oauth-reconnect-toggle');
|
||||
if (!connectBlock || !reconnectToggle) return;
|
||||
if (status.connected) {
|
||||
connectBlock.style.display = 'none';
|
||||
reconnectToggle.style.display = 'inline-block';
|
||||
} else {
|
||||
connectBlock.style.display = 'block';
|
||||
reconnectToggle.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function renderPlantPicker(plants) {
|
||||
|
|
@ -305,6 +318,9 @@ if (oauthAuthorizeLink) {
|
|||
fetch('/api/isolarcloud/oauth/authorize-url').then(r => r.json()).then(data => {
|
||||
oauthAuthorizeLink.href = data.url;
|
||||
});
|
||||
document.getElementById('oauth-reconnect-toggle').addEventListener('click', () => {
|
||||
document.getElementById('oauth-connect-block').style.display = 'block';
|
||||
});
|
||||
document.getElementById('oauth-connect-btn').addEventListener('click', async () => {
|
||||
const flash = document.getElementById('isolarcloud-flash');
|
||||
let code = document.getElementById('oauth-code-input').value.trim();
|
||||
|
|
|
|||
Loading…
Reference in a new issue