Add buttons to remove SD/translate secrets
This commit is contained in:
parent
f17df7d9ad
commit
1842a8ee6d
|
@ -30,7 +30,7 @@ import { SlashCommand } from '../../slash-commands/SlashCommand.js';
|
||||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
||||||
import { debounce_timeout } from '../../constants.js';
|
import { debounce_timeout } from '../../constants.js';
|
||||||
import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js';
|
import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js';
|
||||||
import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js';
|
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js';
|
||||||
export { MODULE_NAME };
|
export { MODULE_NAME };
|
||||||
|
|
||||||
const MODULE_NAME = 'sd';
|
const MODULE_NAME = 'sd';
|
||||||
|
@ -1097,7 +1097,18 @@ function onComfyWorkflowChange() {
|
||||||
|
|
||||||
async function onStabilityKeyClick() {
|
async function onStabilityKeyClick() {
|
||||||
const popupText = 'Stability AI API Key:';
|
const popupText = 'Stability AI API Key:';
|
||||||
const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT);
|
const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT, '', {
|
||||||
|
customButtons: [{
|
||||||
|
text: 'Remove Key',
|
||||||
|
appendAtEnd: true,
|
||||||
|
result: POPUP_RESULT.NEGATIVE,
|
||||||
|
action: async () => {
|
||||||
|
await writeSecret(SECRET_KEYS.STABILITY, '');
|
||||||
|
toastr.success('API Key removed');
|
||||||
|
await loadSettingOptions();
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return;
|
return;
|
||||||
|
@ -2693,15 +2704,15 @@ async function generateBlockEntropyImage(prompt, negativePrompt, signal) {
|
||||||
|
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
const data = await result.json();
|
const data = await result.json();
|
||||||
|
|
||||||
// Default format is 'jpg'
|
// Default format is 'jpg'
|
||||||
let format = 'jpg';
|
let format = 'jpg';
|
||||||
|
|
||||||
// Check if a format is specified in the result
|
// Check if a format is specified in the result
|
||||||
if (data.format) {
|
if (data.format) {
|
||||||
format = data.format.toLowerCase();
|
format = data.format.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
return { format: format, data: data.images[0] };
|
return { format: format, data: data.images[0] };
|
||||||
} else {
|
} else {
|
||||||
const text = await result.text();
|
const text = await result.text();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
updateMessageBlock,
|
updateMessageBlock,
|
||||||
} from '../../../script.js';
|
} from '../../../script.js';
|
||||||
import { extension_settings, getContext, renderExtensionTemplateAsync } from '../../extensions.js';
|
import { extension_settings, getContext, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||||
import { POPUP_TYPE, callGenericPopup } from '../../popup.js';
|
import { POPUP_RESULT, POPUP_TYPE, callGenericPopup } from '../../popup.js';
|
||||||
import { findSecret, secret_state, writeSecret } from '../../secrets.js';
|
import { findSecret, secret_state, writeSecret } from '../../secrets.js';
|
||||||
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
|
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
|
||||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
||||||
|
@ -621,7 +621,18 @@ jQuery(async () => {
|
||||||
const secretKey = extension_settings.translate.provider + '_url';
|
const secretKey = extension_settings.translate.provider + '_url';
|
||||||
const savedUrl = secret_state[secretKey] ? await findSecret(secretKey) : '';
|
const savedUrl = secret_state[secretKey] ? await findSecret(secretKey) : '';
|
||||||
|
|
||||||
const url = await callGenericPopup(popupText, POPUP_TYPE.INPUT, savedUrl);
|
const url = await callGenericPopup(popupText, POPUP_TYPE.INPUT, savedUrl,{
|
||||||
|
customButtons: [{
|
||||||
|
text: 'Remove URL',
|
||||||
|
appendAtEnd: true,
|
||||||
|
result: POPUP_RESULT.NEGATIVE,
|
||||||
|
action: async () => {
|
||||||
|
await writeSecret(secretKey, '');
|
||||||
|
toastr.success('API URL removed');
|
||||||
|
$('#translate_url_button').toggleClass('success', !!secret_state[secretKey]);
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
if (url == false || url == '') {
|
if (url == false || url == '') {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue