Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PortalMEC-React
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PortalMEC
PortalMEC-React
Commits
5053856f
Commit
5053856f
authored
4 years ago
by
Lucas Eduardo Schoenfelder
Browse files
Options
Downloads
Patches
Plain Diff
almost done
parent
64cf0e5d
No related branches found
No related tags found
3 merge requests
!57
Merge of develop into master
,
!56
Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...
,
!24
Tela recurso
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Components/UploadPageComponents/DragAndDrop.tsx
+1
-1
1 addition, 1 deletion
src/Components/UploadPageComponents/DragAndDrop.tsx
src/Components/UploadPageComponents/FileToUpload.ts
+11
-7
11 additions, 7 deletions
src/Components/UploadPageComponents/FileToUpload.ts
with
12 additions
and
8 deletions
src/Components/UploadPageComponents/DragAndDrop.tsx
+
1
−
1
View file @
5053856f
...
...
@@ -16,7 +16,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import
React
,
{
useState
}
from
'
react
'
import
React
,
{
useState
,
useEffect
}
from
'
react
'
import
CloudUploadIcon
from
'
@material-ui/icons/CloudUpload
'
;
import
{
DottedBox
,
BlueButton
}
from
'
./StyledComponents.js
'
;
import
FileToUpload
from
'
./FileToUpload
'
...
...
This diff is collapsed.
Click to expand it.
src/Components/UploadPageComponents/FileToUpload.ts
+
11
−
7
View file @
5053856f
...
...
@@ -9,9 +9,18 @@ export default class FileToUpload {
private
_chunkNumber
:
number
;
currentChunkStartByte
:
number
;
currentChunkFinalByte
:
number
;
uploadFinished
:
boolean
=
false
;
constructor
(
file
:
File
,
name
:
string
,
draftID
:
string
)
{
this
.
request
=
new
XMLHttpRequest
();
this
.
request
.
onreadystatechange
=
function
(
ev
:
Event
)
{
if
(
this
.
readyState
===
XMLHttpRequest
.
DONE
){
if
(
this
.
getResponseHeader
(
'
access-token
'
)
!=
null
)
{
console
.
log
(
this
.
getResponseHeader
(
'
access-token
'
))
sessionStorage
.
setItem
(
'
@portalmec/accessToken
'
,
this
.
getResponseHeader
(
'
access-token
'
)
!
)
}
}
}
this
.
request
.
overrideMimeType
(
'
application/octet-stream
'
);
this
.
file
=
file
;
...
...
@@ -47,6 +56,7 @@ export default class FileToUpload {
if
(
this
.
currentChunkFinalByte
===
this
.
file
.
size
)
{
alert
(
'
Yay, upload completed! Chao!
'
);
this
.
uploadFinished
=
true
;
return
;
}
else
if
(
remainingBytes
<
FileToUpload
.
chunkSize
)
{
// if the remaining chunk is smaller than the chunk size we defined
...
...
@@ -59,8 +69,8 @@ export default class FileToUpload {
this
.
currentChunkFinalByte
=
this
.
currentChunkStartByte
+
FileToUpload
.
chunkSize
;
}
this
.
uploadFile
();
this
.
_chunkNumber
=
this
.
_chunkNumber
+
1
this
.
uploadFile
();
}
//add attributes
...
...
@@ -74,12 +84,6 @@ export default class FileToUpload {
formData
.
append
(
'
_totalSize
'
,
String
(
this
.
file
.
size
));
formData
.
append
(
'
file
'
,
chunk
);
this
.
request
.
onreadystatechange
=
(
request
:
XMLHttpRequest
,
event
:
Event
):
any
=>
{
if
(
request
.
readyState
===
XMLHttpRequest
.
DONE
){
console
.
log
(
request
.
getResponseHeader
(
'
access-token
'
))
sessionStorage
.
setItem
(
'
@portalmec/accessToken
'
,
request
.
getResponseHeader
(
'
access-token
'
)
!
)
}
}
this
.
request
.
send
(
formData
);
// send it now!
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment