mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-08 22:15:34 -04:00
feat: Recipe import progress (#7252)
This commit is contained in:
@@ -83,14 +83,20 @@
|
||||
/>
|
||||
</v-card-text>
|
||||
<v-card-actions class="justify-center">
|
||||
<div style="width: 250px">
|
||||
<BaseButton
|
||||
:disabled="!newRecipeData"
|
||||
rounded
|
||||
block
|
||||
type="submit"
|
||||
:loading="loading"
|
||||
/>
|
||||
<div style="width: 100%" class="text-center">
|
||||
<div style="width: 250px; margin: 0 auto">
|
||||
<BaseButton
|
||||
:disabled="!newRecipeData"
|
||||
rounded
|
||||
block
|
||||
type="submit"
|
||||
:loading="loading"
|
||||
/>
|
||||
</div>
|
||||
<v-card-text class="py-2">
|
||||
<!-- render to maintain layout -->
|
||||
{{ createStatus }}
|
||||
</v-card-text>
|
||||
</div>
|
||||
</v-card-actions>
|
||||
</div>
|
||||
@@ -167,6 +173,7 @@ export default defineNuxtComponent({
|
||||
}
|
||||
handleIsEditJson();
|
||||
|
||||
const createStatus = ref<string | null>(null);
|
||||
async function createFromHtmlOrJson(htmlOrJsonData: string | object | null, importKeywordsAsTags: boolean, importCategories: boolean, url: string | null = null) {
|
||||
if (!htmlOrJsonData) {
|
||||
return;
|
||||
@@ -186,7 +193,14 @@ export default defineNuxtComponent({
|
||||
}
|
||||
|
||||
state.loading = true;
|
||||
const { response } = await api.recipes.createOneByHtmlOrJson(dataString, importKeywordsAsTags, importCategories, url);
|
||||
const { response } = await api.recipes.createOneByHtmlOrJson(
|
||||
dataString,
|
||||
importKeywordsAsTags,
|
||||
importCategories,
|
||||
url,
|
||||
(message: string) => createStatus.value = message,
|
||||
);
|
||||
createStatus.value = null;
|
||||
handleResponse(response, importKeywordsAsTags);
|
||||
}
|
||||
|
||||
@@ -199,6 +213,7 @@ export default defineNuxtComponent({
|
||||
newRecipeData,
|
||||
newRecipeUrl,
|
||||
handleIsEditJson,
|
||||
createStatus,
|
||||
createFromHtmlOrJson,
|
||||
...toRefs(state),
|
||||
validators,
|
||||
|
||||
@@ -65,14 +65,20 @@
|
||||
:label="$t('recipe.parse-recipe-ingredients-after-import')"
|
||||
/>
|
||||
<v-card-actions class="justify-center">
|
||||
<div style="width: 250px">
|
||||
<BaseButton
|
||||
:disabled="recipeUrl === null"
|
||||
rounded
|
||||
block
|
||||
type="submit"
|
||||
:loading="loading"
|
||||
/>
|
||||
<div style="width: 100%" class="text-center">
|
||||
<div style="width: 250px; margin: 0 auto">
|
||||
<BaseButton
|
||||
:disabled="recipeUrl === null"
|
||||
rounded
|
||||
block
|
||||
type="submit"
|
||||
:loading="loading"
|
||||
/>
|
||||
</div>
|
||||
<v-card-text class="py-2">
|
||||
<!-- render to maintain layout -->
|
||||
{{ createStatus }}
|
||||
</v-card-text>
|
||||
</div>
|
||||
</v-card-actions>
|
||||
</div>
|
||||
@@ -234,6 +240,7 @@ export default defineNuxtComponent({
|
||||
router.replace({ query: undefined }).then(() => router.push(to));
|
||||
});
|
||||
|
||||
const createStatus = ref<string | null>(null);
|
||||
async function createByUrl(url: string | null, importKeywordsAsTags: boolean, importCategories: boolean) {
|
||||
if (url === null) {
|
||||
return;
|
||||
@@ -244,7 +251,13 @@ export default defineNuxtComponent({
|
||||
return;
|
||||
}
|
||||
state.loading = true;
|
||||
const { response } = await api.recipes.createOneByUrl(url, importKeywordsAsTags, importCategories);
|
||||
const { response } = await api.recipes.createOneByUrl(
|
||||
url,
|
||||
importKeywordsAsTags,
|
||||
importCategories,
|
||||
(message: string) => createStatus.value = message,
|
||||
);
|
||||
createStatus.value = null;
|
||||
handleResponse(response, importKeywordsAsTags);
|
||||
}
|
||||
|
||||
@@ -257,6 +270,7 @@ export default defineNuxtComponent({
|
||||
stayInEditMode,
|
||||
parseRecipe,
|
||||
domUrlForm,
|
||||
createStatus,
|
||||
createByUrl,
|
||||
...toRefs(state),
|
||||
validators,
|
||||
|
||||
Reference in New Issue
Block a user