snappymail/dev/Settings/Admin/Licensing.js

79 lines
1.7 KiB
JavaScript
Raw Normal View History

2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
(function () {
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
Settings = require('Storage/Settings'),
LicenseStore = require('Stores/Admin/License')
2014-08-21 23:08:34 +08:00
;
/**
* @constructor
*/
function LicensingAdminSettings()
2014-08-21 23:08:34 +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())
{
require('App/Admin').reloadLicensing(true);
2014-08-21 23:08:34 +08:00
}
}, this);
}
LicensingAdminSettings.prototype.onBuild = function ()
2014-08-21 23:08:34 +08:00
{
if (this.subscriptionEnabled())
{
require('App/Admin').reloadLicensing(false);
2014-08-21 23:08:34 +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
};
LicensingAdminSettings.prototype.showActivationForm = function ()
2014-08-21 23:08:34 +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}
*/
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
module.exports = LicensingAdminSettings;
2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
}());