Feature/about api (#253)

* fix settings

* app info cleanup

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-04-02 11:02:01 -08:00 committed by GitHub
parent fd21777990
commit bc595d5cfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 23 deletions

View File

@ -53,7 +53,6 @@ import AddRecipeFab from "@/components/UI/AddRecipeFab";
import LanguageMenu from "@/components/UI/LanguageMenu"; import LanguageMenu from "@/components/UI/LanguageMenu";
import Vuetify from "./plugins/vuetify"; import Vuetify from "./plugins/vuetify";
import { user } from "@/mixins/user"; import { user } from "@/mixins/user";
import { api } from "./api";
export default { export default {
name: "App", name: "App",
@ -76,6 +75,10 @@ export default {
isMobile() { isMobile() {
return this.$vuetify.breakpoint.name === "xs"; return this.$vuetify.breakpoint.name === "xs";
}, },
demo() {
const appInfo = this.$store.getters.getAppInfo;
return appInfo.demoStatus;
},
}, },
created() { created() {
@ -96,14 +99,11 @@ export default {
this.$store.dispatch("requestTags"); this.$store.dispatch("requestTags");
this.darkModeSystemCheck(); this.darkModeSystemCheck();
this.darkModeAddEventListener(); this.darkModeAddEventListener();
this.$store.dispatch("requestAppInfo");
const api_status = await api.meta.getIsDemo();
this.demo = api_status.demoStatus;
}, },
data: () => ({ data: () => ({
search: false, search: false,
demo: false,
}), }),
methods: { methods: {
// For Later! // For Later!
@ -166,7 +166,6 @@ export default {
opacity: 0.9 !important; opacity: 0.9 !important;
} }
*::-webkit-scrollbar { *::-webkit-scrollbar {
width: 0.25rem; width: 0.25rem;
} }

View File

@ -10,7 +10,7 @@ const debugURLs = {
}; };
export const metaAPI = { export const metaAPI = {
async get_version() { async getAppInfo() {
let response = await apiReq.get(debugURLs.version); let response = await apiReq.get(debugURLs.version);
return response.data; return response.data;
}, },

View File

@ -83,7 +83,7 @@
<v-list-item-content> <v-list-item-content>
<v-list-item-title> <v-list-item-title>
{{ $t("settings.current") }} {{ $t("settings.current") }}
{{ version }} {{ appVersion }}
</v-list-item-title> </v-list-item-title>
<v-list-item-subtitle> <v-list-item-subtitle>
<a <a
@ -106,14 +106,12 @@
import { validators } from "@/mixins/validators"; import { validators } from "@/mixins/validators";
import { initials } from "@/mixins/initials"; import { initials } from "@/mixins/initials";
import { user } from "@/mixins/user"; import { user } from "@/mixins/user";
import { api } from "@/api";
import axios from "axios"; import axios from "axios";
export default { export default {
mixins: [validators, initials, user], mixins: [validators, initials, user],
data() { data() {
return { return {
latestVersion: null, latestVersion: null,
version: null,
hideImage: false, hideImage: false,
showSidebar: false, showSidebar: false,
mobile: false, mobile: false,
@ -163,8 +161,6 @@ export default {
this.mobile = this.viewScale(); this.mobile = this.viewScale();
this.showSidebar = !this.viewScale(); this.showSidebar = !this.viewScale();
this.getVersion(); this.getVersion();
let versionData = await api.meta.get_version();
this.version = versionData.version;
}, },
computed: { computed: {
@ -172,7 +168,11 @@ export default {
return `api/users/${this.user.id}/image`; return `api/users/${this.user.id}/image`;
}, },
newVersionAvailable() { newVersionAvailable() {
return this.latestVersion == this.version ? false : true; return this.latestVersion == this.appVersion ? false : true;
},
appVersion() {
const appInfo = this.$store.getters.getAppInfo;
return appInfo.version;
}, },
}, },

View File

@ -28,6 +28,10 @@ const store = new Vuex.Store({
mealPlanCategories: [], mealPlanCategories: [],
allCategories: [], allCategories: [],
allTags: [], allTags: [],
appInfo: {
version: "",
demoStatus: false,
},
}, },
mutations: { mutations: {
@ -43,6 +47,9 @@ const store = new Vuex.Store({
setAllTags(state, payload) { setAllTags(state, payload) {
state.allTags = payload; state.allTags = payload;
}, },
setAppInfo(state, payload) {
state.appInfo = payload;
},
}, },
actions: { actions: {
@ -67,6 +74,11 @@ const store = new Vuex.Store({
const tags = await api.tags.getAll(); const tags = await api.tags.getAll();
commit("setAllTags", tags); commit("setAllTags", tags);
}, },
async requestAppInfo({ commit }) {
const response = await api.meta.getAppInfo();
commit("setAppInfo", response);
},
}, },
getters: { getters: {
@ -76,6 +88,7 @@ const store = new Vuex.Store({
state.allCategories.sort((a, b) => (a.slug > b.slug ? 1 : -1)), state.allCategories.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
getAllTags: state => getAllTags: state =>
state.allTags.sort((a, b) => (a.slug > b.slug ? 1 : -1)), state.allTags.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
getAppInfo: state => state.appInfo,
}, },
}); });

View File

@ -12,7 +12,7 @@ CWD = Path(__file__).parent
BASE_DIR = CWD.parent.parent BASE_DIR = CWD.parent.parent
ENV = BASE_DIR.joinpath(".env") ENV = BASE_DIR.joinpath(".env")
PRODUCTION = os.environ.get("ENV") PRODUCTION = os.getenv("ENV", "False").lower() in ["true", "1"]
def determine_data_dir(production: bool) -> Path: def determine_data_dir(production: bool) -> Path:
@ -111,7 +111,7 @@ class AppSettings(BaseSettings):
SQLITE_FILE: Optional[Union[str, Path]] SQLITE_FILE: Optional[Union[str, Path]]
@validator("SQLITE_FILE", pre=True) @validator("SQLITE_FILE", pre=True)
def identify_sqlite_file(_cls, v: str) -> Optional[str]: def identify_sqlite_file(cls, v: str) -> Optional[str]:
return app_dirs.SQLITE_DIR.joinpath(f"mealie_{DB_VERSION}.sqlite") return app_dirs.SQLITE_DIR.joinpath(f"mealie_{DB_VERSION}.sqlite")
DEFAULT_GROUP: str = "Home" DEFAULT_GROUP: str = "Home"
@ -127,3 +127,5 @@ class AppSettings(BaseSettings):
settings = AppSettings() settings = AppSettings()
print(settings.dict())

View File

@ -3,20 +3,15 @@ import json
from fastapi import APIRouter, Depends from fastapi import APIRouter, Depends
from mealie.core.config import APP_VERSION, LOGGER_FILE, app_dirs, settings from mealie.core.config import APP_VERSION, LOGGER_FILE, app_dirs, settings
from mealie.routes.deps import get_current_user from mealie.routes.deps import get_current_user
from mealie.schema.debug import AppInfo
router = APIRouter(prefix="/api/debug", tags=["Debug"]) router = APIRouter(prefix="/api/debug", tags=["Debug"])
@router.get("/version") @router.get("/version")
async def get_mealie_version(current_user=Depends(get_current_user)): async def get_mealie_version():
""" Returns the current version of mealie""" """ Returns the current version of mealie"""
return {"version": APP_VERSION} return AppInfo(version=APP_VERSION, demo_status=settings.IS_DEMO)
@router.get("/is-demo")
async def get_demo_status():
print(settings.IS_DEMO)
return {"demoStatus": settings.IS_DEMO}
@router.get("/last-recipe-json") @router.get("/last-recipe-json")

6
mealie/schema/debug.py Normal file
View File

@ -0,0 +1,6 @@
from fastapi_camelcase import CamelModel
class AppInfo(CamelModel):
version: str
demo_status: bool