mirror of
https://github.com/documize/community.git
synced 2025-07-28 09:39:42 +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';
|
import TooltipMixin from '../../mixins/tooltip';
|
||||||
|
|
||||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
userService: Ember.inject.service('user'),
|
userService: Ember.inject.service('user'),
|
||||||
localStorage: Ember.inject.service(),
|
localStorage: Ember.inject.service(),
|
||||||
drop: null,
|
drop: null,
|
||||||
|
@ -44,12 +45,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 url = this.get('appMeta.url');
|
let url = this.get('appMeta.endpoint');
|
||||||
let uploadUrl = `${url}/documents/${documentId}/attachments`;
|
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.get('localStorage').getSessionItem('session.session.authenticated.token')
|
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('token')
|
||||||
},
|
},
|
||||||
url: uploadUrl,
|
url: uploadUrl,
|
||||||
method: "post",
|
method: "post",
|
||||||
|
@ -61,22 +62,22 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
addRemoveLinks: false,
|
addRemoveLinks: false,
|
||||||
autoProcessQueue: true,
|
autoProcessQueue: true,
|
||||||
|
|
||||||
init: function() {
|
init: function () {
|
||||||
this.on("success", function(file /*, response*/ ) {
|
this.on("success", function (file /*, response*/ ) {
|
||||||
self.showNotification(`Attached ${file.name}`);
|
self.showNotification(`Attached ${file.name}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on("queuecomplete", function() {
|
this.on("queuecomplete", function () {
|
||||||
self.attrs.onAttachmentUpload();
|
self.attrs.onAttachmentUpload();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on("addedfile", function( /*file*/ ) {
|
this.on("addedfile", function ( /*file*/ ) {
|
||||||
self.audit.record('attached-file');
|
self.audit.record('attached-file');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dzone.on("complete", function(file) {
|
dzone.on("complete", function (file) {
|
||||||
dzone.removeFile(file);
|
dzone.removeFile(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -73,14 +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 url = this.get('appMeta.url');
|
let url = this.get('appMeta.endpoint');
|
||||||
let importUrl = `${url}/import/folder/${folderId}`;
|
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.get('localStorage').getSessionItem('session.session.authenticated.token')
|
'Authorization': 'Bearer ' + self.get('localStorage').getSessionItem('token')
|
||||||
},
|
},
|
||||||
url: importUrl,
|
url: importUrl,
|
||||||
method: "post",
|
method: "post",
|
||||||
|
@ -93,26 +93,25 @@ export default Ember.Component.extend(NotifierMixin, {
|
||||||
addRemoveLinks: false,
|
addRemoveLinks: false,
|
||||||
autoProcessQueue: true,
|
autoProcessQueue: true,
|
||||||
|
|
||||||
init: function() {
|
init: function () {
|
||||||
this.on("success", function(document) {
|
this.on("success", function (document) {
|
||||||
self.attrs.onDocumentImported(document.name, 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
|
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.attrs.onDocumentImporting(file.name);
|
||||||
self.audit.record('converted-document');
|
self.audit.record('converted-document');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dzone.on("complete", function(file) {
|
dzone.on("complete", function (file) {
|
||||||
dzone.removeFile(file);
|
dzone.removeFile(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ const {
|
||||||
export default Ember.Service.extend({
|
export default Ember.Service.extend({
|
||||||
ajax: service(),
|
ajax: service(),
|
||||||
|
|
||||||
url: `${config.apiHost}/${config.apiNamespace}`,
|
endpoint: `${config.apiHost}/${config.apiNamespace}`,
|
||||||
orgId: '',
|
orgId: '',
|
||||||
title: '',
|
title: '',
|
||||||
version: '',
|
version: '',
|
||||||
|
@ -44,11 +44,11 @@ export default Ember.Service.extend({
|
||||||
title: htmlSafe("Documize Setup"),
|
title: htmlSafe("Documize Setup"),
|
||||||
allowAnonymousAccess: false
|
allowAnonymousAccess: false
|
||||||
});
|
});
|
||||||
|
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('ajax').request('public/meta')
|
return this.get('ajax').request('public/meta').then((response) => {
|
||||||
.then((response) => {
|
|
||||||
this.setProperties(response);
|
this.setProperties(response);
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{{#each attachments key="id" as |a index|}}
|
{{#each attachments key="id" as |a index|}}
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<img class="icon" src="assets/img/attachments/{{document/file-icon a.extension}}" />
|
<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>
|
<span class="file">{{ a.filename }}</span>
|
||||||
</a>
|
</a>
|
||||||
{{#if isEditor}}
|
{{#if isEditor}}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import stringUtil from '../utils/string';
|
import stringUtil from '../utils/string';
|
||||||
import config from '../config/environment';
|
|
||||||
import constants from '../utils/constants';
|
import constants from '../utils/constants';
|
||||||
|
|
||||||
let BaseModel = Ember.Object.extend({
|
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({
|
let FolderPermissionModel = Ember.Object.extend({
|
||||||
orgId: "",
|
orgId: "",
|
||||||
folderId: "",
|
folderId: "",
|
||||||
|
@ -68,7 +43,7 @@ let ProtectedFolderParticipant = Ember.Object.extend({
|
||||||
folderId: "",
|
folderId: "",
|
||||||
folderType: 0,
|
folderType: 0,
|
||||||
|
|
||||||
fullname: Ember.computed('firstname', 'lastname', function() {
|
fullname: Ember.computed('firstname', 'lastname', function () {
|
||||||
return `${this.get('firstname')} ${this.get('lastname')}`;
|
return `${this.get('firstname')} ${this.get('lastname')}`;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -83,7 +58,7 @@ let UserModel = BaseModel.extend({
|
||||||
admin: false,
|
admin: false,
|
||||||
accounts: [],
|
accounts: [],
|
||||||
|
|
||||||
fullname: Ember.computed('firstname', 'lastname', function() {
|
fullname: Ember.computed('firstname', 'lastname', function () {
|
||||||
return `${this.get('firstname')} ${this.get('lastname')}`;
|
return `${this.get('firstname')} ${this.get('lastname')}`;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -129,7 +104,7 @@ let DocumentModel = BaseModel.extend({
|
||||||
tags: "",
|
tags: "",
|
||||||
template: "",
|
template: "",
|
||||||
|
|
||||||
slug: Ember.computed('name', function() {
|
slug: Ember.computed('name', function () {
|
||||||
return stringUtil.makeSlug(this.get('name'));
|
return stringUtil.makeSlug(this.get('name'));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -144,7 +119,7 @@ let TemplateModel = BaseModel.extend({
|
||||||
title: "",
|
title: "",
|
||||||
type: 0,
|
type: 0,
|
||||||
|
|
||||||
slug: Ember.computed('title', function() {
|
slug: Ember.computed('title', function () {
|
||||||
return stringUtil.makeSlug(this.get('title'));
|
return stringUtil.makeSlug(this.get('title'));
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -155,19 +130,19 @@ let FolderModel = BaseModel.extend({
|
||||||
userId: "",
|
userId: "",
|
||||||
folderType: constants.FolderType.Private,
|
folderType: constants.FolderType.Private,
|
||||||
|
|
||||||
slug: Ember.computed('name', function() {
|
slug: Ember.computed('name', function () {
|
||||||
return stringUtil.makeSlug(this.get('name'));
|
return stringUtil.makeSlug(this.get('name'));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
markAsRestricted: function() {
|
markAsRestricted: function () {
|
||||||
this.set('folderType', constants.FolderType.Protected);
|
this.set('folderType', constants.FolderType.Protected);
|
||||||
},
|
},
|
||||||
|
|
||||||
markAsPrivate: function() {
|
markAsPrivate: function () {
|
||||||
this.set('folderType', constants.FolderType.Private);
|
this.set('folderType', constants.FolderType.Private);
|
||||||
},
|
},
|
||||||
|
|
||||||
markAsPublic: function() {
|
markAsPublic: function () {
|
||||||
this.set('folderType', constants.FolderType.Public);
|
this.set('folderType', constants.FolderType.Public);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -196,15 +171,15 @@ let PageModel = BaseModel.extend({
|
||||||
rawBody: "",
|
rawBody: "",
|
||||||
meta: {},
|
meta: {},
|
||||||
|
|
||||||
tagName: Ember.computed('level', function() {
|
tagName: Ember.computed('level', function () {
|
||||||
return "h" + this.get('level');
|
return "h" + this.get('level');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
tocIndent: Ember.computed('level', function() {
|
tocIndent: Ember.computed('level', function () {
|
||||||
return (this.get('level') - 1) * 20;
|
return (this.get('level') - 1) * 20;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
tocIndentCss: Ember.computed('tocIndent', function() {
|
tocIndentCss: Ember.computed('tocIndent', function () {
|
||||||
let tocIndent = this.get('tocIndent');
|
let tocIndent = this.get('tocIndent');
|
||||||
return `margin-left-${tocIndent}`;
|
return `margin-left-${tocIndent}`;
|
||||||
}),
|
}),
|
||||||
|
@ -226,13 +201,12 @@ let SectionModel = BaseModel.extend({
|
||||||
iconFont: "",
|
iconFont: "",
|
||||||
iconFile: "",
|
iconFile: "",
|
||||||
|
|
||||||
hasImage: Ember.computed('iconFont', 'iconFile', function() {
|
hasImage: Ember.computed('iconFont', 'iconFile', function () {
|
||||||
return this.get('iconFile').length > 0;
|
return this.get('iconFile').length > 0;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
AppMeta,
|
|
||||||
TemplateModel,
|
TemplateModel,
|
||||||
AttachmentModel,
|
AttachmentModel,
|
||||||
DocumentModel,
|
DocumentModel,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue