added basic support for files

This commit is contained in:
vabene1111
2021-06-08 20:17:48 +02:00
parent c71a7dad24
commit 9eb17df575
17 changed files with 383 additions and 105 deletions

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.4 on 2021-06-08 17:29
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cookbook', '0130_alter_userfile_file_size_kb'),
]
operations = [
migrations.AddField(
model_name='step',
name='file',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='cookbook.userfile'),
),
migrations.AlterField(
model_name='step',
name='type',
field=models.CharField(choices=[('TEXT', 'Text'), ('TIME', 'Time'), ('FILE', 'File')], default='TEXT', max_length=16),
),
]

View File

@ -7,6 +7,7 @@ from datetime import date, timedelta
from annoying.fields import AutoOneToOneField
from django.contrib import auth
from django.contrib.auth.models import Group, User
from django.core.files.uploadedfile import UploadedFile, InMemoryUploadedFile
from django.core.validators import MinLengthValidator
from django.db import models
from django.utils import timezone
@ -332,10 +333,11 @@ class Ingredient(ExportModelOperationsMixin('ingredient'), models.Model, Permiss
class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixin):
TEXT = 'TEXT'
TIME = 'TIME'
FILE = 'FILE'
name = models.CharField(max_length=128, default='', blank=True)
type = models.CharField(
choices=((TEXT, _('Text')), (TIME, _('Time')),),
choices=((TEXT, _('Text')), (TIME, _('Time')), (FILE, _('File')),),
default=TEXT,
max_length=16
)
@ -343,6 +345,7 @@ class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixi
ingredients = models.ManyToManyField(Ingredient, blank=True)
time = models.IntegerField(default=0, blank=True)
order = models.IntegerField(default=0)
file = models.ForeignKey('UserFile', on_delete=models.PROTECT, null=True, blank=True)
show_as_header = models.BooleanField(default=True)
objects = ScopedManager(space='recipe__space')
@ -708,6 +711,7 @@ class UserFile(ExportModelOperationsMixin('user_files'), models.Model, Permissio
space = models.ForeignKey(Space, on_delete=models.CASCADE)
def save(self, *args, **kwargs):
self.file.name = f'{uuid.uuid4()}' + pathlib.Path(self.file.name).suffix
self.file_size_kb = round(self.file.size / 1000)
if hasattr(self.file, 'file') and isinstance(self.file.file, UploadedFile) or isinstance(self.file.file, InMemoryUploadedFile):
self.file.name = f'{uuid.uuid4()}' + pathlib.Path(self.file.name).suffix
self.file_size_kb = round(self.file.size / 1000)
super(UserFile, self).save(*args, **kwargs)

View File

@ -103,6 +103,20 @@ class UserPreferenceSerializer(serializers.ModelSerializer):
)
class UserFileSerializer(serializers.ModelSerializer):
def create(self, validated_data):
validated_data['created_by'] = self.context['request'].user
validated_data['space'] = self.context['request'].space
return super().create(validated_data)
class Meta:
model = UserFile
fields = ('name', 'file', 'file_size_kb', 'id',)
read_only_fields = ('id', 'file_size_kb')
extra_kwargs = {"file": {"required": False, }}
class StorageSerializer(SpacedModelSerializer):
def create(self, validated_data):
@ -251,6 +265,7 @@ class StepSerializer(WritableNestedModelSerializer):
ingredients = IngredientSerializer(many=True)
ingredients_markdown = serializers.SerializerMethodField('get_ingredients_markdown')
ingredients_vue = serializers.SerializerMethodField('get_ingredients_vue')
file = UserFileSerializer(allow_null=True)
def get_ingredients_vue(self, obj):
return obj.get_instruction_render()
@ -262,7 +277,7 @@ class StepSerializer(WritableNestedModelSerializer):
model = Step
fields = (
'id', 'name', 'type', 'instruction', 'ingredients', 'ingredients_markdown',
'ingredients_vue', 'time', 'order', 'show_as_header'
'ingredients_vue', 'time', 'order', 'show_as_header', 'file',
)
@ -494,18 +509,6 @@ class BookmarkletImportSerializer(serializers.ModelSerializer):
read_only_fields = ('created_by', 'space')
class UserFileSerializer(serializers.ModelSerializer):
def create(self, validated_data):
validated_data['created_by'] = self.context['request'].user
validated_data['space'] = self.context['request'].space
return super().create(validated_data)
class Meta:
model = UserFile
fields = ('id', 'name', 'file_size_kb', 'file')
# Export/Import Serializers
class KeywordExportSerializer(KeywordSerializer):

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

@ -201,17 +201,40 @@
<select class="form-control" id="id_type" v-model="step.type">
<option value="TEXT">{% trans 'Text' %}</option>
<option value="TIME">{% trans 'Time' %}</option>
<option value="FILE">{% trans 'File' %}</option>
</select>
</div>
</div>
<div class="row" style="margin-top: 12px">
<div class="col-md-12">
<div class="col-md-3">
<label :for="'id_step_' + step.id + '_time'">{% trans 'Step time in Minutes' %}</label>
<input class="form-control" v-model="step.time"
:id="'id_step_' + step.id + '_time'">
</div>
<div class="col-md-9">
<label :for="'id_step_' + step.id + '_file'">{% trans 'File' %}</label>
<multiselect
v-tabindex
ref="file"
v-model="step.file"
:options="files"
:close-on-select="true"
:clear-on-select="true"
:allow-empty="true"
:preserve-search="true"
placeholder="{% trans 'Select File' %}"
select-label="{% trans 'Select' %}"
:id="'id_step_' + step.id + '_file'"
label="name"
track-by="name"
:multiple="false"
:loading="files_loading"
@search-change="searchFiles">
</multiselect>
</div>
</div>
<template v-if="step.type == 'TEXT'">
@ -498,6 +521,8 @@
foods_loading: false,
units: [],
units_loading: false,
files: [],
files_loading: false,
message: '',
},
directives: {
@ -523,6 +548,7 @@
this.searchUnits('')
this.searchFoods('')
this.searchKeywords('')
this.searchFiles('')
this._keyListener = function (e) {
if (e.code === "Space" && e.ctrlKey) {
@ -572,6 +598,9 @@
this.sortSteps()
for (let s of this.recipe.steps) {
this.sortIngredients(s)
if (s.file !== null){
delete s.file.file //TODO stupid quick hack because I cant figure out how to fix the writable serializer right now
}
}
this.$http.put("{% url 'api:recipe-detail' recipe.pk %}", this.recipe,
{}).then((response) => {
@ -606,8 +635,6 @@
}
reader.readAsDataURL(event.target.files[0]);
}
},
addStep: function () { //TODO see if default can be generated from options request
this.recipe.steps.push(
@ -685,6 +712,16 @@
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
searchFiles: function (query) {
this.files_loading = true
this.$http.get("{% url 'api:userfile-list' %}" + '?query=' + query + '&limit=10').then((response) => {
this.files = response.data
this.files_loading = false
}).catch((err) => {
console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
searchUnits: function (query) {
this.units_loading = true
this.$http.get("{% url 'api:unit-list' %}" + '?query=' + query + '&limit=10').then((response) => {

View File

@ -495,13 +495,15 @@ class BookmarkletImportViewSet(viewsets.ModelViewSet):
return self.queryset.filter(space=self.request.space).all()
class UserFileViewSet(viewsets.ModelViewSet):
class UserFileViewSet(viewsets.ModelViewSet, StandardFilterMixin):
queryset = UserFile.objects
serializer_class = UserFileSerializer
permission_classes = [CustomIsUser]
parser_classes = [MultiPartParser]
def get_queryset(self):
return self.queryset.filter(space=self.request.space).all()
self.queryset = self.queryset.filter(space=self.request.space).all()
return super().get_queryset()
# -------------- non django rest api views --------------------

View File

@ -238,7 +238,10 @@ def supermarket(request):
@group_required('user')
def files(request):
current_file_size_mb = UserFile.objects.filter(space=request.space).aggregate(Sum('file_size_kb'))['file_size_kb__sum'] / 1000
try:
current_file_size_mb = UserFile.objects.filter(space=request.space).aggregate(Sum('file_size_kb'))['file_size_kb__sum'] / 1000
except TypeError:
current_file_size_mb = 0
return render(request, 'files.html', {'current_file_size_mb': current_file_size_mb, 'max_file_size_mb': request.space.max_file_storage_mb})
@ -261,9 +264,7 @@ def meal_plan_entry(request, pk):
@group_required('user')
def latest_shopping_list(request):
sl = ShoppingList.objects.filter(Q(created_by=request.user) | Q(shared=request.user)).filter(finished=False,
space=request.space).order_by(
'-created_at').first()
sl = ShoppingList.objects.filter(Q(created_by=request.user) | Q(shared=request.user)).filter(finished=False, pace=request.space).order_by('-created_at').first()
if sl:
return HttpResponseRedirect(reverse('view_shopping', kwargs={'pk': sl.pk}) + '?edit=true')

View File

@ -5,7 +5,7 @@
<div class="row">
<div class="col col-md-12">
<h3>{{ $t('Files') }} <a class="btn btn-success float-right"><i class="fas fa-plus-circle"></i> {{ $t('New') }}</a>
<h3>{{ $t('Files') }} <span class="float-right"><file-editor @change="loadInitial()" ></file-editor></span>
</h3>
</div>
@ -14,8 +14,8 @@
<div class="row" style="margin-top: 2vh">
<div class="col col-md-12">
<b-progress :max="max_file_size_mb">
<b-progress-bar :value="current_file_size_mb">
<span><strong>{{ current_file_size_mb.toFixed(2) }} / {{ max_file_size_mb }} MB</strong></span>
<b-progress-bar :value="current_file_size_mb" >
<span><strong class="text-dark ">{{ current_file_size_mb.toFixed(2) }} / {{ max_file_size_mb }} MB</strong></span>
</b-progress-bar>
</b-progress>
</div>
@ -29,11 +29,16 @@
<tr>
<th>{{ $t('Name') }}</th>
<th>{{ $t('Size') }} (MB)</th>
<th>{{ $t('Edit') }}</th>
</tr>
</thead>
<tr v-for="f in files" v-bind:key="f.id">
<td>{{ f.name }}</td>
<td>{{ f.file_size_kb / 1000 }}</td>
<td><a :href="f.file" target="_blank" rel="noreferrer nofollow">{{$t('Download')}}</a></td>
<td>
<file-editor @change="loadInitial()" :file_id="f.id"></file-editor>
</td>
</tr>
</table>
</div>
@ -58,6 +63,7 @@ Vue.use(BootstrapVue)
// import draggable from 'vuedraggable'
import axios from 'axios'
import FileEditor from "@/components/FileEditor";
// import Multiselect from "vue-multiselect";
axios.defaults.xsrfHeaderName = 'X-CSRFToken'
@ -70,8 +76,7 @@ export default {
ToastMixin,
],
components: {
// Multiselect,
// draggable
FileEditor
},
data() {
return {
@ -91,19 +96,6 @@ export default {
apiClient.listUserFiles().then(results => {
this.files = results.data
})
},
supermarketModalOk: function () {
let apiClient = new ApiApiFactory()
if (this.selected_supermarket.new) {
apiClient.createSupermarket({name: this.selected_supermarket.name}).then(results => {
this.selected_supermarket = undefined
this.loadInitial()
})
} else {
apiClient.partialUpdateSupermarket(this.selected_supermarket.id, {name: this.selected_supermarket.name})
}
},
}
}

View File

@ -0,0 +1,93 @@
<template>
<div>
<b-button v-b-modal="'modal-file-editor'+file_id" v-bind:class="{'btn-success': (file_id === undefined)}">
<template v-if="this.file_id">{{ $t('Edit') }}</template>
<template v-else>{{ $t('New') }}</template>
</b-button>
<b-modal :id="'modal-file-editor'+file_id" v-bind:title="$t('File')" @ok="modalOk()">
<template v-if="file!==undefined">
{{ $t('Name') }}
<b-input v-model="file.name"></b-input>
{{ $t('File') }}
<b-form-file v-model="file.file"></b-form-file>
</template>
</b-modal>
</div>
</template>
<script>
import {ApiApiFactory} from "@/utils/openapi/api";
import {makeToast} from "@/utils/utils";
export default {
name: "FileEditor",
data() {
return {
file: undefined
}
},
props: {
file_id: Number,
},
mounted() {
if (this.file_id !== undefined) {
this.loadFile(this.file_id.toString())
} else {
this.file = {
name: '',
file: undefined
}
}
},
methods: {
loadFile: function (id) {
let apiClient = new ApiApiFactory()
apiClient.retrieveUserFile(id).then(result => {
this.file = result.data
})
},
modalOk: function () {
if (this.file_id === undefined) {
console.log('CREATING')
this.createFile()
} else {
console.log('UPDATING')
this.updateFile()
}
},
updateFile: function () {
let apiClient = new ApiApiFactory()
let passedFile = undefined
if (!(typeof this.file.file === 'string' || this.file.file instanceof String)) { // only update file if it was changed
passedFile = this.file.file
}
console.log(passedFile)
apiClient.updateUserFile(this.file.id, this.file.name, passedFile).then(request => {
makeToast(this.$t('Success'), this.$t('success_updating_resource'), 'success')
this.$emit('change',)
}).catch(err => {
makeToast(this.$t('Error'), this.$t('err_updating_resource'), 'danger')
console.log(err.request, err.response)
})
},
createFile: function () {
let apiClient = new ApiApiFactory()
apiClient.createUserFile(this.file.name, this.file.file).then(request => {
makeToast(this.$t('Success'), this.$t('success_creating_resource'), 'success')
this.$emit('change',)
}).catch(err => {
makeToast(this.$t('Error'), this.$t('err_creating_resource'), 'danger')
console.log(err.request, err.response)
})
}
}
}
</script>

View File

@ -34,19 +34,21 @@
<table class="table table-sm">
<!-- eslint-disable vue/no-v-for-template-key-on-child -->
<template v-for="i in step.ingredients">
<Ingredient v-bind:ingredient="i" :ingredient_factor="ingredient_factor" :key="i.id" @checked-state-changed="$emit('checked-state-changed', i)"></Ingredient>
<Ingredient v-bind:ingredient="i" :ingredient_factor="ingredient_factor" :key="i.id"
@checked-state-changed="$emit('checked-state-changed', i)"></Ingredient>
</template>
<!-- eslint-enable vue/no-v-for-template-key-on-child -->
</table>
</div>
<div class="col" :class="{ 'col-md-8': recipe.steps.length > 1, 'col-md-12': recipe.steps.length <= 1,}">
<compile-component :code="step.ingredients_markdown" :ingredient_factor="ingredient_factor"></compile-component>
<compile-component :code="step.ingredients_markdown"
:ingredient_factor="ingredient_factor"></compile-component>
</div>
</div>
</b-collapse>
</template>
<template v-if="step.type === 'TIME'">
<template v-if="step.type === 'TIME' || step.type === 'FILE'">
<div class="row">
<div class="col-md-8 offset-md-2" style="text-align: center">
<h4 class="text-primary">
@ -55,7 +57,8 @@
</h4>
<span style="margin-left: 4px" class="text-muted" v-if="step.time !== 0"><i class="fa fa-stopwatch"></i>
{{ step.time }} {{ $t('min') }}</span>
<b-link class="d-print-none" :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#" v-if="start_time !== ''">
<b-link class="d-print-none" :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#"
v-if="start_time !== ''">
{{ moment(start_time).add(step.time_offset, 'minutes').format('HH:mm') }}
</b-link>
</div>
@ -71,12 +74,28 @@
<b-collapse id="collapse-1" v-model="details_visible">
<div class="row" v-if="step.instruction !== ''">
<div class="col col-md-12" style="text-align: center">
<compile-component :code="step.ingredients_markdown" :ingredient_factor="ingredient_factor"></compile-component>
<compile-component :code="step.ingredients_markdown"
:ingredient_factor="ingredient_factor"></compile-component>
</div>
</div>
</b-collapse>
</template>
<div class="row" style="text-align: center">
<div class="col col-md-12">
<template v-if="step.file !== null">
<div
v-if="step.file.file.includes('.png') || recipe.file_path.includes('.jpg') || recipe.file_path.includes('.jpeg') || recipe.file_path.includes('.gif')">
<img :src="step.file.file" style="max-width: 50vw; max-height: 50vh">
</div>
<div v-else>
<a :href="step.file.file" target="_blank" rel="noreferrer nofollow">{{ $t('Download') }} {{ $t('File') }}</a>
</div>
</template>
</div>
</div>
<div v-if="start_time !== ''">
<b-popover
:target="`id_reactive_popover_${step.id}`"

View File

@ -1,4 +1,11 @@
{
"err_fetching_resource": "There was an error fetching a resource!",
"err_creating_resource": "There was an error creating a resource!",
"err_updating_resource": "There was an error updating a resource!",
"success_fetching_resource": "Successfully fetched a resource!",
"success_creating_resource": "Successfully created a resource!",
"success_updating_resource": "Successfully updated a resource!",
"import_running": "Import running, please wait!",
"all_fields_optional": "All fields are optional and can be left empty.",
"convert_internal": "Convert to internal recipe",
@ -38,6 +45,7 @@
"Close": "Close",
"Add": "Add",
"New": "New",
"Success": "Success",
"Ingredients": "Ingredients",
"Supermarket": "Supermarket",
"Categories": "Categories",
@ -50,6 +58,7 @@
"External": "External",
"Size": "Size",
"Files": "Files",
"File": "File",
"Edit": "Edit",
"Open": "Open",
"Save": "Save",
@ -60,5 +69,6 @@
"Settings": "Settings",
"or": "or",
"and": "and",
"Information": "Information"
"Information": "Information",
"Download": "Download"
}

View File

@ -1778,18 +1778,18 @@ export interface Unit {
* @interface UserFile
*/
export interface UserFile {
/**
*
* @type {number}
* @memberof UserFile
*/
id?: number;
/**
*
* @type {string}
* @memberof UserFile
*/
name: string;
/**
*
* @type {any}
* @memberof UserFile
*/
file?: any;
/**
*
* @type {number}
@ -1798,10 +1798,10 @@ export interface UserFile {
file_size_kb?: number;
/**
*
* @type {any}
* @type {number}
* @memberof UserFile
*/
file: any;
id?: number;
}
/**
*
@ -2634,11 +2634,16 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
},
/**
*
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUserFile: async (userFile?: UserFile, options: any = {}): Promise<RequestArgs> => {
createUserFile: async (name: string, file?: any, fileSizeKb?: number, id?: number, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('createUserFile', 'name', name)
const localVarPath = `/api/user-file/`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@ -2650,15 +2655,32 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
if (name !== undefined) {
localVarFormParams.append('name', name as any);
}
if (file !== undefined) {
localVarFormParams.append('file', file as any);
}
if (fileSizeKb !== undefined) {
localVarFormParams.append('file_size_kb', fileSizeKb as any);
}
if (id !== undefined) {
localVarFormParams.append('id', id as any);
}
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(userFile, localVarRequestOptions, configuration)
localVarRequestOptions.data = localVarFormParams;
return {
url: toPathString(localVarUrlObj),
@ -5055,13 +5077,18 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
partialUpdateUserFile: async (id: string, userFile?: UserFile, options: any = {}): Promise<RequestArgs> => {
partialUpdateUserFile: async (id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('partialUpdateUserFile', 'id', id)
// verify required parameter 'name' is not null or undefined
assertParamExists('partialUpdateUserFile', 'name', name)
const localVarPath = `/api/user-file/{id}/`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
@ -5074,15 +5101,32 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
if (name !== undefined) {
localVarFormParams.append('name', name as any);
}
if (file !== undefined) {
localVarFormParams.append('file', file as any);
}
if (fileSizeKb !== undefined) {
localVarFormParams.append('file_size_kb', fileSizeKb as any);
}
if (id2 !== undefined) {
localVarFormParams.append('id', id2 as any);
}
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(userFile, localVarRequestOptions, configuration)
localVarRequestOptions.data = localVarFormParams;
return {
url: toPathString(localVarUrlObj),
@ -6731,13 +6775,18 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateUserFile: async (id: string, userFile?: UserFile, options: any = {}): Promise<RequestArgs> => {
updateUserFile: async (id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('updateUserFile', 'id', id)
// verify required parameter 'name' is not null or undefined
assertParamExists('updateUserFile', 'name', name)
const localVarPath = `/api/user-file/{id}/`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
@ -6750,15 +6799,32 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
if (name !== undefined) {
localVarFormParams.append('name', name as any);
}
if (file !== undefined) {
localVarFormParams.append('file', file as any);
}
if (fileSizeKb !== undefined) {
localVarFormParams.append('file_size_kb', fileSizeKb as any);
}
if (id2 !== undefined) {
localVarFormParams.append('id', id2 as any);
}
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(userFile, localVarRequestOptions, configuration)
localVarRequestOptions.data = localVarFormParams;
return {
url: toPathString(localVarUrlObj),
@ -7051,12 +7117,15 @@ export const ApiApiFp = function(configuration?: Configuration) {
},
/**
*
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async createUserFile(userFile?: UserFile, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createUserFile(userFile, options);
async createUserFile(name: string, file?: any, fileSizeKb?: number, id?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createUserFile(name, file, fileSizeKb, id, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
@ -7779,12 +7848,15 @@ export const ApiApiFp = function(configuration?: Configuration) {
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async partialUpdateUserFile(id: string, userFile?: UserFile, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateUserFile(id, userFile, options);
async partialUpdateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateUserFile(id, name, file, fileSizeKb, id2, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
@ -8282,12 +8354,15 @@ export const ApiApiFp = function(configuration?: Configuration) {
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateUserFile(id: string, userFile?: UserFile, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateUserFile(id, userFile, options);
async updateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateUserFile(id, name, file, fileSizeKb, id2, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
@ -8504,12 +8579,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?:
},
/**
*
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUserFile(userFile?: UserFile, options?: any): AxiosPromise<UserFile> {
return localVarFp.createUserFile(userFile, options).then((request) => request(axios, basePath));
createUserFile(name: string, file?: any, fileSizeKb?: number, id?: number, options?: any): AxiosPromise<UserFile> {
return localVarFp.createUserFile(name, file, fileSizeKb, id, options).then((request) => request(axios, basePath));
},
/**
*
@ -9160,12 +9238,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?:
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
partialUpdateUserFile(id: string, userFile?: UserFile, options?: any): AxiosPromise<UserFile> {
return localVarFp.partialUpdateUserFile(id, userFile, options).then((request) => request(axios, basePath));
partialUpdateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): AxiosPromise<UserFile> {
return localVarFp.partialUpdateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(axios, basePath));
},
/**
*
@ -9615,12 +9696,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?:
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateUserFile(id: string, userFile?: UserFile, options?: any): AxiosPromise<UserFile> {
return localVarFp.updateUserFile(id, userFile, options).then((request) => request(axios, basePath));
updateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): AxiosPromise<UserFile> {
return localVarFp.updateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(axios, basePath));
},
/**
*
@ -9874,13 +9958,16 @@ export class ApiApi extends BaseAPI {
/**
*
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApiApi
*/
public createUserFile(userFile?: UserFile, options?: any) {
return ApiApiFp(this.configuration).createUserFile(userFile, options).then((request) => request(this.axios, this.basePath));
public createUserFile(name: string, file?: any, fileSizeKb?: number, id?: number, options?: any) {
return ApiApiFp(this.configuration).createUserFile(name, file, fileSizeKb, id, options).then((request) => request(this.axios, this.basePath));
}
/**
@ -10674,13 +10761,16 @@ export class ApiApi extends BaseAPI {
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApiApi
*/
public partialUpdateUserFile(id: string, userFile?: UserFile, options?: any) {
return ApiApiFp(this.configuration).partialUpdateUserFile(id, userFile, options).then((request) => request(this.axios, this.basePath));
public partialUpdateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any) {
return ApiApiFp(this.configuration).partialUpdateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(this.axios, this.basePath));
}
/**
@ -11225,13 +11315,16 @@ export class ApiApi extends BaseAPI {
/**
*
* @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile]
* @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApiApi
*/
public updateUserFile(id: string, userFile?: UserFile, options?: any) {
return ApiApiFp(this.configuration).updateUserFile(id, userFile, options).then((request) => request(this.axios, this.basePath));
public updateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any) {
return ApiApiFp(this.configuration).updateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(this.axios, this.basePath));
}
/**