Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Added user settings handling #250

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/layouts/DashboardLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export default {
created() {
//load this data once:
this.$store.dispatch("user/getInfo");
this.$store.dispatch("user/getSettings");

//refresh this data every 20s:
this.fetchData();
Expand Down
27 changes: 26 additions & 1 deletion src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const state = () => ({
jwt: window.localStorage.getItem("jwt") || "",
registered: true,
seed: [],
installedApps: []
installedApps: [],
settings: {}
});

// Functions to update the state directly
Expand All @@ -27,6 +28,9 @@ const mutations = {
},
setSeed(state, seed) {
state.seed = seed;
},
setSettings(state, settings) {
state.settings = settings;
}
};

Expand Down Expand Up @@ -76,6 +80,27 @@ const actions = {
commit("setInstalledApps", installedApps);
},

async getSettings({ commit }) {
const settings = await API.get(
`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/settings`
);
commit("setSettings", settings);
},

async updateSetting({ commit }, { setting, value }) {
const { data: settings } = await API.post(
`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/settings`,
{
setting,
value
}
);

if(settings) {
commit("setSettings", settings);
}
},

async getSeed({ commit, state, dispatch }, plainTextPassword) {
let rawSeed;

Expand Down