2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
(function () {
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
'use strict';
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
var
|
2014-08-25 23:49:01 +08:00
|
|
|
ko = require('ko'),
|
|
|
|
moment = require('moment'),
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
Settings = require('Storage/Settings'),
|
2015-01-27 05:06:00 +08:00
|
|
|
LicenseStore = require('Stores/Admin/License')
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
2014-10-30 21:59:25 +08:00
|
|
|
function LicensingAdminSettings()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2015-01-27 05:06:00 +08:00
|
|
|
this.licensing = LicenseStore.licensing;
|
|
|
|
this.licensingProcess = LicenseStore.licensingProcess;
|
|
|
|
this.licenseValid = LicenseStore.licenseValid;
|
|
|
|
this.licenseExpired = LicenseStore.licenseExpired;
|
|
|
|
this.licenseError = LicenseStore.licenseError;
|
|
|
|
this.licenseTrigger = LicenseStore.licenseTrigger;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
this.adminDomain = ko.observable('');
|
2014-08-27 23:59:44 +08:00
|
|
|
this.subscriptionEnabled = ko.observable(!!Settings.settingsGet('SubscriptionEnabled'));
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
this.licenseTrigger.subscribe(function () {
|
|
|
|
if (this.subscriptionEnabled())
|
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
require('App/Admin').reloadLicensing(true);
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
LicensingAdminSettings.prototype.onBuild = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
|
|
|
if (this.subscriptionEnabled())
|
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
require('App/Admin').reloadLicensing(false);
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
LicensingAdminSettings.prototype.onShow = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-08-27 23:59:44 +08:00
|
|
|
this.adminDomain(Settings.settingsGet('AdminDomain'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
LicensingAdminSettings.prototype.showActivationForm = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Activate'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
2014-11-15 04:23:46 +08:00
|
|
|
/**
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
LicensingAdminSettings.prototype.licenseIsUnlim = function ()
|
|
|
|
{
|
|
|
|
return 1898625600 === this.licenseExpired();
|
|
|
|
};
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2014-10-30 21:59:25 +08:00
|
|
|
LicensingAdminSettings.prototype.licenseExpiredMomentValue = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
|
|
|
var
|
|
|
|
iTime = this.licenseExpired(),
|
|
|
|
oDate = moment.unix(iTime)
|
|
|
|
;
|
|
|
|
|
2014-11-15 04:23:46 +08:00
|
|
|
return this.licenseIsUnlim() ? 'Never' :
|
|
|
|
(iTime && (oDate.format('LL') + ' (' + oDate.from(moment()) + ')'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
2014-08-25 15:10:51 +08:00
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
module.exports = LicensingAdminSettings;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
}());
|