Track profile changes and add save changes button
This commit is contained in:
parent
b67f336b58
commit
75aaef48ea
|
@ -111,7 +111,7 @@ html {
|
||||||
.is-disabled {
|
.is-disabled {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
opacity: .65;
|
opacity: .50;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rotate {
|
.rotate {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
export let chatSettings:ChatSettings
|
export let chatSettings:ChatSettings
|
||||||
export let chat:Chat
|
export let chat:Chat
|
||||||
export let chatDefaults:Record<string, any>
|
export let chatDefaults:Record<string, any>
|
||||||
|
export let defaultProfile:String
|
||||||
|
|
||||||
const chatId = chat.id
|
const chatId = chat.id
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { applyProfile, getDefaultProfileKey, getProfileSelect } from './Profiles.svelte'
|
import { applyProfile, getDefaultProfileKey, getProfile, getProfileSelect } from './Profiles.svelte'
|
||||||
import { getChatDefaults, getChatSettingList, getChatSettingObjectByKey } from './Settings.svelte'
|
import { getChatDefaults, getChatSettingList, getChatSettingObjectByKey } from './Settings.svelte'
|
||||||
import {
|
import {
|
||||||
saveChatStore,
|
saveChatStore,
|
||||||
|
@ -38,6 +38,8 @@
|
||||||
let showSettingsModal = 0
|
let showSettingsModal = 0
|
||||||
let showProfileMenu:boolean = false
|
let showProfileMenu:boolean = false
|
||||||
let profileFileInput
|
let profileFileInput
|
||||||
|
let defaultProfile = getDefaultProfileKey()
|
||||||
|
let isDefault = false
|
||||||
|
|
||||||
const settingsList = getChatSettingList()
|
const settingsList = getChatSettingList()
|
||||||
const modelSetting = getChatSettingObjectByKey('model') as ChatSetting & SettingSelect
|
const modelSetting = getChatSettingObjectByKey('model') as ChatSetting & SettingSelect
|
||||||
|
@ -76,6 +78,7 @@
|
||||||
saveCustomProfile(clone)
|
saveCustomProfile(clone)
|
||||||
chat.settings.profile = clone.profile
|
chat.settings.profile = clone.profile
|
||||||
chat.settings.profileName = clone.profileName
|
chat.settings.profileName = clone.profileName
|
||||||
|
applyProfile(chatId, clone.profile)
|
||||||
refreshSettings()
|
refreshSettings()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.alert('Error cloning profile: \n' + e.message)
|
window.alert('Error cloning profile: \n' + e.message)
|
||||||
|
@ -126,6 +129,8 @@
|
||||||
chatDefaults.profile = getDefaultProfileKey()
|
chatDefaults.profile = getDefaultProfileKey()
|
||||||
chatDefaults.max_tokens = getModelMaxTokens(chatSettings.model||'')
|
chatDefaults.max_tokens = getModelMaxTokens(chatSettings.model||'')
|
||||||
// const defaultProfile = globalStore.defaultProfile || profileSelect.options[0].value
|
// const defaultProfile = globalStore.defaultProfile || profileSelect.options[0].value
|
||||||
|
defaultProfile = getDefaultProfileKey()
|
||||||
|
isDefault = defaultProfile === chatSettings.profile
|
||||||
}
|
}
|
||||||
|
|
||||||
const showSettings = async () => {
|
const showSettings = async () => {
|
||||||
|
@ -192,9 +197,14 @@
|
||||||
return cname
|
return cname
|
||||||
}
|
}
|
||||||
|
|
||||||
const setDirty = () => {
|
const setDirty = (e:CustomEvent) => {
|
||||||
chatSettings.isDirty = true
|
const setting = e.detail as ChatSetting
|
||||||
|
const key = setting.key
|
||||||
|
if (key === 'profile') return
|
||||||
|
const profile = getProfile(chatSettings.profile)
|
||||||
|
const isDirty = profile[key] !== chatSettings[key]
|
||||||
|
console.log('Is dirty?', setting, isDirty, profile[key], chatSettings[key])
|
||||||
|
chatSettings.isDirty = isDirty
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -215,14 +225,14 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-menu" id="dropdown-menu3" role="menu">
|
<div class="dropdown-menu" id="dropdown-menu3" role="menu">
|
||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
<a href={'#'} class="dropdown-item disabled" on:click|preventDefault={saveProfile}>
|
<a href={'#'} class="dropdown-item" class:is-disabled={!chatSettings.isDirty} on:click|preventDefault={saveProfile}>
|
||||||
<span class="menu-icon"><Fa icon={faFloppyDisk}/></span> Save Profile
|
<span class="menu-icon"><Fa icon={faFloppyDisk}/></span> Save Changes
|
||||||
</a>
|
</a>
|
||||||
<a href={'#'} class="dropdown-item" on:click|preventDefault={cloneProfile}>
|
<a href={'#'} class="dropdown-item" on:click|preventDefault={cloneProfile}>
|
||||||
<span class="menu-icon"><Fa icon={faClone}/></span> Clone Profile
|
<span class="menu-icon"><Fa icon={faClone}/></span> Clone Profile
|
||||||
</a>
|
</a>
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
<a href={'#'} class="dropdown-item" on:click|preventDefault={pinDefaultProfile}>
|
<a href={'#'} class="dropdown-item" class:is-disabled={isDefault} on:click|preventDefault={pinDefaultProfile}>
|
||||||
<span class="menu-icon"><Fa icon={faThumbtack}/></span> Set as Default Profile
|
<span class="menu-icon"><Fa icon={faThumbtack}/></span> Set as Default Profile
|
||||||
</a>
|
</a>
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
|
@ -246,7 +256,7 @@
|
||||||
<section class="modal-card-body">
|
<section class="modal-card-body">
|
||||||
{#key showSettingsModal}
|
{#key showSettingsModal}
|
||||||
{#each settingsList as setting}
|
{#each settingsList as setting}
|
||||||
<ChatSettingField on:refresh={refreshSettings} on:change={setDirty} chat={chat} chatDefaults={chatDefaults} chatSettings={chatSettings} setting={setting} />
|
<ChatSettingField on:refresh={refreshSettings} on:change={setDirty} chat={chat} chatDefaults={chatDefaults} chatSettings={chatSettings} setting={setting} defaultProfile={defaultProfile} />
|
||||||
{/each}
|
{/each}
|
||||||
{/key}
|
{/key}
|
||||||
</section>
|
</section>
|
||||||
|
@ -254,6 +264,7 @@
|
||||||
<footer class="modal-card-foot">
|
<footer class="modal-card-foot">
|
||||||
<button class="button is-info" on:click={closeSettings}>Close</button>
|
<button class="button is-info" on:click={closeSettings}>Close</button>
|
||||||
<button class="button is-warning" on:click={clearSettings}>Reset</button>
|
<button class="button is-warning" on:click={clearSettings}>Reset</button>
|
||||||
|
<button class="button" class:is-disabled={!chatSettings.isDirty} on:click={saveProfile}>Save Changes</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -383,6 +383,8 @@
|
||||||
})
|
})
|
||||||
profiles[profile.profile as string] = clone
|
profiles[profile.profile as string] = clone
|
||||||
globalStorage.set(store)
|
globalStorage.set(store)
|
||||||
|
profile.isDirty = false
|
||||||
|
saveChatStore()
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue