2014-08-21 23:08:34 +08:00
|
|
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
|
|
|
|
|
|
(function (module) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var
|
|
|
|
ko = require('../External/ko.js'),
|
|
|
|
moment = require('../External/moment.js'),
|
|
|
|
|
2014-08-22 23:08:56 +08:00
|
|
|
AppSettings = require('../Storages/AppSettings.js'),
|
2014-08-21 23:08:34 +08:00
|
|
|
Data = require('../Storages/AdminDataStorage.js'),
|
2014-08-22 23:08:56 +08:00
|
|
|
|
|
|
|
RL = require('../Boots/AdminApp.js'),
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
kn = require('../Knoin/Knoin.js'),
|
|
|
|
PopupsActivateViewModel = require('../ViewModels/Popups/PopupsActivateViewModel.js')
|
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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-22 23:08:56 +08:00
|
|
|
this.subscriptionEnabled = ko.observable(!!AppSettings.settingsGet('SubscriptionEnabled'));
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
this.licenseTrigger.subscribe(function () {
|
|
|
|
if (this.subscriptionEnabled())
|
|
|
|
{
|
|
|
|
RL.reloadLicensing(true);
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
AdminSettingsLicensing.prototype.onBuild = function ()
|
|
|
|
{
|
|
|
|
if (this.subscriptionEnabled())
|
|
|
|
{
|
|
|
|
RL.reloadLicensing(false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
AdminSettingsLicensing.prototype.onShow = function ()
|
|
|
|
{
|
2014-08-22 23:08:56 +08:00
|
|
|
this.adminDomain(AppSettings.settingsGet('AdminDomain'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
AdminSettingsLicensing.prototype.showActivationForm = function ()
|
|
|
|
{
|
|
|
|
kn.showScreenPopup(PopupsActivateViewModel);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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()) + ')');
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = AdminSettingsLicensing;
|
|
|
|
|
|
|
|
}(module));
|