Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
f01a54dd
Unverified
Commit
f01a54dd
authored
Sep 26, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a loading indicator on the upload button
parent
cd8509be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
UploadButton.vue
Modules/Media/Assets/js/components/UploadButton.vue
+5
-1
app.js
public/js/app.js
+11
-2
No files found.
Modules/Media/Assets/js/components/UploadButton.vue
View file @
f01a54dd
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
:show-file-list=
"false"
:show-file-list=
"false"
:http-request=
"uploadFile"
:http-request=
"uploadFile"
style=
"display: inline-block; margin-right: 10px;"
>
style=
"display: inline-block; margin-right: 10px;"
>
<el-button
size=
"small"
type=
"primary"
style=
"padding: 11px 9px;"
>
Upload File
</el-button>
<el-button
size=
"small"
type=
"primary"
style=
"padding: 11px 9px;"
:loading=
"fileIsUploading"
>
Upload File
</el-button>
</el-upload>
</el-upload>
</
template
>
</
template
>
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
},
},
data
()
{
data
()
{
return
{
return
{
fileIsUploading
:
false
,
}
}
},
},
computed
:
{
computed
:
{
...
@@ -53,15 +54,18 @@
...
@@ -53,15 +54,18 @@
this
.
$events
.
emit
(
'
fileWasUploaded
'
,
response
);
this
.
$events
.
emit
(
'
fileWasUploaded
'
,
response
);
},
},
uploadFile
(
event
)
{
uploadFile
(
event
)
{
this
.
fileIsUploading
=
true
;
let
data
=
new
FormData
();
let
data
=
new
FormData
();
data
.
append
(
'
parent_id
'
,
this
.
parentId
);
data
.
append
(
'
parent_id
'
,
this
.
parentId
);
data
.
append
(
'
file
'
,
event
.
file
);
data
.
append
(
'
file
'
,
event
.
file
);
axios
.
post
(
route
(
'
api.media.store
'
),
data
)
axios
.
post
(
route
(
'
api.media.store
'
),
data
)
.
then
(
response
=>
{
.
then
(
response
=>
{
this
.
$events
.
emit
(
'
fileWasUploaded
'
,
response
);
this
.
$events
.
emit
(
'
fileWasUploaded
'
,
response
);
this
.
fileIsUploading
=
false
;
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
log
(
error
.
response
.
data
);
console
.
log
(
error
.
response
.
data
);
this
.
fileIsUploading
=
false
;
this
.
$notify
.
error
({
this
.
$notify
.
error
({
title
:
'
Error
'
,
title
:
'
Error
'
,
message
:
error
.
response
.
data
.
errors
.
file
[
0
]
message
:
error
.
response
.
data
.
errors
.
file
[
0
]
...
...
public/js/app.js
View file @
f01a54dd
...
@@ -94580,7 +94580,9 @@ exports.default = {
...
@@ -94580,7 +94580,9 @@ exports.default = {
parentId: { type: Number }
parentId: { type: Number }
},
},
data: function data() {
data: function data() {
return {};
return {
fileIsUploading: false
};
},
},
computed: {
computed: {
...
@@ -94601,13 +94603,16 @@ exports.default = {
...
@@ -94601,13 +94603,16 @@ exports.default = {
uploadFile: function uploadFile(event) {
uploadFile: function uploadFile(event) {
var _this = this;
var _this = this;
this.fileIsUploading = true;
var data = new FormData();
var data = new FormData();
data.append('parent_id', this.parentId);
data.append('parent_id', this.parentId);
data.append('file', event.file);
data.append('file', event.file);
_axios2.default.post(route('api.media.store'), data).then(function (response) {
_axios2.default.post(route('api.media.store'), data).then(function (response) {
_this.$events.emit('fileWasUploaded', response);
_this.$events.emit('fileWasUploaded', response);
_this.fileIsUploading = false;
}).catch(function (error) {
}).catch(function (error) {
console.log(error.response.data);
console.log(error.response.data);
_this.fileIsUploading = false;
_this.$notify.error({
_this.$notify.error({
title: 'Error',
title: 'Error',
message: error.response.data.errors.file[0]
message: error.response.data.errors.file[0]
...
@@ -94672,7 +94677,11 @@ var render = function() {
...
@@ -94672,7 +94677,11 @@ var render = function() {
"el-button",
"el-button",
{
{
staticStyle: { padding: "11px 9px" },
staticStyle: { padding: "11px 9px" },
attrs: { size: "small", type: "primary" }
attrs: {
size: "small",
type: "primary",
loading: _vm.fileIsUploading
}
},
},
[_vm._v("Upload File")]
[_vm._v("Upload File")]
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment