aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/misc
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-16 16:35:32 +0100
committerChocobozzz <me@florianbigard.com>2018-02-16 16:35:32 +0100
commit6de36768980ef6063b8fcd730b59fa685dd2b99c (patch)
treea8e5a87b14013b33bf2d306552a380c407a1551d /client/src/app/shared/misc
parentb6a4fd6b099b3363ac59c06cfd81b54e1356d8bc (diff)
downloadPeerTube-6de36768980ef6063b8fcd730b59fa685dd2b99c.tar.gz
PeerTube-6de36768980ef6063b8fcd730b59fa685dd2b99c.tar.zst
PeerTube-6de36768980ef6063b8fcd730b59fa685dd2b99c.zip
Add ability to update thumbnail and preview on client
Diffstat (limited to 'client/src/app/shared/misc')
-rw-r--r--client/src/app/shared/misc/utils.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index e6a697098..e2e4c5b36 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -67,6 +67,27 @@ function isInMobileView () {
67 return window.innerWidth < 500 67 return window.innerWidth < 500
68} 68}
69 69
70// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
71function objectToFormData (obj: any, form?: FormData, namespace?: string) {
72 let fd = form || new FormData()
73 let formKey
74
75 for (let key of Object.keys(obj)) {
76 if (namespace) formKey = `${namespace}[${key}]`
77 else formKey = key
78
79 if (obj[key] === undefined) continue
80
81 if (typeof obj[ key ] === 'object' && !(obj[ key ] instanceof File)) {
82 objectToFormData(obj[ key ], fd, key)
83 } else {
84 fd.append(formKey, obj[ key ])
85 }
86 }
87
88 return fd
89}
90
70export { 91export {
71 viewportHeight, 92 viewportHeight,
72 getParameterByName, 93 getParameterByName,
@@ -75,5 +96,6 @@ export {
75 dateToHuman, 96 dateToHuman,
76 isInSmallView, 97 isInSmallView,
77 isInMobileView, 98 isInMobileView,
78 immutableAssign 99 immutableAssign,
100 objectToFormData
79} 101}