mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05:28 +02:00
Fix calls to session and appMeta services
This commit is contained in:
parent
37e3434158
commit
d1714db6f8
9 changed files with 40 additions and 41 deletions
|
@ -15,6 +15,7 @@ import TooltipMixin from '../../mixins/tooltip';
|
||||||
|
|
||||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
userService: Ember.inject.service('user'),
|
userService: Ember.inject.service('user'),
|
||||||
|
localStorage: Ember.inject.service(),
|
||||||
drop: null,
|
drop: null,
|
||||||
users: [],
|
users: [],
|
||||||
saveTemplate: {
|
saveTemplate: {
|
||||||
|
@ -43,11 +44,12 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
if (this.get('isEditor')) {
|
if (this.get('isEditor')) {
|
||||||
let self = this;
|
let self = this;
|
||||||
let documentId = this.get('document.id');
|
let documentId = this.get('document.id');
|
||||||
let uploadUrl = this.session.appMeta.getUrl(`documents/${documentId}/attachments`);
|
let url = this.get('appMeta.url');
|
||||||
|
let uploadUrl = `${url}/documents/${documentId}/attachments`;
|
||||||
|
|
||||||
let dzone = new Dropzone("#attachment-button > i", {
|
let dzone = new Dropzone("#attachment-button > i", {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + self.session.getSessionItem('token')
|
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('session.session.authenticated.token')
|
||||||
},
|
},
|
||||||
url: uploadUrl,
|
url: uploadUrl,
|
||||||
method: "post",
|
method: "post",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
folderService: Ember.inject.service('folder'),
|
folderService: Ember.inject.service('folder'),
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
users: [],
|
users: [],
|
||||||
folders: [],
|
folders: [],
|
||||||
folder: {},
|
folder: {},
|
||||||
|
@ -23,7 +24,7 @@ export default Ember.Component.extend({
|
||||||
permissions: {},
|
permissions: {},
|
||||||
|
|
||||||
getDefaultInvitationMessage() {
|
getDefaultInvitationMessage() {
|
||||||
return "Hey there, I am sharing the " + this.folder.get('name') + " (in " + this.session.appMeta.title + ") with you so we can both access the same documents.";
|
return "Hey there, I am sharing the " + this.folder.get('name') + " (in " + this.get("appMeta.title") + ") with you so we can both access the same documents.";
|
||||||
},
|
},
|
||||||
|
|
||||||
willRender() {
|
willRender() {
|
||||||
|
@ -106,4 +107,4 @@ export default Ember.Component.extend({
|
||||||
this.sendAction("onPermission", this.get('folder'), message, this.get('permissions'));
|
this.sendAction("onPermission", this.get('folder'), message, this.get('permissions'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,12 +13,14 @@ import Ember from 'ember';
|
||||||
import NotifierMixin from '../../mixins/notifier';
|
import NotifierMixin from '../../mixins/notifier';
|
||||||
|
|
||||||
export default Ember.Component.extend(NotifierMixin, {
|
export default Ember.Component.extend(NotifierMixin, {
|
||||||
|
localStorage: Ember.inject.service(),
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
selectedTemplate: {
|
selectedTemplate: {
|
||||||
id: "0"
|
id: "0"
|
||||||
},
|
},
|
||||||
canEditTemplate: "",
|
canEditTemplate: "",
|
||||||
drop: null,
|
drop: null,
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this.send('setTemplate', this.get('savedTemplates')[0]);
|
this.send('setTemplate', this.get('savedTemplates')[0]);
|
||||||
|
@ -71,13 +73,14 @@ export default Ember.Component.extend(NotifierMixin, {
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
let folderId = this.get('folder.id');
|
let folderId = this.get('folder.id');
|
||||||
let importUrl = this.session.appMeta.getUrl('import/folder/' + folderId);
|
let url = this.get('appMeta.url');
|
||||||
|
let importUrl = `${url}/import/folder/${folderId}`;
|
||||||
|
|
||||||
Dropzone.options.uploadDocuments = false;
|
Dropzone.options.uploadDocuments = false;
|
||||||
|
|
||||||
let dzone = new Dropzone("#upload-documents", {
|
let dzone = new Dropzone("#upload-documents", {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + self.session.getSessionItem('token')
|
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('session.session.authenticated.token')
|
||||||
},
|
},
|
||||||
url: importUrl,
|
url: importUrl,
|
||||||
method: "post",
|
method: "post",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
pageBody: "",
|
pageBody: "",
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this.set('pageBody', this.get('meta.rawBody'));
|
this.set('pageBody', this.get('meta.rawBody'));
|
||||||
|
@ -76,7 +77,7 @@ export default Ember.Component.extend({
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof tinymce === 'undefined') {
|
if (typeof tinymce === 'undefined') {
|
||||||
$.getScript(this.session.appMeta.getBaseUrl("tinymce/tinymce.min.js?v=430"), function() {
|
$.getScript(this.get("appMeta").getBaseUrl("tinymce/tinymce.min.js?v=430"), function() {
|
||||||
window.tinymce.dom.Event.domLoaded = true;
|
window.tinymce.dom.Event.domLoaded = true;
|
||||||
tinymce.baseURL = "//" + window.location.host + "/tinymce";
|
tinymce.baseURL = "//" + window.location.host + "/tinymce";
|
||||||
tinymce.suffix = ".min";
|
tinymce.suffix = ".min";
|
||||||
|
@ -110,4 +111,4 @@ export default Ember.Component.extend({
|
||||||
this.attrs.onAction(page, meta);
|
this.attrs.onAction(page, meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,6 +28,8 @@ export default Ember.Controller.extend({
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.get('audit').record("logged-in");
|
this.get('audit').record("logged-in");
|
||||||
return response;
|
return response;
|
||||||
|
}).catch(() => {
|
||||||
|
this.set('invalidCredentials', true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,10 @@ export default Ember.Service.extend({
|
||||||
message: '',
|
message: '',
|
||||||
allowAnonymousAccess: false,
|
allowAnonymousAccess: false,
|
||||||
|
|
||||||
|
getBaseUrl(endpoint) {
|
||||||
|
return [this.get('host'), endpoint].join('/');
|
||||||
|
},
|
||||||
|
|
||||||
boot() {
|
boot() {
|
||||||
let dbhash;
|
let dbhash;
|
||||||
if (is.not.null(document.head.querySelector("[property=dbhash]"))) {
|
if (is.not.null(document.head.querySelector("[property=dbhash]"))) {
|
||||||
|
|
|
@ -20,6 +20,8 @@ const {
|
||||||
export default BaseService.extend({
|
export default BaseService.extend({
|
||||||
sessionService: Ember.inject.service('session'),
|
sessionService: Ember.inject.service('session'),
|
||||||
ajax: Ember.inject.service(),
|
ajax: Ember.inject.service(),
|
||||||
|
localStorage: Ember.inject.service(),
|
||||||
|
|
||||||
|
|
||||||
// selected folder
|
// selected folder
|
||||||
currentFolder: null,
|
currentFolder: null,
|
||||||
|
@ -159,7 +161,7 @@ export default BaseService.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('currentFolder', folder);
|
this.set('currentFolder', folder);
|
||||||
this.get('sessionService').storeSessionItem("folder", get(folder, 'id'));
|
this.get('localStorage').storeSessionItem("folder", get(folder, 'id'));
|
||||||
this.set('canEditCurrentFolder', false);
|
this.set('canEditCurrentFolder', false);
|
||||||
|
|
||||||
let userId = this.get('sessionService.user.id');
|
let userId = this.get('sessionService.user.id');
|
||||||
|
|
|
@ -15,6 +15,7 @@ import models from '../utils/model';
|
||||||
export default Ember.Service.extend({
|
export default Ember.Service.extend({
|
||||||
sessionService: Ember.inject.service('session'),
|
sessionService: Ember.inject.service('session'),
|
||||||
ajax: Ember.inject.service(),
|
ajax: Ember.inject.service(),
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
|
|
||||||
// Returns attributes for specified org id.
|
// Returns attributes for specified org id.
|
||||||
getOrg(id) {
|
getOrg(id) {
|
||||||
|
@ -30,9 +31,10 @@ export default Ember.Service.extend({
|
||||||
save(org) {
|
save(org) {
|
||||||
let id = org.get('id');
|
let id = org.get('id');
|
||||||
|
|
||||||
// refresh on-screen data
|
this.get('appMeta').setProperties({
|
||||||
this.get('sessionService').get('appMeta').setSafe('message', org.message);
|
message: org.message,
|
||||||
this.get('sessionService').get('appMeta').setSafe('title', org.title);
|
title: org.title
|
||||||
|
});
|
||||||
|
|
||||||
return this.get('ajax').request(`organizations/${id}`, {
|
return this.get('ajax').request(`organizations/${id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
|
|
@ -10,14 +10,12 @@
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import encodingUtil from '../utils/encoding';
|
|
||||||
import netUtil from '../utils/net';
|
|
||||||
import models from '../utils/model';
|
import models from '../utils/model';
|
||||||
import SimpleAuthSession from 'ember-simple-auth/services/session';
|
import SimpleAuthSession from 'ember-simple-auth/services/session';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
inject: { service },
|
inject: { service },
|
||||||
computed: { oneWay, or },
|
computed: { oneWay, or, notEmpty },
|
||||||
computed
|
computed
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
|
@ -25,34 +23,18 @@ export default SimpleAuthSession.extend({
|
||||||
ajax: service(),
|
ajax: service(),
|
||||||
appMeta: service(),
|
appMeta: service(),
|
||||||
|
|
||||||
authenticated: oneWay('isAuthenticated'),
|
authenticated: notEmpty('user.id'),
|
||||||
isAdmin: oneWay('user.admin'),
|
isAdmin: oneWay('user.admin'),
|
||||||
isEditor: or('user.admin', 'user.editor'),
|
isEditor: or('user.admin', 'user.editor'),
|
||||||
|
|
||||||
user: computed('session.content.authenticated.user', function(){
|
user: computed('isAuthenticated', 'session.content.authenticated.user', function(){
|
||||||
let user = this.get('session.content.authenticated.user');
|
if (this.get('isAuthenticated')) {
|
||||||
if (user) {
|
let user = this.get('session.content.authenticated.user') || { id: '' };
|
||||||
return models.UserModel.create(user);
|
return models.UserModel.create(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
folderPermissions: null,
|
folderPermissions: null,
|
||||||
currentFolder: null,
|
currentFolder: null
|
||||||
|
|
||||||
clearSession: function() {
|
|
||||||
// TODO: clear session properly with ESA
|
|
||||||
localStorage.clear();
|
|
||||||
},
|
|
||||||
|
|
||||||
storeSessionItem: function(key, data) {
|
|
||||||
localStorage[key] = data;
|
|
||||||
},
|
|
||||||
|
|
||||||
getSessionItem: function(key) {
|
|
||||||
return localStorage[key];
|
|
||||||
},
|
|
||||||
|
|
||||||
clearSessionItem: function(key) {
|
|
||||||
delete localStorage[key];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue