space settings

This commit is contained in:
vabene1111
2024-09-02 17:48:59 +02:00
parent 6087668e26
commit 5f184693ca
6 changed files with 102 additions and 24 deletions

View File

@@ -23,6 +23,7 @@ export enum ErrorMessageType {
export enum PreparedMessage {
UPDATE_SUCCESS = 'UPDATE_SUCCESS',
CREATE_SUCCESS = 'CREATE_SUCCESS',
DELETE_SUCCESS = 'DELETE_SUCCESS',
}
/**
@@ -93,6 +94,7 @@ export const useMessageStore = defineStore('message_store', () => {
if (preparedMessage == PreparedMessage.UPDATE_SUCCESS) {
addMessage(MessageType.SUCCESS, 'Updated Successfully', 7000, {}) // TODO localize and make more useful ?
addMessage(MessageType.SUCCESS, 'Created Successfully', 7000, {})
addMessage(MessageType.SUCCESS, 'Deleted Successfully', 7000, {})
}
}

View File

@@ -64,10 +64,28 @@ export const useUserPreferenceStore = defineStore('user_preference_store', () =>
})
}
/**
* load data for currently active space
*/
function loadActiveSpace(){
let api = new ApiApi()
api.apiSpaceCurrentRetrieve().then(r => {
activeSpace.value = r
}).catch(err => {
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
})
}
/**
* switch to the given space
*/
function switchSpace(space: Space){
let api = new ApiApi()
api.apiSwitchActiveSpaceRetrieve({spaceId: space.id}).then(r => {
loadActiveSpace()
}).catch(err => {
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
})
}
@@ -76,7 +94,7 @@ export const useUserPreferenceStore = defineStore('user_preference_store', () =>
// always load active space on first initialization of store
loadActiveSpace()
return {deviceSettings, userSettings, activeSpace, loadUserSettings, updateUserSettings}
return {deviceSettings, userSettings, activeSpace, loadUserSettings, updateUserSettings, switchSpace}
})
// enable hot reload for store