lollms-webui/web/src/main.js

850 lines
27 KiB
JavaScript
Raw Normal View History

2023-06-14 15:23:13 +00:00
import { createApp, ref } from 'vue'
2023-06-13 15:09:25 +00:00
import { createStore } from 'vuex'
2023-07-09 17:32:25 +00:00
import axios from "axios";
2023-05-02 20:53:27 +00:00
import App from './App.vue'
import router from './router'
2024-04-02 06:50:24 +00:00
import './assets/tailwind.css'
//import './assets/tailwind_april_fool.css'
2023-05-02 20:53:27 +00:00
const app = createApp(App)
2023-07-09 17:32:25 +00:00
console.log("Loaded main.js")
2023-05-02 20:53:27 +00:00
2023-09-29 17:31:20 +00:00
function copyObject(obj) {
const copy = {};
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
copy[key] = obj[key];
}
}
return copy;
}
2023-06-13 15:09:25 +00:00
// Create a new store instance.
2023-07-06 17:19:48 +00:00
export const store = createStore({
2023-06-13 15:09:25 +00:00
state () {
return {
2024-05-19 12:35:05 +00:00
is_rt_on:false,
2024-04-30 23:24:40 +00:00
language: "english",
languages: [],
2024-03-01 23:41:38 +00:00
currentTheme: '',
2024-02-08 22:04:27 +00:00
personality_editor:null,
showPersonalityEditor: false,
selectedPersonality:null,
currentPersonConfig: {
ai_name: '',
ai_author: '',
ai_category: '',
ai_language: '',
ai_description: '',
ai_conditionning: '',
ai_disclaimer: '',
ai_icon: null,
2024-04-30 23:24:40 +00:00
},
posts_headers : {
'accept': 'application/json',
'Content-Type': 'application/json'
},
2024-02-27 16:06:22 +00:00
client_id:"",
2023-06-17 10:53:40 +00:00
// count: 0,
2023-12-27 11:32:58 +00:00
yesNoDialog:null,
2023-12-18 00:53:18 +00:00
universalForm:null,
toast:null,
2024-02-26 22:46:08 +00:00
news:null,
2023-12-18 00:53:18 +00:00
messageBox:null,
2023-12-17 13:46:15 +00:00
api_get_req:null,
api_post_req:null,
2023-12-17 11:02:54 +00:00
startSpeechRecognition:null,
2023-07-10 20:01:20 +00:00
ready:false,
2023-11-26 18:54:09 +00:00
loading_infos: "",
loading_progress: 0,
2023-09-02 18:37:06 +00:00
version : "unknown",
2023-07-06 11:47:23 +00:00
settingsChanged:false,
isConnected: false, // Add the isConnected property
2023-12-08 00:00:22 +00:00
isModelOk: false,
2023-11-23 22:26:54 +00:00
isGenerating: false,
2023-07-09 17:32:25 +00:00
config:null,
mountedPers:null,
mountedPersArr:[],
mountedExtensions:[],
2023-11-26 18:54:09 +00:00
bindingsZoo:[],
modelsArr:[],
2023-09-05 22:57:23 +00:00
selectedModel:null,
personalities:[],
2023-07-10 20:01:20 +00:00
diskUsage:null,
ramUsage:null,
vramUsage:null,
2023-10-23 23:40:39 +00:00
modelsZoo:[],
installedModels:[],
2024-03-24 02:42:04 +00:00
installedBindings:[],
2023-10-23 23:40:39 +00:00
currentModel:null,
2024-03-24 02:42:04 +00:00
currentBinding:null,
extensionsZoo:[],
2023-10-07 21:16:27 +00:00
databases:[],
2023-06-13 15:09:25 +00:00
}
},
2024-04-30 23:24:40 +00:00
mutations: {
2024-05-19 12:35:05 +00:00
setisRTOn(state, is_rt_on) {
state.is_rt_on = is_rt_on;
},
2024-04-30 23:24:40 +00:00
setLanguages(state, languages) {
state.languages = languages;
},
setLanguage(state, language) {
state.language = language;
},
2023-10-02 00:18:57 +00:00
setIsReady(state, ready) {
state.ready = ready;
},
2023-07-10 20:01:20 +00:00
setIsConnected(state, isConnected) {
state.isConnected = isConnected;
},
2023-12-08 00:00:22 +00:00
setIsModelOk(state, isModelOk) {
state.isModelOk = isModelOk;
},
2023-11-23 22:26:54 +00:00
setIsGenerating(state, isGenerating) {
state.isGenerating = isGenerating;
},
2023-07-09 17:32:25 +00:00
setConfig(state, config) {
state.config = config;
},
setPersonalities(state, personalities) {
state.personalities = personalities;
},
setMountedPers(state, mountedPers) {
state.mountedPers = mountedPers;
},
2023-07-10 22:45:47 +00:00
setMountedPersArr(state, mountedPersArr) {
state.mountedPersArr = mountedPersArr;
},
setMountedExtensions(state, mountedExtensions) {
state.mountedExtensions = mountedExtensions;
},
2023-11-26 18:54:09 +00:00
setbindingsZoo(state, bindingsZoo) {
state.bindingsZoo = bindingsZoo;
2023-07-10 20:01:20 +00:00
},
setModelsArr(state, modelsArr) {
state.modelsArr = modelsArr;
},
2023-09-05 22:57:23 +00:00
setselectedModel(state, selectedModel) {
state.selectedModel = selectedModel;
},
2023-07-10 20:01:20 +00:00
setDiskUsage(state, diskUsage) {
state.diskUsage = diskUsage;
},
setRamUsage(state, ramUsage) {
state.ramUsage = ramUsage;
},
setVramUsage(state, vramUsage) {
state.vramUsage = vramUsage;
},
2023-10-23 23:40:39 +00:00
setModelsZoo(state, modelsZoo) {
state.modelsZoo = modelsZoo;
2023-11-17 20:19:42 +00:00
},
2024-03-24 02:42:04 +00:00
setCurrentBinding(state, currentBinding){
state.currentBinding = currentBinding
},
2023-11-17 20:19:42 +00:00
setCurrentModel(state, currentModel) {
state.currentModel = currentModel;
},
2023-07-20 09:44:33 +00:00
setExtensionsZoo(state, extensionsZoo) {
state.extensionsZoo = extensionsZoo;
},
2023-10-07 21:16:27 +00:00
setDatabases(state, databases) {
state.databases = databases;
},
2023-06-17 10:53:40 +00:00
// increment (state) {
// state.count++
2024-03-01 23:41:38 +00:00
// }
setTheme(theme) {
this.currentTheme = theme;
}
2023-07-09 17:32:25 +00:00
},
getters: {
2024-05-19 12:35:05 +00:00
getisRTOn(state) {
return state.is_rt_on;
},
2024-04-30 23:24:40 +00:00
getLanguages(state) {
return state.languages;
},
getLanguage(state) {
return state.language;
},
2023-07-10 20:01:20 +00:00
getIsConnected(state) {
return state.isConnected
},
2023-12-08 00:00:22 +00:00
getIsModelOk(state) {
return state.isModelOk;
},
2023-11-23 22:26:54 +00:00
getIsGenerating(state) {
return state.isGenerating
},
2023-07-09 17:32:25 +00:00
getConfig(state) {
return state.config
},
2023-07-10 20:01:20 +00:00
getPersonalities(state) {
return state.personalities;
2023-07-09 17:32:25 +00:00
},
2023-07-10 22:45:47 +00:00
getMountedPersArr(state) {
return state.mountedPersArr;
},
getmmountedExtensions(state) {
return state.mountedExtensions;
},
2023-07-09 17:32:25 +00:00
getMountedPers(state) {
return state.mountedPers;
2023-07-10 20:01:20 +00:00
},
2023-11-26 18:54:09 +00:00
getbindingsZoo(state) {
return state.bindingsZoo;
2023-07-10 20:01:20 +00:00
},
getModelsArr(state) {
return state.modelsArr;
},
getDiskUsage(state) {
return state.diskUsage;
},
getRamUsage(state) {
return state.ramUsage;
},
getVramUsage(state) {
return state.vramUsage;
},
2023-10-02 23:13:02 +00:00
2023-10-07 21:16:27 +00:00
getDatabasesList(state){
return state.databases;
2023-10-02 23:13:02 +00:00
},
2023-10-23 23:40:39 +00:00
getModelsZoo(state) {
return state.modelsZoo;
},
2024-03-24 02:42:04 +00:00
getCyrrentBinding(state){
return state.currentBinding
},
2023-11-17 20:19:42 +00:00
getCurrentModel(state) {
return state.currentModel;
},
2023-07-20 09:44:33 +00:00
getExtensionsZoo(state) {
return state.extensionsZoo;
},
2023-07-09 17:32:25 +00:00
},
actions: {
2023-09-02 18:37:06 +00:00
async getVersion(){
2023-11-30 00:38:25 +00:00
try{
let res = await axios.get('/get_lollms_webui_version', {});
if (res) {
2024-02-26 20:43:12 +00:00
this.state.version = res.data
console.log("version res:", res)
console.log("version :", this.state.version)
2023-11-30 00:38:25 +00:00
}
}
catch{
console.log("Coudln't get version")
2023-09-02 18:37:06 +00:00
}
},
2023-07-09 17:32:25 +00:00
async refreshConfig({ commit }) {
console.log("Fetching configuration");
try {
2023-07-10 22:45:47 +00:00
const configFile = await api_get_req('get_config')
2023-09-19 00:33:16 +00:00
if(configFile.active_personality_id<0){
configFile.active_personality_id=0;
}
2023-07-10 22:45:47 +00:00
let personality_path_infos = configFile.personalities[configFile.active_personality_id].split("/")
//let personality_path_infos = await this.api_get_req("get_current_personality_path_infos")
2023-08-17 23:29:53 +00:00
configFile.personality_category = personality_path_infos[0]
configFile.personality_folder = personality_path_infos[1]
2023-10-05 23:23:47 +00:00
if (configFile.extensions.length>0){
configFile.extension_category = configFile.extensions[-1]
}
else{
configFile.extension_category = "ai_sensors"
}
console.log("Recovered config")
console.log(configFile)
2023-09-19 00:33:16 +00:00
console.log("Committing config");
console.log(configFile)
console.log(this.state.config)
2023-07-09 17:32:25 +00:00
commit('setConfig', configFile);
} catch (error) {
console.log(error.message, 'refreshConfig');
// Handle error
}
},
2023-10-07 21:16:27 +00:00
async refreshDatabase({ commit }) {
let databases = await api_get_req("list_databases")
console.log("databases:",databases)
commit('setDatabases', databases);
},
2024-05-19 12:35:05 +00:00
async fetchisRTOn({ commit }) {
console.log("is_rt_on", this.state.client_id)
const response = await axios.get(
'/is_rt_on'
);
console.log("response", response)
const is_rt_on = response.data;
console.log("languages", is_rt_on)
commit('setRTOn', is_rt_on);
},
2024-04-30 23:24:40 +00:00
async fetchLanguages({ commit }) {
console.log("get_personality_languages_list", this.state.client_id)
const response = await axios.post(
'/get_personality_languages_list',
{client_id: this.state.client_id}
);
console.log("response", response)
const languages = response.data;
console.log("languages", languages)
commit('setLanguages', languages);
},
async fetchLanguage({ commit }) {
console.log("get_personality_language", this.state.client_id)
const response = await axios.post(
'/get_personality_language',
{client_id: this.state.client_id}
);
console.log("response", response)
const language = response.data;
console.log("language", language)
commit('setLanguage', language);
},
2024-05-01 18:02:57 +00:00
2024-04-30 23:24:40 +00:00
async changeLanguage({ commit }, new_language) {
console.log("Changing language to ", new_language)
let response = await axios.post('/set_personality_language', {
client_id: this.state.client_id,
language: new_language,
})
console.log("get_personality_languages_list", this.state.client_id)
2024-05-01 18:02:57 +00:00
response = await axios.post(
'/get_personality_languages_list',
{client_id: this.state.client_id}
);
console.log("response", response)
const languages = response.data;
console.log("languages", languages)
commit('setLanguages', languages);
response = await axios.post(
'/get_personality_language',
{client_id: this.state.client_id}
);
console.log("response", response)
const language = response.data;
console.log("language", language)
commit('setLanguage', language);
console.log('Language changed successfully:', response.data.message);
},
async deleteLanguage({ commit }, new_language) {
console.log("Deleting ", new_language)
let response = await axios.post('/del_personality_language', {
client_id: this.state.client_id,
language: new_language,
})
console.log("get_personality_languages_list", this.state.client_id)
2024-04-30 23:24:40 +00:00
response = await axios.post(
'/get_personality_languages_list',
{client_id: this.state.client_id}
);
console.log("response", response)
const languages = response.data;
console.log("languages", languages)
commit('setLanguages', languages);
response = await axios.post(
'/get_personality_language',
{client_id: this.state.client_id}
);
console.log("response", response)
const language = response.data;
console.log("language", language)
commit('setLanguage', language);
console.log('Language changed successfully:', response.data.message);
},
2023-09-29 17:31:20 +00:00
async refreshPersonalitiesZoo({ commit }) {
2023-07-09 17:32:25 +00:00
let personalities = []
2023-08-17 23:29:53 +00:00
const catdictionary = await api_get_req("get_all_personalities")
const catkeys = Object.keys(catdictionary); // returns categories
console.log("Personalities recovered:"+this.state.config.personalities)
2023-07-09 17:32:25 +00:00
2023-08-17 23:29:53 +00:00
for (let j = 0; j < catkeys.length; j++) {
const catkey = catkeys[j];
const personalitiesArray = catdictionary[catkey];
const modPersArr = personalitiesArray.map((item) => {
2023-09-19 00:33:16 +00:00
let isMounted = false;
for(const personality of this.state.config.personalities){
if(personality.includes(catkey + '/' + item.folder)){
isMounted = true;
if(personality.includes(":")){
const parts = personality.split(':');
item.language = parts[1];
}
else{
item.language = null
}
2023-09-19 00:33:16 +00:00
}
}
2023-08-17 23:29:53 +00:00
// if (isMounted) {
// console.log(item)
// }
let newItem = {}
newItem = item
newItem.category = catkey // add new props to items
newItem.full_path = catkey + '/' + item.folder // add new props to items
newItem.isMounted = isMounted // add new props to items
return newItem
})
2023-07-09 17:32:25 +00:00
2023-08-17 23:29:53 +00:00
if (personalities.length == 0) {
personalities = modPersArr
} else {
personalities = personalities.concat(modPersArr)
2023-07-09 17:32:25 +00:00
}
}
personalities.sort((a, b) => a.name.localeCompare(b.name))
2023-07-15 21:06:27 +00:00
2023-07-10 20:01:20 +00:00
commit('setPersonalities', personalities);
2023-07-09 17:32:25 +00:00
2023-07-10 20:01:20 +00:00
console.log("Done loading personalities")
2023-07-09 17:32:25 +00:00
},
refreshMountedPersonalities({ commit }) {
2023-09-19 00:33:16 +00:00
if(this.state.config.active_personality_id<0){
this.state.config.active_personality_id=0;
}
2023-09-28 13:56:41 +00:00
let mountedPersArr = []
// console.log('perrs listo',this.state.personalities)
2023-10-02 00:18:57 +00:00
const indicesToRemove = [];
2023-09-28 13:56:41 +00:00
for (let i = 0; i < this.state.config.personalities.length; i++) {
const full_path_item = this.state.config.personalities[i]
2023-09-29 17:31:20 +00:00
const parts = full_path_item.split(':')
const index = this.state.personalities.findIndex(item => item.full_path == full_path_item || item.full_path == parts[0])
2023-09-28 13:56:41 +00:00
if(index>=0){
2023-09-29 17:31:20 +00:00
let pers = copyObject(this.state.personalities[index])
if(parts.length>1){
2023-09-29 17:31:20 +00:00
pers.language = parts[1]
}
2023-09-19 00:33:16 +00:00
// console.log(`Personality : ${JSON.stringify(pers)}`)
2023-07-09 17:32:25 +00:00
if (pers) {
mountedPersArr.push(pers)
}
else {
mountedPersArr.push(this.state.personalities[this.state.personalities.findIndex(item => item.full_path == "generic/lollms")])
2023-07-09 17:32:25 +00:00
}
2023-09-28 13:56:41 +00:00
}
else{
2023-10-02 00:18:57 +00:00
indicesToRemove.push(i)
2023-09-28 13:56:41 +00:00
console.log("Couldn't load personality : ",full_path_item)
}
}
2023-10-02 00:18:57 +00:00
// Remove the broken personalities using the collected indices
for (let i = indicesToRemove.length - 1; i >= 0; i--) {
console.log("Removing personality : ",this.state.config.personalities[indicesToRemove[i]])
this.state.config.personalities.splice(indicesToRemove[i], 1);
if(this.state.config.active_personality_id>indicesToRemove[i]){
this.state.config.active_personality_id -= 1;
}
}
2023-09-28 13:56:41 +00:00
commit('setMountedPersArr', mountedPersArr);
this.state.mountedPers = this.state.personalities[this.state.personalities.findIndex(item => item.full_path == this.state.config.personalities[this.state.config.active_personality_id] || item.full_path+':'+item.language ==this.state.config.personalities[this.state.config.active_personality_id])]
// console.log(`${this.state.config.personalities[this.state.config.active_personality_id]}`)
// console.log(`Mounted personality: ${this.state.mountedPers}`)
2023-07-09 17:32:25 +00:00
},
2023-07-10 20:01:20 +00:00
async refreshBindings({ commit }) {
2023-11-26 18:54:09 +00:00
let bindingsZoo = await api_get_req("list_bindings")
2024-03-24 02:42:04 +00:00
console.log("Loaded bindings zoo :",bindingsZoo)
this.state.installedBindings = bindingsZoo.filter(item=> item.installed)
2024-04-17 23:57:05 +00:00
console.log("Loaded bindings zoo ", this.state.installedBindings)
commit('setbindingsZoo',bindingsZoo)
2024-03-24 02:42:04 +00:00
const index = bindingsZoo.findIndex(item=>item.name == this.state.config.binding_name)
if (index!=-1){
commit('setCurrentBinding',bindingsZoo[index])
}
2023-07-10 20:01:20 +00:00
},
2023-10-23 23:40:39 +00:00
async refreshModelsZoo({ commit }) {
console.log("Fetching models")
const response = await axios.get('/get_available_models');
2024-03-02 23:32:52 +00:00
const models_zoo = response.data.filter(model => model.variants && model.variants.length>0)
console.log(`get_available_models: ${models_zoo}`)
commit('setModelsZoo', models_zoo)
2023-07-10 20:01:20 +00:00
},
2023-12-08 00:00:22 +00:00
async refreshModelStatus({ commit }) {
let modelstatus = await api_get_req("get_model_status");
commit('setIsModelOk',modelstatus["status"])
},
2023-10-23 23:40:39 +00:00
async refreshModels({ commit }) {
console.log("Fetching models")
let modelsArr = await api_get_req("list_models");
console.log(`Found ${modelsArr}`)
let selectedModel = await api_get_req('get_active_model');
2023-11-26 18:54:09 +00:00
console.log("Selected model ", selectedModel);
2023-10-23 23:40:39 +00:00
if(selectedModel!=undefined){
commit('setselectedModel',selectedModel["model"])
}
commit('setModelsArr',modelsArr)
2023-12-08 00:00:22 +00:00
console.log("setModelsArr",modelsArr)
2024-02-24 01:49:04 +00:00
console.log("this.state.modelsZoo",this.state.modelsZoo)
2023-10-23 23:40:39 +00:00
this.state.modelsZoo.map((item)=>{
item.isInstalled=modelsArr.includes(item.name)
})
this.state.installedModels = this.state.modelsZoo.filter(item=> item.isInstalled)
const index = this.state.modelsZoo.findIndex(item=>item.name == this.state.config.model_name)
2023-11-17 20:19:42 +00:00
if (index!=-1){
commit('setCurrentModel',this.state.modelsZoo[index])
}
2023-10-23 23:40:39 +00:00
},
async refreshExtensionsZoo({ commit }) {
2023-10-02 23:13:02 +00:00
let extensions = []
let catdictionary = await api_get_req("list_extensions")
const catkeys = Object.keys(catdictionary); // returns categories
2023-10-05 23:23:47 +00:00
console.log("Extensions recovered:"+catdictionary)
2023-10-02 23:13:02 +00:00
for (let j = 0; j < catkeys.length; j++) {
const catkey = catkeys[j];
const extensionsArray = catdictionary[catkey];
const modExtArr = extensionsArray.map((item) => {
let isMounted = false;
for(const extension of this.state.config.extensions){
2023-10-02 23:13:02 +00:00
if(extension.includes(catkey + '/' + item.folder)){
isMounted = true;
}
}
// if (isMounted) {
// console.log(item)
// }
let newItem = {}
newItem = item
newItem.category = catkey // add new props to items
newItem.full_path = catkey + '/' + item.folder // add new props to items
newItem.isMounted = isMounted // add new props to items
return newItem
})
if (extensions.length == 0) {
extensions = modExtArr
} else {
extensions = extensions.concat(modExtArr)
}
}
extensions.sort((a, b) => a.name.localeCompare(b.name))
2023-12-09 10:41:17 +00:00
//commit('setActiveExtensions', this.state.config.extensions);
2023-10-02 23:13:02 +00:00
console.log("Done loading extensions")
commit('setExtensionsZoo',extensions)
2023-07-20 09:44:33 +00:00
},
refreshmountedExtensions({ commit }) {
2023-10-15 23:36:28 +00:00
console.log("Mounting extensions")
let mountedExtensions = []
// console.log('perrs listo',this.state.personalities)
const indicesToRemove = [];
for (let i = 0; i < this.state.config.extensions.length; i++) {
const full_path_item = this.state.config.extensions[i]
const index = this.state.extensionsZoo.findIndex(item => item.full_path == full_path_item)
if(index>=0){
2023-10-15 23:36:28 +00:00
let ext = copyObject(this.state.config.extensions[index])
if (ext) {
mountedExtensions.push(ext)
}
}
else{
indicesToRemove.push(i)
console.log("Couldn't load extension : ",full_path_item)
}
}
// Remove the broken extensions using the collected indices
for (let i = indicesToRemove.length - 1; i >= 0; i--) {
console.log("Removing extensions : ",this.state.config.extensions[indicesToRemove[i]])
this.state.config.extensions.splice(indicesToRemove[i], 1);
}
2023-07-10 20:01:20 +00:00
commit('setMountedExtensions', mountedExtensions);
},
2023-07-10 20:01:20 +00:00
async refreshDiskUsage({ commit }) {
this.state.diskUsage = await api_get_req("disk_usage")
},
async refreshRamUsage({ commit }) {
this.state.ramUsage = await api_get_req("ram_usage")
},
async refreshVramUsage({ commit }) {
const resp = await api_get_req("vram_usage")
const gpuArr = []
if (resp.nb_gpus > 0) {
// Get keys
const keys = Object.keys(resp)
// for each gpu
for (let i = 0; i < resp.nb_gpus; i++) {
const total_vram = resp[`gpu_${i}_total_vram`];
const used_vram = resp[`gpu_${i}_used_vram`];
const model = resp[`gpu_${i}_model`];
const percentage = (used_vram / total_vram) * 100
const available_space = total_vram - used_vram
gpuArr.push({
total_vram: total_vram,
used_vram: used_vram,
gpu_index: i,
gpu_model: model,
percentage: percentage.toFixed(2),
available_space: available_space
});
}
const result = {
"nb_gpus": resp.nb_gpus,
"gpus": gpuArr
}
console.log('gpu usage: ',result)
this.state.vramUsage = result
}
else{
const result = {
"nb_gpus": 0,
"gpus": []
}
console.log('gpu usage: ',result)
this.state.vramUsage = result
}
},
2023-09-21 01:39:25 +00:00
2023-07-09 17:32:25 +00:00
}
})
async function api_get_req(endpoint) {
try {
const res = await axios.get('/' + endpoint);
if (res) {
return res.data;
}
} catch (error) {
console.log(error.message, 'api_get_req');
throw error;
}
}
async function api_post_req(endpoint, client_id) {
try {
const res = await axios.post("/" + endpoint, {client_id: client_id});
if (res) {
return res.data
}
} catch (error) {
console.log(error.message, 'api_post_req - settings')
return
}
}
2023-10-14 02:27:37 +00:00
async function refreshHardwareUsage(store) {
await store.dispatch('refreshDiskUsage');
await store.dispatch('refreshRamUsage');
await store.dispatch('refreshVramUsage');
}
2023-07-09 17:32:25 +00:00
let actionsExecuted = false;
app.mixin({
2023-10-02 00:18:57 +00:00
async created() {
2023-07-09 17:32:25 +00:00
if (!actionsExecuted) {
2023-12-17 13:46:15 +00:00
this.$store.state.api_get_req = api_get_req
this.$store.state.api_post_req = api_post_req
2023-07-09 17:32:25 +00:00
actionsExecuted = true;
2023-07-10 20:01:20 +00:00
console.log("Calling")
2024-02-26 20:43:12 +00:00
try{
this.$store.state.loading_infos = "Getting version"
this.$store.state.loading_progress = 30
await this.$store.dispatch('getVersion');
}
catch (ex){
console.log("Error cought:", ex)
}
2023-12-27 00:25:18 +00:00
try{
2023-12-27 11:32:58 +00:00
this.$store.state.loading_infos = "Loading Configuration"
this.$store.state.loading_progress = 10
await this.$store.dispatch('refreshConfig');
console.log("Config ready")
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Loading Database"
this.$store.state.loading_progress = 20
await this.$store.dispatch('refreshDatabase');
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 00:25:18 +00:00
}
2023-12-27 11:32:58 +00:00
try{
this.$store.state.loading_infos = "Getting Bindings list"
this.$store.state.loading_progress = 40
await this.$store.dispatch('refreshBindings');
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Getting Hardware usage"
await refreshHardwareUsage(this.$store);
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Getting extensions zoo"
this.$store.state.loading_progress = 50
await this.$store.dispatch('refreshExtensionsZoo');
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Getting mounted extensions"
this.$store.state.loading_progress = 60
await this.$store.dispatch('refreshmountedExtensions');
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Getting personalities zoo"
this.$store.state.loading_progress = 70
await this.$store.dispatch('refreshPersonalitiesZoo')
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Getting mounted personalities"
this.$store.state.loading_progress = 80
await this.$store.dispatch('refreshMountedPersonalities');
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Getting models zoo"
this.$store.state.loading_progress = 90
await this.$store.dispatch('refreshModelsZoo');
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
try{
this.$store.state.loading_infos = "Getting active models"
this.$store.state.loading_progress = 100
await this.$store.dispatch('refreshModels');
await this.$store.dispatch('refreshModelStatus');
}
catch (ex){
console.log("Error cought:", ex)
2023-12-27 11:32:58 +00:00
}
2024-04-30 23:24:40 +00:00
try{
await this.$store.dispatch('fetchLanguages');
await this.$store.dispatch('fetchLanguage');
}
catch (ex){
console.log("Error cought:", ex)
}
2024-05-19 12:35:05 +00:00
try{
await this.$store.dispatch('fetchisRTOn');
}
catch (ex){
console.log("Error cought:", ex)
}
2023-10-02 00:18:57 +00:00
this.$store.state.ready = true;
2023-06-13 15:09:25 +00:00
}
2023-07-10 20:01:20 +00:00
},
beforeMount() {
2023-07-09 17:32:25 +00:00
}
})
2023-09-28 13:56:41 +00:00
function logObjectProperties(obj) {
if (typeof obj !== 'object' || obj === null) {
console.log('Invalid object');
return;
}
let logString = "Object parameters and values:\n";
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] !== 'function') {
logString += `${key}: ${obj[key]}\n`;
}
}
console.log(logString);
}
2023-10-02 23:13:02 +00:00
function flattenObject(obj, parentKey = "") {
let result = [];
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const newKey = parentKey ? `${parentKey}/${key}` : key;
if (typeof obj[key] === "object") {
const nestedFields = flattenObject(obj[key], newKey);
result = result.concat(nestedFields);
} else {
result.push(newKey);
}
}
}
return result;
}
2023-05-02 20:53:27 +00:00
app.use(router)
2023-06-13 15:09:25 +00:00
app.use(store)
2023-07-10 20:01:20 +00:00
app.mount('#app')
2023-05-02 20:53:27 +00:00
2024-04-02 06:50:24 +00:00
export{logObjectProperties, copyObject, flattenObject, refreshHardwareUsage }