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

View file

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

View file

@ -83,7 +83,7 @@
<v-list-item-content>
<v-list-item-title>
{{ $t("settings.current") }}
{{ version }}
{{ appVersion }}
</v-list-item-title>
<v-list-item-subtitle>
<a
@ -106,14 +106,12 @@
import { validators } from "@/mixins/validators";
import { initials } from "@/mixins/initials";
import { user } from "@/mixins/user";
import { api } from "@/api";
import axios from "axios";
export default {
mixins: [validators, initials, user],
data() {
return {
latestVersion: null,
version: null,
hideImage: false,
showSidebar: false,
mobile: false,
@ -163,8 +161,6 @@ export default {
this.mobile = this.viewScale();
this.showSidebar = !this.viewScale();
this.getVersion();
let versionData = await api.meta.get_version();
this.version = versionData.version;
},
computed: {
@ -172,7 +168,11 @@ export default {
return `api/users/${this.user.id}/image`;
},
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: [],
allCategories: [],
allTags: [],
appInfo: {
version: "",
demoStatus: false,
},
},
mutations: {
@ -43,6 +47,9 @@ const store = new Vuex.Store({
setAllTags(state, payload) {
state.allTags = payload;
},
setAppInfo(state, payload) {
state.appInfo = payload;
},
},
actions: {
@ -67,6 +74,11 @@ const store = new Vuex.Store({
const tags = await api.tags.getAll();
commit("setAllTags", tags);
},
async requestAppInfo({ commit }) {
const response = await api.meta.getAppInfo();
commit("setAppInfo", response);
},
},
getters: {
@ -76,6 +88,7 @@ const store = new Vuex.Store({
state.allCategories.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
getAllTags: state =>
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
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:
@ -111,7 +111,7 @@ class AppSettings(BaseSettings):
SQLITE_FILE: Optional[Union[str, Path]]
@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")
DEFAULT_GROUP: str = "Home"
@ -127,3 +127,5 @@ class AppSettings(BaseSettings):
settings = AppSettings()
print(settings.dict())

View file

@ -3,20 +3,15 @@ import json
from fastapi import APIRouter, Depends
from mealie.core.config import APP_VERSION, LOGGER_FILE, app_dirs, settings
from mealie.routes.deps import get_current_user
from mealie.schema.debug import AppInfo
router = APIRouter(prefix="/api/debug", tags=["Debug"])
@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"""
return {"version": APP_VERSION}
@router.get("/is-demo")
async def get_demo_status():
print(settings.IS_DEMO)
return {"demoStatus": settings.IS_DEMO}
return AppInfo(version=APP_VERSION, demo_status=settings.IS_DEMO)
@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