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'),
|
|
|
|
Data = require('Storage/Admin/Data')
|
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
|
|
|
{
|
|
|
|
this.licensing = Data.licensing;
|
|
|
|
this.licensingProcess = Data.licensingProcess;
|
|
|
|
this.licenseValid = Data.licenseValid;
|
|
|
|
this.licenseExpired = Data.licenseExpired;
|
|
|
|
this.licenseError = Data.licenseError;
|
|
|
|
this.licenseTrigger = Data.licenseTrigger;
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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)
|
|
|
|
;
|
|
|
|
|
|
|
|
return iTime && 1898625600 === iTime ? 'Never' : (oDate.format('LL') + ' (' + oDate.from(moment()) + ')');
|
|
|
|
};
|
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
|
|
|
}());
|