Commit 470bf527 authored by ecrombag's avatar ecrombag

Added auto-refreshing of the client in case a remote task is executed.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@698 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 1f46bf02
......@@ -665,7 +665,9 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
}
}]
});
itasks.WorkListPanel.superclass.initComponent.apply(this, arguments);
this.addEvents("workListRefreshed");
//Check session error responses
this.store.on('loadexception',function() {
......@@ -673,6 +675,8 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
itasks.app.restart(this.store.reader.jsonData.error);
}
},this);
this.startAutoRefresh();
},
/*
* Return the taskid of the selected row
......@@ -687,7 +691,28 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
this.store.load({
params: {_session: itasks.app.session}
});
}
this.fireEvent("workListRefreshed", this);
},
/*
* Start the timed task for auto-refreshing.
*/
startAutoRefresh: function(){
console.log(itasks.config);
if(itasks.config.autoRefresh){
var parent = this;
Ext.TaskMgr.start({
run: function(){
parent.refresh();
},
interval: itasks.config.refreshRate
})
}
},
});
Ext.reg('itasks.worklist',itasks.WorkListPanel);
......@@ -939,6 +964,7 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
this.on("remoteCallEnd",function() {
this.getComponent(0).setBusy(false);
},this);
this.on("workListRefreshed",this.receiveWorkListRefreshEvent,this);
},
update: function(data) {
......@@ -1035,6 +1061,10 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
},
scope: this
});
},
receiveWorkListRefreshEvent: function(worklist){
console.log("Refresh!");
console.log(worklist);
}
});
......
This diff is collapsed.
......@@ -3,4 +3,6 @@
, appTitle: "iTasks"
, skin: "default"
, debug: true
, autoRefresh: true
, refreshRate: 2000
}
\ No newline at end of file
......@@ -87,6 +87,22 @@ itasks.ApplicationPanel = Ext.extend(Ext.Panel, {
worklist.on("cellclick",function (grid,row,col,event) {
attachTabHandlers(worktabs.openWorkTab(grid.getTaskId(row)));
});
worklist.on("workListRefreshed",function(worklist) {
worklist.workStore.each(function(){
var tab = worktabs.getComponent("worktab-"+this.data.taskid);
var wlTStamp = this.data.latestExtEvent;
if(tab != null){
var tTStamp = tab.properties.systemProps.latestEvent
if(wlTStamp > tTStamp){
tab.refresh();
}
}
});
});
newpanel.on("processStarted",function(taskid) {
//When new work is started, refresh the worklist
//and immediately open a tab for the work
......
......@@ -55,6 +55,7 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
{name: 'progress'},
{name: 'delegatorName'},
{name: 'timestamp'},
{name: 'latestExtEvent'},
{name: 'deadline'},
{name: 'tree_path'},
{name: 'tree_last'},
......@@ -81,7 +82,8 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
{id: 'priority', header: 'Priority', dataindex: 'priority', renderer: itasks.util.formatPriority, width: 100},
{id: 'progress', header: 'Progress', dataindex: 'progress', renderer: itasks.util.formatProgress, width: 100},
{id: 'delegatorName', header: 'Managed by', dataIndex: 'delegatorName', width: 100},
{id: 'timestamp', header: 'Date', dataIndex: 'timestamp', renderer: itasks.util.formatDate, width: 100},
{id: 'timestamp', header: 'Date', dataIndex: 'timestamp', renderer: itasks.util.formatDate, width: 120},
{id: 'latestExtEvent', header: 'Latest Ext Event', dataIndex: 'latestExtEvent', renderer: itasks.util.formatDate, width: 120},
{id: 'deadline', header: 'Deadline', dataIndex: 'deadline', renderer: itasks.util.formatDeadline, width: 100}
],
autoExpandColumn: 'subject',
......@@ -103,7 +105,9 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
}
}]
});
itasks.WorkListPanel.superclass.initComponent.apply(this, arguments);
this.addEvents("workListRefreshed");
//Check session error responses
this.store.on('loadexception',function() {
......@@ -111,7 +115,10 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
itasks.app.restart(this.store.reader.jsonData.error);
}
},this);
this.startAutoRefresh();
},
/*
* Return the taskid of the selected row
*/
......@@ -122,10 +129,31 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
* Refresh the list
*/
refresh: function () {
this.store.load({
params: {_session: itasks.app.session}
});
}
if(this.store != null){
this.store.load({
params: {_session: itasks.app.session}
});
this.fireEvent("workListRefreshed", this);
}
},
/*
* Start the timed task for auto-refreshing.
*/
startAutoRefresh: function(){
if(itasks.config.autoRefresh){
var parent = this;
Ext.TaskMgr.start({
run: function(){
parent.refresh();
},
interval: itasks.config.refreshRate
})
}
},
});
Ext.reg('itasks.worklist',itasks.WorkListPanel);
......@@ -580,7 +580,7 @@ itasks.TaskWaitingPanel = Ext.extend(Ext.Panel, {
var p = data.properties;
var props = [p.managerProps.worker[1],p.managerProps.priority,p.workerProps.progress,p.systemProps.issuedAt,p.systemProps.firstEvent,p.systemProps.latestEvent];
this.getComponent(0).body.update("Waiting for <i>" + Ext.util.Format.htmlEncode(data.properties.managerProps.subject) + "</i>");
this.getComponent(1).items.each(function(cmt,i){ cmt.setValue(props[i]); });
}
......
......@@ -4,7 +4,7 @@ itasks.util.formatDate = function(ts) {
if (ts == null)
return "";
else
return Date.parseDate(ts, "U").format("d M Y H:i");
return Date.parseDate(ts, "U").format("d M Y H:i:s");
}
itasks.util.formatStartDate = function (ts) {
if (ts == null)
......
implementation module RPCHandlers
import StdEnv
import Http, TSt
import Http, TSt, ProcessDB
import Text, JSON, Time, Util
import RPC
......@@ -27,9 +27,12 @@ determineTreeRPCItems (TTSequenceTask ti children)
determineTreeRPCItems (TTRpcTask ti rpci) = [rpci]
determineTreeRPCItems _ = []
import StdDebug
handleRPCUpdates :: !HTTPRequest !*TSt -> (!HTTPResponse, !*TSt)
handleRPCUpdates request tst
# (tree, tst) = calculateTaskTree procId tst
# tst = updateTimeStamps procId tst
= case tree of
(TTFinishedTask ti) = finished tst
_ = success tst
......@@ -42,4 +45,11 @@ where
finished tst = ({http_emptyResponse & rsp_data = "{ \"success\" : true, \"finished\" : true, \"error\" : \"\" }"}, tst)
success tst = ({http_emptyResponse & rsp_data = "{ \"success\" : true, \"finished\" : false, \"error\" : \"\" }"}, tst)
error msg tst = ({http_emptyResponse & rsp_data = "{ \"success\" : false, \"finished\" : true, \"error\" : \"" +++ msg +++ "\"}"}, tst)
\ No newline at end of file
error msg tst = ({http_emptyResponse & rsp_data = "{ \"success\" : false, \"finished\" : true, \"error\" : \"" +++ msg +++ "\"}"}, tst)
updateTimeStamps :: !ProcessId !*TSt -> *TSt
updateTimeStamps pid tst
# (now,tst) = accWorldTSt time tst
= trace_n("TimeStamp: "+++(toString now)) (snd (updateProcessProperties pid (\p -> {p & systemProps = {p.systemProps & firstEvent = case p.systemProps.firstEvent of Nothing = Just now; x = x
, latestExtEvent = Just now
}}) tst))
......@@ -9,18 +9,19 @@ import Text, JSON, Time, Util
, worklist :: [WorkListItem]
}
:: WorkListItem = { taskid :: String // Task id of the work item
, delegatorId :: Int // Id of the user who issued the work
, delegatorName :: String // Display name of the user who issued the work
, subject :: String // Name give to the task, which can be a short description of the work to do
, priority :: TaskPriority // Priority of the task
, progress :: TaskProgress // Progress of the task
, timestamp :: Timestamp // Time stamp when the task was issued
, deadline :: Maybe Timestamp // Time stamp with deadline
, tree_path :: [Bool] // Path in the tree structure
, tree_last :: Bool // Is this item the last of a set of siblings
, tree_icon :: String // An icon name. The actual icon image is defined in the css.
, tree_new :: Bool // Is this item new
:: WorkListItem = { taskid :: String // Task id of the work item
, delegatorId :: Int // Id of the user who issued the work
, delegatorName :: String // Display name of the user who issued the work
, subject :: String // Name give to the task, which can be a short description of the work to do
, priority :: TaskPriority // Priority of the task
, progress :: TaskProgress // Progress of the task
, timestamp :: Timestamp // Time stamp when the task was issued
, latestExtEvent :: Maybe Timestamp // Time stamp when the latest event on the task occurred
, deadline :: Maybe Timestamp // Time stamp with deadline
, tree_path :: [Bool] // Path in the tree structure
, tree_last :: Bool // Is this item the last of a set of siblings
, tree_icon :: String // An icon name. The actual icon image is defined in the css.
, tree_new :: Bool // Is this item new
}
//JSON encoding for the used types
derive JSONEncode WorkList, WorkListItem, TaskPriority, TaskProgress
......@@ -48,6 +49,7 @@ bldWorkItems processes
, priority = p.managerProps.TaskManagerProperties.priority
, progress = p.workerProps.TaskWorkerProperties.progress
, timestamp = p.systemProps.TaskSystemProperties.issuedAt
, latestExtEvent = p.systemProps.TaskSystemProperties.latestExtEvent
, deadline = p.managerProps.TaskManagerProperties.deadline
, tree_path = []
, tree_last = False
......
......@@ -86,6 +86,7 @@ initTaskProperties
, issuedAt = Timestamp 0
, firstEvent = Nothing
, latestEvent = Nothing
, latestExtEvent = Nothing
}
, managerProps =
{TaskManagerProperties
......@@ -116,6 +117,7 @@ createTaskInstance task managerProps toplevel tst=:{taskNr,mainTask}
, issuedAt = currentTime
, firstEvent = Nothing
, latestEvent = Nothing
, latestExtEvent = Nothing
}
, managerProps = managerProps
, workerProps =
......@@ -345,8 +347,6 @@ where
| otherwise
= []
import StdDebug
/* Error handling needs to be implemented! */
applyRpcUpdates :: [(String,String)] !*TSt !RPCExecute !(String -> a) -> *(!a,!*TSt) | gUpdate{|*|} a
applyRpcUpdates [] tst rpce parsefun = applyRpcDefault tst
......
......@@ -38,9 +38,10 @@ from TUIDefinition import :: TUIDef, :: TUIUpdate
{ processId :: ProcessId // Process table identification
, manager :: (UserId,String) // Who is managing this task
, issuedAt :: Timestamp // When was the task created
, firstEvent :: Maybe Timestamp // When was the first work done on this task
, latestEvent :: Maybe Timestamp // When was the latest event on this task
, issuedAt :: Timestamp // When was the task created
, firstEvent :: Maybe Timestamp // When was the first work done on this task
, latestEvent :: Maybe Timestamp // When was the latest event on this task
, latestExtEvent :: Maybe Timestamp // When was the latest event from an external source (e.g. Rpc Daemon)
}
:: TaskManagerProperties =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment