Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
#60: active queue-scripts indicated in webui
Browse files Browse the repository at this point in the history
- the number of active (and queued) scripts are shown in the status
dialog in web-interface; this new row is hidden if no scripts are
queued;
- active queue scripts accounts for activity indicator in web-interface
(rotating button);
- new field “QueueScriptCount” in API-method “status” indicates number
of queue-scripts queued for execution including the currently running.
  • Loading branch information
hugbug committed Aug 11, 2015
1 parent 6e0a3e0 commit ca0af70
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
13 changes: 13 additions & 0 deletions daemon/extension/QueueScript.cpp
Expand Up @@ -504,3 +504,16 @@ bool QueueScriptCoordinator::HasJob(int iNZBID, bool* pActive)

return bWorking;
}

int QueueScriptCoordinator::GetQueueSize()
{
m_mutexQueue.Lock();
int iQueuedCount = m_Queue.size();
if (m_pCurItem)
{
iQueuedCount++;
}
m_mutexQueue.Unlock();

return iQueuedCount;
}
1 change: 1 addition & 0 deletions daemon/extension/QueueScript.h
Expand Up @@ -74,6 +74,7 @@ class QueueScriptCoordinator
void EnqueueScript(NZBInfo* pNZBInfo, EEvent eEvent);
void CheckQueue();
bool HasJob(int iNZBID, bool* pActive);
int GetQueueSize();
};

extern QueueScriptCoordinator* g_pQueueScriptCoordinator;
Expand Down
7 changes: 5 additions & 2 deletions daemon/remote/XmlRpc.cpp
Expand Up @@ -1267,6 +1267,7 @@ void StatusXmlCommand::Execute()
"<member><name>ServerTime</name><value><i4>%i</i4></value></member>\n"
"<member><name>ResumeTime</name><value><i4>%i</i4></value></member>\n"
"<member><name>FeedActive</name><value><boolean>%s</boolean></value></member>\n"
"<member><name>QueueScriptCount</name><value><i4>%i</i4></value></member>\n"
"<member><name>NewsServers</name><value><array><data>\n";

const char* XML_STATUS_END =
Expand Down Expand Up @@ -1308,6 +1309,7 @@ void StatusXmlCommand::Execute()
"\"ServerTime\" : %i,\n"
"\"ResumeTime\" : %i,\n"
"\"FeedActive\" : %s,\n"
"\"QueueScriptCount\" : %i,\n"
"\"NewsServers\" : [\n";

const char* JSON_STATUS_END =
Expand Down Expand Up @@ -1374,7 +1376,8 @@ void StatusXmlCommand::Execute()
int iServerTime = time(NULL);
int iResumeTime = g_pOptions->GetResumeTime();
bool bFeedActive = g_pFeedCoordinator->HasActiveDownloads();

int iQueuedScripts = g_pQueueScriptCoordinator->GetQueueSize();

char szContent[3072];
snprintf(szContent, 3072, IsJson() ? JSON_STATUS_START : XML_STATUS_START,
iRemainingSizeLo, iRemainingSizeHi, iRemainingMBytes, iForcedSizeLo,
Expand All @@ -1385,7 +1388,7 @@ void StatusXmlCommand::Execute()
BoolToStr(bDownloadPaused), BoolToStr(bDownloadPaused), BoolToStr(bDownloadPaused),
BoolToStr(bServerStandBy), BoolToStr(bPostPaused), BoolToStr(bScanPaused),
iFreeDiskSpaceLo, iFreeDiskSpaceHi, iFreeDiskSpaceMB, iServerTime, iResumeTime,
BoolToStr(bFeedActive));
BoolToStr(bFeedActive), iQueuedScripts);
szContent[3072-1] = '\0';

AppendResponse(szContent);
Expand Down
1 change: 1 addition & 0 deletions webui/index.html
Expand Up @@ -721,6 +721,7 @@ <h3 id="StatDialog_Title">Statistics and Status</h3>
<tr><td>Current download speed</td><td class="text-right" id="StatDialog_DataCurrentSpeed"></td></tr>
<tr><td>Current speed limit</td><td class="text-right" id="StatDialog_DataSpeedLimit"></td></tr>
<tr id="StatDialog_ArticleCache_Row"><td>Article cache</td><td class="text-right" id="StatDialog_ArticleCache"></td></tr>
<tr id="StatDialog_QueueScripts_Row"><td>Queue-scripts</td><td class="text-right" id="StatDialog_QueueScripts"></td></tr>
</tbody>
</table>
<br>
Expand Down
8 changes: 6 additions & 2 deletions webui/status.js
Expand Up @@ -229,7 +229,7 @@ var Status = (new function($)
function updatePlayAnim()
{
// Animate if either any downloads or post-processing is in progress
var Anim = (!status.ServerStandBy || status.FeedActive ||
var Anim = (!status.ServerStandBy || status.FeedActive || status.QueueScriptCount > 0 ||
(status.PostJobCount > 0 && !status.PostPaused) ||
(status.UrlCount > 0 && (!status.DownloadPaused || Options.option('UrlForce') === 'yes'))) &&
(UISettings.refreshInterval !== 0) && !UISettings.connectionError;
Expand Down Expand Up @@ -375,6 +375,7 @@ var StatDialog = (new function($)
var $StatDialog_DataCurrentSpeed;
var $StatDialog_DataSpeedLimit;
var $StatDialog_ArticleCache;
var $StatDialog_QueueScripts;
var $StatDialog_ChartBlock;
var $StatDialog_Server;
var $StatRangeDialog;
Expand Down Expand Up @@ -421,7 +422,8 @@ var StatDialog = (new function($)
$StatDialog_DataAverageSpeed = $('#StatDialog_DataAverageSpeed');
$StatDialog_DataCurrentSpeed = $('#StatDialog_DataCurrentSpeed');
$StatDialog_DataSpeedLimit = $('#StatDialog_DataSpeedLimit');
$StatDialog_ArticleCache = $('#StatDialog_ArticleCache');
$StatDialog_ArticleCache = $('#StatDialog_ArticleCache');
$StatDialog_QueueScripts = $('#StatDialog_QueueScripts');
$StatDialog_ChartBlock = $('#StatDialog_ChartBlock');
$StatDialog_Server = $('#StatDialog_Server');
$StatRangeDialog = $('#StatRangeDialog');
Expand Down Expand Up @@ -498,6 +500,7 @@ var StatDialog = (new function($)
$('#StatDialog_BackSpace').show();
$('#StatDialog_Title').text('Statistics and Status');
Util.show('#StatDialog_ArticleCache_Row', Options.option('ArticleCache') !== '0');
Util.show('#StatDialog_QueueScripts_Row', Status.status.QueueScriptCount > 0);
$StatDialog.removeClass('modal-large').addClass('modal-mini');
monthListInitialized = false;
updateServerList();
Expand Down Expand Up @@ -546,6 +549,7 @@ var StatDialog = (new function($)
$StatDialog_DataCurrentSpeed.html(Util.formatSpeed(status.DownloadRate));
$StatDialog_DataSpeedLimit.html(Util.formatSpeed(status.DownloadLimit));
$StatDialog_ArticleCache.html(Util.formatSizeMB(status.ArticleCacheMB, status.ArticleCacheLo));
$StatDialog_QueueScripts.html(status.QueueScriptCount);

var content = '';
content += '<tr><td>Download</td><td class="text-right">' +
Expand Down

0 comments on commit ca0af70

Please sign in to comment.