:gem: [Feature] New Chat Agents Sidebar
Browse files- components/buttons_binder.js +74 -15
- components/inputs_binder.js +12 -7
- css/default.css +3 -2
- index.html +26 -3
components/buttons_binder.js
CHANGED
@@ -32,6 +32,9 @@ export class ButtonsBinder {
|
|
32 |
let chat_history_sidebar_toggle_button_binder =
|
33 |
new ChatHistorySidebarToggleButtonBinder();
|
34 |
chat_history_sidebar_toggle_button_binder.bind();
|
|
|
|
|
|
|
35 |
let clear_chat_history_button_binder =
|
36 |
new ClearChatHistoryButtonBinder();
|
37 |
clear_chat_history_button_binder.bind();
|
@@ -201,43 +204,46 @@ class ScreenshotButtonBinder {
|
|
201 |
}
|
202 |
|
203 |
class ChatHistorySidebarToggleButtonBinder {
|
204 |
-
constructor() {
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
207 |
}
|
208 |
bind() {
|
209 |
-
const sidebar = $(
|
210 |
-
|
211 |
// this line is not to check value as false,
|
212 |
// but to check item not existed in localStorage
|
213 |
-
if (!this.
|
214 |
-
localStorage.setItem(
|
215 |
}
|
216 |
-
if (this.
|
217 |
sidebar.addClass("show");
|
218 |
}
|
219 |
|
220 |
-
const toggle_button = $(
|
221 |
toggle_button.click(() => {
|
222 |
sidebar.toggleClass("show");
|
223 |
localStorage.setItem(
|
224 |
-
|
225 |
sidebar.hasClass("show").toString()
|
226 |
);
|
227 |
});
|
228 |
-
|
229 |
-
const close_button = $("#chat-history-sidebar-close-button");
|
230 |
close_button.click(() => {
|
231 |
sidebar.removeClass("show");
|
232 |
-
localStorage.setItem(
|
233 |
});
|
234 |
}
|
235 |
}
|
236 |
|
237 |
class ClearChatHistoryButtonBinder {
|
238 |
-
constructor() {
|
|
|
|
|
239 |
bind() {
|
240 |
-
const button = $(
|
241 |
button.attr("title", "Clear chat history");
|
242 |
button.click(() => {
|
243 |
if (confirm("Clear chat history?")) {
|
@@ -249,6 +255,59 @@ class ClearChatHistoryButtonBinder {
|
|
249 |
}
|
250 |
}
|
251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
class AvailableModelsSelectBinder {
|
253 |
constructor() {}
|
254 |
bind() {
|
|
|
32 |
let chat_history_sidebar_toggle_button_binder =
|
33 |
new ChatHistorySidebarToggleButtonBinder();
|
34 |
chat_history_sidebar_toggle_button_binder.bind();
|
35 |
+
let chat_agents_sidebar_toggle_button_binder =
|
36 |
+
new ChatAgentsSidebarToggleButtonBinder();
|
37 |
+
chat_agents_sidebar_toggle_button_binder.bind();
|
38 |
let clear_chat_history_button_binder =
|
39 |
new ClearChatHistoryButtonBinder();
|
40 |
clear_chat_history_button_binder.bind();
|
|
|
204 |
}
|
205 |
|
206 |
class ChatHistorySidebarToggleButtonBinder {
|
207 |
+
constructor() {
|
208 |
+
this.storage_key = "show_chat_history_sidebar";
|
209 |
+
this.sidebar_name = "chat-history";
|
210 |
+
}
|
211 |
+
get_show_history_sidebar_storage() {
|
212 |
+
return localStorage.getItem(this.storage_key);
|
213 |
}
|
214 |
bind() {
|
215 |
+
const sidebar = $(`#${this.sidebar_name}-sidebar`);
|
|
|
216 |
// this line is not to check value as false,
|
217 |
// but to check item not existed in localStorage
|
218 |
+
if (!this.get_show_history_sidebar_storage()) {
|
219 |
+
localStorage.setItem(this.storage_key, "true");
|
220 |
}
|
221 |
+
if (this.get_show_history_sidebar_storage() === "true") {
|
222 |
sidebar.addClass("show");
|
223 |
}
|
224 |
|
225 |
+
const toggle_button = $(`#${this.sidebar_name}-sidebar-toggle-button`);
|
226 |
toggle_button.click(() => {
|
227 |
sidebar.toggleClass("show");
|
228 |
localStorage.setItem(
|
229 |
+
this.storage_key,
|
230 |
sidebar.hasClass("show").toString()
|
231 |
);
|
232 |
});
|
233 |
+
const close_button = $(`#${this.sidebar_name}-sidebar-close-button`);
|
|
|
234 |
close_button.click(() => {
|
235 |
sidebar.removeClass("show");
|
236 |
+
localStorage.setItem(this.storage_key, "false");
|
237 |
});
|
238 |
}
|
239 |
}
|
240 |
|
241 |
class ClearChatHistoryButtonBinder {
|
242 |
+
constructor() {
|
243 |
+
this.sidebar_name = "chat-history";
|
244 |
+
}
|
245 |
bind() {
|
246 |
+
const button = $(`#clear-${this.sidebar_name}-button`);
|
247 |
button.attr("title", "Clear chat history");
|
248 |
button.click(() => {
|
249 |
if (confirm("Clear chat history?")) {
|
|
|
255 |
}
|
256 |
}
|
257 |
|
258 |
+
class ChatAgentsSidebarToggleButtonBinder {
|
259 |
+
constructor() {
|
260 |
+
this.storage_key = "show_chat_agents_sidebar";
|
261 |
+
this.sidebar_name = "chat-agents";
|
262 |
+
}
|
263 |
+
get_show_sidebar_storage() {
|
264 |
+
return localStorage.getItem(this.storage_key);
|
265 |
+
}
|
266 |
+
bind() {
|
267 |
+
const sidebar = $(`#${this.sidebar_name}-sidebar`);
|
268 |
+
// this line is not to check value as false,
|
269 |
+
// but to check item not existed in localStorage
|
270 |
+
if (!this.get_show_sidebar_storage()) {
|
271 |
+
localStorage.setItem(this.storage_key, "true");
|
272 |
+
}
|
273 |
+
if (this.get_show_sidebar_storage() === "true") {
|
274 |
+
sidebar.addClass("show");
|
275 |
+
}
|
276 |
+
|
277 |
+
const toggle_button = $(`#${this.sidebar_name}-sidebar-toggle-button`);
|
278 |
+
toggle_button.click(() => {
|
279 |
+
sidebar.toggleClass("show");
|
280 |
+
localStorage.setItem(
|
281 |
+
this.storage_key,
|
282 |
+
sidebar.hasClass("show").toString()
|
283 |
+
);
|
284 |
+
});
|
285 |
+
|
286 |
+
const close_button = $(`#${this.sidebar_name}-sidebar-close-button`);
|
287 |
+
close_button.click(() => {
|
288 |
+
sidebar.removeClass("show");
|
289 |
+
localStorage.setItem(this.storage_key, "false");
|
290 |
+
});
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
class ClearChatAgentsButtonBinder {
|
295 |
+
constructor() {
|
296 |
+
this.sidebar_name = "chat-agents";
|
297 |
+
}
|
298 |
+
bind() {
|
299 |
+
const button = $(`#clear-${this.sidebar_name}-button`);
|
300 |
+
button.attr("title", "Clear agents");
|
301 |
+
button.click(() => {
|
302 |
+
if (confirm("Clear agents?")) {
|
303 |
+
// chat_history_storer.clear_database();
|
304 |
+
} else {
|
305 |
+
console.log("Clear agents canceled.");
|
306 |
+
}
|
307 |
+
});
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
class AvailableModelsSelectBinder {
|
312 |
constructor() {}
|
313 |
bind() {
|
components/inputs_binder.js
CHANGED
@@ -69,18 +69,18 @@ class ChatHistorySidebarResizeBinder {
|
|
69 |
this.SIDEBAR_GAP
|
70 |
);
|
71 |
}
|
72 |
-
need_to_show() {
|
73 |
-
let sidebar = $(
|
74 |
return (
|
75 |
!sidebar.hasClass("show") &&
|
76 |
-
localStorage.getItem(
|
77 |
);
|
78 |
}
|
79 |
-
|
80 |
-
let sidebar = $(
|
81 |
let is_sidebar_show = sidebar[0].classList.contains("show");
|
82 |
if (this.get_side_margin() >= this.SIDEBAR_MAX_WIDTH) {
|
83 |
-
if (this.need_to_show()) {
|
84 |
sidebar.addClass("show");
|
85 |
}
|
86 |
sidebar.css("max-width", this.SIDEBAR_MAX_WIDTH + "px");
|
@@ -92,11 +92,16 @@ class ChatHistorySidebarResizeBinder {
|
|
92 |
sidebar.css("max-width", this.SIDEBAR_MAX_WIDTH + "px");
|
93 |
sidebar.css("min-width", this.SIDEBAR_MIN_WIDTH + "px");
|
94 |
} else {
|
95 |
-
if (this.need_to_show()) {
|
96 |
sidebar.addClass("show");
|
97 |
}
|
98 |
sidebar.css("max-width", this.get_side_margin());
|
99 |
sidebar.css("min-width", this.SIDEBAR_MIN_WIDTH + "px");
|
100 |
}
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
|
|
69 |
this.SIDEBAR_GAP
|
70 |
);
|
71 |
}
|
72 |
+
need_to_show(sidebar_name = null) {
|
73 |
+
let sidebar = $(`#chat-${sidebar_name}-sidebar`);
|
74 |
return (
|
75 |
!sidebar.hasClass("show") &&
|
76 |
+
localStorage.getItem(`show_chat_${sidebar_name}_sidebar`) === "true"
|
77 |
);
|
78 |
}
|
79 |
+
resize_sidebar(sidebar_name = null) {
|
80 |
+
let sidebar = $(`#chat-${sidebar_name}-sidebar`);
|
81 |
let is_sidebar_show = sidebar[0].classList.contains("show");
|
82 |
if (this.get_side_margin() >= this.SIDEBAR_MAX_WIDTH) {
|
83 |
+
if (this.need_to_show(sidebar_name)) {
|
84 |
sidebar.addClass("show");
|
85 |
}
|
86 |
sidebar.css("max-width", this.SIDEBAR_MAX_WIDTH + "px");
|
|
|
92 |
sidebar.css("max-width", this.SIDEBAR_MAX_WIDTH + "px");
|
93 |
sidebar.css("min-width", this.SIDEBAR_MIN_WIDTH + "px");
|
94 |
} else {
|
95 |
+
if (this.need_to_show(sidebar_name)) {
|
96 |
sidebar.addClass("show");
|
97 |
}
|
98 |
sidebar.css("max-width", this.get_side_margin());
|
99 |
sidebar.css("min-width", this.SIDEBAR_MIN_WIDTH + "px");
|
100 |
}
|
101 |
}
|
102 |
+
resize() {
|
103 |
+
for (let sidebar_name of ["history", "agents"]) {
|
104 |
+
this.resize_sidebar(sidebar_name);
|
105 |
+
}
|
106 |
+
}
|
107 |
}
|
css/default.css
CHANGED
@@ -48,10 +48,10 @@ body {
|
|
48 |
|
49 |
.message-user,
|
50 |
.message-assistant {
|
51 |
-
box-shadow: 0px 0px
|
52 |
border-radius: 5px;
|
53 |
padding: 5px 0px 5px 0px;
|
54 |
-
margin: 0px 0px
|
55 |
}
|
56 |
|
57 |
.message-user {
|
@@ -75,6 +75,7 @@ body {
|
|
75 |
background-color: #fff5e5;
|
76 |
}
|
77 |
|
|
|
78 |
#chat-history-sidebar {
|
79 |
box-shadow: 0px 0px 8px 0px rgba(122, 122, 122, 0.4);
|
80 |
/* background-image: linear-gradient(-45deg, #eef3ff, #e9efff); */
|
|
|
48 |
|
49 |
.message-user,
|
50 |
.message-assistant {
|
51 |
+
box-shadow: 0px 0px 6px 0px rgba(122, 122, 122, 0.5);
|
52 |
border-radius: 5px;
|
53 |
padding: 5px 0px 5px 0px;
|
54 |
+
margin: 0px 0px 8px 0px;
|
55 |
}
|
56 |
|
57 |
.message-user {
|
|
|
75 |
background-color: #fff5e5;
|
76 |
}
|
77 |
|
78 |
+
#chat-agents-sidebar,
|
79 |
#chat-history-sidebar {
|
80 |
box-shadow: 0px 0px 8px 0px rgba(122, 122, 122, 0.4);
|
81 |
/* background-image: linear-gradient(-45deg, #eef3ff, #e9efff); */
|
index.html
CHANGED
@@ -23,8 +23,9 @@
|
|
23 |
</head>
|
24 |
|
25 |
<body>
|
26 |
-
|
27 |
-
|
|
|
28 |
<div class="offcanvas-header">
|
29 |
<h5 class="offcanvas-title" id="chat-history-label">
|
30 |
<a style="text-decoration: none; color:inherit;" href="#">Chat History</a>
|
@@ -49,6 +50,28 @@
|
|
49 |
</div>
|
50 |
</div>
|
51 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
<div id="main-container" class="container">
|
53 |
<div id="top-toolbar" class="container mt-2">
|
54 |
<div class="my-1 row no-gutters justify-content-start">
|
@@ -71,7 +94,7 @@
|
|
71 |
</button>
|
72 |
</div>
|
73 |
<div class="col-auto">
|
74 |
-
<button id="
|
75 |
<i class="fa fa-user"></i>
|
76 |
</button>
|
77 |
</div>
|
|
|
23 |
</head>
|
24 |
|
25 |
<body>
|
26 |
+
|
27 |
+
<div class="offcanvas offcanvas-start" data-bs-scroll="true" data-bs-backdrop="false" id="chat-history-sidebar"
|
28 |
+
aria-labelledby="chat-history-sidebar-label">
|
29 |
<div class="offcanvas-header">
|
30 |
<h5 class="offcanvas-title" id="chat-history-label">
|
31 |
<a style="text-decoration: none; color:inherit;" href="#">Chat History</a>
|
|
|
50 |
</div>
|
51 |
</div>
|
52 |
</div>
|
53 |
+
<div class="offcanvas offcanvas-end" data-bs-scroll="true" data-bs-backdrop="false" id="chat-agents-sidebar"
|
54 |
+
aria-labelledby="chat-agents-sidebar-label">
|
55 |
+
<div class="offcanvas-header">
|
56 |
+
<button id="chat-agents-sidebar-close-button" class="btn-close">
|
57 |
+
</button>
|
58 |
+
<h5 class="offcanvas-title" id="chat-agents-label">
|
59 |
+
<a style="text-decoration: none; color:inherit;" href="#">Agents</a>
|
60 |
+
</h5>
|
61 |
+
</div>
|
62 |
+
<div class="offcanvas-body">
|
63 |
+
<ul id="chat-agents-sidebar-items" class="navbar-nav justify-content-end flex-grow-1">
|
64 |
+
</ul>
|
65 |
+
</div>
|
66 |
+
<div class="my-2 row no-gutters justify-content-start">
|
67 |
+
<div class="col">
|
68 |
+
<button id="clear-chat-agents-button" class="btn">
|
69 |
+
<i class="fa fa-trash"></i>
|
70 |
+
</button>
|
71 |
+
</div>
|
72 |
+
|
73 |
+
</div>
|
74 |
+
</div>
|
75 |
<div id="main-container" class="container">
|
76 |
<div id="top-toolbar" class="container mt-2">
|
77 |
<div class="my-1 row no-gutters justify-content-start">
|
|
|
94 |
</button>
|
95 |
</div>
|
96 |
<div class="col-auto">
|
97 |
+
<button id="chat-agents-sidebar-toggle-button" class="btn px-0">
|
98 |
<i class="fa fa-user"></i>
|
99 |
</button>
|
100 |
</div>
|