diff --git a/gui/app/components/customize/change-log.js b/gui/app/components/customize/change-log.js new file mode 100644 index 00000000..01244e19 --- /dev/null +++ b/gui/app/components/customize/change-log.js @@ -0,0 +1,39 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// 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 . +// +// https://documize.com + +import $ from 'jquery'; +import { inject as service } from '@ember/service'; +import Notifier from '../../mixins/notifier'; +import Component from '@ember/component'; + +export default Component.extend(Notifier, { + appMeta: service(), + global: service(), + changelog: '', + + init() { + this._super(...arguments); + + let self = this; + let cacheBuster = + new Date(); + $.ajax({ + url: `https://storage.googleapis.com/documize/news/summary.html?cb=${cacheBuster}`, + type: 'GET', + dataType: 'html', + success: function (response) { + self.set('changelog', response); + } + }); + }, + + actions: { + } +}); diff --git a/gui/app/components/customize/license-key.js b/gui/app/components/customize/license-key.js index 9eb271d8..f13928ae 100644 --- a/gui/app/components/customize/license-key.js +++ b/gui/app/components/customize/license-key.js @@ -9,7 +9,6 @@ // // https://documize.com -import $ from 'jquery'; import { empty } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import Notifier from '../../mixins/notifier'; @@ -18,20 +17,21 @@ import Component from '@ember/component'; export default Component.extend(Notifier, { appMeta: service(), global: service(), - LicenseError: empty('license'), - changelog: '', + licenseError: empty('license'), + subscription: null, + planCloud: false, + planSelfhost: false, - init() { + didReceiveAttrs() { this._super(...arguments); - - let self = this; - let cacheBuster = + new Date(); - $.ajax({ - url: `https://storage.googleapis.com/documize/news/summary.html?cb=${cacheBuster}`, - type: 'GET', - dataType: 'html', - success: function (response) { - self.set('changelog', response); + this.get('global').getSubscription().then((subs) => { + this.set('subscription', subs); + if (subs.plan === 'Installed') { + this.set('planCloud', false); + this.set('planSelfhost', true); + } else { + this.set('planCloud', true); + this.set('planSelfhost', false); } }); }, @@ -40,7 +40,7 @@ export default Component.extend(Notifier, { saveLicense() { this.showWait(); - this.get('global').saveLicense(this.get('license')).then(() => { + this.get('global').setLicense(this.get('license')).then(() => { this.showDone(); window.location.reload(); }); diff --git a/gui/app/components/layout/top-bar.js b/gui/app/components/layout/top-bar.js index f0e1b99f..fe6682aa 100644 --- a/gui/app/components/layout/top-bar.js +++ b/gui/app/components/layout/top-bar.js @@ -13,9 +13,10 @@ import $ from 'jquery'; import { notEmpty } from '@ember/object/computed'; import { inject as service } from '@ember/service' import ModalMixin from '../../mixins/modal'; +import TooltipMixin from '../../mixins/tooltip'; import Component from '@ember/component'; -export default Component.extend(ModalMixin, { +export default Component.extend(ModalMixin, TooltipMixin, { classNames: ['layout-header', 'non-printable'], tagName: 'header', folderService: service('folder'), @@ -69,6 +70,8 @@ export default Component.extend(ModalMixin, { this.eventBus.subscribe('pinChange', this, 'setupPins'); this.setupPins(); } + + this.renderTooltips(); }, setupPins() { @@ -87,6 +90,7 @@ export default Component.extend(ModalMixin, { willDestroyElement() { this._super(...arguments); + this.removeTooltips(); this.eventBus.unsubscribe('pinChange'); }, @@ -113,6 +117,14 @@ export default Component.extend(ModalMixin, { this.get('session').seenNewVersion(); this.set('hasWhatsNew', false); } + }, + + onBilling() { + if (!this.get('session.isAdmin')) { + return; + } + + this.get('router').transitionTo('customize.billing'); } } }); diff --git a/gui/app/helpers/formatted-price.js b/gui/app/helpers/formatted-price.js new file mode 100644 index 00000000..9f0e840c --- /dev/null +++ b/gui/app/helpers/formatted-price.js @@ -0,0 +1,32 @@ +// Copyright 2016 Documize Inc. . All rights reserved. +// +// This software (Documize Community Edition) is licensed under +// 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 . +// +// https://documize.com + +import { helper } from '@ember/component/helper'; + +export function formattedPrice(params) { + let pence = params[0]; + + if(is.not.number(pence)) { + return '$0' + } + + let p = parseInt(pence); + + if(p === 0) { + return '$0' + } + + let a = pence / 100; + + return `$` + a; +} + +export default helper(formattedPrice); diff --git a/gui/app/pods/customize/license/template.hbs b/gui/app/pods/customize/license/template.hbs deleted file mode 100644 index e019dde0..00000000 --- a/gui/app/pods/customize/license/template.hbs +++ /dev/null @@ -1 +0,0 @@ -{{customize/license-key license=model}} diff --git a/gui/app/pods/customize/license/controller.js b/gui/app/pods/customize/product/controller.js similarity index 100% rename from gui/app/pods/customize/license/controller.js rename to gui/app/pods/customize/product/controller.js diff --git a/gui/app/pods/customize/license/route.js b/gui/app/pods/customize/product/route.js similarity index 84% rename from gui/app/pods/customize/license/route.js rename to gui/app/pods/customize/product/route.js index 5c338ef8..7034c2a5 100644 --- a/gui/app/pods/customize/license/route.js +++ b/gui/app/pods/customize/product/route.js @@ -10,8 +10,8 @@ // https://documize.com import { inject as service } from '@ember/service'; -import Route from '@ember/routing/route'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; +import Route from '@ember/routing/route'; export default Route.extend(AuthenticatedRouteMixin, { appMeta: service(), @@ -19,16 +19,15 @@ export default Route.extend(AuthenticatedRouteMixin, { global: service(), beforeModel() { - if (!this.get("session.isGlobalAdmin")) { + if (!this.get("session.isAdmin")) { this.transitionTo('auth.login'); } }, model() { - return this.get('global').getLicense(); }, activate() { - this.get('browser').setTitle('Product Licensing & Updates'); + this.get('browser').setTitle('Product Changelog'); } }); diff --git a/gui/app/pods/customize/product/template.hbs b/gui/app/pods/customize/product/template.hbs new file mode 100644 index 00000000..7e68401b --- /dev/null +++ b/gui/app/pods/customize/product/template.hbs @@ -0,0 +1 @@ +{{customize/change-log}} diff --git a/gui/app/pods/customize/template.hbs b/gui/app/pods/customize/template.hbs index d0e620c2..966aa1bf 100644 --- a/gui/app/pods/customize/template.hbs +++ b/gui/app/pods/customize/template.hbs @@ -10,27 +10,49 @@