1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 05:25:26 +02:00

Frontend Fixes + Adjust Caddyfile (#518)

* token error handling

* Add additional settings to recipes

* fixes #515

* remove index.html

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-06-14 19:37:38 -08:00 committed by GitHub
parent 17a7d0b31e
commit d7c883feca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 48 additions and 319 deletions

View file

@ -36,7 +36,6 @@ export const recipeAPI = {
async requestDetails(recipeSlug) {
const response = await apiReq.getSafe(API_ROUTES.recipesRecipeSlug(recipeSlug));
console.log(response);
return response;
},

View file

@ -1,20 +1,16 @@
import { API_ROUTES } from "./apiRoutes";
import { apiReq } from "./api-utils";
import axios from "axios";
import i18n from "@/i18n.js";
export const userAPI = {
async login(formData) {
let response = await apiReq.post(API_ROUTES.authToken, formData, null, function() {
let response = await apiReq.post(API_ROUTES.authToken, formData, null, () => {
return i18n.t("user.user-successfully-logged-in");
});
return response;
},
async refresh() {
let response = await axios.get(API_ROUTES.authRefresh).catch(function(event) {
console.log("Fetch failed", event);
});
return response.data ? response.data : false;
return apiReq.getSafe(API_ROUTES.authRefresh);
},
async allUsers() {
let response = await apiReq.get(API_ROUTES.users);
@ -29,8 +25,7 @@ export const userAPI = {
);
},
async self() {
let response = await apiReq.get(API_ROUTES.usersSelf);
return response.data;
return apiReq.getSafe(API_ROUTES.usersSelf);
},
async byID(id) {
let response = await apiReq.get(API_ROUTES.usersId(id));

View file

@ -106,9 +106,6 @@ export default {
},
watch: {
startDate(val) {
console.log(val);
},
dateDif() {
this.planDays = [];
for (let i = 0; i < this.dateDif; i++) {

View file

@ -10,12 +10,10 @@
<slot> </slot>
</v-img>
<div class="icon-slot" v-else @click="$emit('click')">
<div>
<slot> </slot>
</div>
<v-icon color="primary" class="icon-position" :size="iconSize">
{{ $globals.icons.primary }}
</v-icon>
<slot> </slot>
</div>
</template>

View file

@ -82,9 +82,6 @@ export default {
this.$set(this.editKeys, comment.id, false);
}
},
editKeys() {
console.log(this.editKeys);
},
},
methods: {
resetImage() {
@ -103,7 +100,6 @@ export default {
this.$emit(UPDATE_COMMENT_EVENT);
},
async createNewComment() {
console.log(this.slug);
await api.recipes.createComment(this.slug, { text: this.newComment });
this.$emit(NEW_COMMENT_EVENT);

View file

@ -47,6 +47,8 @@ export default {
showNutrition: this.$t("recipe.show-nutrition-values"),
showAssets: this.$t("recipe.show-assets"),
landscapeView: this.$t("recipe.landscape-view-coming-soon"),
disableComments: this.$t("recipe.disable-comments"),
disableAmount: this.$t("recipe.disable-amount"),
};
},
},

View file

@ -27,7 +27,7 @@
<Rating :value="rating" :name="name" :slug="slug" :small="true" />
<v-spacer></v-spacer>
<RecipeChips :truncate="true" :items="tags" :title="false" :limit="2" :small="true" :isCategory="false" />
<ContextMenu :slug="slug" :name="name"/>
<ContextMenu :slug="slug" :name="name" />
</v-card-actions>
</v-card>
</v-hover>

View file

@ -210,6 +210,8 @@
"calories-suffix": "calories",
"carbohydrate-content": "Carbohydrate",
"categories": "Categories",
"disable-comments": "Disable Comments",
"disable-amount": "Disable Ingredient Amounts",
"delete-confirmation": "Are you sure you want to delete this recipe?",
"delete-recipe": "Delete Recipe",
"description": "Description",

View file

@ -150,7 +150,13 @@ export default {
methods: {
async refreshProfile() {
this.user = await api.users.self();
const [response, err] = await api.users.self();
if (err) {
return; // TODO: Log or Notifty User of Error
}
this.user = response.data;
},
openAvatarPicker() {
this.showAvatarPicker = true;

View file

@ -55,6 +55,7 @@
/>
</v-card>
<CommentsSection
v-if="recipeDetails.settings && !recipeDetails.settings.disableComments"
class="mt-2 d-print-none"
:slug="recipeDetails.slug"
:comments="recipeDetails.comments"

View file

@ -199,7 +199,6 @@ export default {
},
async importIngredients(selected) {
const [response, error] = await api.recipes.requestDetails(selected.slug);
console.log(response);
if (error) {
console.log(error);

View file

@ -56,8 +56,13 @@ const mutations = {
const actions = {
async requestUserData({ getters, commit }) {
if (getters.getIsLoggedIn) {
const userData = await api.users.self();
commit("setUserData", userData);
const [response, err] = await api.users.self();
if (err) {
return; // TODO: Log or Notifty User of Error
}
commit("setUserData", response.data);
}
},
@ -76,13 +81,15 @@ const actions = {
console.log("Not Logged In");
return;
}
try {
let authResponse = await api.users.refresh();
commit("setToken", authResponse.access_token);
} catch {
const [response, err] = await api.users.refresh();
if (err) {
console.log("Failed Token Refresh, Logging Out...");
commit("setIsLoggedIn", false);
}
commit("setToken", response.data.access_token);
},
async initTheme({ dispatch, getters }) {