Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
frontend-uploads
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
4ae84755
authored
2016-09-02 14:49:51 -0500
by
Ean Schuessler
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add owner content creation
Refs: #7591
1 parent
06f78870
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
2 deletions
src/scripts/Upload.js
src/scripts/Upload.js
View file @
4ae8475
...
...
@@ -4,6 +4,8 @@ define(function(require) {
var
$
=
require
(
'jquery'
);
var
Backbone
=
require
(
'backbone'
);
var
Flow
=
require
(
'flow'
);
var
api
=
require
(
'api'
);
var
OwnerContent
=
require
(
'models/OwnerContent'
);
var
Status
=
Backbone
.
Model
.
extend
({
defaults
:
function
()
{
...
...
@@ -72,6 +74,45 @@ define(function(require) {
Uploads
:
Uploads
,
Status
:
Status
,
flowEventHandlers
:
{
uploadStart
:
function
()
{
var
self
=
this
;
// Pre-allocate the contentIds for each file's upload
if
(
!
this
.
model
.
get
(
'prechecked'
))
{
this
.
flow
.
pause
();
var
ownerContentDeferreds
=
[];
self
.
model
.
get
(
'collection'
).
each
(
function
(
file
)
{
if
(
file
.
flowFile
!=
undefined
)
{
var
flowFile
=
file
.
flowFile
;
var
flowTotalChunks
=
Math
.
floor
(
file
.
get
(
'size'
)
/
flowFile
.
flowObj
.
opts
.
chunkSize
);
if
(
flowTotalChunks
==
0
)
{
flowTotalChunks
=
1
;
}
var
ownerContent
=
new
OwnerContent
({
flowChunkNumber
:
0
,
flowChunkSize
:
flowFile
.
flowObj
.
opts
.
chunkSize
,
flowCurrentChunkSize
:
(
file
.
get
(
'size'
)
<
flowFile
.
flowObj
.
opts
.
chunkSize
)
?
file
.
get
(
'size'
)
:
flowFile
.
flowObj
.
opts
.
chunkSize
,
flowTotalSize
:
file
.
get
(
'size'
),
flowIdentifier
:
flowFile
.
uniqueIdentifier
,
flowFilename
:
flowFile
.
name
,
flowRelativePath
:
flowFile
.
relativePath
,
flowTotalChunks
:
flowTotalChunks
});
flowFile
.
flowObj
.
ownerContent
=
ownerContent
;
var
deferred
=
ownerContent
.
save
();
ownerContentDeferreds
.
push
(
deferred
);
}
});
$
.
when
(
ownerContentDeferreds
).
done
(
function
(
ownerContent
)
{
self
.
model
.
set
(
'prechecked'
,
true
);
self
.
flow
.
resume
();
setTimeout
(
function
()
{
self
.
model
.
set
(
'prechecked'
,
false
);
},
500
);
});
}
},
fileAdded
:
function
(
flowFile
)
{
var
model
=
flowFile
.
_model
;
if
(
!
model
)
{
...
...
@@ -109,6 +150,12 @@ define(function(require) {
result
:
'success'
,
resultData
:
message
,
});
console
.
log
(
'UPLOAD COMPLETE'
,
flowFile
.
flowObj
.
ownerContent
);
flowFile
.
flowObj
.
ownerContent
.
set
(
'statusId'
,
'CTNT_AVAILABLE'
);
flowFile
.
flowObj
.
ownerContent
.
save
(
function
()
{
console
.
log
(
'MARKED'
,
flowFile
.
flowObj
.
ownerContent
,
' AVAILABLE'
);
});
}
},
fileError
:
function
(
flowFile
,
message
,
chunk
)
{
...
...
@@ -178,8 +225,8 @@ define(function(require) {
'fileRemoved'
,
'fileRetry'
,
'fileError'
,
//
'uploadStart',
//
'complete',
'uploadStart'
,
'complete'
,
//'progress',
//'error',
],
function
(
eventName
)
{
...
...
Please
register
or
sign in
to post a comment