diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 83c7c2776258..d87abafaf490 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -4,7 +4,9 @@ - This is a Demo of the v0.5.0 (BETA) | Username: changeme@email.com | Password: demo + + This is a Demo of the v0.5.0 (BETA) | Username: changeme@email.com | Password: demo + @@ -76,4 +78,5 @@ export default { :root { scrollbar-color: transparent transparent; } + diff --git a/frontend/src/components/Recipe/ContextMenu.vue b/frontend/src/components/Recipe/ContextMenu.vue index ca7a40c80847..c78b06847ec4 100644 --- a/frontend/src/components/Recipe/ContextMenu.vue +++ b/frontend/src/components/Recipe/ContextMenu.vue @@ -58,10 +58,10 @@ export default { defaultMenu() { return [ { - title: this.$t("general.download"), - icon: "mdi-download", + title: this.$t("general.print"), + icon: "mdi-printer", color: "accent", - action: "download", + action: "print", }, { title: this.$t("general.link"), @@ -108,8 +108,8 @@ export default { case "edit": this.$router.push(`/recipe/${this.slug}` + "?edit=true"); break; - case "download": - await this.downloadJson(); + case "print": + this.$router.push(`/recipe/${this.slug}` + "?print=true"); break; default: break; @@ -127,25 +127,6 @@ export default { () => console.log("Copied Failed", copyText) ); }, - async downloadJson() { - const recipe = await api.recipes.requestDetails(this.slug); - this.downloadString(JSON.stringify(recipe, "", 4), "text/json", recipe.slug + ".json"); - }, - downloadString(text, fileType, fileName) { - let blob = new Blob([text], { type: fileType }); - - let a = document.createElement("a"); - a.download = fileName; - a.href = URL.createObjectURL(blob); - a.dataset.downloadurl = [fileType, a.download, a.href].join(":"); - a.style.display = "none"; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - setTimeout(function() { - URL.revokeObjectURL(a.href); - }, 1500); - }, }, }; diff --git a/frontend/src/components/Recipe/PrintView.vue b/frontend/src/components/Recipe/PrintView.vue new file mode 100644 index 000000000000..69b3055091a4 --- /dev/null +++ b/frontend/src/components/Recipe/PrintView.vue @@ -0,0 +1,155 @@ + + + + + + + + {{ recipe.name }} + + + + + + + {{ recipe.recipeYield }} + + + + {{ $t("recipe.ingredients") }} + + + + mdi-checkbox-blank-outline + + {{ ingredient }} + + + + + {{ $t("recipe.instructions") }} + + {{ step.title }} + + {{ $t("recipe.step-index", { step: index + 1 }) }} + + + + + + + + + {{ note.title }} + + + + + + + + + \ No newline at end of file diff --git a/frontend/src/components/Recipe/RecipePrint.vue b/frontend/src/components/Recipe/RecipePrint.vue deleted file mode 100644 index 0744ea533785..000000000000 --- a/frontend/src/components/Recipe/RecipePrint.vue +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - mdi-arrow-left - - - Font Size - - - mdi-minus - - - mdi-plus - - - - - - - - - - - - {{ recipe.name }} - - {{ recipe.description }} - - - - - - - - - - - - - - - {{ recipe.recipeYield }} - - - - - Ingredients - - - - - mdi-minus - - {{ ingredient }} - - - - - - - Categories - - {{ category }} - - - - - Tags - - {{ tag }} - - - - Notes - - {{ note.title }} - - {{ note.text }} - - - - - Instructions - - - Step: {{ index + 1 }} - {{ step.text }} - - - - - - - - - - - diff --git a/frontend/src/components/UI/TheRecipeFab.vue b/frontend/src/components/UI/TheRecipeFab.vue index 6bb8e267bc97..e810e13257b4 100644 --- a/frontend/src/components/UI/TheRecipeFab.vue +++ b/frontend/src/components/UI/TheRecipeFab.vue @@ -1,5 +1,5 @@ - + diff --git a/frontend/src/components/UI/TheSidebar.vue b/frontend/src/components/UI/TheSidebar.vue index bec446857a72..016f02964548 100644 --- a/frontend/src/components/UI/TheSidebar.vue +++ b/frontend/src/components/UI/TheSidebar.vue @@ -1,5 +1,5 @@ - + @@ -231,4 +231,10 @@ export default { bottom: 0 !important; width: 100%; } + +@media print { + .no-print { + display: none; + } +} diff --git a/frontend/src/locales/messages/en-US.json b/frontend/src/locales/messages/en-US.json index 58fba36e838c..0a86d022df78 100644 --- a/frontend/src/locales/messages/en-US.json +++ b/frontend/src/locales/messages/en-US.json @@ -79,6 +79,7 @@ "no": "No", "ok": "OK", "options": "Options:", + "print": "Print", "random": "Random", "rating": "Rating", "recent": "Recent", diff --git a/frontend/src/pages/Recipe/ViewRecipe.vue b/frontend/src/pages/Recipe/ViewRecipe.vue index 3a33183167f5..d1d31564e1fa 100644 --- a/frontend/src/pages/Recipe/ViewRecipe.vue +++ b/frontend/src/pages/Recipe/ViewRecipe.vue @@ -3,7 +3,7 @@ - + + @@ -43,6 +44,7 @@ import { api } from "@/api"; import VJsoneditor from "v-jsoneditor"; import RecipeViewer from "@/components/Recipe/RecipeViewer"; +import PrintView from "@/components/Recipe/PrintView"; import RecipeEditor from "@/components/Recipe/RecipeEditor"; import RecipeTimeCard from "@/components/Recipe/RecipeTimeCard.vue"; import EditorButtonRow from "@/components/Recipe/EditorButtonRow"; @@ -56,6 +58,7 @@ export default { RecipeEditor, EditorButtonRow, RecipeTimeCard, + PrintView, }, mixins: [user], inject: { @@ -93,10 +96,17 @@ export default { imageKey: 1, }; }, - mounted() { - this.getRecipeDetails(); + + async mounted() { + await this.getRecipeDetails(); this.jsonEditor = false; this.form = this.$route.query.edit === "true" && this.loggedIn; + + console.log(this.$route.query.print); + if (this.$route.query.print) { + this.printPage(); + this.$router.push(this.$route.path); + } }, watch: { @@ -174,6 +184,9 @@ export default { } } }, + printPage() { + window.print(); + }, }, };
{{ ingredient }}