mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-25 15:01:03 +00:00
Merge branch 'discussion-improvement'
This commit is contained in:
commit
530b4df200
38
docs/dev/new_ui_dev.md
Normal file
38
docs/dev/new_ui_dev.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# UI development log, todo's and more
|
||||||
|
|
||||||
|
The new UI is build using Node.js VUE3 + Vite. It uses tailwindcss, feathericons, openfonts and flowbite-vue components.
|
||||||
|
|
||||||
|
## Todo's
|
||||||
|
|
||||||
|
- Add ability to select multiple discussions to export or delete [WIP]
|
||||||
|
- Add toast messages for errors and successes
|
||||||
|
- Populate settings with settings controls [WIP]
|
||||||
|
- Connect Settings to backend, ability to save changes
|
||||||
|
- Add DB switcher (im thinking in the settings view)
|
||||||
|
- Make the UI work good on mobile
|
||||||
|
- Scroll to bottom
|
||||||
|
- Scroll to top
|
||||||
|
- Need to fix colors for `<input />` fields
|
||||||
|
- Create status bar for backend to display if something is generating on the backend
|
||||||
|
- Create stop generating button
|
||||||
|
- Fix the generated message formatting - add line breaks, also for user input messages.
|
||||||
|
- Add ability for users to style the whole UI, either changing Hue or changing every color manually.
|
||||||
|
- Maybe try to set the chatbox to float to the bottom (always on the bottom of the screen)
|
||||||
|
- Create a panel in the Settings tab to create new personalities
|
||||||
|
- Need to fix when user inputs message it shows up in the discussion array and then add new message for bot that is typing.
|
||||||
|
- Need to investigate performance of websocket when message is being streamed back to the UI
|
||||||
|
- On first launch of the UI force users to create "User" personality, to be used as "User" for any or all input messages.
|
||||||
|
- Connect delete / export discussions to backend functions.
|
||||||
|
- Need to fix when deleting multiple discussions to not loose loading animation for each discussion when list gets updated
|
||||||
|
- Need to add loading feedback for when a new discussion is being created
|
||||||
|
|
||||||
|
## Done
|
||||||
|
|
||||||
|
- Fix discussion list width so that it stays static and dont resize depending on message contents [DONE]
|
||||||
|
- Add chat input field [DONE]
|
||||||
|
- Make search filter work [DONE]
|
||||||
|
- Add clear filter button to search input field [DONE]
|
||||||
|
- Add modal to ask user if you sure about to delete [DONE but in different way]
|
||||||
|
- Fix up the discussion array to filter out the messages by type not by count. (conditionner and )[DONE]
|
||||||
|
- Add title of current discussion to page [DONE]
|
||||||
|
|
@ -1,21 +1,5 @@
|
|||||||
# GPT4ALL-UI Web interface VUE3
|
# GPT4ALL-UI Web interface VUE3
|
||||||
|
|
||||||
## Todo's
|
|
||||||
|
|
||||||
- Fix discussion list width so that it stays static and dont resize depending on message contents [DONE]
|
|
||||||
- Add chat input field [DONE]
|
|
||||||
- Add ability to select multiple discussions to export or delete
|
|
||||||
- Add modal to ask user if you sure about to delete
|
|
||||||
- Add toast messages for errors and successes
|
|
||||||
- Populate settings with settings controls [WIP]
|
|
||||||
- Make search filter work [DONE]
|
|
||||||
- Add clear filter button to search input field [DONE]
|
|
||||||
- Add DB switcher (im thinking in the settings view)
|
|
||||||
- Make the UI work good on mobile
|
|
||||||
- Scroll to bottom
|
|
||||||
- Scroll to top
|
|
||||||
- Need to fix colors for `<input />` fields
|
|
||||||
|
|
||||||
## Dependencies for development
|
## Dependencies for development
|
||||||
|
|
||||||
You mus have [Node.js](https://nodejs.org/en) installed on your computer.
|
You mus have [Node.js](https://nodejs.org/en) installed on your computer.
|
||||||
|
1
web/dist/assets/index-2edf1005.css
vendored
1
web/dist/assets/index-2edf1005.css
vendored
File diff suppressed because one or more lines are too long
11
web/dist/assets/index-2f3efff7.js
vendored
Normal file
11
web/dist/assets/index-2f3efff7.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
web/dist/assets/index-76ef06fb.css
vendored
Normal file
1
web/dist/assets/index-76ef06fb.css
vendored
Normal file
File diff suppressed because one or more lines are too long
11
web/dist/assets/index-ffda5761.js
vendored
11
web/dist/assets/index-ffda5761.js
vendored
File diff suppressed because one or more lines are too long
4
web/dist/index.html
vendored
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>GPT4All - WEBUI</title>
|
<title>GPT4All - WEBUI</title>
|
||||||
<script type="module" crossorigin src="/assets/index-ffda5761.js"></script>
|
<script type="module" crossorigin src="/assets/index-2f3efff7.js"></script>
|
||||||
<link rel="stylesheet" href="/assets/index-2edf1005.css">
|
<link rel="stylesheet" href="/assets/index-76ef06fb.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
@ -5,16 +5,37 @@
|
|||||||
<div
|
<div
|
||||||
class="flex items-center gap-2 px-3 py-3 rounded-lg bg-bg-light-tone-panel dark:bg-bg-dark-tone-panel shadow-lg ">
|
class="flex items-center gap-2 px-3 py-3 rounded-lg bg-bg-light-tone-panel dark:bg-bg-dark-tone-panel shadow-lg ">
|
||||||
|
|
||||||
<textarea id="chat" rows="1"
|
<textarea id="chat" rows="1" v-model="message"
|
||||||
class="block min-h-11 no-scrollbar p-2.5 w-full text-sm text-gray-900 bg-bg-light rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-bg-dark dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="block min-h-11 no-scrollbar p-2.5 w-full text-sm text-gray-900 bg-bg-light rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-bg-dark dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="Send message..." @keydown.enter.exact="submitOnEnter($event)"></textarea>
|
placeholder="Send message..." @keydown.enter.exact="submitOnEnter($event)"></textarea>
|
||||||
<button type="submit" on on-click=""
|
|
||||||
class="inline-flex justify-center p-2 rounded-full cursor-pointer hover:text-primary duration-75 active:scale-90">
|
|
||||||
|
|
||||||
<i data-feather="send" class=" w-6 h-6 m-1"></i>
|
<!-- BUTTONS -->
|
||||||
|
<div class="inline-flex justify-center rounded-full cursor-pointer">
|
||||||
|
|
||||||
|
<button v-if="!loading" type="button" @click="submit"
|
||||||
|
class=" w-6 hover:text-secondary duration-75 active:scale-90">
|
||||||
|
|
||||||
|
<i data-feather="send"></i>
|
||||||
|
|
||||||
<span class="sr-only">Send message</span>
|
<span class="sr-only">Send message</span>
|
||||||
</button>
|
</button>
|
||||||
|
<div v-if=" loading" title="Waiting for reply">
|
||||||
|
<!-- SPINNER -->
|
||||||
|
<div role="status">
|
||||||
|
<svg aria-hidden="true"
|
||||||
|
class="w-6 h-6 animate-spin fill-secondary"
|
||||||
|
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor" />
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill" />
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -28,9 +49,19 @@ import feather from 'feather-icons'
|
|||||||
export default {
|
export default {
|
||||||
name: 'ChatBox',
|
name: 'ChatBox',
|
||||||
emits: ["messageSentEvent"],
|
emits: ["messageSentEvent"],
|
||||||
|
props: {
|
||||||
|
|
||||||
|
loading: false
|
||||||
|
|
||||||
|
},
|
||||||
setup() {
|
setup() {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
message: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
sendMessageEvent(msg) {
|
sendMessageEvent(msg) {
|
||||||
|
|
||||||
@ -40,15 +71,22 @@ export default {
|
|||||||
submitOnEnter(event) {
|
submitOnEnter(event) {
|
||||||
if (event.which === 13) {
|
if (event.which === 13) {
|
||||||
event.preventDefault(); // Prevents the addition of a new line in the text field
|
event.preventDefault(); // Prevents the addition of a new line in the text field
|
||||||
console.log("enter detected");
|
|
||||||
if (!event.repeat) {
|
if (!event.repeat) {
|
||||||
|
|
||||||
this.sendMessageEvent(event.target.value)
|
this.sendMessageEvent(this.message)
|
||||||
event.target.value="" // Clear input field
|
this.message = "" // Clear input field
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
submit() {
|
||||||
|
if (this.message) {
|
||||||
|
this.sendMessageEvent(this.message)
|
||||||
|
this.message = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
@ -1,17 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="selected ? 'bg-bg-light-discussion dark:bg-bg-dark-discussion shadow-md' : ''"
|
<div :class="selected ? 'bg-bg-light-discussion dark:bg-bg-dark-discussion shadow-md' : ''"
|
||||||
class="container flex flex-col sm:flex-row item-center shadow-sm gap-2 py-2 my-2 hover:shadow-md hover:bg-primary-light dark:hover:bg-primary rounded-md p-2 duration-75 group cursor-pointer"
|
class="container flex sm:flex-row item-center shadow-sm gap-2 py-2 my-2 hover:shadow-md hover:bg-primary-light dark:hover:bg-primary rounded-md p-2 duration-75 group cursor-pointer"
|
||||||
:id="'dis-' + id" @click.stop="selectEvent()">
|
:id="'dis-' + id" @click.stop="selectEvent()">
|
||||||
|
|
||||||
|
<!-- PRE TITLE SECTION -->
|
||||||
|
<div class="flex flex-row items-center gap-2">
|
||||||
|
<!-- CHECKBOX -->
|
||||||
|
<div v-if="isCheckbox">
|
||||||
|
<input type="checkbox"
|
||||||
|
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500"
|
||||||
|
@click.stop v-model="checkBoxValue_local" @input="checkedChangeEvent($event, id)">
|
||||||
|
|
||||||
|
</div>
|
||||||
<!-- INDICATOR FOR SELECTED ITEM -->
|
<!-- INDICATOR FOR SELECTED ITEM -->
|
||||||
<div v-if="selected" class="items-center inline-block min-h-full w-2 rounded-xl self-stretch "
|
<div v-if="selected" class="min-h-full w-2 rounded-xl self-stretch "
|
||||||
:class="loading ? 'animate-bounce bg-accent ' : ' bg-secondary '"></div>
|
:class="loading ? 'animate-bounce bg-accent ' : ' bg-secondary '"></div>
|
||||||
<div v-if="!selected" class="items-center inline-block min-h-full w-2 rounded-xl self-stretch"></div>
|
<div v-if="!selected" class="w-2"
|
||||||
|
:class="loading ? 'min-h-full w-2 rounded-xl self-stretch animate-bounce bg-accent ' : ' '"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
<!-- TITLE -->
|
<!-- TITLE -->
|
||||||
<p v-if="!editTitle" :title="title" class="truncate w-full">{{ title ? title === "untitled" ? "New discussion" : title : "New discussion" }}</p>
|
<p v-if="!editTitle" :title="title" class="truncate w-full">{{ title ? title === "untitled" ? "New discussion" :
|
||||||
|
title : "New discussion" }}</p>
|
||||||
|
|
||||||
<input v-if="editTitle" type="text" id="title-box" class="bg-bg-light dark:bg-bg-dark rounded-md border-0 w-full -m-1 p-1"
|
<input v-if="editTitle" type="text" id="title-box"
|
||||||
:value="title" required @input="chnageTitle($event.target.value)" @click.stop>
|
class="bg-bg-light dark:bg-bg-dark rounded-md border-0 w-full -m-1 p-1" :value="title" required
|
||||||
|
@keydown.enter.exact="editTitleEvent()" @keydown.esc.exact="editTitleMode = false"
|
||||||
|
@input="chnageTitle($event.target.value)" @click.stop>
|
||||||
|
|
||||||
<!-- CONTROL BUTTONS -->
|
<!-- CONTROL BUTTONS -->
|
||||||
<div class="flex items-center flex-1 max-h-6">
|
<div class="flex items-center flex-1 max-h-6">
|
||||||
@ -29,7 +44,7 @@
|
|||||||
<!-- EDIT TITLE CONFIRM -->
|
<!-- EDIT TITLE CONFIRM -->
|
||||||
<div v-if="showConfirmation && editTitleMode" class="flex gap-3 flex-1 items-center justify-end duration-75">
|
<div v-if="showConfirmation && editTitleMode" class="flex gap-3 flex-1 items-center justify-end duration-75">
|
||||||
<button class="text-2xl hover:text-red-600 duration-75 active:scale-90 " title="Discard title changes"
|
<button class="text-2xl hover:text-red-600 duration-75 active:scale-90 " title="Discard title changes"
|
||||||
type="button" @click.stop="editTitleMode = false ">
|
type="button" @click.stop="editTitleMode = false">
|
||||||
<i data-feather="x"></i>
|
<i data-feather="x"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="text-2xl hover:text-secondary duration-75 active:scale-90" title="Confirm title changes"
|
<button class="text-2xl hover:text-secondary duration-75 active:scale-90" title="Confirm title changes"
|
||||||
@ -60,12 +75,14 @@ import feather from 'feather-icons'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Discussion',
|
name: 'Discussion',
|
||||||
emits: ['delete', 'select', 'editTitle'],
|
emits: ['delete', 'select', 'editTitle', 'checked'],
|
||||||
props: {
|
props: {
|
||||||
id: Number,
|
id: Number,
|
||||||
title: String,
|
title: String,
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
loading: Boolean
|
loading: Boolean,
|
||||||
|
isCheckbox: Boolean,
|
||||||
|
checkBoxValue: Boolean
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
@ -76,6 +93,7 @@ export default {
|
|||||||
editTitleMode: false,
|
editTitleMode: false,
|
||||||
editTitle: false,
|
editTitle: false,
|
||||||
newTitle: String,
|
newTitle: String,
|
||||||
|
checkBoxValue_local: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -87,8 +105,8 @@ export default {
|
|||||||
this.$emit("select")
|
this.$emit("select")
|
||||||
},
|
},
|
||||||
editTitleEvent() {
|
editTitleEvent() {
|
||||||
this.editTitle= false
|
this.editTitle = false
|
||||||
this.editTitleMode= false
|
this.editTitleMode = false
|
||||||
this.showConfirmation = false
|
this.showConfirmation = false
|
||||||
this.$emit("editTitle",
|
this.$emit("editTitle",
|
||||||
{
|
{
|
||||||
@ -96,12 +114,15 @@ export default {
|
|||||||
id: this.id
|
id: this.id
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
chnageTitle(text){
|
chnageTitle(text) {
|
||||||
this.newTitle=text
|
this.newTitle = text
|
||||||
|
},
|
||||||
|
checkedChangeEvent(event, id) {
|
||||||
|
this.$emit("checked", event, id)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.newTitle= this.title
|
this.newTitle = this.title
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
feather.replace()
|
feather.replace()
|
||||||
|
|
||||||
@ -116,8 +137,18 @@ export default {
|
|||||||
},
|
},
|
||||||
editTitleMode(newval) {
|
editTitleMode(newval) {
|
||||||
|
|
||||||
this.showConfirmation=newval
|
this.showConfirmation = newval
|
||||||
this.editTitle = newval
|
this.editTitle = newval
|
||||||
|
},
|
||||||
|
checkBoxValue(newval, oldval) {
|
||||||
|
this.checkBoxValue_local = newval
|
||||||
|
|
||||||
|
},
|
||||||
|
selected(newval, oldval) {
|
||||||
|
if (newval) {
|
||||||
|
const realTitle= this.title ? this.title === "untitled" ? "New discussion" : this.title : "New discussion"
|
||||||
|
document.title = 'GPT4ALL - WEBUI - '+ realTitle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,6 @@ import SettingsView from '../views/SettingsView.vue'
|
|||||||
import TrainingView from '../views/TrainingView.vue'
|
import TrainingView from '../views/TrainingView.vue'
|
||||||
import DiscussionsView from '../views/DiscussionsView.vue'
|
import DiscussionsView from '../views/DiscussionsView.vue'
|
||||||
|
|
||||||
// const scrollBehavior = (to, from, savedPosition) => {
|
|
||||||
// return savedPosition || { top: 0, left: 0 }
|
|
||||||
// }
|
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
@ -40,6 +37,8 @@ const router = createRouter({
|
|||||||
|
|
||||||
],
|
],
|
||||||
// scrollBehavior
|
// scrollBehavior
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
@ -1,73 +1,98 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="overflow-y-scroll flex flex-col no-scrollbar shadow-lg min-w-[24rem] max-w-[24rem] bg-bg-light-tone dark:bg-bg-dark-tone ">
|
class="overflow-y-scroll flex flex-col no-scrollbar shadow-lg min-w-[24rem] max-w-[24rem] bg-bg-light-tone dark:bg-bg-dark-tone">
|
||||||
<!-- LEFT SIDE PANEL -->
|
<!-- LEFT SIDE PANEL -->
|
||||||
<div
|
<div class="z-10 sticky top-0 flex-col bg-bg-light-tone dark:bg-bg-dark-tone shadow-md">
|
||||||
class="z-10 sticky top-0 flex-row p-2 flex items-center gap-3 flex-0 bg-bg-light-tone dark:bg-bg-dark-tone mt-0 px-4 shadow-md">
|
|
||||||
<!-- CONTROL PANEL -->
|
|
||||||
<button class=" text-2xl hover:text-secondary duration-75 active:scale-90 " title="Create new discussion"
|
|
||||||
type="button" @click="createNewDiscussion()">
|
|
||||||
<i data-feather="plus"></i>
|
|
||||||
</button>
|
|
||||||
<button class=" text-2xl hover:text-secondary duration-75 active:scale-90 "
|
|
||||||
title="Reset database, remove all discussions">
|
|
||||||
<i data-feather="refresh-ccw"></i>
|
|
||||||
</button>
|
|
||||||
<button class=" text-2xl hover:text-secondary duration-75 active:scale-90 " title="Export database"
|
|
||||||
type="button">
|
|
||||||
<i data-feather="database"></i>
|
|
||||||
</button>
|
|
||||||
<button class=" text-2xl hover:text-secondary duration-75 active:scale-90 rotate-90"
|
|
||||||
title="Export discussion to a file" type="button">
|
|
||||||
<i data-feather="log-out"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- SEARCH BAR -->
|
<!-- SEARCH BAR -->
|
||||||
<form>
|
<form class="flex-row p-4 items-center gap-3 flex-0 w-full">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
||||||
<div class="scale-75 ">
|
<div class="scale-75">
|
||||||
<i data-feather="search"></i>
|
<i data-feather="search"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="absolute inset-y-0 right-0 flex items-center pr-3 ">
|
<div class="absolute inset-y-0 right-0 flex items-center pr-3">
|
||||||
<div class=" hover:text-secondary duration-75 active:scale-90 "
|
<div class="hover:text-secondary duration-75 active:scale-90"
|
||||||
:class="filterTitle ? 'visible' : 'invisible'" title="Clear" @click="filterTitle = ''">
|
:class="filterTitle ? 'visible' : 'invisible'" title="Clear" @click="filterTitle = ''">
|
||||||
<i data-feather="x"></i>
|
<i data-feather="x"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="search" id="default-search"
|
<input type="search" id="default-search"
|
||||||
class="block w-full p-2 pl-10 pr-10 text-sm border border-gray-300 rounded-lg bg-bg-light focus:ring-secondary focus:border-secondary dark:bg-bg-dark dark:border-gray-600 dark:placeholder-gray-400 dark:focus:ring-secondary dark:focus:border-secondary "
|
class="block w-full p-2 pl-10 pr-10 text-sm border border-gray-300 rounded-lg bg-bg-light focus:ring-secondary focus:border-secondary dark:bg-bg-dark dark:border-gray-600 dark:placeholder-gray-400 dark:focus:ring-secondary dark:focus:border-secondary"
|
||||||
placeholder="Search..." title="Filter discussions by title" v-model="filterTitle"
|
placeholder="Search..." title="Filter discussions by title" v-model="filterTitle"
|
||||||
@input="filterDiscussions()">
|
@input="filterDiscussions()" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- CONTROL PANEL -->
|
||||||
|
<div class="flex-row p-4 pt-0 flex items-center gap-3 flex-0">
|
||||||
|
|
||||||
|
<!-- MAIN BUTTONS -->
|
||||||
|
<button class="text-2xl hover:text-secondary duration-75 active:scale-90" title="Create new discussion"
|
||||||
|
type="button" @click="createNewDiscussion()">
|
||||||
|
<i data-feather="plus"></i>
|
||||||
|
</button>
|
||||||
|
<button class="text-2xl hover:text-secondary duration-75 active:scale-90" title="Edit discussion list"
|
||||||
|
type="button" @click="isCheckbox = !isCheckbox" :class="isCheckbox ? 'text-secondary' : ''">
|
||||||
|
<i data-feather="check-square"></i>
|
||||||
|
</button>
|
||||||
|
<button class="text-2xl hover:text-secondary duration-75 active:scale-90"
|
||||||
|
title="Reset database, remove all discussions">
|
||||||
|
<i data-feather="refresh-ccw"></i>
|
||||||
|
</button>
|
||||||
|
<button class="text-2xl hover:text-secondary duration-75 active:scale-90" title="Export database"
|
||||||
|
type="button">
|
||||||
|
<i data-feather="database"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<hr v-if="isCheckbox" class="h-px bg-bg-light p-0 mb-4 px-4 mx-4 border-0 dark:bg-bg-dark">
|
||||||
|
<div v-if="isCheckbox" class="flex flex-row flex-grow p-4 pt-0 items-center">
|
||||||
|
|
||||||
|
<!-- CHECK BOX OPERATIONS -->
|
||||||
|
<div class="flex flex-row flex-grow gap-3">
|
||||||
|
Selected: {{ list.filter((item) => item.checkBoxValue == true).length }}
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-3">
|
||||||
|
|
||||||
|
|
||||||
|
<button class="text-2xl hover:text-secondary duration-75 active:scale-90 " title="Select All" type="button"
|
||||||
|
@click.stop="selectAllDiscussions">
|
||||||
|
<i data-feather="list"></i>
|
||||||
|
</button>
|
||||||
|
<button class="text-2xl hover:text-secondary duration-75 active:scale-90 rotate-90"
|
||||||
|
title="Export selected to a file" type="button">
|
||||||
|
<i data-feather="log-out"></i>
|
||||||
|
</button>
|
||||||
|
<button class="text-2xl hover:text-red-600 duration-75 active:scale-90 " title="Remove selected"
|
||||||
|
type="button">
|
||||||
|
<i data-feather="trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="relative overflow-y-scroll no-scrollbar">
|
<div class="relative overflow-y-scroll no-scrollbar">
|
||||||
<!-- DISCUSSION LIST -->
|
<!-- DISCUSSION LIST -->
|
||||||
<div class="mx-4 flex-grow" :class="filterInProgress ? 'opacity-20 pointer-events-none' : ''">
|
<div class="mx-4 flex-grow" :class="filterInProgress ? 'opacity-20 pointer-events-none' : ''">
|
||||||
|
<Discussion v-for="(item, index) in list" :key="index" :id="item.id" :title="item.title"
|
||||||
<Discussion v-for="(item, index) in list" :key="index" :id="item.id" :title="item.title" ref="discussionList"
|
:selected="currentDiscussion.id == item.id" :loading="item.loading"
|
||||||
:selected="currentDiscussion.id == item.id" :loading="currentDiscussion.id == item.id && loading"
|
:isCheckbox="isCheckbox" :checkBoxValue="item.checkBoxValue" @select="selectDiscussion(item)"
|
||||||
@select="selectDiscussion(item)" @delete="deleteDiscussion(item.id)" @editTitle="editTitle" />
|
@delete="deleteDiscussion(item.id)" @editTitle="editTitle" @checked="checkUncheckDiscussion" />
|
||||||
|
|
||||||
<div v-if="list.length < 1"
|
<div v-if="list.length < 1"
|
||||||
class=" gap-2 py-2 my-2 hover:shadow-md hover:bg-primary-light dark:hover:bg-primary rounded-md p-2 duration-75 group cursor-pointer">
|
class="gap-2 py-2 my-2 hover:shadow-md hover:bg-primary-light dark:hover:bg-primary rounded-md p-2 duration-75 group cursor-pointer">
|
||||||
<p class="px-3">No discussions are found</p>
|
<p class="px-3">No discussions are found</p>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="sticky bottom-0 bg-gradient-to-t pointer-events-none from-bg-light-tone dark:from-bg-dark-tone flex height-64 ">
|
class="sticky bottom-0 bg-gradient-to-t pointer-events-none from-bg-light-tone dark:from-bg-dark-tone flex height-64">
|
||||||
<!-- FADING DISCUSSION LIST END ELEMENT -->
|
<!-- FADING DISCUSSION LIST END ELEMENT -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-y-scroll flex flex-col no-scrollbar flex-grow "
|
<div class="overflow-y-scroll flex flex-col no-scrollbar flex-grow">
|
||||||
:class="loading ? 'opacity-20 pointer-events-none' : ''">
|
<!-- :class="loading ? 'opacity-20 pointer-events-none' : ''"> -->
|
||||||
<!-- CHAT AREA -->
|
<!-- CHAT AREA -->
|
||||||
<div>
|
<div>
|
||||||
<Message v-for="(msg, index) in discussionArr" :key="index" :message="msg"
|
<Message v-for="(msg, index) in discussionArr" :key="index" :message="msg"
|
||||||
@ -75,11 +100,8 @@
|
|||||||
|
|
||||||
<WelcomeComponent v-if="discussionArr.length < 1" />
|
<WelcomeComponent v-if="discussionArr.length < 1" />
|
||||||
|
|
||||||
<ChatBox v-if="discussionArr.length > 0" @messageSentEvent="sendMsg" />
|
<ChatBox v-if="discussionArr.length > 0" @messageSentEvent="sendMsg" :loading="isGenerating" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@ -89,72 +111,73 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
setup() { },
|
||||||
setup() {
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
list: [],
|
list: [], // Discussion list
|
||||||
tempList: [],
|
tempList: [], // Copy of Discussion list (used for keeping the original list during filtering discussions/searching action)
|
||||||
currentDiscussion: Number,
|
currentDiscussion: {}, // Current/selected discussion id
|
||||||
discussionArr: [],
|
discussionArr: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
filterTitle: "",
|
filterTitle: '',
|
||||||
filterInProgress: false,
|
filterInProgress: false,
|
||||||
showCreateDiscussionModal: false
|
isCreated: false,
|
||||||
|
isGenerating: false,
|
||||||
|
isCheckbox: false,
|
||||||
|
isSelectAll: false,
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async list_discussions() {
|
async list_discussions() {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get("/list_discussions");
|
const res = await axios.get('/list_discussions')
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
this.list = res.data
|
|
||||||
this.tempList = this.list
|
|
||||||
return res.data
|
|
||||||
|
|
||||||
|
this.createDiscussionList(res.data)
|
||||||
|
return res.data
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
async load_discussion(id) {
|
async load_discussion(id) {
|
||||||
try {
|
try {
|
||||||
if (id) {
|
if (id) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const res = await axios.post("/load_discussion", {
|
this.setDiscussionLoading(id,this.loading)
|
||||||
|
const res = await axios.post('/load_discussion', {
|
||||||
id: id
|
id: id
|
||||||
});
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.setDiscussionLoading(id,this.loading)
|
||||||
if (res) {
|
if (res) {
|
||||||
|
// Filter out the user and bot entries
|
||||||
this.discussionArr = res.data.filter((item) => item.sender != "conditionner") // Filter out the conditionner entries
|
this.discussionArr = res.data.filter((item) => item.type == 0)
|
||||||
|
const lastMessage = this.discussionArr[this.discussionArr.length - 1]
|
||||||
|
if (lastMessage) {
|
||||||
|
nextTick(() => {
|
||||||
|
const selectedElement = document.getElementById('msg-' + lastMessage.id)
|
||||||
|
this.scrollToElement(selectedElement)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.setDiscussionLoading(id,this.loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
async new_discussion(title) {
|
async new_discussion(title) {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get("/new_discussion", { params: { title: title } });
|
const res = await axios.get('/new_discussion', { params: { title: title } })
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
return res.data
|
return res.data
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -165,97 +188,112 @@ export default {
|
|||||||
try {
|
try {
|
||||||
if (id) {
|
if (id) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const res = await axios.post("/delete_discussion", {
|
this.setDiscussionLoading(id,this.loading)
|
||||||
|
const res = await axios.post('/delete_discussion', {
|
||||||
id: id
|
id: id
|
||||||
});
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.setDiscussionLoading(id,this.loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.setDiscussionLoading(id,this.loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
async edit_title(discussion_id, new_title) {
|
async edit_title(id, new_title) {
|
||||||
try {
|
try {
|
||||||
if (discussion_id) {
|
if (id) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const res = await axios.post("/edit_title", {
|
this.setDiscussionLoading(id,this.loading)
|
||||||
id: discussion_id,
|
const res = await axios.post('/edit_title', {
|
||||||
|
id: id,
|
||||||
title: new_title
|
title: new_title
|
||||||
});
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.setDiscussionLoading(id,this.loading)
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
const index = this.list.findIndex(x => x.id == discussion_id);
|
const index = this.list.findIndex((x) => x.id == id)
|
||||||
const discussionItem = this.list[index]
|
const discussionItem = this.list[index]
|
||||||
discussionItem.title = new_title
|
discussionItem.title = new_title
|
||||||
this.tempList = this.list
|
this.tempList = this.list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.setDiscussionLoading(id,this.loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
filterDiscussions() {
|
filterDiscussions() {
|
||||||
|
// Search bar in for filtering discussions by title (serch)
|
||||||
|
|
||||||
if (!this.filterInProgress) {
|
if (!this.filterInProgress) {
|
||||||
this.filterInProgress = true
|
this.filterInProgress = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
this.list = this.tempList.filter((item) => item.title && item.title.includes(this.filterTitle))
|
||||||
this.list = this.tempList.filter((item) => item.title.includes(this.filterTitle))
|
|
||||||
this.filterInProgress = false
|
this.filterInProgress = false
|
||||||
|
|
||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async selectDiscussion(item) {
|
async selectDiscussion(item) {
|
||||||
|
// When discussion is selected it loads the discussion array
|
||||||
|
|
||||||
this.currentDiscussion = item
|
this.currentDiscussion = item
|
||||||
|
|
||||||
|
localStorage.setItem('selected_discussion', this.currentDiscussion.id)
|
||||||
|
|
||||||
await this.load_discussion(item.id)
|
await this.load_discussion(item.id)
|
||||||
|
|
||||||
if (this.discussionArr.length > 1) {
|
if (this.discussionArr.length > 1) {
|
||||||
|
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
|
||||||
if (this.currentDiscussion.title === "" || this.currentDiscussion.title === null ) {
|
|
||||||
this.changeTitleUsingUserMSG(this.currentDiscussion.id, this.discussionArr[1].content)
|
this.changeTitleUsingUserMSG(this.currentDiscussion.id, this.discussionArr[1].content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nextTick(() => {
|
||||||
|
const selectedDisElement = document.getElementById('dis-' + item.id)
|
||||||
|
this.scrollToElement(selectedDisElement)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
scrollToElement(el) {
|
scrollToElement(el) {
|
||||||
|
//console.log("scroll", el.id)
|
||||||
if (el) {
|
if (el) {
|
||||||
|
el.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' })
|
||||||
el.scrollIntoView({ behavior: 'smooth', block: "center", inline: "nearest" });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createMsg(msgObj) {
|
createMsg(msgObj) {
|
||||||
// From websocket.on("infos")
|
// From websocket.on("infos")
|
||||||
|
// {
|
||||||
|
// "type": "input_message_infos",
|
||||||
|
// "bot": "gpt4all",
|
||||||
|
// "user": "user",
|
||||||
|
// "message": "giv emoney",
|
||||||
|
// "id": 112,
|
||||||
|
// "response_id": 113
|
||||||
|
// }
|
||||||
|
|
||||||
// Create user input message
|
// Create user input message
|
||||||
let usrMessage = {
|
let usrMessage = {
|
||||||
content: msgObj.message,
|
content: msgObj.message,
|
||||||
id: msgObj.message,
|
id: msgObj.id,
|
||||||
//parent: 10,
|
//parent: 10,
|
||||||
rank: 0,
|
rank: 0,
|
||||||
sender: msgObj.user,
|
sender: msgObj.user
|
||||||
//type: 0
|
//type: 0
|
||||||
}
|
}
|
||||||
this.discussionArr.push(usrMessage)
|
this.discussionArr.push(usrMessage)
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const userMsgElement = document.getElementById('msg-' + msgObj.message)
|
const userMsgElement = document.getElementById('msg-' + msgObj.message)
|
||||||
this.scrollToElement(userMsgElement)
|
this.scrollToElement(userMsgElement)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Create response message
|
// Create response message
|
||||||
let responseMessage = {
|
let responseMessage = {
|
||||||
content: "..typing",
|
content: '..typing',
|
||||||
id: msgObj.response_id,
|
id: msgObj.response_id,
|
||||||
//parent: 10,
|
//parent: 10,
|
||||||
rank: 0,
|
rank: 0,
|
||||||
sender: msgObj.bot,
|
sender: msgObj.bot
|
||||||
//type: 0
|
//type: 0
|
||||||
}
|
}
|
||||||
this.discussionArr.push(responseMessage)
|
this.discussionArr.push(responseMessage)
|
||||||
@ -264,120 +302,204 @@ export default {
|
|||||||
this.scrollToElement(responseMessageElement)
|
this.scrollToElement(responseMessageElement)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.currentDiscussion.title === "" || this.currentDiscussion.title === null) {
|
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
|
||||||
this.changeTitleUsingUserMSG(this.currentDiscussion.id, usrMessage.content)
|
this.changeTitleUsingUserMSG(this.currentDiscussion.id, usrMessage.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.isGenerating = false
|
||||||
|
this.setDiscussionLoading(this.currentDiscussion.id,this.isGenerating)
|
||||||
},
|
},
|
||||||
sendMsg(msg) {
|
sendMsg(msg) {
|
||||||
|
// Sends message to backend
|
||||||
websocket.emit('generate_msg', { prompt: msg });
|
this.isGenerating = true
|
||||||
|
this.setDiscussionLoading(this.currentDiscussion.id,this.isGenerating)
|
||||||
|
websocket.emit('generate_msg', { prompt: msg })
|
||||||
},
|
},
|
||||||
steamMessageContent(content) {
|
steamMessageContent(content) {
|
||||||
|
// Streams response message content from backend
|
||||||
|
|
||||||
const lastMsg = this.discussionArr[this.discussionArr.length - 1]
|
const lastMsg = this.discussionArr[this.discussionArr.length - 1]
|
||||||
lastMsg.content = content.data
|
lastMsg.content = content.data
|
||||||
},
|
},
|
||||||
async changeTitleUsingUserMSG(id, msg) {
|
async changeTitleUsingUserMSG(id, msg) {
|
||||||
const index = this.list.findIndex(x => x.id == id);
|
// If discussion is untitled or title is null then it sets the title to first user message.
|
||||||
|
|
||||||
|
const index = this.list.findIndex((x) => x.id == id)
|
||||||
const discussionItem = this.list[index]
|
const discussionItem = this.list[index]
|
||||||
if (msg) {
|
if (msg) {
|
||||||
discussionItem.title = msg
|
discussionItem.title = msg
|
||||||
this.tempList = this.list
|
this.tempList = this.list
|
||||||
}
|
}
|
||||||
await this.edit_title(id,msg)
|
await this.edit_title(id, msg)
|
||||||
|
|
||||||
},
|
},
|
||||||
async createNewDiscussion() {
|
async createNewDiscussion() {
|
||||||
|
// Creates new discussion on backend,
|
||||||
|
// gets new discussion list, selects
|
||||||
|
// newly created discussion,
|
||||||
|
// scrolls to the discussion
|
||||||
|
|
||||||
const res = await this.new_discussion()
|
const res = await this.new_discussion()
|
||||||
await this.list_discussions()
|
await this.list_discussions()
|
||||||
const index = this.list.findIndex(x => x.id == res.id);
|
const index = this.list.findIndex((x) => x.id == res.id)
|
||||||
const discussionItem = this.list[index]
|
const discussionItem = this.list[index]
|
||||||
this.selectDiscussion(discussionItem)
|
this.selectDiscussion(discussionItem)
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const selectedDisElement = document.getElementById('dis-' + res.id)
|
const selectedDisElement = document.getElementById('dis-' + res.id)
|
||||||
this.scrollToElement(selectedDisElement)
|
this.scrollToElement(selectedDisElement)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
loadLastUsedDiscussion() {
|
||||||
|
// Checks local storage for last selected discussion
|
||||||
|
const id = localStorage.getItem('selected_discussion')
|
||||||
|
if (id) {
|
||||||
|
const index = this.list.findIndex((x) => x.id == id)
|
||||||
|
const discussionItem = this.list[index]
|
||||||
|
if(discussionItem){
|
||||||
|
this.selectDiscussion(discussionItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async deleteDiscussion(id) {
|
async deleteDiscussion(id) {
|
||||||
const index = this.list.findIndex(x => x.id == id);
|
// Deletes discussion from backend and frontend
|
||||||
|
|
||||||
|
const index = this.list.findIndex((x) => x.id == id)
|
||||||
const discussionItem = this.list[index]
|
const discussionItem = this.list[index]
|
||||||
discussionItem.loading=true
|
discussionItem.loading = true
|
||||||
this.delete_discussion(id)
|
await this.delete_discussion(id)
|
||||||
if (this.currentDiscussion.id == id) {
|
if (this.currentDiscussion.id == id) {
|
||||||
this.currentDiscussion = {}
|
this.currentDiscussion = {}
|
||||||
|
this.discussionArr=[]
|
||||||
}
|
}
|
||||||
await this.list_discussions()
|
this.list.splice(this.list.findIndex(item => item.id==id),1)
|
||||||
|
|
||||||
|
this.createDiscussionList(this.list)
|
||||||
|
//await this.list_discussions()
|
||||||
},
|
},
|
||||||
async editTitle(newTitleObj) {
|
async editTitle(newTitleObj) {
|
||||||
//const index = this.$refs.discussionList.findIndex(x => x.id == newTitleObj.id);
|
|
||||||
//const discussionItem = this.$refs.discussionList[index]
|
const index = this.list.findIndex((x) => x.id == newTitleObj.id)
|
||||||
//console.log(JSON.stringify(discussionItem))
|
const discussionItem = this.list[index]
|
||||||
//discussionItem.loading.value=true
|
discussionItem.title = newTitleObj.title
|
||||||
//console.log(discussionItem.title)
|
discussionItem.loading = true
|
||||||
await this.edit_title(newTitleObj.id, newTitleObj.title)
|
await this.edit_title(newTitleObj.id, newTitleObj.title)
|
||||||
|
discussionItem.loading = false
|
||||||
},
|
},
|
||||||
|
checkUncheckDiscussion(event, id) {
|
||||||
|
// If checked = true and item is not in array then add item to list
|
||||||
|
const index = this.list.findIndex((x) => x.id == id)
|
||||||
|
const discussionItem = this.list[index]
|
||||||
|
discussionItem.checkBoxValue = event.target.checked
|
||||||
|
this.tempList = this.list
|
||||||
|
},
|
||||||
|
selectAllDiscussions() {
|
||||||
|
|
||||||
|
// Check if there is one discussion not selected
|
||||||
|
this.isSelectAll = !this.tempList.filter((item) => item.checkBoxValue == false).length > 0
|
||||||
|
// Selects or deselects all discussions
|
||||||
|
for (let i = 0; i < this.tempList.length; i++) {
|
||||||
|
this.tempList[i].checkBoxValue = !this.isSelectAll
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tempList = this.list
|
||||||
|
this.isSelectAll = !this.isSelectAll
|
||||||
|
},
|
||||||
|
createDiscussionList(disList) {
|
||||||
|
// This creates a discussion list for UI with additional properties
|
||||||
|
if (disList) {
|
||||||
|
const newDisList = disList.map((item) => {
|
||||||
|
|
||||||
|
const newItem = {
|
||||||
|
id: item.id,
|
||||||
|
title: item.title,
|
||||||
|
selected: false,
|
||||||
|
loading: false,
|
||||||
|
checkBoxValue: false
|
||||||
|
}
|
||||||
|
return newItem
|
||||||
|
|
||||||
|
})
|
||||||
|
this.list = newDisList
|
||||||
|
this.tempList = newDisList
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setDiscussionLoading(id,loading){
|
||||||
|
const index = this.list.findIndex((x) => x.id == id)
|
||||||
|
const discussionItem = this.list[index]
|
||||||
|
discussionItem.loading = loading
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
||||||
await this.list_discussions()
|
await this.list_discussions()
|
||||||
|
|
||||||
|
this.loadLastUsedDiscussion()
|
||||||
|
this.isCreated = true
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
feather.replace()
|
feather.replace()
|
||||||
})
|
})
|
||||||
|
|
||||||
// WebSocket responses
|
// WebSocket responses
|
||||||
websocket.on("infos", this.createMsg)
|
websocket.on('infos', this.createMsg)
|
||||||
websocket.on("message", this.steamMessageContent)
|
websocket.on('message', this.steamMessageContent)
|
||||||
|
},
|
||||||
|
activated() {
|
||||||
|
// This lifecycle hook runs every time you switch from other page back to this page (vue-router)
|
||||||
|
// To fix scrolling back to last message, this hook is needed.
|
||||||
|
// If anyone knows hor to fix scroll issue when changing pages, please do fix it :D
|
||||||
|
|
||||||
}, components: {
|
if (this.isCreated) {
|
||||||
|
this.loadLastUsedDiscussion()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
Discussion,
|
Discussion,
|
||||||
Message,
|
Message,
|
||||||
ChatBox,
|
ChatBox,
|
||||||
WelcomeComponent,
|
WelcomeComponent
|
||||||
|
},
|
||||||
}, watch: {
|
watch: {
|
||||||
filterTitle(newVal, oldVal) {
|
filterTitle(newVal, oldVal) {
|
||||||
if (newVal == "") {
|
if (newVal == '') {
|
||||||
this.filterInProgress = true
|
this.filterInProgress = true
|
||||||
this.list = this.tempList
|
this.list = this.tempList
|
||||||
this.filterInProgress = false
|
this.filterInProgress = false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isCheckbox(newval, oldval) {
|
||||||
|
nextTick(() => {
|
||||||
|
feather.replace()
|
||||||
|
})
|
||||||
|
if (!newval) {
|
||||||
|
this.isSelectAll = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup >
|
<script setup>
|
||||||
import Discussion from '../components/Discussion.vue';
|
import Discussion from '../components/Discussion.vue'
|
||||||
import Message from '../components/Message.vue';
|
import Message from '../components/Message.vue'
|
||||||
import ChatBox from '../components/ChatBox.vue'
|
import ChatBox from '../components/ChatBox.vue'
|
||||||
import WelcomeComponent from '../components/WelcomeComponent.vue'
|
import WelcomeComponent from '../components/WelcomeComponent.vue'
|
||||||
|
|
||||||
import feather from 'feather-icons'
|
import feather from 'feather-icons'
|
||||||
|
|
||||||
import axios from "axios";
|
import axios from 'axios'
|
||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue'
|
||||||
|
|
||||||
import websocket from '@/services/websocket.js';
|
import websocket from '@/services/websocket.js'
|
||||||
|
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { initFlowbite } from 'flowbite'
|
import { initFlowbite } from 'flowbite'
|
||||||
|
|
||||||
// initialize components based on data attribute selectors
|
// initialize components based on data attribute selectors
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initFlowbite();
|
initFlowbite()
|
||||||
})
|
})
|
||||||
|
|
||||||
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL;
|
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
|
||||||
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue
Block a user