2014-08-21 23:08:34 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
var
|
|
|
|
ko = require('ko'),
|
|
|
|
|
|
|
|
Translator = require('Common/Translator'),
|
|
|
|
|
|
|
|
Settings = require('Storage/Settings'),
|
|
|
|
CoreStore = require('Stores/Admin/Core'),
|
|
|
|
AppStore = require('Stores/Admin/App');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function AboutAdminSettings()
|
|
|
|
{
|
|
|
|
this.version = ko.observable(Settings.appSettingsGet('version'));
|
|
|
|
this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
|
|
|
|
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.coreWarning = CoreStore.coreWarning;
|
|
|
|
this.coreVersion = CoreStore.coreVersion;
|
|
|
|
this.coreRemoteVersion = CoreStore.coreRemoteVersion;
|
|
|
|
this.coreRemoteRelease = CoreStore.coreRemoteRelease;
|
|
|
|
this.coreVersionCompare = CoreStore.coreVersionCompare;
|
|
|
|
|
|
|
|
this.community = RL_COMMUNITY || AppStore.community();
|
|
|
|
|
|
|
|
this.coreRemoteVersionHtmlDesc = ko.computed(function() {
|
|
|
|
Translator.trigger();
|
|
|
|
return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
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.');
|
|
|
|
}
|
2015-01-27 05:06:00 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
return sType;
|
2015-03-28 06:06:56 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
}, this);
|
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
AboutAdminSettings.prototype.onBuild = function()
|
|
|
|
{
|
|
|
|
if (this.access() && !this.community)
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2016-06-30 08:02:45 +08:00
|
|
|
require('App/Admin').default.reloadCoreData();
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
};
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
AboutAdminSettings.prototype.updateCoreData = function()
|
|
|
|
{
|
|
|
|
if (!this.coreUpdating() && !this.community)
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2016-06-30 08:02:45 +08:00
|
|
|
require('App/Admin').default.updateCoreData();
|
|
|
|
}
|
|
|
|
};
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-07-16 03:54:37 +08:00
|
|
|
export {AboutAdminSettings, AboutAdminSettings as default};
|