mirror of
https://github.com/documize/community.git
synced 2025-07-28 01:29:43 +02:00
refactored appMeta URL property
This commit is contained in:
parent
1c92691bdb
commit
786ba6e8d6
6 changed files with 324 additions and 350 deletions
|
@ -14,6 +14,7 @@ import NotifierMixin from '../../mixins/notifier';
|
|||
import TooltipMixin from '../../mixins/tooltip';
|
||||
|
||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||
appMeta: Ember.inject.service(),
|
||||
userService: Ember.inject.service('user'),
|
||||
localStorage: Ember.inject.service(),
|
||||
drop: null,
|
||||
|
@ -44,12 +45,12 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
if (this.get('isEditor')) {
|
||||
let self = this;
|
||||
let documentId = this.get('document.id');
|
||||
let url = this.get('appMeta.url');
|
||||
let url = this.get('appMeta.endpoint');
|
||||
let uploadUrl = `${url}/documents/${documentId}/attachments`;
|
||||
|
||||
let dzone = new Dropzone("#attachment-button > i", {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('session.session.authenticated.token')
|
||||
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('token')
|
||||
},
|
||||
url: uploadUrl,
|
||||
method: "post",
|
||||
|
@ -61,22 +62,22 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
addRemoveLinks: false,
|
||||
autoProcessQueue: true,
|
||||
|
||||
init: function() {
|
||||
this.on("success", function(file /*, response*/ ) {
|
||||
init: function () {
|
||||
this.on("success", function (file /*, response*/ ) {
|
||||
self.showNotification(`Attached ${file.name}`);
|
||||
});
|
||||
|
||||
this.on("queuecomplete", function() {
|
||||
this.on("queuecomplete", function () {
|
||||
self.attrs.onAttachmentUpload();
|
||||
});
|
||||
|
||||
this.on("addedfile", function( /*file*/ ) {
|
||||
this.on("addedfile", function ( /*file*/ ) {
|
||||
self.audit.record('attached-file');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
dzone.on("complete", function(file) {
|
||||
dzone.on("complete", function (file) {
|
||||
dzone.removeFile(file);
|
||||
});
|
||||
|
||||
|
|
|
@ -73,14 +73,14 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
|
||||
let self = this;
|
||||
let folderId = this.get('folder.id');
|
||||
let url = this.get('appMeta.url');
|
||||
let url = this.get('appMeta.endpoint');
|
||||
let importUrl = `${url}/import/folder/${folderId}`;
|
||||
|
||||
Dropzone.options.uploadDocuments = false;
|
||||
|
||||
let dzone = new Dropzone("#upload-documents", {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('session.session.authenticated.token')
|
||||
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('token')
|
||||
},
|
||||
url: importUrl,
|
||||
method: "post",
|
||||
|
@ -93,26 +93,25 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
addRemoveLinks: false,
|
||||
autoProcessQueue: true,
|
||||
|
||||
init: function() {
|
||||
this.on("success", function(document) {
|
||||
init: function () {
|
||||
this.on("success", function (document) {
|
||||
self.attrs.onDocumentImported(document.name, document);
|
||||
});
|
||||
|
||||
this.on("error", function(x) {
|
||||
this.on("error", function (x) {
|
||||
console.log("Conversion failed for ", x.name, " obj ", x); // TODO proper error handling
|
||||
});
|
||||
|
||||
this.on("queuecomplete", function() {
|
||||
});
|
||||
this.on("queuecomplete", function () {});
|
||||
|
||||
this.on("addedfile", function(file) {
|
||||
this.on("addedfile", function (file) {
|
||||
self.attrs.onDocumentImporting(file.name);
|
||||
self.audit.record('converted-document');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
dzone.on("complete", function(file) {
|
||||
dzone.on("complete", function (file) {
|
||||
dzone.removeFile(file);
|
||||
});
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ const {
|
|||
export default Ember.Service.extend({
|
||||
ajax: service(),
|
||||
|
||||
url: `${config.apiHost}/${config.apiNamespace}`,
|
||||
endpoint: `${config.apiHost}/${config.apiNamespace}`,
|
||||
orgId: '',
|
||||
title: '',
|
||||
version: '',
|
||||
|
@ -44,11 +44,11 @@ export default Ember.Service.extend({
|
|||
title: htmlSafe("Documize Setup"),
|
||||
allowAnonymousAccess: false
|
||||
});
|
||||
|
||||
return resolve();
|
||||
}
|
||||
|
||||
return this.get('ajax').request('public/meta')
|
||||
.then((response) => {
|
||||
return this.get('ajax').request('public/meta').then((response) => {
|
||||
this.setProperties(response);
|
||||
return response;
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{{#each attachments key="id" as |a index|}}
|
||||
<li class="item">
|
||||
<img class="icon" src="assets/img/attachments/{{document/file-icon a.extension}}" />
|
||||
<a href="{{ appMeta.apiUrl }}api/public/attachments/{{ appMeta.orgId }}/{{ a.job }}/{{ a.fileId }}">
|
||||
<a href="{{ appMeta.endpoint }}/public/attachments/{{ appMeta.orgId }}/{{ a.job }}/{{ a.fileId }}">
|
||||
<span class="file">{{ a.filename }}</span>
|
||||
</a>
|
||||
{{#if isEditor}}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
import Ember from 'ember';
|
||||
import stringUtil from '../utils/string';
|
||||
import config from '../config/environment';
|
||||
import constants from '../utils/constants';
|
||||
|
||||
let BaseModel = Ember.Object.extend({
|
||||
|
@ -24,30 +23,6 @@ let BaseModel = Ember.Object.extend({
|
|||
}
|
||||
});
|
||||
|
||||
let AppMeta = BaseModel.extend({
|
||||
host: "",
|
||||
namespace: "",
|
||||
url: "",
|
||||
orgId: "",
|
||||
title: "",
|
||||
message: "",
|
||||
allowAnonymousAccess: false,
|
||||
|
||||
init() {
|
||||
this.set('host', config.apiHost);
|
||||
this.set('namespace', config.apiNamespace);
|
||||
this.set('url', [config.apiHost, config.apiNamespace, ""].join('/'));
|
||||
},
|
||||
|
||||
getBaseUrl(endpoint) {
|
||||
return [this.get('host'), endpoint].join('/');
|
||||
},
|
||||
|
||||
getUrl(endpoint) {
|
||||
return [this.get('host'), this.get('namespace'), endpoint].join('/');
|
||||
}
|
||||
});
|
||||
|
||||
let FolderPermissionModel = Ember.Object.extend({
|
||||
orgId: "",
|
||||
folderId: "",
|
||||
|
@ -68,7 +43,7 @@ let ProtectedFolderParticipant = Ember.Object.extend({
|
|||
folderId: "",
|
||||
folderType: 0,
|
||||
|
||||
fullname: Ember.computed('firstname', 'lastname', function() {
|
||||
fullname: Ember.computed('firstname', 'lastname', function () {
|
||||
return `${this.get('firstname')} ${this.get('lastname')}`;
|
||||
})
|
||||
});
|
||||
|
@ -83,7 +58,7 @@ let UserModel = BaseModel.extend({
|
|||
admin: false,
|
||||
accounts: [],
|
||||
|
||||
fullname: Ember.computed('firstname', 'lastname', function() {
|
||||
fullname: Ember.computed('firstname', 'lastname', function () {
|
||||
return `${this.get('firstname')} ${this.get('lastname')}`;
|
||||
}),
|
||||
|
||||
|
@ -129,7 +104,7 @@ let DocumentModel = BaseModel.extend({
|
|||
tags: "",
|
||||
template: "",
|
||||
|
||||
slug: Ember.computed('name', function() {
|
||||
slug: Ember.computed('name', function () {
|
||||
return stringUtil.makeSlug(this.get('name'));
|
||||
}),
|
||||
|
||||
|
@ -144,7 +119,7 @@ let TemplateModel = BaseModel.extend({
|
|||
title: "",
|
||||
type: 0,
|
||||
|
||||
slug: Ember.computed('title', function() {
|
||||
slug: Ember.computed('title', function () {
|
||||
return stringUtil.makeSlug(this.get('title'));
|
||||
}),
|
||||
});
|
||||
|
@ -155,19 +130,19 @@ let FolderModel = BaseModel.extend({
|
|||
userId: "",
|
||||
folderType: constants.FolderType.Private,
|
||||
|
||||
slug: Ember.computed('name', function() {
|
||||
slug: Ember.computed('name', function () {
|
||||
return stringUtil.makeSlug(this.get('name'));
|
||||
}),
|
||||
|
||||
markAsRestricted: function() {
|
||||
markAsRestricted: function () {
|
||||
this.set('folderType', constants.FolderType.Protected);
|
||||
},
|
||||
|
||||
markAsPrivate: function() {
|
||||
markAsPrivate: function () {
|
||||
this.set('folderType', constants.FolderType.Private);
|
||||
},
|
||||
|
||||
markAsPublic: function() {
|
||||
markAsPublic: function () {
|
||||
this.set('folderType', constants.FolderType.Public);
|
||||
},
|
||||
|
||||
|
@ -196,15 +171,15 @@ let PageModel = BaseModel.extend({
|
|||
rawBody: "",
|
||||
meta: {},
|
||||
|
||||
tagName: Ember.computed('level', function() {
|
||||
tagName: Ember.computed('level', function () {
|
||||
return "h" + this.get('level');
|
||||
}),
|
||||
|
||||
tocIndent: Ember.computed('level', function() {
|
||||
tocIndent: Ember.computed('level', function () {
|
||||
return (this.get('level') - 1) * 20;
|
||||
}),
|
||||
|
||||
tocIndentCss: Ember.computed('tocIndent', function() {
|
||||
tocIndentCss: Ember.computed('tocIndent', function () {
|
||||
let tocIndent = this.get('tocIndent');
|
||||
return `margin-left-${tocIndent}`;
|
||||
}),
|
||||
|
@ -226,13 +201,12 @@ let SectionModel = BaseModel.extend({
|
|||
iconFont: "",
|
||||
iconFile: "",
|
||||
|
||||
hasImage: Ember.computed('iconFont', 'iconFile', function() {
|
||||
hasImage: Ember.computed('iconFont', 'iconFile', function () {
|
||||
return this.get('iconFile').length > 0;
|
||||
}),
|
||||
});
|
||||
|
||||
export default {
|
||||
AppMeta,
|
||||
TemplateModel,
|
||||
AttachmentModel,
|
||||
DocumentModel,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue