#284 Add a button to quickly remove the saved API key

This commit is contained in:
SillyLossy
2023-05-12 20:36:48 +03:00
parent 69feecd0fa
commit 473b57ce97
2 changed files with 25 additions and 4 deletions

View File

@ -1008,7 +1008,10 @@
<h5>Get it here: <a target="_blank" href="https://horde.koboldai.net/register">Register</a><br> <h5>Get it here: <a target="_blank" href="https://horde.koboldai.net/register">Register</a><br>
Enter <span class="monospace">0000000000</span> to use anonymous mode. Enter <span class="monospace">0000000000</span> to use anonymous mode.
</h5> </h5>
<input id="horde_api_key" name="horde_api_key" class="text_pole" maxlength="500" type="text" placeholder="0000000000"> <div class="flex-container">
<input id="horde_api_key" name="horde_api_key" class="text_pole flex1" maxlength="500" type="text" placeholder="0000000000">
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_horde"></div>
</div>
<div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div> <div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div>
<h4 class="horde_model_title"> <h4 class="horde_model_title">
Model Model
@ -1039,7 +1042,10 @@
<li>Enter it in the box below:</li> <li>Enter it in the box below:</li>
</ol> </ol>
</span> </span>
<input id="api_key_novel" name="api_key_novel" class="text_pole" maxlength="500" size="35" type="text"> <div class="flex-container">
<input id="api_key_novel" name="api_key_novel" class="text_pole flex1" maxlength="500" size="35" type="text">
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_novel"></div>
</div>
<div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div> <div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div>
<input id="api_button_novel" class="menu_button" type="submit" value="Connect"> <input id="api_button_novel" class="menu_button" type="submit" value="Connect">
<div id="api_loading_novel" class="api-load-icon fa-solid fa-hourglass fa-spin"></div> <div id="api_loading_novel" class="api-load-icon fa-solid fa-hourglass fa-spin"></div>
@ -1093,7 +1099,10 @@
<li>Enter it in the box below:</li> <li>Enter it in the box below:</li>
</ol> </ol>
</span> </span>
<input id="api_key_openai" name="api_key_openai" class="text_pole" maxlength="500" value="" type="text"> <div class="flex-container">
<input id="api_key_openai" name="api_key_openai" class="text_pole flex1" maxlength="500" value="" type="text">
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_openai"></div>
</div>
<div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div> <div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div>
<input id="api_button_openai" class="menu_button" type="submit" value="Connect"> <input id="api_button_openai" class="menu_button" type="submit" value="Connect">
<div id="api_loading_openai" class=" api-load-icon fa-solid fa-hourglass fa-spin"></div> <div id="api_loading_openai" class=" api-load-icon fa-solid fa-hourglass fa-spin"></div>
@ -1130,7 +1139,10 @@
</ol> </ol>
</span> </span>
<div class="widthFreeExpand"> <div class="widthFreeExpand">
<input id="poe_token" class="text_pole" type="text" maxlength="100" /> <div class="flex-container">
<input id="poe_token" class="text_pole flex1" type="text" maxlength="100" />
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_poe"></div>
</div>
<div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div> <div class="neutral_warning">For privacy reasons, your API key will hidden after you reload the page.</div>
</div> </div>

View File

@ -14,6 +14,14 @@ const INPUT_MAP = {
[SECRET_KEYS.NOVEL]: '#api_key_novel', [SECRET_KEYS.NOVEL]: '#api_key_novel',
} }
async function clearSecret() {
const key = $(this).data('key');
await writeSecret(key, '');
secret_state[key] = false;
updateSecretDisplay();
$(INPUT_MAP[key]).val('');
}
function updateSecretDisplay() { function updateSecretDisplay() {
for (const [secret_key, input_selector] of Object.entries(INPUT_MAP)) { for (const [secret_key, input_selector] of Object.entries(INPUT_MAP)) {
const validSecret = !!secret_state[secret_key]; const validSecret = !!secret_state[secret_key];
@ -91,4 +99,5 @@ export async function readSecretState() {
jQuery(() => { jQuery(() => {
$('#viewSecrets').on('click', viewSecrets); $('#viewSecrets').on('click', viewSecrets);
$(document).on('click', '.clear-api-key', clearSecret);
}); });