Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/doubt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export default DS.Model.extend({
comments: DS.hasMany('comment'),
feedbacks: DS.hasMany('doubt-feedback'),
resolvedById: DS.attr(),
createdAt: DS.attr('date')
createdAt: DS.attr('date'),
file_link: DS.attr()
})
9 changes: 9 additions & 0 deletions app/pods/components/file-upload-minio/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ export default FileField.extend({
}
})

if(this.maxSize){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just give a default value to maxSize for file-upload-minio component. We never allow unlimited size uploads and backend checks will ensure this anyways. It makes sense to use a reasonable default here and skip the "existence" check

if(files[0].size/1024 > this.maxSize){
alert("file is way too large")
this.enableUpload(false)
}else{
this.enableUpload(true)
}
}

if(this.onProgress) {
uploader.on('progress', e => {
this.onProgress(e)
Expand Down
19 changes: 19 additions & 0 deletions app/pods/components/player/player-ask-doubt-modal/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,23 @@ export default class AskDoubtModal extends Component {
if (!this.doubt.isNew)
this.onClose()
}
canUpload = true;

@action
uploaded(e) {
this.set("doubt.file_link",e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeat after me: space after a comma

this.set('triggerUpload', false)
}

@action
resetUpload () {
this.set("doubt.file_link", null)
this.set('triggerUpload', false)
}

@action
uploadFailed () {
alert(`Can't Upload file.`)
this.set('triggerUpload', false)
}
}
21 changes: 21 additions & 0 deletions app/pods/components/player/player-ask-doubt-modal/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@
@text={{doubt.body}} />
<div class="card-sm">Describe your problem thoroughly. You can drag and drop images in your description.</div>
</div>
<div class="d-flex justify-content-between align-items-center">
{{#if doubt.file_link}}
<span>
<a href="{{doubt.file_link}}" class="white" download>Download File</a>
<button {{action 'resetUpload'}}><i class="fa fa-times" ></i></button>
</span>
{{yield}}
{{else}}
<div>
<span class="bold mr-3">
Upload File:
</span>
{{file-upload-minio triggerUpload=triggerUpload onComplete=(action 'uploaded') onError=(action 'uploadFailed') enableUpload=(action (mut this.canUpload)) maxSize=5120 }}
</div>
<span class="float-right">
<button class="button-solid button-orange" disabled={{ not this.canUpload}} {{action (mut triggerUpload) true}}>
Upload File
</button>
</span>
{{/if}}
</div>
<div class="mt-5 d-flex justify-content-end">
<button class="mr-3" {{action onClose}}>Cancel</button>
<button
Expand Down