1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-26 00:29:47 +02:00

Introduce new nofications framework

Integrated https://github.com/documize/iziToast and added 4 log levels.
This commit is contained in:
sauls8t 2018-12-05 13:44:10 +00:00
parent f44cda66e6
commit f05a6fc999
40 changed files with 4187 additions and 1031 deletions

View file

@ -141,15 +141,13 @@ export default Component.extend(ModalMixin, Notifier, {
},
onLDAPPreview() {
this.showWait();
let config = this.get('ldapConfig');
config.serverPort = parseInt(this.get('ldapConfig.serverPort'));
this.get('globalSvc').previewLDAP(config).then((preview) => {
this.set('ldapPreview', preview);
this.modalOpen("#ldap-preview-modal", {"show": true});
this.showDone();
this.notifySuccess('Saved');
});
},
@ -231,8 +229,6 @@ export default Component.extend(ModalMixin, Notifier, {
break;
}
this.showWait();
let data = { authProvider: provider, authConfig: JSON.stringify(config) };
this.get('onSave')(data).then(() => {
@ -274,7 +270,7 @@ export default Component.extend(ModalMixin, Notifier, {
});
}
this.showDone();
this.notifySuccess('Saved');
});
}
}

View file

@ -60,7 +60,6 @@ export default Component.extend(Notifier, Modal, {
},
doBackup() {
this.showWait();
this.set('backupFilename', '');
this.set('backupSuccess', false);
this.set('backupFailed', false);
@ -69,13 +68,13 @@ export default Component.extend(Notifier, Modal, {
let spec = this.get('backupSpec');
this.get('onBackup')(spec).then((filename) => {
this.showDone();
this.notifySuccess('Completed');
this.set('backupLabel', 'Start Backup');
this.set('backupSuccess', true);
this.set('backupFilename', filename);
this.set('backupRunning', false);
}, ()=> {
this.showDone();
this.notifyError('Failed');
this.set('backupLabel', 'Run Backup');
this.set('backupFailed', true);
this.set('backupRunning', false);
@ -134,7 +133,6 @@ export default Component.extend(Notifier, Modal, {
}
// start restore process
this.showWait();
this.set('restoreButtonLabel', 'Please wait, restore running...');
this.set('restoreSuccess', false);
this.set('restoreFailed', false);
@ -147,12 +145,12 @@ export default Component.extend(Notifier, Modal, {
}
this.get('onRestore')(spec, filedata).then(() => {
this.showDone();
this.notifySuccess('Completed');
this.set('backupLabel', 'Restore');
this.set('restoreSuccess', true);
this.get('router').transitionTo('auth.logout');
}, ()=> {
this.showDone();
this.notifyError('Failed');
this.set('restorbackupLabel', 'Restore');
this.set('restoreFailed', true);
});

View file

@ -64,10 +64,8 @@ export default Component.extend(Notifier, {
this.set('model.general.maxTags', this.get('maxTags'));
this.model.general.set('allowAnonymousAccess', $("#allowAnonymousAccess").prop('checked'));
this.showWait();
this.get('save')().then(() => {
this.showDone();
this.notifySuccess('Saved');
set(this, 'titleError', false);
set(this, 'messageError', false);
set(this, 'conversionEndpointError', false);

View file

@ -56,13 +56,12 @@ export default Component.extend(Notifier, {
this.set('jiraCreds.url', url.substring(0, url.length-1));
}
this.showWait();
this.get('orgSvc').saveOrgSetting(orgId, 'jira', this.get('jiraCreds')).then(() => {
if (this.get('session.isGlobalAdmin')) {
this.get('orgSvc').saveGlobalSetting('SECTION-TRELLO', this.get('trelloCreds'));
}
this.showDone();
this.notifySuccess('Saved');
});
}
}

View file

@ -40,10 +40,8 @@ export default Component.extend(Notifier, Modals, {
actions: {
saveLicense() {
this.showWait();
this.get('global').setLicense(this.get('license')).then(() => {
this.showDone();
this.notifySuccess('Saved');
window.location.reload();
});
},
@ -57,7 +55,7 @@ export default Component.extend(Notifier, Modals, {
let comment = this.get('comment');
this.get('global').deactivate(comment).then(() => {
this.showDone();
this.notifySuccess('Saved');
this.modalOpen("#deactivation-confirmation-modal", {"show": true});
});
}

View file

@ -48,11 +48,10 @@ export default Component.extend(Notifier, {
},
);
this.showWait();
this.set('buttonText', 'Please wait...');
this.get('saveSMTP')().then((result) => {
this.showDone();
this.notifySuccess('Saved');
this.set('buttonText', 'Save & Test');
this.set('testSMTP', result);
});

View file

@ -80,8 +80,6 @@ export default Component.extend(Notifier, Modals, {
},
onExport() {
this.showWait();
let spec = {
spaceId: '',
data: _.pluck(this.get('folders'), 'id'),
@ -90,15 +88,13 @@ export default Component.extend(Notifier, Modals, {
this.get('documentSvc').export(spec).then((htmlExport) => {
this.get('browserSvc').downloadFile(htmlExport, 'documize.html');
this.showDone();
this.notifySuccess('Exported');
});
},
onOwner(spaceId) {
this.showWait();
this.get('spaceSvc').grantOwnerPermission(spaceId).then(() => { /* jshint ignore:line */
this.showDone();
this.notifySuccess('Saved');
});
}
}

View file

@ -125,8 +125,6 @@ export default Component.extend(Notifier, {
actions: {
onSave() {
this.showWait();
let docId = this.get('document.id');
let folderId = this.get('space.id');
let link = this.get('categories').filterBy('selected', true);
@ -158,7 +156,7 @@ export default Component.extend(Notifier, {
this.get('categoryService').setCategoryMembership(toUnlink, 'unlink').then(() => {
this.get('categoryService').setCategoryMembership(toLink, 'link').then(() => {
this.showDone();
this.notifySuccess('Saved');
});
});

View file

@ -66,16 +66,15 @@ export default Component.extend(Modals, Notifier, {
});
this.on("queuecomplete", function () {
self.showDone();
self.notifySuccess('Saved');
self.getAttachments();
});
this.on("addedfile", function ( /*file*/ ) {
self.showWait();
});
this.on("error", function (error, msg) { // // eslint-disable-line no-unused-vars
self.showNotification(msg);
self.notifyError(msg);
console.log(msg); // eslint-disable-line no-console
});
}

View file

@ -52,11 +52,9 @@ export default Component.extend(AuthMixin, Notifier, {
let id = this.get('deleteBlockId');
this.showWait();
this.get('sectionSvc').deleteBlock(id).then(() => {
this.set('deleteBlockId', '');
this.showDone();
this.notifySuccess('Deleted');
this.get('sectionSvc').getSpaceBlocks(this.get('space.id')).then((blocks) => {
this.set('blocks', blocks);

View file

@ -120,10 +120,9 @@ export default Component.extend(ModalMixin, TooltipMixin, Notifer, {
spaceId: this.get('space.id')
};
this.showWait();
this.get('categorySvc').add(c).then(() => {
this.load();
this.showDone();
this.notifySuccess('Category added');
});
},

View file

@ -84,10 +84,8 @@ export default Component.extend(AuthMixin, Notifier, {
if (spaceName.length === 0) return;
space.set('name', spaceName);
this.showWait();
this.get('spaceSvc').save(space).then(() => {
this.showDone();
this.notifySuccess('Saved');
});
}
}

View file

@ -132,8 +132,6 @@ export default Component.extend(Notifier, Modals, {
let spacePermissions = this.get('spacePermissions');
let filteredUsers = A([]);
this.showWait();
this.get('userSvc').matchUsers(s).then((users) => {
users.forEach((user) => {
let exists = spacePermissions.findBy('whoId', user.get('id'));
@ -144,7 +142,6 @@ export default Component.extend(Notifier, Modals, {
});
this.set('filteredUsers', filteredUsers);
this.showDone();
});
},
@ -160,9 +157,7 @@ export default Component.extend(Notifier, Modals, {
onSave() {
if (!this.get('isSpaceAdmin')) return;
this.showWait();
let message = this.getDefaultInvitationMessage();
let message = this.getDefaultInvitationMessage();
let permissions = this.get('spacePermissions');
let folder = this.get('folder');
let payload = { Message: message, Permissions: permissions };
@ -197,7 +192,7 @@ export default Component.extend(Notifier, Modals, {
}
this.get('spaceSvc').savePermissions(folder.get('id'), payload).then(() => {
this.showDone();
this.notifySuccess('Saved');
this.get('onRefresh')();
});
},
@ -219,17 +214,13 @@ export default Component.extend(Notifier, Modals, {
let spacePermissions = this.get('spacePermissions');
let constants = this.get('constants');
this.showWait();
let exists = spacePermissions.findBy('whoId', user.get('id'));
let exists = spacePermissions.findBy('whoId', user.get('id'));
if (is.undefined(exists)) {
spacePermissions.pushObject(this.permissionRecord(constants.WhoType.User, user.get('id'), user.get('fullname')));
this.set('spacePermissions', spacePermissions);
this.send('onSearch');
}
this.showDone();
},
onSpaceInvite(e) {
@ -248,9 +239,7 @@ export default Component.extend(Notifier, Modals, {
return;
}
this.showWait();
var result = {
var result = {
Message: message,
Recipients: []
};
@ -271,7 +260,7 @@ export default Component.extend(Notifier, Modals, {
this.set('inviteEmail', '');
this.get('spaceSvc').share(this.get('folder.id'), result).then(() => {
this.showDone();
this.notifySuccess('Invites sent');
this.$('#space-invite-email').removeClass('is-invalid');
this.modalClose("#space-invite-user-modal");
this.load();

View file

@ -33,6 +33,7 @@ export default Component.extend(Modals, {
init() {
this._super(...arguments);
let constants = this.get('constants');
this.pins = [];
@ -70,6 +71,16 @@ export default Component.extend(Modals, {
this.eventBus.subscribe('pinChange', this, 'setupPins');
this.setupPins();
}
this.eventBus.subscribe('notifyUser', this, 'processNotification');
},
willDestroyElement() {
this._super(...arguments);
this.eventBus.unsubscribe('notifyUser');
this.eventBus.unsubscribe('pinChange');
iziToast.destroy();
},
setupPins() {
@ -85,10 +96,70 @@ export default Component.extend(Modals, {
});
},
willDestroyElement() {
this._super(...arguments);
processNotification(msg, type) {
if (this.get('isDestroyed') || this.get('isDestroying')) return;
this.eventBus.unsubscribe('pinChange');
// if (msg === 'wait') {
// this.set('showWait', true);
// this.set('showMessage', false);
// this.set('showDone', false);
// }
// New code...
if (is.not.undefined(type)) {
switch (type) {
case 'info':
iziToast.info({
title: '',
message: msg,
});
break;
case 'success':
iziToast.success({
title: '',
message: msg,
});
break;
case 'warn':
iziToast.warning({
title: '',
message: msg,
});
break;
case 'error':
iziToast.error({
title: '',
message: msg,
});
break;
}
return;
}
// Legacy code...
if (msg === 'done') {
$('.progress-done').removeClass('zoomOut').addClass('zoomIn');
this.set('showWait', false);
this.set('showMessage', false);
this.set('showDone', true);
setTimeout(function() {
$('.progress-done').removeClass('zoomIn').addClass('zoomOut');
}, 3000);
}
if (msg !== 'done' && msg !== 'wait') {
$('.progress-notification').removeClass('zoomOut').addClass('zoomIn');
this.set('showWait', false);
this.set('showDone', false);
this.set('showMessage', true);
this.set('message', msg);
setTimeout(function() {
$('.progress-notification').removeClass('zoomIn').addClass('zoomOut');
}, 3000);
}
},
actions: {

View file

@ -135,8 +135,6 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
},
onExport() {
this.showWait();
let spec = {
spaceId: this.get('document.folderId'),
data: [],
@ -147,7 +145,7 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
this.get('documentSvc').export(spec).then((htmlExport) => {
this.get('browserSvc').downloadFile(htmlExport, this.get('document.slug') + '.html');
this.showDone();
this.notifySuccess('Exported');
});
}
}

View file

@ -288,8 +288,6 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
},
onExport() {
this.showWait();
let spec = {
spaceId: this.get('space.id'),
data: [],
@ -310,7 +308,7 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
this.get('documentSvc').export(spec).then((htmlExport) => {
this.get('browserSvc').downloadFile(htmlExport, this.get('space.slug') + '.html');
this.showDone();
this.notifySuccess('Exported');
});
this.modalClose("#space-export-modal");