@@ -20,13 +20,13 @@ const getBackgroundImageURLForSide = (side, brain) => {
return "/dashboard/static/images/chatbot_user.webp";
} else {
if (brain == "teknium/OpenHermes-2.5-Mistral-7B") {
- return "/dashboard/static/images/logos/openhermes.webp"
+ return "/dashboard/static/images/logos/openhermes.webp";
} else if (brain == "Gryphe/MythoMax-L2-13b") {
- return "/dashboard/static/images/logos/mythomax.webp"
+ return "/dashboard/static/images/logos/mythomax.webp";
} else if (brain == "berkeley-nest/Starling-LM-7B-alpha") {
- return "/dashboard/static/images/logos/starling.webp"
+ return "/dashboard/static/images/logos/starling.webp";
} else if (brain == "openai") {
- return "/dashboard/static/images/logos/openai.webp"
+ return "/dashboard/static/images/logos/openai.webp";
}
}
};
@@ -73,15 +73,15 @@ const knowledgeBaseIdToName = (knowledgeBase) => {
const brainIdToName = (brain) => {
if (brain == "teknium/OpenHermes-2.5-Mistral-7B") {
- return "OpenHermes"
+ return "OpenHermes";
} else if (brain == "Gryphe/MythoMax-L2-13b") {
- return "MythoMax"
+ return "MythoMax";
} else if (brain == "berkeley-nest/Starling-LM-7B-alpha") {
- return "Starling"
+ return "Starling";
} else if (brain == "openai") {
- return "ChatGPT"
+ return "ChatGPT";
}
-}
+};
const createKnowledgeBaseNotice = (knowledgeBase) => {
return `
@@ -92,12 +92,12 @@ const createKnowledgeBaseNotice = (knowledgeBase) => {
};
class Message {
- constructor(id, side, brain, text, is_partial=false) {
- this.id = id
- this.side = side
- this.brain = brain
- this.text = text
- this.is_partial = is_partial
+ constructor(id, side, brain, text, is_partial = false) {
+ this.id = id;
+ this.side = side;
+ this.brain = brain;
+ this.text = text;
+ this.is_partial = is_partial;
}
get_html() {
@@ -106,7 +106,7 @@ class Message {
}
class RawMessage extends Message {
- constructor(id, side, text, is_partial=false) {
+ constructor(id, side, text, is_partial = false) {
super(id, side, text, is_partial);
}
@@ -126,17 +126,28 @@ class MessageHistory {
this.messageHistory[knowledgeBase] = [];
}
if (message.is_partial) {
- let current_message = this.messageHistory[knowledgeBase].find(item => item.id == message.id);
+ let current_message = this.messageHistory[knowledgeBase].find(
+ (item) => item.id == message.id,
+ );
if (!current_message) {
this.messageHistory[knowledgeBase].push(message);
} else {
current_message.text += message.text;
}
} else {
- if (this.messageHistory[knowledgeBase].length == 0 || message.side != "system") {
- this.messageHistory[knowledgeBase].push(message);
- } else if (this.messageHistory[knowledgeBase][this.messageHistory[knowledgeBase].length -1].side == "system") {
- this.messageHistory[knowledgeBase][this.messageHistory[knowledgeBase].length -1] = message
+ if (
+ this.messageHistory[knowledgeBase].length == 0 ||
+ message.side != "system"
+ ) {
+ this.messageHistory[knowledgeBase].push(message);
+ } else if (
+ this.messageHistory[knowledgeBase][
+ this.messageHistory[knowledgeBase].length - 1
+ ].side == "system"
+ ) {
+ this.messageHistory[knowledgeBase][
+ this.messageHistory[knowledgeBase].length - 1
+ ] = message;
} else {
this.messageHistory[knowledgeBase].push(message);
}
@@ -156,7 +167,7 @@ export default class extends Controller {
initialize() {
this.messageHistory = new MessageHistory();
this.messageIdToKnowledgeBaseId = {};
-
+
this.expanded = false;
this.chatbot = document.getElementById("chatbot");
this.expandContractImage = document.getElementById(
@@ -179,7 +190,14 @@ export default class extends Controller {
}
openConnection() {
- const url = ((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.hostname + (((window.location.port != 80) && (window.location.port != 443)) ? ":" + window.location.port : "") + window.location.pathname + "/get-answer";
+ const url =
+ (window.location.protocol === "https:" ? "wss://" : "ws://") +
+ window.location.hostname +
+ (window.location.port != 80 && window.location.port != 443
+ ? ":" + window.location.port
+ : "") +
+ window.location.pathname +
+ "/get-answer";
this.socket = new WebSocket(url);
this.socket.onmessage = (message) => {
let result = JSON.parse(message.data);
@@ -190,11 +208,20 @@ export default class extends Controller {
} else {
let message;
if (result.partial_result) {
- message = new Message(result.id, "bot", this.brain, result.partial_result, true);
+ message = new Message(
+ result.id,
+ "bot",
+ this.brain,
+ result.partial_result,
+ true,
+ );
} else {
message = new Message(result.id, "bot", this.brain, result.result);
}
- this.messageHistory.add_message(message, this.messageIdToKnowledgeBaseId[message.id]);
+ this.messageHistory.add_message(
+ message,
+ this.messageIdToKnowledgeBaseId[message.id],
+ );
this.redrawChat();
}
this.chatHistory.scrollTop = this.chatHistory.scrollHeight;
@@ -215,10 +242,16 @@ export default class extends Controller {
const result = await fetch("/chatbot/get-history");
const history = await result.json();
if (history.error) {
- console.log("Error getting chat history", history.error)
+ console.log("Error getting chat history", history.error);
} else {
for (const message of history.result) {
- const newMessage = new Message(getRandomInt(), message.side, message.brain, message.content, false);
+ const newMessage = new Message(
+ getRandomInt(),
+ message.side,
+ message.brain,
+ message.content,
+ false,
+ );
console.log(newMessage);
this.messageHistory.add_message(newMessage, message.knowledge_base);
}
@@ -239,12 +272,15 @@ export default class extends Controller {
// Hide or show example questions
this.hideExampleQuestions();
- if (messages.length == 0 || (messages.length == 1 && messages[0].side == "system")) {
+ if (
+ messages.length == 0 ||
+ (messages.length == 1 && messages[0].side == "system")
+ ) {
document
.getElementById(`chatbot-example-questions-${this.knowledgeBase}`)
.style.setProperty("display", "flex", "important");
}
-
+
this.chatHistory.scrollTop = this.chatHistory.scrollHeight;
}
@@ -255,20 +291,25 @@ export default class extends Controller {
this.hideExampleQuestions();
this.redrawChat();
- let loadingMessage = new Message("loading", "bot", this.brain, LOADING_MESSAGE);
+ let loadingMessage = new Message(
+ "loading",
+ "bot",
+ this.brain,
+ LOADING_MESSAGE,
+ );
this.chatHistory.insertAdjacentHTML(
"beforeend",
createHistoryMessage(loadingMessage),
);
this.chatHistory.scrollTop = this.chatHistory.scrollHeight;
-
+
let id = getRandomInt();
this.messageIdToKnowledgeBaseId[id] = this.knowledgeBase;
let socketData = {
id,
question,
model: this.brain,
- knowledge_base: this.knowledgeBase
+ knowledge_base: this.knowledgeBase,
};
this.socket.send(JSON.stringify(socketData));
}
@@ -293,8 +334,7 @@ export default class extends Controller {
e.preventDefault();
// Don't continue if the question is empty
const question = this.questionInput.value.trim();
- if (question.length == 0)
- return;
+ if (question.length == 0) return;
// Handle resetting the input
// There is probably a better way to do this, but this was the best/easiest I found
this.questionInput.value = "";
@@ -305,18 +345,20 @@ export default class extends Controller {
}
handleBrainChange() {
- let selected = document.querySelector('input[name="chatbot-brain-options"]:checked').value;
- if (selected == this.brain)
- return;
+ let selected = document.querySelector(
+ 'input[name="chatbot-brain-options"]:checked',
+ ).value;
+ if (selected == this.brain) return;
this.brain = selected;
this.questionInput.focus();
this.addBrainAndKnowledgeBaseChangedSystemMessage();
}
handleKnowledgeBaseChange() {
- let selected = document.querySelector('input[name="chatbot-knowledge-base-options"]:checked').value;
- if (selected == this.knowledgeBase)
- return;
+ let selected = document.querySelector(
+ 'input[name="chatbot-knowledge-base-options"]:checked',
+ ).value;
+ if (selected == this.knowledgeBase) return;
this.knowledgeBase = selected;
this.redrawChat();
this.questionInput.focus();
@@ -327,7 +369,12 @@ export default class extends Controller {
let knowledge_base = knowledgeBaseIdToName(this.knowledgeBase);
let brain = brainIdToName(this.brain);
let content = `Chatting with ${brain} about ${knowledge_base}`;
- const newMessage = new Message(getRandomInt(), "system", this.brain, content);
+ const newMessage = new Message(
+ getRandomInt(),
+ "system",
+ this.brain,
+ content,
+ );
this.messageHistory.add_message(newMessage, this.knowledgeBase);
this.redrawChat();
}
@@ -355,7 +402,7 @@ export default class extends Controller {
const toastElement = createToast(message, level);
showToast(toastElement, {
autohide: true,
- delay: 7000
+ delay: 7000,
});
}
diff --git a/pgml-dashboard/src/components/code_block/code_block_controller.js b/pgml-dashboard/src/components/code_block/code_block_controller.js
index 3a4f92483..127d4a6b5 100644
--- a/pgml-dashboard/src/components/code_block/code_block_controller.js
+++ b/pgml-dashboard/src/components/code_block/code_block_controller.js
@@ -6,10 +6,13 @@ import { javascript } from "@codemirror/lang-javascript";
import { rust } from "@codemirror/lang-rust";
import { json } from "@codemirror/lang-json";
import { EditorView, ViewPlugin, Decoration } from "@codemirror/view";
-import { RangeSetBuilder, Facet} from "@codemirror/state";
+import { RangeSetBuilder, Facet } from "@codemirror/state";
import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
-import { highlightStyle, editorTheme } from "../../../static/js/utilities/code_mirror_theme";
+import {
+ highlightStyle,
+ editorTheme,
+} from "../../../static/js/utilities/code_mirror_theme";
const buildEditorView = (target, content, languageExtension, classes) => {
let editorView = new EditorView({
@@ -17,48 +20,55 @@ const buildEditorView = (target, content, languageExtension, classes) => {
extensions: [
basicSetup,
languageExtension !== null ? languageExtension() : [], // if no language chosen do not highlight syntax
- EditorView.theme(editorTheme),
+ EditorView.theme(editorTheme),
syntaxHighlighting(HighlightStyle.define(highlightStyle)),
EditorView.contentAttributes.of({ contenteditable: false }),
addClasses.of(classes),
- highlight
+ highlight,
],
parent: target,
- highlightActiveLine: false
+ highlightActiveLine: false,
});
return editorView;
};
-const highlight = ViewPlugin.fromClass(class {
- constructor(view) {
- this.decorations = highlightLine(view)
- }
+const highlight = ViewPlugin.fromClass(
+ class {
+ constructor(view) {
+ this.decorations = highlightLine(view);
+ }
- update(update) {
- if (update.docChanged || update.viewportChanged)
- this.decorations = highlightLine(update.view)
- }
-}, {
- decorations: v => v.decorations
-})
+ update(update) {
+ if (update.docChanged || update.viewportChanged)
+ this.decorations = highlightLine(update.view);
+ }
+ },
+ {
+ decorations: (v) => v.decorations,
+ },
+);
function highlightLine(view) {
- let builder = new RangeSetBuilder()
- let classes = view.state.facet(addClasses).shift()
- for (let {from, to} of view.visibleRanges) {
- for (let pos = from; pos <= to;) {
- let lineClasses = classes.shift()
- let line = view.state.doc.lineAt(pos)
- builder.add(line.from, line.from, Decoration.line({attributes: {class: lineClasses}}))
- pos = line.to + 1
+ let builder = new RangeSetBuilder();
+ let classes = view.state.facet(addClasses).shift();
+ for (let { from, to } of view.visibleRanges) {
+ for (let pos = from; pos <= to; ) {
+ let lineClasses = classes.shift();
+ let line = view.state.doc.lineAt(pos);
+ builder.add(
+ line.from,
+ line.from,
+ Decoration.line({ attributes: { class: lineClasses } }),
+ );
+ pos = line.to + 1;
}
}
- return builder.finish()
+ return builder.finish();
}
const addClasses = Facet.define({
- combone: values => values
-})
+ combone: (values) => values,
+});
const language = (element) => {
switch (element.getAttribute("language")) {
@@ -77,26 +87,26 @@ const language = (element) => {
default:
return null;
}
-}
+};
const codeBlockCallback = (element) => {
- let highlights = element.getElementsByClassName("highlight")
+ let highlights = element.getElementsByClassName("highlight");
let classes = [];
- for(let lineNum = 0; lineNum < highlights.length; lineNum++) {
- classes.push(highlights[lineNum].classList)
+ for (let lineNum = 0; lineNum < highlights.length; lineNum++) {
+ classes.push(highlights[lineNum].classList);
}
-
- let content = element.textContent.trim()
+
+ let content = element.textContent.trim();
element.innerHTML = "";
- return [element, content, classes]
-}
+ return [element, content, classes];
+};
// Add Codemirror with data controller
export default class extends Controller {
connect() {
- let [element, content, classes] = codeBlockCallback(this.element)
- let lang = language(this.element)
+ let [element, content, classes] = codeBlockCallback(this.element);
+ let lang = language(this.element);
buildEditorView(element, content, lang, classes);
}
@@ -107,11 +117,11 @@ class CodeBlockA extends HTMLElement {
constructor() {
super();
- this.language = language(this)
+ this.language = language(this);
}
connectedCallback() {
- let [element, content, classes] = codeBlockCallback(this)
+ let [element, content, classes] = codeBlockCallback(this);
buildEditorView(element, content, this.language, classes);
}
diff --git a/pgml-dashboard/src/components/inputs/range_group/range_group_controller.js b/pgml-dashboard/src/components/inputs/range_group/range_group_controller.js
index 77cb092ba..c6110f697 100644
--- a/pgml-dashboard/src/components/inputs/range_group/range_group_controller.js
+++ b/pgml-dashboard/src/components/inputs/range_group/range_group_controller.js
@@ -1,7 +1,6 @@
-import { Controller } from '@hotwired/stimulus'
+import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
-
static targets = [
"range",
"text",
@@ -9,40 +8,47 @@ export default class extends Controller {
"line",
"tick",
"tickText",
- "smScreenText"
- ]
+ "smScreenText",
+ ];
static values = {
bounds: Object,
- initial: Number
- }
+ initial: Number,
+ };
initialize() {
- this.textTarget.value = this.rangeTarget.value
- this.updateTicks(this.rangeTarget.value)
- this.updateTicksText(this.rangeTarget.value)
+ this.textTarget.value = this.rangeTarget.value;
+ this.updateTicks(this.rangeTarget.value);
+ this.updateTicksText(this.rangeTarget.value);
}
updateText(e) {
- this.textTarget.value = e.target.value
- this.element.dataset.detail = e.target.value
- this.groupTarget.dispatchEvent(new CustomEvent("rangeInput", { detail: e.target.value }))
+ this.textTarget.value = e.target.value;
+ this.element.dataset.detail = e.target.value;
+ this.groupTarget.dispatchEvent(
+ new CustomEvent("rangeInput", { detail: e.target.value }),
+ );
}
updateRange(e) {
- if( e.target.value < this.boundsValue.min
- || !e.target.value || !this.isNumeric(e.target.value)) {
- this.rangeTarget.value = this.boundsValue.min
- this.textTarget.value = this.boundsValue.min
- } else if( e.target.value > this.boundsValue.max) {
- this.rangeTarget.value = this.boundsValue.max
- this.textTarget.value = this.boundsValue.max
+ if (
+ e.target.value < this.boundsValue.min ||
+ !e.target.value ||
+ !this.isNumeric(e.target.value)
+ ) {
+ this.rangeTarget.value = this.boundsValue.min;
+ this.textTarget.value = this.boundsValue.min;
+ } else if (e.target.value > this.boundsValue.max) {
+ this.rangeTarget.value = this.boundsValue.max;
+ this.textTarget.value = this.boundsValue.max;
} else {
- this.rangeTarget.value = e.target.value
+ this.rangeTarget.value = e.target.value;
}
- this.element.dataset.detail = this.rangeTarget.value
- this.groupTarget.dispatchEvent(new CustomEvent("rangeInput", { detail: this.rangeTarget.value }))
+ this.element.dataset.detail = this.rangeTarget.value;
+ this.groupTarget.dispatchEvent(
+ new CustomEvent("rangeInput", { detail: this.rangeTarget.value }),
+ );
}
isNumeric(n) {
@@ -50,75 +56,77 @@ export default class extends Controller {
}
reset() {
- this.rangeTarget.value = this.initialValue
- this.textTarget.value = this.initialValue
- this.updateTicks(this.initialValue)
- this.updateTicksText(this.initialValue)
- this.element.dataset.detail = this.initialValue
- this.groupTarget.dispatchEvent(new CustomEvent("rangeInput", { detail: this.rangeTarget.value }))
+ this.rangeTarget.value = this.initialValue;
+ this.textTarget.value = this.initialValue;
+ this.updateTicks(this.initialValue);
+ this.updateTicksText(this.initialValue);
+ this.element.dataset.detail = this.initialValue;
+ this.groupTarget.dispatchEvent(
+ new CustomEvent("rangeInput", { detail: this.rangeTarget.value }),
+ );
}
- on_grab () {
- if( this.hasLineTarget ) {
- this.lineTarget.classList.add("grab-brightness")
+ on_grab() {
+ if (this.hasLineTarget) {
+ this.lineTarget.classList.add("grab-brightness");
}
- if( this.hasTickTarget ) {
+ if (this.hasTickTarget) {
this.tickTargets.forEach((tick, index) => {
- if( index < this.rangeTarget.value ) {
- tick.classList.add("grab-brightness")
+ if (index < this.rangeTarget.value) {
+ tick.classList.add("grab-brightness");
} else {
- tick.classList.remove("grab-brightness")
+ tick.classList.remove("grab-brightness");
}
- })
+ });
}
}
on_release() {
- if( this.hasLineTarget ) {
- this.lineTarget.classList.remove("grab-brightness")
+ if (this.hasLineTarget) {
+ this.lineTarget.classList.remove("grab-brightness");
}
- if( this.hasTickTarget ) {
+ if (this.hasTickTarget) {
this.tickTargets.forEach((tick, index) => {
- if( index < this.rangeTarget.value ) {
- tick.classList.remove("grab-brightness")
+ if (index < this.rangeTarget.value) {
+ tick.classList.remove("grab-brightness");
}
- })
+ });
}
}
updateTicks(value) {
- if(!this.hasTickTarget) return;
+ if (!this.hasTickTarget) return;
this.tickTargets.forEach((tick, index) => {
- if( index < value ) {
- tick.classList.add("active-color")
+ if (index < value) {
+ tick.classList.add("active-color");
} else {
- tick.classList.remove("active-color")
+ tick.classList.remove("active-color");
}
- })
+ });
}
updateTicksText(value) {
- if(this.hasTickTextTarget && this.hasSmScreenTextTarget) {
+ if (this.hasTickTextTarget && this.hasSmScreenTextTarget) {
this.tickTextTargets.forEach((tickText, index) => {
- if( index + 1 == value ) {
- tickText.classList.add("active-color")
- this.smScreenTextTargets[index].style.display = "flex"
+ if (index + 1 == value) {
+ tickText.classList.add("active-color");
+ this.smScreenTextTargets[index].style.display = "flex";
} else {
- tickText.classList.remove("active-color")
- this.smScreenTextTargets[index].style.display = "none"
+ tickText.classList.remove("active-color");
+ this.smScreenTextTargets[index].style.display = "none";
}
- })
+ });
}
}
updateTicksEventWrapper(e) {
- this.updateTicks(e.target.value)
+ this.updateTicks(e.target.value);
}
updateTicksTextEventWrapper(e) {
- this.updateTicksText(e.target.value)
+ this.updateTicksText(e.target.value);
}
}
diff --git a/pgml-dashboard/src/components/inputs/select/select_controller.js b/pgml-dashboard/src/components/inputs/select/select_controller.js
index d5321f1b0..35d479da2 100644
--- a/pgml-dashboard/src/components/inputs/select/select_controller.js
+++ b/pgml-dashboard/src/components/inputs/select/select_controller.js
@@ -1,19 +1,19 @@
-import { Controller } from '@hotwired/stimulus'
+import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
- static targets = ["input", "value"]
+ static targets = ["input", "value"];
choose(e) {
- this.setValue(e.target.innerHTML)
+ this.setValue(e.target.innerHTML);
}
-
+
resetSelect() {
- this.setValue(this.element.dataset.initial)
+ this.setValue(this.element.dataset.initial);
}
setValue(value) {
- this.inputTarget.value = value
- this.valueTarget.innerHTML = value
- this.inputTarget.dispatchEvent(new Event('change'))
+ this.inputTarget.value = value;
+ this.valueTarget.innerHTML = value;
+ this.inputTarget.dispatchEvent(new Event("change"));
}
}
diff --git a/pgml-dashboard/src/components/inputs/switch/switch_controller.js b/pgml-dashboard/src/components/inputs/switch/switch_controller.js
index cffc1ff16..9ad18e66a 100644
--- a/pgml-dashboard/src/components/inputs/switch/switch_controller.js
+++ b/pgml-dashboard/src/components/inputs/switch/switch_controller.js
@@ -1,52 +1,51 @@
-import { Controller } from '@hotwired/stimulus'
+import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
- static targets = [
- "toggle",
- "toggleText",
- "toggleIcon",
- ]
+ static targets = ["toggle", "toggleText", "toggleIcon"];
static values = {
- "left": String,
- "right": String,
- "initial": String,
- "leftIcon": String,
- "rightIcon": String,
- }
+ left: String,
+ right: String,
+ initial: String,
+ leftIcon: String,
+ rightIcon: String,
+ };
toggle() {
- if (this.toggleTarget.classList.contains('right')) {
- this.onToggleLeft()
+ if (this.toggleTarget.classList.contains("right")) {
+ this.onToggleLeft();
} else {
- this.onToggleRight()
+ this.onToggleRight();
}
}
onToggleLeft() {
- this.toggleTarget.classList.remove('right')
- this.toggleTarget.classList.add('left')
- this.toggleTextTarget.innerHTML = this.leftValue
- this.toggleIconTarget.innerHTML = this.leftIconValue
- this.element.dispatchEvent(new CustomEvent('toggle', {detail: this.leftValue}))
+ this.toggleTarget.classList.remove("right");
+ this.toggleTarget.classList.add("left");
+ this.toggleTextTarget.innerHTML = this.leftValue;
+ this.toggleIconTarget.innerHTML = this.leftIconValue;
+ this.element.dispatchEvent(
+ new CustomEvent("toggle", { detail: this.leftValue }),
+ );
}
onToggleRight() {
- this.toggleTarget.classList.remove('left')
- this.toggleTarget.classList.add('right')
- this.toggleTextTarget.innerHTML = this.rightValue
- this.toggleIconTarget.innerHTML = this.rightIconValue
- this.element.dispatchEvent(new CustomEvent('toggle', {detail: this.rightValue}))
+ this.toggleTarget.classList.remove("left");
+ this.toggleTarget.classList.add("right");
+ this.toggleTextTarget.innerHTML = this.rightValue;
+ this.toggleIconTarget.innerHTML = this.rightIconValue;
+ this.element.dispatchEvent(
+ new CustomEvent("toggle", { detail: this.rightValue }),
+ );
}
reset() {
- if( this.initialValue == "left" ) {
- console.log("toggling left")
- this.onToggleLeft()
+ if (this.initialValue == "left") {
+ console.log("toggling left");
+ this.onToggleLeft();
} else {
- console.log("toggling right")
- this.onToggleRight()
+ console.log("toggling right");
+ this.onToggleRight();
}
}
-
}
diff --git a/pgml-dashboard/src/components/inputs/text/editable_header/editable_header_controller.js b/pgml-dashboard/src/components/inputs/text/editable_header/editable_header_controller.js
index b5195a087..bf92a9d9d 100644
--- a/pgml-dashboard/src/components/inputs/text/editable_header/editable_header_controller.js
+++ b/pgml-dashboard/src/components/inputs/text/editable_header/editable_header_controller.js
@@ -1,41 +1,41 @@
-import { Controller } from '@hotwired/stimulus'
+import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
- static targets = ["input", "header", "error"]
+ static targets = ["input", "header", "error"];
focusout(e) {
- this.headerTarget.innerHTML = e.target.value
- this.toggleEditor()
+ this.headerTarget.innerHTML = e.target.value;
+ this.toggleEditor();
}
blur() {
- this.inputTarget.blur()
+ this.inputTarget.blur();
}
toggleEditor(e) {
// dont toggle if click inside input
- if( e && this.inputTarget.contains(e.target)) {
- return
+ if (e && this.inputTarget.contains(e.target)) {
+ return;
}
- if(this.inputTarget.style.display == "none") {
- this.inputTarget.style.display = "block"
- this.headerTarget.style.display = "none"
- this.inputTarget.focus()
+ if (this.inputTarget.style.display == "none") {
+ this.inputTarget.style.display = "block";
+ this.headerTarget.style.display = "none";
+ this.inputTarget.focus();
} else {
- this.inputTarget.style.display = "none"
- this.headerTarget.style.display = "flex"
+ this.inputTarget.style.display = "none";
+ this.headerTarget.style.display = "flex";
}
}
error(e) {
- this.errorTarget.innerHTML = e.detail
- this.errorTarget.style.display = "block"
- this.headerTarget.classList.add("error")
+ this.errorTarget.innerHTML = e.detail;
+ this.errorTarget.style.display = "block";
+ this.headerTarget.classList.add("error");
}
clear() {
- this.errorTarget.style.display = "none"
- this.headerTarget.classList.remove("error")
+ this.errorTarget.style.display = "none";
+ this.headerTarget.classList.remove("error");
}
}
diff --git a/pgml-dashboard/src/components/layouts/marketing/base/mod.rs b/pgml-dashboard/src/components/layouts/marketing/base/mod.rs
index ce80e1655..5d1ee0d36 100644
--- a/pgml-dashboard/src/components/layouts/marketing/base/mod.rs
+++ b/pgml-dashboard/src/components/layouts/marketing/base/mod.rs
@@ -34,6 +34,7 @@ pub struct Base {
pub alert_banner: AlertBanner,
pub user: Option
,
pub theme: Theme,
+ pub no_transparent_nav: bool,
}
impl Base {
@@ -54,6 +55,7 @@ impl Base {
footer,
alert_banner: AlertBanner::from_notification(Notification::next_alert(context)),
user,
+ no_transparent_nav: false,
..Default::default()
}
}
@@ -90,6 +92,11 @@ impl Base {
self
}
+ pub fn no_transparent_nav(mut self) -> Self {
+ self.no_transparent_nav = true;
+ self
+ }
+
pub fn render(mut self, template: T) -> String
where
T: sailfish::TemplateOnce,
diff --git a/pgml-dashboard/src/components/layouts/marketing/base/template.html b/pgml-dashboard/src/components/layouts/marketing/base/template.html
index 6d3387be8..e73e656c8 100644
--- a/pgml-dashboard/src/components/layouts/marketing/base/template.html
+++ b/pgml-dashboard/src/components/layouts/marketing/base/template.html
@@ -16,7 +16,7 @@
<%+ alert_banner %>
- <%+ MarketingNavbar::new(user) %>
+ <%+ MarketingNavbar::new(user).no_transparent_nav(no_transparent_nav) %>
<%- content.unwrap_or_default() %>
<%- footer.unwrap_or_default() %>
diff --git a/pgml-dashboard/src/components/loading/message/mod.rs b/pgml-dashboard/src/components/loading/message/mod.rs
index eabb3ea2a..399b5b877 100644
--- a/pgml-dashboard/src/components/loading/message/mod.rs
+++ b/pgml-dashboard/src/components/loading/message/mod.rs
@@ -1,5 +1,5 @@
-use sailfish::TemplateOnce;
use pgml_components::component;
+use sailfish::TemplateOnce;
#[derive(TemplateOnce, Default)]
#[template(path = "loading/message/template.html")]
diff --git a/pgml-dashboard/src/components/modal/modal_controller.js b/pgml-dashboard/src/components/modal/modal_controller.js
index 5c411dbd8..69b98eeb0 100644
--- a/pgml-dashboard/src/components/modal/modal_controller.js
+++ b/pgml-dashboard/src/components/modal/modal_controller.js
@@ -1,19 +1,17 @@
-import { Controller } from '@hotwired/stimulus'
+import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
- static targets = [
- 'modal',
- ];
+ static targets = ["modal"];
connect() {
- this.modal = new bootstrap.Modal(this.modalTarget)
+ this.modal = new bootstrap.Modal(this.modalTarget);
}
show() {
- this.modal.show()
+ this.modal.show();
}
hide() {
- this.modal.hide()
+ this.modal.hide();
}
}
diff --git a/pgml-dashboard/src/components/navigation/navbar/marketing/mod.rs b/pgml-dashboard/src/components/navigation/navbar/marketing/mod.rs
index 7b8df0f88..211b6e69a 100644
--- a/pgml-dashboard/src/components/navigation/navbar/marketing/mod.rs
+++ b/pgml-dashboard/src/components/navigation/navbar/marketing/mod.rs
@@ -9,6 +9,7 @@ pub struct Marketing {
pub current_user: Option,
pub standalone_dashboard: bool,
pub style_alt: bool,
+ pub no_transparent_nav: bool,
}
impl Marketing {
@@ -17,6 +18,7 @@ impl Marketing {
current_user: user,
standalone_dashboard: config::standalone_dashboard(),
style_alt: false,
+ no_transparent_nav: false,
}
}
@@ -24,6 +26,11 @@ impl Marketing {
self.style_alt = true;
self
}
+
+ pub fn no_transparent_nav(mut self, no_transparent_nav: bool) -> Self {
+ self.no_transparent_nav = no_transparent_nav;
+ self
+ }
}
component!(Marketing);
diff --git a/pgml-dashboard/src/components/navigation/navbar/marketing/template.html b/pgml-dashboard/src/components/navigation/navbar/marketing/template.html
index af250f339..054a27bcc 100644
--- a/pgml-dashboard/src/components/navigation/navbar/marketing/template.html
+++ b/pgml-dashboard/src/components/navigation/navbar/marketing/template.html
@@ -35,7 +35,7 @@
%>
-