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-09-02 08:15:31 +08:00
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
var
|
2014-08-25 23:49:01 +08:00
|
|
|
ko = require('ko')
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
2014-10-30 21:59:25 +08:00
|
|
|
function AboutAdminSettings()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-08-25 15:10:51 +08:00
|
|
|
var
|
2014-09-06 05:44:29 +08:00
|
|
|
Settings = require('Storage/Settings'),
|
|
|
|
Data = require('Storage/Admin/Data')
|
2014-08-25 15:10:51 +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 = Data.coreReal;
|
2014-12-02 01:34:21 +08:00
|
|
|
this.coreChannel = Data.coreChannel;
|
|
|
|
this.coreType = Data.coreType;
|
2014-08-21 23:08:34 +08:00
|
|
|
this.coreUpdatable = Data.coreUpdatable;
|
|
|
|
this.coreAccess = Data.coreAccess;
|
|
|
|
this.coreChecking = Data.coreChecking;
|
|
|
|
this.coreUpdating = Data.coreUpdating;
|
|
|
|
this.coreRemoteVersion = Data.coreRemoteVersion;
|
|
|
|
this.coreRemoteRelease = Data.coreRemoteRelease;
|
|
|
|
this.coreVersionCompare = Data.coreVersionCompare;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
AboutAdminSettings.prototype.onBuild = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
|
|
|
if (this.access())
|
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
require('App/Admin').reloadCoreData();
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
AboutAdminSettings.prototype.updateCoreData = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
|
|
|
if (!this.coreUpdating())
|
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
require('App/Admin').updateCoreData();
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-30 21:59:25 +08:00
|
|
|
module.exports = AboutAdminSettings;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
}());
|