mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
site-settings work
This commit is contained in:
parent
498a895967
commit
ff4ea3d6b6
7 changed files with 101 additions and 30 deletions
|
@ -77,6 +77,7 @@ export default {
|
||||||
this.$store.dispatch("initTheme");
|
this.$store.dispatch("initTheme");
|
||||||
this.$store.dispatch("requestRecentRecipes");
|
this.$store.dispatch("requestRecentRecipes");
|
||||||
this.$store.dispatch("requestHomePageSettings");
|
this.$store.dispatch("requestHomePageSettings");
|
||||||
|
this.$store.dispatch("requestSiteSettings");
|
||||||
this.$store.dispatch("refreshToken");
|
this.$store.dispatch("refreshToken");
|
||||||
this.darkModeSystemCheck();
|
this.darkModeSystemCheck();
|
||||||
this.darkModeAddEventListener();
|
this.darkModeAddEventListener();
|
||||||
|
|
|
@ -10,9 +10,11 @@ import meta from "./meta";
|
||||||
import users from "./users";
|
import users from "./users";
|
||||||
import signUps from "./signUps";
|
import signUps from "./signUps";
|
||||||
import groups from "./groups";
|
import groups from "./groups";
|
||||||
|
import siteSettings from "./siteSettings";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
recipes: recipe,
|
recipes: recipe,
|
||||||
|
siteSettings: siteSettings,
|
||||||
backups: backup,
|
backups: backup,
|
||||||
mealPlans: mealplan,
|
mealPlans: mealplan,
|
||||||
settings: settings,
|
settings: settings,
|
||||||
|
|
22
frontend/src/api/siteSettings.js
Normal file
22
frontend/src/api/siteSettings.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import { baseURL } from "./api-utils";
|
||||||
|
import { apiReq } from "./api-utils";
|
||||||
|
|
||||||
|
const settingsBase = baseURL + "site-settings";
|
||||||
|
|
||||||
|
const settingsURLs = {
|
||||||
|
siteSettings: `${settingsBase}`,
|
||||||
|
updateSiteSettings: `${settingsBase}`,
|
||||||
|
testWebhooks: `${settingsBase}/webhooks/test`,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
async get() {
|
||||||
|
let response = await apiReq.get(settingsURLs.siteSettings);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async update(body) {
|
||||||
|
let response = await apiReq.put(settingsURLs.updateSiteSettings, body);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
};
|
|
@ -3,9 +3,12 @@
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<h2 class="mt-1 mb-1">{{ $t("settings.homepage.home-page") }}</h2>
|
<h2 class="mt-1 mb-1">{{ $t("settings.homepage.home-page") }}</h2>
|
||||||
<v-row align="center" justify="center" dense class="mb-n7 pb-n5">
|
<v-row align="center" justify="center" dense class="mb-n7 pb-n5">
|
||||||
|
<v-col cols="1">
|
||||||
|
<LanguageMenu @select-lang="writeLang" :site-settings="true" />
|
||||||
|
</v-col>
|
||||||
<v-col cols="12" sm="3" md="2">
|
<v-col cols="12" sm="3" md="2">
|
||||||
<v-switch
|
<v-switch
|
||||||
v-model="showRecent"
|
v-model="settings.showRecent"
|
||||||
:label="$t('settings.homepage.show-recent')"
|
:label="$t('settings.homepage.show-recent')"
|
||||||
></v-switch>
|
></v-switch>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -13,7 +16,7 @@
|
||||||
<v-slider
|
<v-slider
|
||||||
class="pt-sm-4"
|
class="pt-sm-4"
|
||||||
:label="$t('settings.homepage.card-per-section')"
|
:label="$t('settings.homepage.card-per-section')"
|
||||||
v-model="showLimit"
|
v-model="settings.cardsPerSection"
|
||||||
max="30"
|
max="30"
|
||||||
dense
|
dense
|
||||||
color="primary"
|
color="primary"
|
||||||
|
@ -43,14 +46,14 @@
|
||||||
<v-list height="300" dense style="overflow:auto">
|
<v-list height="300" dense style="overflow:auto">
|
||||||
<v-list-item-group>
|
<v-list-item-group>
|
||||||
<draggable
|
<draggable
|
||||||
v-model="homeCategories"
|
v-model="settings.categories"
|
||||||
group="categories"
|
group="categories"
|
||||||
:style="{
|
:style="{
|
||||||
minHeight: `150px`,
|
minHeight: `150px`,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="(item, index) in homeCategories"
|
v-for="(item, index) in settings.categories"
|
||||||
:key="`${item.name}-${index}`"
|
:key="`${item.name}-${index}`"
|
||||||
>
|
>
|
||||||
<v-list-item-icon>
|
<v-list-item-icon>
|
||||||
|
@ -85,14 +88,14 @@
|
||||||
<v-list height="300" dense style="overflow:auto">
|
<v-list height="300" dense style="overflow:auto">
|
||||||
<v-list-item-group>
|
<v-list-item-group>
|
||||||
<draggable
|
<draggable
|
||||||
v-model="categories"
|
v-model="allCategories"
|
||||||
group="categories"
|
group="categories"
|
||||||
:style="{
|
:style="{
|
||||||
minHeight: `150px`,
|
minHeight: `150px`,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="(item, index) in categories"
|
v-for="(item, index) in allCategories"
|
||||||
:key="`${item.name}-${index}`"
|
:key="`${item.name}-${index}`"
|
||||||
>
|
>
|
||||||
<v-list-item-icon>
|
<v-list-item-icon>
|
||||||
|
@ -127,47 +130,50 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import api from "@/api";
|
import api from "@/api";
|
||||||
|
import LanguageMenu from "@/components/UI/LanguageMenu";
|
||||||
import draggable from "vuedraggable";
|
import draggable from "vuedraggable";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
draggable,
|
draggable,
|
||||||
|
LanguageMenu,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
homeCategories: null,
|
settings: {
|
||||||
showLimit: null,
|
language: "en",
|
||||||
showRecent: true,
|
showRecent: null,
|
||||||
|
cardsPerSection: null,
|
||||||
|
categories: [],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getOptions();
|
this.getOptions();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
categories() {
|
allCategories() {
|
||||||
return this.$store.getters.getCategories;
|
return this.$store.getters.getCategories;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
writeLang(val) {
|
||||||
|
console.log(val);
|
||||||
|
this.settings.language = val;
|
||||||
|
},
|
||||||
deleteCategoryfromDatabase(category) {
|
deleteCategoryfromDatabase(category) {
|
||||||
api.categories.delete(category);
|
api.categories.delete(category);
|
||||||
this.$store.dispatch("requestHomePageSettings");
|
|
||||||
},
|
},
|
||||||
getOptions() {
|
async getOptions() {
|
||||||
this.showLimit = this.$store.getters.getShowLimit;
|
this.settings = await api.siteSettings.get();
|
||||||
this.showRecent = this.$store.getters.getShowRecent;
|
|
||||||
this.homeCategories = this.$store.getters.getHomeCategories;
|
|
||||||
},
|
},
|
||||||
deleteActiveCategory(index) {
|
deleteActiveCategory(index) {
|
||||||
this.homeCategories.splice(index, 1);
|
this.settings.categories.splice(index, 1);
|
||||||
},
|
},
|
||||||
saveSettings() {
|
async saveSettings() {
|
||||||
this.homeCategories.forEach((element, index) => {
|
await api.siteSettings.update(this.settings);
|
||||||
element.position = index + 1;
|
this.getOptions();
|
||||||
});
|
|
||||||
this.$store.commit("setShowRecent", this.showRecent);
|
|
||||||
this.$store.commit("setShowLimit", this.showLimit);
|
|
||||||
this.$store.commit("setHomeCategories", this.homeCategories);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<LoginDialog ref="loginDialog" />
|
|
||||||
<v-menu
|
<v-menu
|
||||||
transition="slide-x-transition"
|
transition="slide-x-transition"
|
||||||
bottom
|
bottom
|
||||||
|
@ -35,10 +34,12 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LoginDialog from "../Login/LoginDialog";
|
const SELECT_EVENT = "select-lang";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
props: {
|
||||||
LoginDialog,
|
siteSettings: {
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
|
@ -68,7 +69,11 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
setLanguage(selectedLanguage) {
|
setLanguage(selectedLanguage) {
|
||||||
|
if (this.siteSettings) {
|
||||||
|
this.$emit(SELECT_EVENT, selectedLanguage);
|
||||||
|
} else {
|
||||||
this.$store.commit("setLang", selectedLanguage);
|
this.$store.commit("setLang", selectedLanguage);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,22 +5,23 @@ import createPersistedState from "vuex-persistedstate";
|
||||||
import userSettings from "./modules/userSettings";
|
import userSettings from "./modules/userSettings";
|
||||||
import language from "./modules/language";
|
import language from "./modules/language";
|
||||||
import homePage from "./modules/homePage";
|
import homePage from "./modules/homePage";
|
||||||
|
import siteSettings from "./modules/siteSettings";
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
plugins: [
|
plugins: [
|
||||||
createPersistedState({
|
createPersistedState({
|
||||||
paths: ["userSettings", "language", "homePage"],
|
paths: ["userSettings", "language", "homePage", "SideSettings"],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
modules: {
|
modules: {
|
||||||
userSettings,
|
userSettings,
|
||||||
language,
|
language,
|
||||||
homePage,
|
homePage,
|
||||||
|
siteSettings,
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
|
|
||||||
// All Recipe Data Store
|
// All Recipe Data Store
|
||||||
recentRecipes: [],
|
recentRecipes: [],
|
||||||
allRecipes: [],
|
allRecipes: [],
|
||||||
|
|
34
frontend/src/store/modules/siteSettings.js
Normal file
34
frontend/src/store/modules/siteSettings.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import api from "@/api";
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
siteSettings: {
|
||||||
|
language: "en",
|
||||||
|
showRecent: true,
|
||||||
|
cardsPerSection: 9,
|
||||||
|
categories: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
setSettings(state, payload) {
|
||||||
|
state.settings = payload;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
async requestSiteSettings() {
|
||||||
|
let settings = await api.siteSettings.get();
|
||||||
|
this.commit("setSettings", settings);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const getters = {
|
||||||
|
getSiteSettings: state => state.siteSettings,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters,
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue