diff --git a/vue/src/apps/ImportView/ImportView.vue b/vue/src/apps/ImportView/ImportView.vue index 934402234..2c143741f 100644 --- a/vue/src/apps/ImportView/ImportView.vue +++ b/vue/src/apps/ImportView/ImportView.vue @@ -17,7 +17,10 @@ - {{ $t('Website') }} + {{ + $t('Website') + }} +
- {{$t('click_image_import')}}
- {{$t('no_more_images_found')}} + {{ $t('click_image_import') }}
+ {{ + $t('no_more_images_found') + }}
- {{$t('Keywords')}} + {{ $t('Keywords') }} @@ -258,31 +264,94 @@ + +

{{ $t('Select_App_To_Import') }}:

+ + + + + Icon + + {{ i.name }} + + + + + + + + + + + + + Icon + + {{ i.name }} + + + + + + + + + + + {{ $t('Importer_Help') }} {{ $t('Documentation') }} + + - + + {{ $t('import_duplicates') }} + - - {{ $t('import_duplicates') }} - - {{ - $t('Help') - }} - - - - + + +
+ {{ $t('Import') }} + +
+
@@ -329,7 +398,15 @@ import {BootstrapVue} from 'bootstrap-vue' import 'bootstrap-vue/dist/bootstrap-vue.css' -import {resolveDjangoStatic, resolveDjangoUrl, ResolveUrlMixin, StandardToasts, ToastMixin} from "@/utils/utils"; +import { + RandomIconMixin, + resolveDjangoStatic, + resolveDjangoUrl, + ResolveUrlMixin, + StandardToasts, + ToastMixin +} from "@/utils/utils"; + import axios from "axios"; import {ApiApiFactory} from "@/utils/openapi/api"; import {INTEGRATIONS} from "@/utils/integration"; @@ -344,6 +421,7 @@ export default { mixins: [ ResolveUrlMixin, ToastMixin, + RandomIconMixin ], components: { LoadingSpinner, @@ -354,10 +432,21 @@ export default { recipe_app_info: function () { return this.INTEGRATIONS.filter(x => x.id === this.recipe_app)[0] }, + INTEGRATIONS_WO: function () { + return this.INTEGRATIONS.filter((int) => { + return int.id !== "DEFAULT" + }) + + }, + INTEGRATIONS_TD: function () { + return this.INTEGRATIONS.filter((int) => { + return int.id === "DEFAULT" + }) + } }, data() { return { - tab_index: 0, + tab_index: 1, collapse_visible: { url: true, options: false, @@ -400,6 +489,9 @@ export default { if (window.BOOKMARKLET_IMPORT_ID !== -1) { this.loadRecipe('', false, window.BOOKMARKLET_IMPORT_ID) } + this.INTEGRATIONS.forEach((int) => { + int.icon = this.getRandomFoodIcon() + }) }, methods: { /** @@ -420,12 +512,12 @@ export default { let recipe = response.data apiFactory.imageRecipe(response.data.id, undefined, recipe_json.image).then(response => { // save recipe image if (!silent) { - StandardToasts.makeStandardToast(this,StandardToasts.SUCCESS_CREATE) + StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_CREATE) } this.afterImportAction(action, recipe) }).catch(e => { if (!silent) { - StandardToasts.makeStandardToast(this,StandardToasts.FAIL_UPDATE) + StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE) } this.afterImportAction(action, recipe) }) @@ -434,13 +526,13 @@ export default { this.failed_imports.push(recipe_json.source_url) } if (!silent) { - StandardToasts.makeStandardToast(this,StandardToasts.FAIL_CREATE) + StandardToasts.makeStandardToast(this, StandardToasts.FAIL_CREATE) } }) } else { console.log('cant import recipe without data') if (!silent) { - StandardToasts.makeStandardToast(this,StandardToasts.FAIL_CREATE) + StandardToasts.makeStandardToast(this, StandardToasts.FAIL_CREATE) } } }, @@ -576,7 +668,7 @@ export default { window.location.href = resolveDjangoUrl('view_import_response', response.data['import_id']) }).catch((err) => { console.log(err) - StandardToasts.makeStandardToast(this,StandardToasts.FAIL_CREATE) + StandardToasts.makeStandardToast(this, StandardToasts.FAIL_CREATE) }) }, /** diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json index e6e8fed6b..6a3f1810e 100644 --- a/vue/src/locales/en.json +++ b/vue/src/locales/en.json @@ -393,5 +393,12 @@ "Options": "Options", "Create Food": "Create Food", "create_food_desc": "Create a food and link it to this recipe.", - "additional_options": "Additional Options" + "additional_options": "Additional Options", + "Importer_Help": "More information and help on this importer:", + "Documentation": "Documentation", + "Select_App_To_Import": "Please select an App to Import from", + "Import_Supported": "Import supported", + "Export_Supported": "Export supported", + "Import_Not_Yet_Supported": "Import not yet supported", + "Export_Not_Yet_Supported": "Export not yet supported" } diff --git a/vue/src/utils/integration.js b/vue/src/utils/integration.js index f5bace760..5aeb5c172 100644 --- a/vue/src/utils/integration.js +++ b/vue/src/utils/integration.js @@ -1,7 +1,7 @@ // containing all data and functions regarding the different integrations export const INTEGRATIONS = [ - {id: 'DEFAULT', name: "Tandoor", import: true, export: true, help_url: 'https://docs.tandoor.dev/features/import_export/#default'}, + {id: 'DEFAULT', name: "Tandoor", import: true, export: true, help_url: 'https://docs.tandoor.dev/features/import_export/#default', img_src: 'https://raw.githubusercontent.com/TandoorRecipes/recipes/develop/docs/logo_color.svg'}, {id: 'CHEFTAP', name: "Cheftap", import: true, export: false, help_url: 'https://docs.tandoor.dev/features/import_export/#cheftap'}, {id: 'CHOWDOWN', name: "Chowdown", import: true, export: false, help_url: 'https://docs.tandoor.dev/features/import_export/#chowdown'}, {id: 'COOKBOOKAPP', name: "CookBookApp", import: true, export: false, help_url: 'https://docs.tandoor.dev/features/import_export/#cookbookapp'}, diff --git a/vue/src/utils/utils.js b/vue/src/utils/utils.js index 2ebdb6469..5bfeb448c 100644 --- a/vue/src/utils/utils.js +++ b/vue/src/utils/utils.js @@ -147,6 +147,45 @@ export class StandardToasts { } } +/* + * Utility function to get random food icon from fontawesome + * */ + +export const RandomIconMixin = { + name: "RandomIconMixin", + methods: { + getRandomFoodIcon: function () { + return getRandomFoodIcon() + }, + }, +} + +export function getRandomFoodIcon() { + let icons = [ + 'fas fa-hamburger', + 'fas fa-utensils', + 'fas fa-apple-alt', + 'fas fa-bacon', + 'fas fa-bread-slice', + 'fas fa-candy-cane', + 'fas fa-carrot', + 'fas fa-cheese', + 'fas fa-cookie', + 'fas fa-drumstick-bite', + 'fas fa-egg', + 'fas fa-fish', + 'fas fa-hotdog', + 'fas fa-ice-cream', + 'fas fa-lemon', + 'fas fa-pepper-hot', + 'fas fa-pizza-slice', + 'fas fa-cookie-bite' + + ] + + return icons[Math.floor(Math.random() * icons.length)]; +} + /* * Utility functions to use djangos gettext * */