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-08-27 23:59:44 +08:00
|
|
|
Settings = require('Storage:Settings'),
|
|
|
|
Data = require('Storage:Admin:Data')
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function AdminSettingsLicensing()
|
|
|
|
{
|
|
|
|
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-08-27 23:59:44 +08:00
|
|
|
require('App:Admin').reloadLicensing(true);
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
AdminSettingsLicensing.prototype.onBuild = function ()
|
|
|
|
{
|
|
|
|
if (this.subscriptionEnabled())
|
|
|
|
{
|
2014-08-27 23:59:44 +08:00
|
|
|
require('App:Admin').reloadLicensing(false);
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
AdminSettingsLicensing.prototype.onShow = function ()
|
|
|
|
{
|
2014-08-27 23:59:44 +08:00
|
|
|
this.adminDomain(Settings.settingsGet('AdminDomain'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
AdminSettingsLicensing.prototype.showActivationForm = function ()
|
|
|
|
{
|
2014-08-27 23:59:44 +08:00
|
|
|
require('App:Knoin').showScreenPopup(require('View:Popup:Activate'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
AdminSettingsLicensing.prototype.licenseExpiredMomentValue = function ()
|
|
|
|
{
|
|
|
|
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-08-21 23:08:34 +08:00
|
|
|
module.exports = AdminSettingsLicensing;
|
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
}());
|