Skip to content

Commit 1d1b98d

Browse files
author
mrzapp
committed
Fixes #239
1 parent f3bda2c commit 1d1b98d

File tree

6 files changed

+82
-14
lines changed

6 files changed

+82
-14
lines changed

appinfo/routes.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
['name' => 'main#recipe', 'url' => '/recipes/{id}', 'verb' => 'GET', 'requirements' => ['id' => '\d+']],
2525
['name' => 'recipe#image', 'url' => '/recipes/{id}/image', 'verb' => 'GET', 'requirements' => ['id' => '\d+']],
2626
['name' => 'config#reindex', 'url' => '/reindex', 'verb' => 'POST'],
27+
['name' => 'config#list', 'url' => '/config', 'verb' => 'GET'],
2728
['name' => 'config#config', 'url' => '/config', 'verb' => 'POST'],
28-
/* API routes */
2929
],
30+
31+
/* API routes */
3032
'resources' => [
3133
'recipe' => ['url' => '/api/recipes']
3234
]

css/style.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,14 @@
211211
display: flex;
212212
margin-top: 10px;
213213
}
214-
@media(max-width:1199px) { #app-content-wrapper .times {
214+
@media(max-width:991px) { #app-content-wrapper .times {
215215
flex-direction: column;
216216
} }
217-
217+
218+
@media print { #app-content-wrapper .times {
219+
flex-direction: row;
220+
} }
221+
218222
#app-content-wrapper .times .time {
219223
position: relative;
220224
flex-grow: 1;
@@ -247,7 +251,7 @@
247251
#app-content-wrapper main {
248252
flex-basis: calc(100% - 22rem);
249253
}
250-
@media(max-width:1199px) { #app-content-wrapper main {
254+
@media screen and (max-width:1199px) { #app-content-wrapper main {
251255
flex-basis: 100%;
252256
width: 100%;
253257
} }
@@ -295,6 +299,10 @@
295299
}
296300

