Replace details view toggle with a button
| @@ -10082,7 +10082,7 @@ jQuery(async function () { | ||
| 10082 | 10082 | }); |
| 10083 | 10083 | |
| 10084 | 10084 | $('#main_api').change(function () { |
| 10085 | 10085 | cancelStatusCheck("'Canceled because main api changed"'); |
| 10086 | 10086 | changeMainAPI(); |
| 10087 | 10087 | saveSettingsDebounced(); |
| 10088 | 10088 | }); |
| @@ -67,7 +67,7 @@ class ConnectionManagerSpinner { | ||
| 67 | 67 | constructor() { |
| 68 | 68 | // @ts-ignore |
| 69 | 69 | this.spinnerElement = document.getElementById('connection_profile_spinner'); |
| 70 | 70 | this.abortController = new AbortController(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | start() { |
| @@ -318,21 +318,21 @@ function renderConnectionProfiles(profiles) { | ||
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | 320 | * Renders the content of the details element. |
| 321 | - * @param {HTMLDetailsElement} details Details element | |
| 322 | 321 | * @param {HTMLElement} detailsContent Content element of the details |
| 323 | 322 | */ |
| 324 | 323 | async function renderDetailsContent(details, detailsContent) { |
| 325 | 324 | detailsContent.innerHTML = ''; |
| 326 | 325 | if (detailsdetailsContent.openclassList.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 | 333 | detailsContent.textContentinnerHTML = 'No profile selected'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 | 365 | const profileId = selectedProfile.value; |
| 366 | 366 | extension_settings.connectionManager.selectedProfile = profileId; |
| 367 | 367 | saveSettingsDebounced(); |
| 368 | 368 | await renderDetailsContent(details, detailsContent); |
| 369 | 369 | |
| 370 | 370 | // None option selected |
| 371 | 371 | if (!profileId) { |
| @@ -393,7 +393,7 @@ async function renderDetailsContent(details, detailsContent) { | ||
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | await applyConnectionProfile(profile); |
| 396 | 396 | await renderDetailsContent(details, detailsContent); |
| 397 | 397 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); |
| 398 | 398 | toastr.success('Connection profile reloaded', '', { timeOut: 1500 }); |
| 399 | 399 | }); |
| @@ -408,7 +408,7 @@ async function renderDetailsContent(details, detailsContent) { | ||
| 408 | 408 | extension_settings.connectionManager.selectedProfile = profile.id; |
| 409 | 409 | saveSettingsDebounced(); |
| 410 | 410 | renderConnectionProfiles(profiles); |
| 411 | 411 | await renderDetailsContent(details, detailsContent); |
| 412 | 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 | 421 | return; |
| 422 | 422 | } |
| 423 | 423 | await updateConnectionProfile(profile); |
| 424 | 424 | await renderDetailsContent(details, detailsContent); |
| 425 | 425 | saveSettingsDebounced(); |
| 426 | 426 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, profile.name); |
| 427 | 427 | toastr.success('Connection profile updated', '', { timeOut: 1500 }); |
| @@ -431,15 +431,18 @@ async function renderDetailsContent(details, detailsContent) { | ||
| 431 | 431 | deleteButton.addEventListener('click', async () => { |
| 432 | 432 | await deleteConnectionProfile(); |
| 433 | 433 | renderConnectionProfiles(profiles); |
| 434 | 434 | await renderDetailsContent(details, detailsContent); |
| 435 | 435 | await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, NONE); |
| 436 | 436 | }); |
| 437 | 437 | |
| 438 | 438 | /** @type {HTMLDetailsElementHTMLElement} */ |
| 439 | - // @ts-ignore | |
| 439 | + const viewDetails = document.getElementById('view_connection_profile'); | |
| 440 | - const details = document.getElementById('connection_profile_details'); | |
| 441 | 440 | const detailsContent = document.getElementById('connection_profile_details_content'); |
| 442 | 441 | detailsviewDetails.addEventListener('toggleclick', async () => renderDetailsContent(details, detailsContent));{ |
| 442 | + viewDetails.classList.toggle('active'); | |
| 443 | + detailsContent.classList.toggle('hidden'); | |
| 444 | + await renderDetailsContent(detailsContent); | |
| 445 | + }); | |
| 443 | 446 | |
| 444 | 447 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 445 | 448 | name: 'profile', |
| @@ -529,7 +532,7 @@ async function renderDetailsContent(details, detailsContent) { | ||
| 529 | 532 | extension_settings.connectionManager.selectedProfile = profile.id; |
| 530 | 533 | saveSettingsDebounced(); |
| 531 | 534 | renderConnectionProfiles(profiles); |
| 532 | 535 | await renderDetailsContent(details, detailsContent); |
| 533 | 536 | return profile.name; |
| 534 | 537 | }, |
| 535 | 538 | })); |
| @@ -545,7 +548,7 @@ async function renderDetailsContent(details, detailsContent) { | ||
| 545 | 548 | return ''; |
| 546 | 549 | } |
| 547 | 550 | await updateConnectionProfile(profile); |
| 548 | 551 | await renderDetailsContent(details, detailsContent); |
| 549 | 552 | saveSettingsDebounced(); |
| 550 | 553 | return profile.name; |
| 551 | 554 | }, |
| @@ -7,16 +7,11 @@ | ||
| 7 | 7 | </div> |
| 8 | 8 | <div class="flex-container"> |
| 9 | 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 | 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 | 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 | 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 | 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 | 15 | </div> |
| 15 | 16 | <detailsdiv id="connection_profile_detailsconnection_profile_details_content" class="marginBot10hidden"></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 | 17 | </div> |
| @@ -1,13 +1,11 @@ | ||
| 1 | 1 | #connection_profile_details>summaryconnection_profile_details_content { |
| 2 | 2 | cursormargin: pointer5px 0; |
| 3 | - font-weight: bold; | |
| 4 | - font-size: 1.1em; | |
| 5 | 3 | } |
| 6 | 4 | |
| 7 | 5 | #connection_profile_detailsconnection_profile_details_content ul { |
| 8 | 6 | margin: 5px 0; |
| 9 | 7 | } |
| 10 | 8 | |
| 11 | 9 | #connection_profile_spinner { |
| 12 | 10 | margin-lefTleft: 5px; |
| 13 | 11 | } |