Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added option to upload files when asking a doubt #622

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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()
})
8 changes: 8 additions & 0 deletions app/pods/components/file-upload-minio/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Uploader from 'ember-uploader/uploaders/uploader';
export default FileField.extend({
uploader: null,
files: null,
maxSize: 10240,
session: service(),
didUpdateAttrs () {
this._super(...arguments)
Expand All @@ -33,6 +34,13 @@ export default FileField.extend({
}
})

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)
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