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

[NEW] WebDAV file picker loading animations #14759

Merged
merged 2 commits into from
Jun 19, 2019
Merged
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
4 changes: 4 additions & 0 deletions app/theme/client/imports/general/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ button {
animation-delay: -0.16s;
}

.file-picker-loading .loading-animation > .bounce {
background-color: #444444;
}

@keyframes loading-bouncedelay {
0%,
80%,
Expand Down
38 changes: 22 additions & 16 deletions app/webdav/client/webdavFilePicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@
</div>
</li>
{{/if}}
{{#each webdavNodes}}
<li class="attachments__item webdav_{{this.type}}">
{{#with iconType}}
<div class="attachments__thumb attachments__file--{{type}}">
{{>icon icon=icon}}
<div class="attachments__type">{{extension}}</div>
</div>
{{/with}}
<a title="{{this.basename}}" target="_blank" class="attachments__item">
<div class="attachments__content">
<div class="attachments__name">{{this.basename}}</div>
<div class="attachments__details">{{this.lastmod}}</div>
</div>
</a>
</li>
{{/each}}
{{#if isLoading}}
<div class="file-picker-loading">
{{> loading}}
</div>
{{else}}
{{#each webdavNodes}}
<li class="attachments__item webdav_{{this.type}}">
{{#with iconType}}
<div class="attachments__thumb attachments__file--{{type}}">
{{>icon icon=icon}}
<div class="attachments__type">{{extension}}</div>
</div>
{{/with}}
<a title="{{this.basename}}" target="_blank" class="attachments__item">
<div class="attachments__content">
<div class="attachments__name">{{this.basename}}</div>
<div class="attachments__details">{{this.lastmod}}</div>
</div>
</a>
</li>
{{/each}}
{{/if}}
</ul>
</div>
</template>
45 changes: 32 additions & 13 deletions app/webdav/client/webdavFilePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import _ from 'underscore';
import toastr from 'toastr';
import { Session } from 'meteor/session';
import { Handlebars } from 'meteor/ui';
import { ReactiveVar } from 'meteor/reactive-var';

import { modal, call } from '../../ui-utils';
import { t } from '../../utils';
Expand All @@ -18,10 +19,13 @@ Template.webdavFilePicker.rendered = async function() {
return toastr.error(t(response.message));
}
Session.set('webdavNodes', response.data);
this.isLoading.set(false);
};

Template.webdavFilePicker.destroyed = function() {
Session.set('webdavNodes', []);
};

Template.webdavFilePicker.helpers({
iconType() {
// add icon for different types
Expand Down Expand Up @@ -52,16 +56,22 @@ Template.webdavFilePicker.helpers({
}
return { icon, type, extension };
},
isLoading() {
return Template.instance().isLoading.get();
},
webdavNodes() {
return Session.get('webdavNodes');
},
webdavCurrentFolder() {
return Session.get('webdavCurrentFolder');
},
});

Template.webdavFilePicker.events({
async 'click #webdav-go-back'() {
const { accountId } = Template.instance().data;
const instance = Template.instance();
const { accountId } = instance.data;
instance.isLoading.set(true);
let currentFolder = Session.get('webdavCurrentFolder');

// determine parent directory to go back
Expand All @@ -75,16 +85,20 @@ Template.webdavFilePicker.events({
Session.set('webdavCurrentFolder', parentFolder);
Session.set('webdavNodes', []);
const response = await call('getWebdavFileList', accountId, parentFolder);
instance.isLoading.set(false);
if (!response.success) {
return toastr.error(t(response.message));
}
Session.set('webdavNodes', response.data);
},
async 'click .webdav_directory'() {
const { accountId } = Template.instance().data;
const instance = Template.instance();
const { accountId } = instance.data;
instance.isLoading.set(true);
Session.set('webdavCurrentFolder', this.filename);
Session.set('webdavNodes', []);
const response = await call('getWebdavFileList', accountId, this.filename);
instance.isLoading.set(false);
if (!response.success) {
modal.close();
return toastr.error(t(response.message));
Expand All @@ -93,10 +107,12 @@ Template.webdavFilePicker.events({
},
async 'click .webdav_file'() {
const roomId = Session.get('openedRoom');
const { accountId } = Template.instance().data;
const instance = Template.instance();
const { accountId } = instance.data;
instance.isLoading.set(true);
const file = this;
const response = await call('getFileFromWebdav', accountId, file);

instance.isLoading.set(false);
if (!response.success) {
modal.close();
return toastr.error(t('Failed_to_get_webdav_file'));
Expand All @@ -106,15 +122,14 @@ Template.webdavFilePicker.events({
blob.lastModified = file.lastmod;
blob.name = file.basename;
const text = `
<div class='upload-preview-title'>
<div class="rc-input__wrapper">
<input class="rc-input__element" id='file-name' style='display: inherit;' value='${ Handlebars._escape(blob.name) }' placeholder='${ t('Upload_file_name') }'>
</div>
<div class="rc-input__wrapper">
<input class="rc-input__element" id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'>
</div>
</div>`;

<div class='upload-preview-title'>
<div class="rc-input__wrapper">
<input class="rc-input__element" id='file-name' style='display: inherit;' value='${ Handlebars._escape(blob.name) }' placeholder='${ t('Upload_file_name') }'>
</div>
<div class="rc-input__wrapper">
<input class="rc-input__element" id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'>
</div>
</div>`;
return modal.open({
title: t('Upload_file_question'),
text,
Expand Down Expand Up @@ -200,3 +215,7 @@ Template.webdavFilePicker.events({
});
},
});

Template.webdavFilePicker.onCreated(function() {
this.isLoading = new ReactiveVar(true);
});