snappymail/dev/Settings/Admin/About.js

88 lines
1.8 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-21 23:08:34 +08:00
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-21 23:08:34 +08:00
var
ko = require('ko'),
Settings = require('Storage/Settings'),
CoreStore = require('Stores/Admin/Core')
2014-08-21 23:08:34 +08:00
;
/**
* @constructor
*/
function AboutAdminSettings()
2014-08-21 23:08:34 +08:00
{
2014-08-27 23:59:44 +08:00
this.version = ko.observable(Settings.settingsGet('Version'));
this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
2014-08-21 23:08:34 +08:00
this.errorDesc = ko.observable('');
this.coreReal = CoreStore.coreReal;
this.coreChannel = CoreStore.coreChannel;
this.coreType = CoreStore.coreType;
this.coreUpdatable = CoreStore.coreUpdatable;
this.coreAccess = CoreStore.coreAccess;
this.coreChecking = CoreStore.coreChecking;
this.coreUpdating = CoreStore.coreUpdating;
this.coreRemoteVersion = CoreStore.coreRemoteVersion;
this.coreRemoteRelease = CoreStore.coreRemoteRelease;
this.coreVersionCompare = CoreStore.coreVersionCompare;
2014-08-21 23:08:34 +08:00
this.statusType = ko.computed(function () {
var
sType = '',
iVersionCompare = this.coreVersionCompare(),
bChecking = this.coreChecking(),
bUpdating = this.coreUpdating(),
bReal = this.coreReal()
;
if (bChecking)
{
sType = 'checking';
}
else if (bUpdating)
{
sType = 'updating';
}
else if (bReal && 0 === iVersionCompare)
{
sType = 'up-to-date';
}
else if (bReal && -1 === iVersionCompare)
{
sType = 'available';
}
else if (!bReal)
{
sType = 'error';
this.errorDesc('Cannot access the repository at the moment.');
}
return sType;
}, this);
}
AboutAdminSettings.prototype.onBuild = function ()
2014-08-21 23:08:34 +08:00
{
if (this.access())
{
require('App/Admin').reloadCoreData();
2014-08-21 23:08:34 +08:00
}
};
AboutAdminSettings.prototype.updateCoreData = function ()
2014-08-21 23:08:34 +08:00
{
if (!this.coreUpdating())
{
require('App/Admin').updateCoreData();
2014-08-21 23:08:34 +08:00
}
};
module.exports = AboutAdminSettings;
2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
}());