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",
|
||||
|
|
|
@ -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",
|
||||
|
@ -102,8 +102,7 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
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) {
|
||||
self.attrs.onDocumentImporting(file.name);
|
||||
|
|
|
@ -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: "",
|
||||
|
@ -232,7 +207,6 @@ let SectionModel = BaseModel.extend({
|
|||
});
|
||||
|
||||
export default {
|
||||
AppMeta,
|
||||
TemplateModel,
|
||||
AttachmentModel,
|
||||
DocumentModel,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue