import response improvements

This commit is contained in:
vabene1111 2021-06-17 14:08:03 +02:00
parent afc31b313f
commit a9a0716c45
13 changed files with 140 additions and 63 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.4 on 2021-06-17 11:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cookbook', '0135_auto_20210615_2210'),
]
operations = [
migrations.AddField(
model_name='importlog',
name='imported_recipes',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='importlog',
name='total_recipes',
field=models.IntegerField(default=0),
),
]

View File

@ -591,6 +591,10 @@ class IngredientExportSerializer(WritableNestedModelSerializer):
unit = UnitExportSerializer(allow_null=True)
amount = CustomDecimalField()
def create(self, validated_data):
validated_data['space'] = self.context['request'].space
return super().create(validated_data)
class Meta:
model = Ingredient
fields = ('food', 'unit', 'amount', 'note', 'order', 'is_header', 'no_amount')
@ -599,6 +603,10 @@ class IngredientExportSerializer(WritableNestedModelSerializer):
class StepExportSerializer(WritableNestedModelSerializer):
ingredients = IngredientExportSerializer(many=True)
def create(self, validated_data):
validated_data['space'] = self.context['request'].space
return super().create(validated_data)
class Meta:
model = Step
fields = ('name', 'type', 'instruction', 'ingredients', 'time', 'order', 'show_as_header')

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,54 +1,42 @@
<template>
<div id="app">
<div class="row">
<div class="col col-md-12">
<h2>{{ $t('Import') }}</h2>
</div>
</div>
<br/>
<br/>
<template v-if="import_info !== undefined">
<template v-if="import_info.running" style="text-align: center;">
<div class="row">
<div class="col col-md-12">
</div>
</div>
<loading-spinner></loading-spinner>
<br/>
<br/>
<template v-if="import_info.running">
<h5 style="text-align: center">{{ $t('Importing') }}...</h5>
<b-progress :max="import_info.total_recipes">
<b-progress-bar :value="import_info.imported_recipes" :label="`${import_info.imported_recipes}/${import_info.total_recipes}`"></b-progress-bar>
</b-progress>
<loading-spinner :size="25"></loading-spinner>
</template>
<template v-else>
<div class="row">
<div class="col col-md-12">
<span>{{ $t('Import_finished') }}! </span>
<a :href="`${resolveDjangoUrl('view_search') }?keyword=${import_info.keyword.id}`"
v-if="import_info.keyword !== null">{{ $t('View_Recipes') }}</a>
</div>
<div class="row">
<div class="col col-md-12" v-if="!import_info.running">
<span>{{ $t('Import_finished') }}! </span>
<a :href="`${resolveDjangoUrl('view_search') }?keyword=${import_info.keyword.id}`"
v-if="import_info.keyword !== null">{{ $t('View_Recipes') }}</a>
</div>
</div>
<br/>
<br/>
<div class="row">
<div class="col col-md-12">
<label for="id_textarea">{{ $t('Information') }}</label>
<textarea id="id_textarea" class="form-control" style="height: 50vh" v-html="import_info.msg"
disabled></textarea>
<div class="row">
<div class="col col-md-12">
<label for="id_textarea">{{ $t('Information') }}</label>
<textarea id="id_textarea" ref="output_text" class="form-control" style="height: 50vh"
v-html="import_info.msg"
disabled></textarea>
</div>
</div>
</template>
</div>
<br/>
<br/>
</template>
</div>
@ -90,6 +78,8 @@ export default {
setInterval(() => {
if ((this.import_id !== null) && window.navigator.onLine && this.import_info.running) {
this.refreshData()
let el = this.$refs.output_text
el.scrollTop = el.scrollHeight;
}
}, 5000)
@ -100,6 +90,7 @@ export default {
apiClient.retrieveImportLog(this.import_id).then(result => {
this.import_info = result.data
})
}
}

View File

@ -1,9 +1,9 @@
<template>
<div class="row">
<div class="col" style="text-align: center">
<img class="spinner-tandoor" alt="loading spinner" src="" style="height: 30vh"/>
</div>
<div class="row">
<div class="col" style="text-align: center">
<img class="spinner-tandoor" alt="loading spinner" src="" v-bind:style="{ height: size + 'vh' }"/>
</div>
</div>
</template>
<script>
@ -12,6 +12,10 @@ export default {
name: 'LoadingSpinner',
props: {
recipe: Object,
size: {
type: Number,
default: 30
},
},
}
</script>

View File

@ -193,6 +193,18 @@ export interface ImportLog {
* @memberof ImportLog
*/
keyword?: ImportLogKeyword;
/**
*
* @type {number}
* @memberof ImportLog
*/
total_recipes?: number;
/**
*
* @type {number}
* @memberof ImportLog
*/
imported_recipes?: number;
/**
*
* @type {string}
@ -1031,6 +1043,12 @@ export interface RecipeSteps {
* @memberof RecipeSteps
*/
show_as_header?: boolean;
/**
*
* @type {StepFile}
* @memberof RecipeSteps
*/
file?: StepFile | null;
}
/**
@ -1039,7 +1057,8 @@ export interface RecipeSteps {
*/
export enum RecipeStepsTypeEnum {
Text = 'TEXT',
Time = 'TIME'
Time = 'TIME',
File = 'FILE'
}
/**
@ -1429,6 +1448,12 @@ export interface Step {
* @memberof Step
*/
show_as_header?: boolean;
/**
*
* @type {StepFile}
* @memberof Step
*/
file?: StepFile | null;
}
/**
@ -1437,9 +1462,35 @@ export interface Step {
*/
export enum StepTypeEnum {
Text = 'TEXT',
Time = 'TIME'
Time = 'TIME',
File = 'FILE'
}
/**
*
* @export
* @interface StepFile
*/
export interface StepFile {
/**
*
* @type {string}
* @memberof StepFile
*/
name: string;
/**
*
* @type {any}
* @memberof StepFile
*/
file?: any;
/**
*
* @type {number}
* @memberof StepFile
*/
id?: number;
}
/**
*
* @export

View File

@ -1 +1 @@
{"status":"done","chunks":{"recipe_search_view":["js/chunk-vendors.js","js/recipe_search_view.js","recipe_search_view.8ddb3d95083697d49aed.hot-update.js"],"recipe_view":["js/chunk-vendors.js","js/recipe_view.js","recipe_view.8ddb3d95083697d49aed.hot-update.js"],"offline_view":["js/chunk-vendors.js","js/offline_view.js"],"import_response_view":["js/chunk-vendors.js","js/import_response_view.js"],"supermarket_view":["js/chunk-vendors.js","js/supermarket_view.js"],"user_file_view":["js/chunk-vendors.js","js/user_file_view.js"]},"publicPath":"http://localhost:8080/","assets":{"js/chunk-vendors.js":{"name":"js/chunk-vendors.js","path":"js\\chunk-vendors.js","publicPath":"http://localhost:8080/js/chunk-vendors.js"},"js/import_response_view.js":{"name":"js/import_response_view.js","path":"js\\import_response_view.js","publicPath":"http://localhost:8080/js/import_response_view.js"},"js/offline_view.js":{"name":"js/offline_view.js","path":"js\\offline_view.js","publicPath":"http://localhost:8080/js/offline_view.js"},"js/recipe_search_view.js":{"name":"js/recipe_search_view.js","path":"js\\recipe_search_view.js","publicPath":"http://localhost:8080/js/recipe_search_view.js"},"js/recipe_view.js":{"name":"js/recipe_view.js","path":"js\\recipe_view.js","publicPath":"http://localhost:8080/js/recipe_view.js"},"js/supermarket_view.js":{"name":"js/supermarket_view.js","path":"js\\supermarket_view.js","publicPath":"http://localhost:8080/js/supermarket_view.js"},"js/user_file_view.js":{"name":"js/user_file_view.js","path":"js\\user_file_view.js","publicPath":"http://localhost:8080/js/user_file_view.js"},"recipe_search_view.8ddb3d95083697d49aed.hot-update.js":{"name":"recipe_search_view.8ddb3d95083697d49aed.hot-update.js","path":"recipe_search_view.8ddb3d95083697d49aed.hot-update.js","publicPath":"http://localhost:8080/recipe_search_view.8ddb3d95083697d49aed.hot-update.js"},"recipe_view.8ddb3d95083697d49aed.hot-update.js":{"name":"recipe_view.8ddb3d95083697d49aed.hot-update.js","path":"recipe_view.8ddb3d95083697d49aed.hot-update.js","publicPath":"http://localhost:8080/recipe_view.8ddb3d95083697d49aed.hot-update.js"},"8ddb3d95083697d49aed.hot-update.json":{"name":"8ddb3d95083697d49aed.hot-update.json","path":"8ddb3d95083697d49aed.hot-update.json","publicPath":"http://localhost:8080/8ddb3d95083697d49aed.hot-update.json"},"recipe_search_view.html":{"name":"recipe_search_view.html","path":"recipe_search_view.html","publicPath":"http://localhost:8080/recipe_search_view.html"},"recipe_view.html":{"name":"recipe_view.html","path":"recipe_view.html","publicPath":"http://localhost:8080/recipe_view.html"},"offline_view.html":{"name":"offline_view.html","path":"offline_view.html","publicPath":"http://localhost:8080/offline_view.html"},"import_response_view.html":{"name":"import_response_view.html","path":"import_response_view.html","publicPath":"http://localhost:8080/import_response_view.html"},"supermarket_view.html":{"name":"supermarket_view.html","path":"supermarket_view.html","publicPath":"http://localhost:8080/supermarket_view.html"},"user_file_view.html":{"name":"user_file_view.html","path":"user_file_view.html","publicPath":"http://localhost:8080/user_file_view.html"},"manifest.json":{"name":"manifest.json","path":"manifest.json","publicPath":"http://localhost:8080/manifest.json"}}}
{"status":"done","chunks":{"recipe_search_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_search_view.js"],"recipe_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_view.js"],"offline_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/offline_view.js"],"import_response_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/import_response_view.js"],"supermarket_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/supermarket_view.js"],"user_file_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/user_file_view.js"]},"assets":{"../../templates/sw.js":{"name":"../../templates/sw.js","path":"..\\..\\templates\\sw.js"},"css/chunk-vendors.css":{"name":"css/chunk-vendors.css","path":"css\\chunk-vendors.css"},"js/chunk-vendors.js":{"name":"js/chunk-vendors.js","path":"js\\chunk-vendors.js"},"js/import_response_view.js":{"name":"js/import_response_view.js","path":"js\\import_response_view.js"},"js/offline_view.js":{"name":"js/offline_view.js","path":"js\\offline_view.js"},"js/recipe_search_view.js":{"name":"js/recipe_search_view.js","path":"js\\recipe_search_view.js"},"js/recipe_view.js":{"name":"js/recipe_view.js","path":"js\\recipe_view.js"},"js/supermarket_view.js":{"name":"js/supermarket_view.js","path":"js\\supermarket_view.js"},"js/user_file_view.js":{"name":"js/user_file_view.js","path":"js\\user_file_view.js"},"recipe_search_view.html":{"name":"recipe_search_view.html","path":"recipe_search_view.html"},"recipe_view.html":{"name":"recipe_view.html","path":"recipe_view.html"},"offline_view.html":{"name":"offline_view.html","path":"offline_view.html"},"import_response_view.html":{"name":"import_response_view.html","path":"import_response_view.html"},"supermarket_view.html":{"name":"supermarket_view.html","path":"supermarket_view.html"},"user_file_view.html":{"name":"user_file_view.html","path":"user_file_view.html"},"manifest.json":{"name":"manifest.json","path":"manifest.json"}}}