profiling + research + download
This commit is contained in:
38
src/stores/KsDocumentStore.js
Normal file
38
src/stores/KsDocumentStore.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { KsDocumentService } from '../service/KsDocumentService';
|
||||
import { LoadingStore } from './LoadingStore';
|
||||
|
||||
|
||||
export const KsDocumentStore = defineStore('ksdocument_store', () => {
|
||||
|
||||
const lstKsDocument = ref([])
|
||||
const selectedKsDocument = ref(null)
|
||||
const loadingStore = LoadingStore()
|
||||
|
||||
|
||||
async function fetchKsDocument() {
|
||||
console.log("i'm in");
|
||||
loadingStore.scenario_loading = true;
|
||||
await KsDocumentService.getKsDocuments().then(resp => {
|
||||
lstKsDocument.value = resp.data;
|
||||
console.log("lstKsDocument", lstKsDocument.value);
|
||||
loadingStore.scenario_loading = false;
|
||||
});
|
||||
|
||||
}
|
||||
const ksDocument = computed(() => {
|
||||
return lstKsDocument.value
|
||||
})
|
||||
|
||||
const getSelectedKsDocument = computed(() => {
|
||||
return selectedKsDocument.value
|
||||
})
|
||||
|
||||
async function setSelectedKsDocument(ksDoc){
|
||||
selectedKsDocument.value = ksDoc
|
||||
console.log("selectedExecScenario", selectedKsDocument.value);
|
||||
}
|
||||
|
||||
return { fetchKsDocument, selectedKsDocument, lstKsDocument, ksDocument, getSelectedKsDocument, setSelectedKsDocument}
|
||||
})
|
||||
35
src/stores/LoadingStore.js
Normal file
35
src/stores/LoadingStore.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
|
||||
export const LoadingStore = defineStore('loading_store', () => {
|
||||
|
||||
|
||||
const scenario_loading = ref(false)
|
||||
const user_loading = ref(false)
|
||||
const another_loading = ref(false)
|
||||
const exectuion_loading = ref(false)
|
||||
const re_loading = ref(false)
|
||||
|
||||
const isLoading = computed(() => {
|
||||
return scenario_loading.value || user_loading.value || another_loading.value || exectuion_loading.value || re_loading.value
|
||||
})
|
||||
|
||||
const loadingType = computed(() => {
|
||||
if(exectuion_loading.value) return 'ai'
|
||||
if(re_loading.value) return 'ai'
|
||||
if(scenario_loading.value) return 'data'
|
||||
if(user_loading.value) return 'data'
|
||||
if(another_loading.value) return 'data'
|
||||
return 'none'
|
||||
})
|
||||
|
||||
return {isLoading,
|
||||
user_loading,
|
||||
scenario_loading,
|
||||
another_loading,
|
||||
exectuion_loading,
|
||||
re_loading,
|
||||
loadingType
|
||||
}
|
||||
})
|
||||
73
src/stores/UserPrefStore.js
Normal file
73
src/stores/UserPrefStore.js
Normal file
@@ -0,0 +1,73 @@
|
||||
import { useAuth } from '@websanova/vue-auth/src/v3.js';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { ProjectService } from '../service/ProjectService';
|
||||
import { LoadingStore } from './LoadingStore';
|
||||
|
||||
export const UserPrefStore = defineStore('userpref_store', () => {
|
||||
|
||||
const user = ref(null)
|
||||
const userLoaded = ref(false)
|
||||
const selectedApp = ref(null)
|
||||
const loadingStore = LoadingStore()
|
||||
|
||||
|
||||
async function fetchUserData(){
|
||||
console.log("fetchUserData");
|
||||
const auth = useAuth();
|
||||
loadingStore.user_loading = true;
|
||||
await auth.fetch().then((fetchedUser) => {
|
||||
|
||||
user.value = fetchedUser.data.data;
|
||||
selectedApp.value = user.value.selectedApplication;
|
||||
userLoaded.value = true;
|
||||
loadingStore.user_loading = false;
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
};
|
||||
|
||||
async function updateSelectedProject(project) {
|
||||
try {
|
||||
loadingStore.user_loading = true;
|
||||
selectedApp.value = null;
|
||||
// Aspetta che l'aggiornamento del progetto finisca
|
||||
await ProjectService.updateSelectedProject(project);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Errore durante l'aggiornamento del progetto:", error);
|
||||
} finally {
|
||||
// Assicurati che il caricamento venga disabilitato anche in caso di errore
|
||||
loadingStore.user_loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
async function setSelectedApp(app){
|
||||
loadingStore.user_loading = true;
|
||||
await ProjectService.updateSelectedApplication(app);
|
||||
selectedApp.value = app;
|
||||
loadingStore.user_loading = false;
|
||||
}
|
||||
|
||||
const selectedProject = computed(() => user.value.selectedProject)
|
||||
//const availableApp = computed(() => user.value.selectedProject.lstApplications)
|
||||
const availableApp = computed(() => {
|
||||
if (user.value.selectedProject!=null) {
|
||||
return user.value.selectedProject.lstApplications
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
});
|
||||
|
||||
const getSelApp = computed(() => {
|
||||
return selectedApp.value
|
||||
})
|
||||
|
||||
|
||||
|
||||
return { user,fetchUserData, selectedProject, availableApp, getSelApp, userLoaded,setSelectedApp,selectedApp,
|
||||
updateSelectedProject }
|
||||
})
|
||||
Reference in New Issue
Block a user