Add option to copy profile as URL
This commit is contained in:
		
							parent
							
								
									0360c2649b
								
							
						
					
					
						commit
						189e0acfb1
					
				| 
						 | 
				
			
			@ -35,6 +35,7 @@
 | 
			
		|||
  import { openModal } from 'svelte-modals'
 | 
			
		||||
  import PromptConfirm from './PromptConfirm.svelte'
 | 
			
		||||
  import { getChatModelOptions, getImageModelOptions } from './Models.svelte'
 | 
			
		||||
  import { faClipboard } from '@fortawesome/free-regular-svg-icons'
 | 
			
		||||
 | 
			
		||||
  export let chatId:number
 | 
			
		||||
  export const show = () => { showSettings() }
 | 
			
		||||
| 
						 | 
				
			
			@ -97,6 +98,20 @@
 | 
			
		|||
    showSettingsModal && showSettings()
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  const copySettingsAsUri = () => {
 | 
			
		||||
    // location.protocol + '//' + location.host + location.pathname
 | 
			
		||||
    const uri = '#/chat/new?petals=true&' + Object.entries(chatSettings).reduce((a, [k, v]) => {
 | 
			
		||||
      const t = typeof v
 | 
			
		||||
      if (t === 'boolean' || t === 'string' || t === 'number') {
 | 
			
		||||
        a.push(encodeURI(k) + '=' + encodeURI(v as any))
 | 
			
		||||
      }
 | 
			
		||||
      return a
 | 
			
		||||
    }, [] as string[]).join('&')
 | 
			
		||||
    const profileUri = window.location.protocol + '//' + window.location.host + window.location.pathname + uri
 | 
			
		||||
    navigator.clipboard.writeText(profileUri)
 | 
			
		||||
    return profileUri
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const cloneProfile = () => {
 | 
			
		||||
    showProfileMenu = false
 | 
			
		||||
    const clone = JSON.parse(JSON.stringify(chat.settings))
 | 
			
		||||
| 
						 | 
				
			
			@ -312,6 +327,9 @@
 | 
			
		|||
                <a href={'#'} class="dropdown-item" on:click|preventDefault={() => { showProfileMenu = false; profileFileInput.click() }}>
 | 
			
		||||
                  <span class="menu-icon"><Fa icon={faUpload}/></span> Restore Profile JSON
 | 
			
		||||
                </a>
 | 
			
		||||
                <a href={'#'} class="dropdown-item" on:click|preventDefault={() => { showProfileMenu = false; copySettingsAsUri() }}>
 | 
			
		||||
                  <span class="menu-icon"><Fa icon={faClipboard}/></span> Copy Profile URL to Clipboard
 | 
			
		||||
                </a>
 | 
			
		||||
                <hr class="dropdown-divider">
 | 
			
		||||
                <a href={'#'} class="dropdown-item" on:click|preventDefault={promptDeleteProfile}>
 | 
			
		||||
                  <span class="menu-icon"><Fa icon={faTrash}/></span> Delete Profile
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue