1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

Enable custom logo upload and rendering

This commit is contained in:
McMatts 2019-01-06 13:50:12 +00:00
parent a211ba051a
commit 036f36ba1d
36 changed files with 574 additions and 211 deletions

View file

@ -32,6 +32,51 @@ export default Component.extend(Notifier, {
this.set('maxTags', this.get('model.general.maxTags'));
},
didInsertElement() {
this._super(...arguments);
let self = this;
let url = this.get('appMeta.endpoint');
let orgId = this.get('appMeta.orgId');
let uploadUrl = `${url}/organization/${orgId}/logo`;
let dzone = new Dropzone("#upload-logo > div", {
headers: {
'Authorization': 'Bearer ' + self.get('session.authToken')
},
url: uploadUrl,
method: "post",
paramName: 'attachment',
clickable: true,
maxFilesize: 50,
parallelUploads: 1,
uploadMultiple: false,
addRemoveLinks: false,
autoProcessQueue: true,
createImageThumbnails: false,
init: function () {
this.on("success", function (/*file, response*/ ) {
});
this.on("queuecomplete", function () {
self.notifySuccess('Logo uploaded');
});
this.on("error", function (error, msg) {
self.notifyError(msg);
self.notifyError(error);
});
}
});
dzone.on("complete", function (file) {
dzone.removeFile(file);
});
this.set('drop', dzone);
},
actions: {
change() {
const selectEl = this.$('#maxTags')[0];
@ -63,7 +108,7 @@ export default Component.extend(Notifier, {
this.set('model.general.maxTags', this.get('maxTags'));
this.get('save')().then(() => {
this.get('onUpdate')().then(() => {
this.notifySuccess('Saved');
set(this, 'titleError', false);
set(this, 'messageError', false);
@ -74,6 +119,11 @@ export default Component.extend(Notifier, {
onThemeChange(theme) {
this.get('appMeta').setTheme(theme);
this.set('model.general.theme', theme);
},
onDefaultLogo() {
this.get('onDefaultLogo')(this.get('appMeta.orgId'));
this.notifySuccess('Using default logo');
}
}
});

View file

@ -20,6 +20,7 @@ import Component from '@ember/component';
export default Component.extend(AuthMixin, Notifier, {
router: service(),
spaceSvc: service('folder'),
iconSvc: service('icon'),
localStorage: service('localStorage'),
isSpaceAdmin: computed('permissions', function() {
return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage');
@ -40,7 +41,7 @@ export default Component.extend(AuthMixin, Notifier, {
init() {
this._super(...arguments);
this.populateIconList();
this.set('iconList', this.get('iconSvc').getSpaceIconList());
},
didReceiveAttrs() {
@ -76,62 +77,6 @@ export default Component.extend(AuthMixin, Notifier, {
this.set('spaceIcon', icon);
},
populateIconList() {
let list = this.get('iconList');
let constants = this.get('constants');
list = A([]);
list.pushObject(constants.IconMeta.Star);
list.pushObject(constants.IconMeta.Support);
list.pushObject(constants.IconMeta.Message);
list.pushObject(constants.IconMeta.Apps);
list.pushObject(constants.IconMeta.Box);
list.pushObject(constants.IconMeta.Gift);
list.pushObject(constants.IconMeta.Design);
list.pushObject(constants.IconMeta.Bulb);
list.pushObject(constants.IconMeta.Metrics);
list.pushObject(constants.IconMeta.PieChart);
list.pushObject(constants.IconMeta.BarChart);
list.pushObject(constants.IconMeta.Finance);
list.pushObject(constants.IconMeta.Lab);
list.pushObject(constants.IconMeta.Code);
list.pushObject(constants.IconMeta.Help);
list.pushObject(constants.IconMeta.Manuals);
list.pushObject(constants.IconMeta.Flow);
list.pushObject(constants.IconMeta.Out);
list.pushObject(constants.IconMeta.In);
list.pushObject(constants.IconMeta.Partner);
list.pushObject(constants.IconMeta.Org);
list.pushObject(constants.IconMeta.Home);
list.pushObject(constants.IconMeta.Infinite);
list.pushObject(constants.IconMeta.Todo);
list.pushObject(constants.IconMeta.Procedure);
list.pushObject(constants.IconMeta.Outgoing);
list.pushObject(constants.IconMeta.Incoming);
list.pushObject(constants.IconMeta.Travel);
list.pushObject(constants.IconMeta.Winner);
list.pushObject(constants.IconMeta.Roadmap);
list.pushObject(constants.IconMeta.Money);
list.pushObject(constants.IconMeta.Security);
list.pushObject(constants.IconMeta.Tune);
list.pushObject(constants.IconMeta.Guide);
list.pushObject(constants.IconMeta.Smile);
list.pushObject(constants.IconMeta.Rocket);
list.pushObject(constants.IconMeta.Time);
list.pushObject(constants.IconMeta.Cup);
list.pushObject(constants.IconMeta.Marketing);
list.pushObject(constants.IconMeta.Announce);
list.pushObject(constants.IconMeta.Devops);
list.pushObject(constants.IconMeta.World);
list.pushObject(constants.IconMeta.Plan);
list.pushObject(constants.IconMeta.Components);
list.pushObject(constants.IconMeta.People);
list.pushObject(constants.IconMeta.Checklist);
this.set('iconList', list);
},
actions: {
onSetSpaceType(t) {
this.set('spaceType', t);

View file

@ -9,9 +9,20 @@
//
// https://documize.com
import { inject as service } from '@ember/service';
import Component from '@ember/component';
export default Component.extend({
appMeta: service(),
icon: null,
meta: null
meta: null,
logo: false,
didReceiveAttrs() {
this._super(...arguments);
if (this.get('logo')) {
let cb = + new Date();
this.set('cacheBuster', cb);
}
}
});