297301
@media print {
302+
#header {
303+
display: none !important;
304+
}
305+
298306
a:link:after,
299307
a:visited:after {
300308
content:" [" attr(href) "] ";

lib/Controller/ConfigController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ public function __construct($AppName, IRequest $request, IURLGenerator $urlGener
3434
$this->urlGenerator = $urlGenerator;
3535
}
3636

37+
/**
38+
* @NoAdminRequired
39+
* @NoCSRFRequired
40+
*/
41+
public function list() {
42+
return new DataResponse([
43+
'folder' => $this->service->getUserFolderPath(),
44+
'update_interval' => $this->service->getSearchIndexUpdateInterval(),
45+
'print_image' => $this->service->getPrintImage(),
46+
], Http::STATUS_OK);
47+
}
48+
3749
/**
3850
* @NoAdminRequired
3951
* @NoCSRFRequired

lib/Controller/RecipeController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public function show($id)
6464
if (null === $json) {
6565
return new DataResponse($id, Http::STATUS_NOT_FOUND, ['Content-Type' => 'application/json']);
6666
}
67+
68+
$json['printImage'] = $this->service->getPrintImage();
6769
$json['imageUrl'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $json['id'], 'size' => 'full']);
70+
6871
return new DataResponse($json, Http::STATUS_OK, ['Content-Type' => 'application/json']);
6972
}
7073

src/components/AppNavi.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,30 @@ export default {
163163
},
164164
},
165165
methods: {
166+
/**
167+
* Initial setup
168+
*/
169+
setup: function() {
170+
let $this = this
171+
172+
$.ajax({
173+
url: this.$window.baseUrl + '/config',
174+
method: 'GET',
175+
data: null,
176+
}).done(function (config) {
177+
$this.resetPrintImage = false;
178+
$this.printImage = config['print_image'];
179+
$this.updateInterval = config['update_interval'];
180+
$this.recipeFolder = config['folder'];
181+
182+
}).fail(function(e) {
183+
alert($this.t('Loading config failed'))
184+
})
185+
},
186+
187+
/**
188+
* Opens a category
189+
*/
166190
categoryOpen: function(idx) {
167191
if (!this.categories[idx].recipes.length || this.categories[idx].recipes[0].id) {
168192
// Recipes have already been loaded
@@ -179,6 +203,7 @@ export default {
179203
}
180204
})
181205
},
206+
182207
/**
183208
* Download and import the recipe at given URL
184209
*/
@@ -202,6 +227,7 @@ export default {
202227
})
203228
return deferred.promise()
204229
},
230+
205231
/**
206232
* Fetch and display recipe categories
207233
*/
@@ -241,6 +267,7 @@ export default {
241267
}
242268
})
243269
},
270+
244271
/**
245272
* Select a recipe folder using the Nextcloud file picker
246273
*/
@@ -269,6 +296,7 @@ export default {
269296
true
270297
)
271298
},
299+
272300
/**
273301
* Reindex all recipes
274302
*/
@@ -299,6 +327,7 @@ export default {
299327
})
300328
return deferred.promise()
301329
},
330+
302331
/**
303332
* Set loading recipe index to show the loading icon
304333
*/
@@ -307,6 +336,7 @@ export default {
307336
},
308337
},
309338
mounted () {
339+
this.setup()
310340
// Register a method hook for navigation refreshing
311341
// This component should only load once, but better safe than sorry...
312342
this.$root.$off('refreshNavigation')

src/components/RecipeView.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<div class="wrapper">
3-
43
<RecipeImages v-if="$store.state.recipe" />
54

65
<div v-if="$store.state.recipe" class="content">
@@ -76,61 +75,75 @@ export default {
7675
},
7776
methods: {
7877
setup: function() {
78+
// Make the control row show that a recipe is loading
7979
if (!this.$store.state.recipe) {
80-
// Make the control row show that a recipe is loading
8180
this.$store.dispatch('setLoadingRecipe', { recipe: -1 })
81+
82+
// Make the control row show that the recipe is reloading
8283
} else if (this.$store.state.recipe.id === parseInt(this.$route.params.id)) {
83-
// Make the control row show that the recipe is reloading
8484
this.$store.dispatch('setReloadingRecipe', {
8585
recipe: this.$route.params.id
8686
})
87+
88+
// Make the control row show that a new recipe is loading
8789
} else {
88-
// Make the control row show that a new recipe is loading
8990
this.$store.dispatch('setLoadingRecipe', { recipe: this.$route.params.id })
9091
}
92+
9193
let $this = this
94+
9295
$.ajax({
93-
url: this.$window.baseUrl + '/api/recipes/'+this.$route.params.id,
96+
url: this.$window.baseUrl + '/api/recipes/' + this.$route.params.id,
9497
method: 'GET',
9598
data: null,
99+
96100
}).done(function (recipe) {
97101
// Store recipe data in vuex
98102
$this.$store.dispatch('setRecipe', { recipe: recipe })
103+
99104
if ($this.$store.state.recipe.recipeIngredient) {
100105
$this.ingredients = Object.values($this.$store.state.recipe.recipeIngredient)
101106
}
107+
102108
if ($this.$store.state.recipe.recipeInstructions) {
103109
$this.instructions = Object.values($this.$store.state.recipe.recipeInstructions)
104110
}
111+
105112
if ($this.$store.state.recipe.cookTime) {
106113
let cookT = $this.$store.state.recipe.cookTime.match(/PT(\d+?)H(\d+?)M/)
107114
$this.timerCook = { hours: parseInt(cookT[1]), minutes: parseInt(cookT[2]) }
108115
}
116+
109117
if ($this.$store.state.recipe.prepTime) {
110118
let prepT = $this.$store.state.recipe.prepTime.match(/PT(\d+?)H(\d+?)M/)
111119
$this.timerPrep = { hours: parseInt(prepT[1]), minutes: parseInt(prepT[2]) }
112120
}
121+
113122
if ($this.$store.state.recipe.totalTime) {
114123
let totalT = $this.$store.state.recipe.totalTime.match(/PT(\d+?)H(\d+?)M/)
115124
$this.timerTotal = { hours: parseInt(totalT[1]), minutes: parseInt(totalT[2]) }
116125
}
126+
117127
if ($this.$store.state.recipe.tool) {
118128
$this.tools = $this.$store.state.recipe.tool
119129
}
130+
120131
// Always set the active page last!
121132
$this.$store.dispatch('setPage', { page: 'recipe' })
122-
123-
console.log('DEBUG', $this);
133+
124134
}).fail(function(e) {
125135
if ($this.$store.state.loadingRecipe) {
126136
// Reset loading recipe
127137
$this.$store.dispatch('setLoadingRecipe', { recipe: 0 })
128138
}
139+
129140
if ($this.$store.state.reloadingRecipe) {
130141
// Reset reloading recipe
131142
$this.$store.dispatch('setReloadingRecipe', { recipe: 0 })
132143
}
144+
133145
$this.$store.dispatch('setPage', { page: 'recipe' })
146+
134147
alert($this.t('Loading recipe failed'))
135148
})
136149
}
@@ -186,7 +199,7 @@ aside {
186199
width: 30%;
187200
float: left;
188201
}
189-
@media(max-width:1199px) { .content aside {
202+
@media screen and (max-width:1199px) { .content aside {
190203
width: 100%;
191204
float: none;
192205
} }
@@ -198,7 +211,7 @@ aside {
198211
text-align: justify;
199212
}
200213
201-
@media(max-width:1199px) { main {
214+
@media screen and (max-width:1199px) { main {
202215
flex-basis: 100%;
203216
width: 100%;
204217
} }
@@ -221,7 +234,7 @@ aside {
221234
clear: both;
222235
}
223236
224-
@media(max-width:1199px) { .recipe-content aside {
237+
@media screen and (max-width:1199px) { .recipe-content aside {
225238
display: block;
226239
width: 100%;
227240
float: none;

0 commit comments

Comments
 (0)