Browse Source

Use server refresh interval

Use torrents table refresh interval from server in web-client.
adaptive-webui-19844
buinsky 10 years ago
parent
commit
8931eec5b0
  1. 4
      src/webui/btjson.cpp
  2. 7
      src/webui/www/public/scripts/client.js

4
src/webui/btjson.cpp

@ -147,6 +147,7 @@ static const char KEY_TRANSFER_CONNECTION_STATUS[] = "connection_status";
// Sync main data keys // Sync main data keys
static const char KEY_SYNC_MAINDATA_QUEUEING[] = "queueing"; static const char KEY_SYNC_MAINDATA_QUEUEING[] = "queueing";
static const char KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS[] = "use_alt_speed_limits"; static const char KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS[] = "use_alt_speed_limits";
static const char KEY_SYNC_MAINDATA_REFRESH_INTERVAL[] = "refresh_interval";
static const char KEY_FULL_UPDATE[] = "full_update"; static const char KEY_FULL_UPDATE[] = "full_update";
static const char KEY_RESPONSE_ID[] = "rid"; static const char KEY_RESPONSE_ID[] = "rid";
@ -306,6 +307,7 @@ QByteArray btjson::getTorrents(QString filter, QString label,
* - "up_info_speed: upload speed * - "up_info_speed: upload speed
* - "up_rate_limit: upload speed limit * - "up_rate_limit: upload speed limit
* - "queueing": priority system usage flag * - "queueing": priority system usage flag
* - "refresh_interval": torrents table refresh interval
*/ */
QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData, QVariantMap &lastAcceptedData) QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData, QVariantMap &lastAcceptedData)
{ {
@ -335,6 +337,7 @@ QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData
QVariantMap serverState = getTranserInfoMap(); QVariantMap serverState = getTranserInfoMap();
serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled();
serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = Preferences::instance()->isAltBandwidthEnabled(); serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = Preferences::instance()->isAltBandwidthEnabled();
serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = Preferences::instance()->getRefreshInterval();
data["server_state"] = serverState; data["server_state"] = serverState;
return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData)); return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData));
@ -610,6 +613,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
case QVariant::Bool: case QVariant::Bool:
case QVariant::Double: case QVariant::Double:
case QVariant::ULongLong: case QVariant::ULongLong:
case QVariant::UInt:
if (prevData[key] != data[key]) if (prevData[key] != data[key])
syncData[key] = data[key]; syncData[key] = data[key];
break; break;

7
src/webui/www/public/scripts/client.js

@ -28,6 +28,7 @@ var updatePropertiesPanel = function(){};
var updateMainData = function(){}; var updateMainData = function(){};
var alternativeSpeedLimits = false; var alternativeSpeedLimits = false;
var queueing_enabled = true; var queueing_enabled = true;
var syncMainDataTimerPeriod = 1500;
selected_filter = getLocalStorageItem('selected_filter', 'all'); selected_filter = getLocalStorageItem('selected_filter', 'all');
selected_label = null; selected_label = null;
@ -174,7 +175,7 @@ window.addEvent('load', function () {
} }
} }
clearTimeout(syncMainDataTimer); clearTimeout(syncMainDataTimer);
syncMainDataTimer = syncMainData.delay(1500); syncMainDataTimer = syncMainData.delay(syncMainDataTimerPeriod);
} }
}).send(); }).send();
}; };
@ -228,6 +229,10 @@ window.addEvent('load', function () {
alternativeSpeedLimits = serverState.use_alt_speed_limits; alternativeSpeedLimits = serverState.use_alt_speed_limits;
updateAltSpeedIcon(alternativeSpeedLimits); updateAltSpeedIcon(alternativeSpeedLimits);
} }
syncMainDataTimerPeriod = serverState.refresh_interval;
if (syncMainDataTimerPeriod < 500)
syncMainDataTimerPeriod = 500;
}; };
var updateAltSpeedIcon = function(enabled) { var updateAltSpeedIcon = function(enabled) {

Loading…
Cancel
Save