Replace details view toggle with a button
| @@ -10082,7 +10082,7 @@ jQuery(async function () { | |||
| 10082 | }); | 10082 | }); |
| 10083 | 10083 | ||
| 10084 | $('#main_api').change(function () { | 10084 | $('#main_api').change(function () { |
| 10085 | cancelStatusCheck("Canceled because main api changed"); | 10085 | cancelStatusCheck('Canceled because main api changed'); |
| 10086 | changeMainAPI(); | 10086 | changeMainAPI(); |
| 10087 | saveSettingsDebounced(); | 10087 | saveSettingsDebounced(); |
| 10088 | }); | 10088 | }); |
| @@ -67,7 +67,7 @@ class ConnectionManagerSpinner { | |||
| 67 | constructor() { | 67 | constructor() { |
| 68 | // @ts-ignore | 68 | // @ts-ignore |
| 69 | this.spinnerElement = document.getElementById('connection_profile_spinner'); | 69 | this.spinnerElement = document.getElementById('connection_profile_spinner'); |
| 70 | this.abortController = new AbortController(); | 70 | this.abortController = new AbortController(); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | start() { | 73 | start() { |
| @@ -318,21 +318,21 @@ function renderConnectionProfiles(profiles) { | |||
| 318 | 318 | ||
| 319 | /** | 319 | /** |
| 320 | * Renders the content of the details element. | 320 | * Renders the content of the details element. |
| 321 | * @param {HTMLDetailsElement} details Details element | ||
| 322 | * @param {HTMLElement} detailsContent Content element of the details | 321 | * @param {HTMLElement} detailsContent Content element of the details |
| 323 | */ | 322 | */ |
| 324 | async function renderDetailsContent(details, detailsContent) { | 323 | async function renderDetailsContent(detailsContent) { |
| 325 | detailsContent.innerHTML = ''; | 324 | detailsContent.innerHTML = ''; |
| 326 | if (details.open) { | 325 | if (detailsContent.classList.contains('hidden')) { |
| 327 | const selectedProfile = extension_settings.connectionManager.selectedProfile; | 326 | return; |
| 328 | const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile); | 327 | } |
| 329 | if (profile) { | 328 | const selectedProfile = extension_settings.connectionManager.selectedProfile; |
| 330 | const profileForDisplay = makeFancyProfile(profile); | 329 | const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile); |
| 331 | const template = await renderExtensionTemplateAsync(MODULE_NAME, 'view', { profile: profileForDisplay }); | 330 | if (profile) { |
| 332 | detailsContent.innerHTML = template; | 331 | const profileForDisplay = makeFancyProfile(profile); |
| 333 | } else { | 332 | const template = await renderExtensionTemplateAsync(MODULE_NAME, 'view', { profile: profileForDisplay }); |
| 334 | detailsContent.textContent = 'No profile selected'; | 333 | detailsContent.innerHTML = template; |
| 335 | } | 334 | } else { |
| 335 | detailsContent.textContent = 'No profile selected'; | ||
| 336 | } | 336 | } |
| 337 | } | 337 | } |
| 338 | 338 | ||
| @@ -365,7 +365,7 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 365 | const profileId = selectedProfile.value; | 365 | const profileId = selectedProfile.value; |
| 366 | extension_settings.connectionManager.selectedProfile = profileId; | 366 | extension_settings.connectionManager.selectedProfile = profileId; |
| 367 | saveSettingsDebounced(); | 367 | saveSettingsDebounced(); |
| 368 | await renderDetailsContent(details, detailsContent); | 368 | await renderDetailsContent(detailsContent); |
| 369 | 369 | ||
| 370 | // None option selected | 370 | // None option selected |
| 371 | if (!profileId) { | 371 | if (!profileId) { |
| @@ -393,7 +393,7 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 393 | return; | 393 | return; |
| 394 | } | 394 | } |
| 395 | await applyConnectionProfile(profile); | 395 | await applyConnectionProfile(profile); |
| 396 | await renderDetailsContent(details, detailsContent); | 396 | await renderDetailsContent(detailsContent); |
| 397 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); | 397 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); |
| 398 | toastr.success('Connection profile reloaded', '', { timeOut: 1500 }); | 398 | toastr.success('Connection profile reloaded', '', { timeOut: 1500 }); |
| 399 | }); | 399 | }); |
| @@ -408,7 +408,7 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 408 | extension_settings.connectionManager.selectedProfile = profile.id; | 408 | extension_settings.connectionManager.selectedProfile = profile.id; |
| 409 | saveSettingsDebounced(); | 409 | saveSettingsDebounced(); |
| 410 | renderConnectionProfiles(profiles); | 410 | renderConnectionProfiles(profiles); |
| 411 | await renderDetailsContent(details, detailsContent); | 411 | await renderDetailsContent(detailsContent); |
| 412 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); | 412 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); |
| 413 | }); | 413 | }); |
| 414 | 414 | ||
| @@ -421,7 +421,7 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 421 | return; | 421 | return; |
| 422 | } | 422 | } |
| 423 | await updateConnectionProfile(profile); | 423 | await updateConnectionProfile(profile); |
| 424 | await renderDetailsContent(details, detailsContent); | 424 | await renderDetailsContent(detailsContent); |
| 425 | saveSettingsDebounced(); | 425 | saveSettingsDebounced(); |
| 426 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); | 426 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); |
| 427 | toastr.success('Connection profile updated', '', { timeOut: 1500 }); | 427 | toastr.success('Connection profile updated', '', { timeOut: 1500 }); |
| @@ -431,15 +431,18 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 431 | deleteButton.addEventListener('click', async () => { | 431 | deleteButton.addEventListener('click', async () => { |
| 432 | await deleteConnectionProfile(); | 432 | await deleteConnectionProfile(); |
| 433 | renderConnectionProfiles(profiles); | 433 | renderConnectionProfiles(profiles); |
| 434 | await renderDetailsContent(details, detailsContent); | 434 | await renderDetailsContent(detailsContent); |
| 435 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, NONE); | 435 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, NONE); |
| 436 | }); | 436 | }); |
| 437 | 437 | ||
| 438 | /** @type {HTMLDetailsElement} */ | 438 | /** @type {HTMLElement} */ |
| 439 | // @ts-ignore | 439 | const viewDetails = document.getElementById('view_connection_profile'); |
| 440 | const details = document.getElementById('connection_profile_details'); | ||
| 441 | const detailsContent = document.getElementById('connection_profile_details_content'); | 440 | const detailsContent = document.getElementById('connection_profile_details_content'); |
| 442 | details.addEventListener('toggle', () => renderDetailsContent(details, detailsContent)); | 441 | viewDetails.addEventListener('click', async () => { |
| 442 | viewDetails.classList.toggle('active'); | ||
| 443 | detailsContent.classList.toggle('hidden'); | ||
| 444 | await renderDetailsContent(detailsContent); | ||
| 445 | }); | ||
| 443 | 446 | ||
| 444 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 447 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 445 | name: 'profile', | 448 | name: 'profile', |
| @@ -529,7 +532,7 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 529 | extension_settings.connectionManager.selectedProfile = profile.id; | 532 | extension_settings.connectionManager.selectedProfile = profile.id; |
| 530 | saveSettingsDebounced(); | 533 | saveSettingsDebounced(); |
| 531 | renderConnectionProfiles(profiles); | 534 | renderConnectionProfiles(profiles); |
| 532 | await renderDetailsContent(details, detailsContent); | 535 | await renderDetailsContent(detailsContent); |
| 533 | return profile.name; | 536 | return profile.name; |
| 534 | }, | 537 | }, |
| 535 | })); | 538 | })); |
| @@ -545,7 +548,7 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 545 | return ''; | 548 | return ''; |
| 546 | } | 549 | } |
| 547 | await updateConnectionProfile(profile); | 550 | await updateConnectionProfile(profile); |
| 548 | await renderDetailsContent(details, detailsContent); | 551 | await renderDetailsContent(detailsContent); |
| 549 | saveSettingsDebounced(); | 552 | saveSettingsDebounced(); |
| 550 | return profile.name; | 553 | return profile.name; |
| 551 | }, | 554 | }, |
| @@ -7,16 +7,11 @@ | |||
| 7 | </div> | 7 | </div> |
| 8 | <div class="flex-container"> | 8 | <div class="flex-container"> |
| 9 | <select class="text_pole flex1" id="connection_profiles"></select> | 9 | <select class="text_pole flex1" id="connection_profiles"></select> |
| 10 | <i id="view_connection_profile" class="menu_button fa-solid fa-info-circle" title="View connection profile details" data-i18n="[title]View connection profile details"></i> | ||
| 10 | <i id="create_connection_profile" class="menu_button fa-solid fa-file-circle-plus" title="Create a new connection profile" data-i18n="[title]Create a new connection profile"></i> | 11 | <i id="create_connection_profile" class="menu_button fa-solid fa-file-circle-plus" title="Create a new connection profile" data-i18n="[title]Create a new connection profile"></i> |
| 11 | <i id="update_connection_profile" class="menu_button fa-solid fa-save" title="Update a connection profile" data-i18n="[title]Update a connection profile"></i> | 12 | <i id="update_connection_profile" class="menu_button fa-solid fa-save" title="Update a connection profile" data-i18n="[title]Update a connection profile"></i> |
| 12 | <i id="reload_connection_profile" class="menu_button fa-solid fa-recycle" title="Reload a connection profile" data-i18n="[title]Reload a connection profile"></i> | 13 | <i id="reload_connection_profile" class="menu_button fa-solid fa-recycle" title="Reload a connection profile" data-i18n="[title]Reload a connection profile"></i> |
| 13 | <i id="delete_connection_profile" class="menu_button fa-solid fa-trash-can" title="Delete a connection profile" data-i18n="[title]Delete a connection profile"></i> | 14 | <i id="delete_connection_profile" class="menu_button fa-solid fa-trash-can" title="Delete a connection profile" data-i18n="[title]Delete a connection profile"></i> |
| 14 | </div> | 15 | </div> |
| 15 | <details id="connection_profile_details" class="marginBot10"> | 16 | <div id="connection_profile_details_content" class="hidden"></div> |
| 16 | <summary> | ||
| 17 | <span data-i18n="Profile Details">Profile Details</span> | ||
| 18 | <i id="connection_profile_spinner" class="fa-solid fa-spinner fa-spin hidden"></i> | ||
| 19 | </summary> | ||
| 20 | <div id="connection_profile_details_content" class="marginTop5"></div> | ||
| 21 | </details> | ||
| 22 | </div> | 17 | </div> |
| @@ -1,13 +1,11 @@ | |||
| 1 | #connection_profile_details>summary { | 1 | #connection_profile_details_content { |
| 2 | cursor: pointer; | 2 | margin: 5px 0; |
| 3 | font-weight: bold; | ||
| 4 | font-size: 1.1em; | ||
| 5 | } | 3 | } |
| 6 | 4 | ||
| 7 | #connection_profile_details ul { | 5 | #connection_profile_details_content ul { |
| 8 | margin: 5px 0; | 6 | margin: 0; |
| 9 | } | 7 | } |
| 10 | 8 | ||
| 11 | #connection_profile_spinner { | 9 | #connection_profile_spinner { |
| 12 | margin-lefT: 5px; | 10 | margin-left: 5px; |
| 13 | } | 11 | } |