1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00
documize/gui/app/services/app-meta.js

88 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-07-07 18:54:16 -07:00
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
2016-07-07 18:54:16 -07:00
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
2016-07-07 18:54:16 -07:00
//
// https://documize.com
import { htmlSafe } from '@ember/string';
import { resolve } from 'rsvp';
import Service, { inject as service } from '@ember/service';
2016-07-07 18:54:16 -07:00
import config from '../config/environment';
import constants from '../utils/constants';
2016-07-07 18:54:16 -07:00
export default Service.extend({
2016-07-07 18:54:16 -07:00
ajax: service(),
localStorage: service(),
kcAuth: service(),
2017-04-03 16:34:42 +01:00
apiHost: `${config.apiHost}`,
2016-07-08 16:08:23 -07:00
endpoint: `${config.apiHost}/${config.apiNamespace}`,
conversionEndpoint: '',
2016-07-07 18:54:16 -07:00
orgId: '',
title: '',
version: '',
message: '',
2017-02-23 16:39:23 -08:00
edition: 'Community',
valid: true,
2016-07-07 18:54:16 -07:00
allowAnonymousAccess: false,
authProvider: constants.AuthProvider.Documize,
2017-03-14 17:19:53 +00:00
authConfig: null,
setupMode: false,
2017-08-29 17:55:41 +01:00
secureMode: false,
2016-07-07 18:54:16 -07:00
2017-02-23 16:39:23 -08:00
invalidLicense() {
return this.valid === false;
},
2016-07-07 18:54:16 -07:00
getBaseUrl(endpoint) {
2016-07-26 11:48:40 -07:00
return [this.get('endpoint'), endpoint].join('/');
2016-07-07 18:54:16 -07:00
},
2017-05-03 11:37:39 +01:00
boot(requestedRoute, requestedUrl) { // eslint-disable-line no-unused-vars
2016-07-07 18:54:16 -07:00
let dbhash;
if (is.not.null(document.head.querySelector("[property=dbhash]"))) {
dbhash = document.head.querySelector("[property=dbhash]").content;
}
let isInSetupMode = dbhash && dbhash !== "{{.DBhash}}";
if (isInSetupMode) {
this.setProperties({
2016-07-07 18:54:16 -07:00
title: htmlSafe("Documize Setup"),
allowAnonymousAccess: true,
setupMode: true
2016-07-07 18:54:16 -07:00
});
this.get('localStorage').clearAll();
2016-07-08 16:08:23 -07:00
return resolve(this);
2016-07-07 18:54:16 -07:00
}
2017-05-03 11:37:39 +01:00
if (requestedRoute === 'secure') {
2017-03-22 12:21:18 +00:00
this.setProperties({
title: htmlSafe("Secure document viewing"),
allowAnonymousAccess: true,
2017-08-29 17:55:41 +01:00
secureMode: true
2017-03-22 12:21:18 +00:00
});
this.get('localStorage').clearAll();
return resolve(this);
}
2016-07-08 16:08:23 -07:00
return this.get('ajax').request('public/meta').then((response) => {
this.setProperties(response);
if (is.not.include(requestedUrl, '/auth/')) {
this.get('localStorage').storeSessionItem('entryUrl', requestedUrl);
}
2016-07-08 16:08:23 -07:00
return response;
});
2016-07-07 18:54:16 -07:00
}
});