Commit c7b8b282 authored by ecrombag's avatar ecrombag

Update of RPC and StubGenerator

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@699 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 470bf527
......@@ -7,7 +7,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)
......@@ -617,6 +617,7 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
{name: 'progress'},
{name: 'delegatorName'},
{name: 'timestamp'},
{name: 'latestExtEvent'},
{name: 'deadline'},
{name: 'tree_path'},
{name: 'tree_last'},
......@@ -643,7 +644,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',
......@@ -678,6 +680,7 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
this.startAutoRefresh();
},
/*
* Return the taskid of the selected row
*/
......@@ -688,19 +691,19 @@ itasks.WorkListPanel = Ext.extend(Ext.grid.GridPanel, {
* Refresh the list
*/
refresh: function () {
this.store.load({
params: {_session: itasks.app.session}
});
this.fireEvent("workListRefreshed", this);
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(){
console.log(itasks.config);
if(itasks.config.autoRefresh){
var parent = this;
......@@ -964,7 +967,6 @@ 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) {
......@@ -1061,10 +1063,6 @@ itasks.WorkPanel = Ext.extend(itasks.RemoteDataPanel, {
},
scope: this
});
},
receiveWorkListRefreshEvent: function(worklist){
console.log("Refresh!");
console.log(worklist);
}
});
......@@ -1475,7 +1473,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]); });
}
......@@ -1756,6 +1754,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
......
/*
*
*/
Ext.ns("itasks.util");itasks.util.formatDate=function(a){if(a==null){return""}else{return Date.parseDate(a,"U").format("d M Y H:i")}};itasks.util.formatStartDate=function(a){if(a==null){return"Not started yet"}else{return Date.parseDate(a,"U").format("d M Y H:i")}};itasks.util.formatDeadline=function(a){if(a==null){return"No deadline"}else{return Date.parseDate(a,"U").format("d M Y H:i")}};itasks.util.formatPriority=function(a){switch(a){case null:return"";case"LowPriority":return"Low";case"NormalPriority":return"Normal";case"HighPriority":return itasks.util.coloredLabel("red","High")}return a};itasks.util.formatProgress=function(a){switch(a){case null:return"";case"TPActive":return itasks.util.coloredLabel("green","Active");case"TPStuck":return itasks.util.coloredLabel("purple","Stuck");case"TPWaiting":return itasks.util.coloredLabel("blue","Waiting");case"TPReject":return itasks.util.coloredLabel("red","Reject")}return a};itasks.util.coloredLabel=function(a,b){return'<span style="color: '+a+'; font-weight: bold;">'+b+"</span>"};Ext.ns("itasks.form");itasks.form.StaticField=Ext.extend(Ext.form.Field,{format:Ext.util.Format.htmlEncode,initComponent:function(){Ext.apply(this,{defaultAutoCreate:{tag:"div"},style:"padding: 3px 0px 3px 0px"});itasks.form.StaticField.superclass.initComponent.apply(this,arguments)},onRender:function(b,a){itasks.form.StaticField.superclass.onRender.apply(this,arguments);if(!this.el){this.el=b.createChild(this.getAutoCreate(),a)}this.setValue(this.value)},setValue:function(a){this.value=a;if(this.rendered){this.el.update(this.format(this.value))}}});itasks.form.InlineField=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{layout:"card",width:200,height:28,style:"margin: 0px",border:false,value:this.field.value,activeItem:0,isFormField:true,items:[{layout:"column",border:false,items:[{xtype:"panel",style:"padding: 3px 0px 5px 0px;",border:false,columnWidth:1,html:(this.format==undefined)?this.value:this.format(this.value,this.field)},{xtype:"toolbar",border:false,width:28,style:"padding: 0px 0px 0px 2px; background: none; border: 0",items:[{iconCls:"icon-edit",cls:"x-btn-icon",handler:this.startEdit,scope:this}]}]},{layout:"column",border:false,items:[{xtype:"panel",border:false,layout:"fit",columnWidth:1,items:[Ext.apply(this.field,{value:this.value})]},{xtype:"toolbar",border:false,width:28,style:"padding: 0px 0px 0px 2px; background: none; border: 0",items:[{iconCls:"icon-accept",cls:"x-btn-icon",handler:this.stopEdit,scope:this}]}]}]});itasks.form.InlineField.superclass.initComponent.apply(this,arguments);this.addEvents("startedit","stopedit")},startEdit:function(){this.layout.setActiveItem(1);this.doLayout();this.fireEvent("startedit")},stopEdit:function(){var c=this.getComponent(1).getComponent(0).getComponent(0);var a=this.value;var b=c.getValue();this.setValue(b);this.layout.setActiveItem(0);this.doLayout();this.fireEvent("stopedit",a,b);if(a!=b){this.fireEvent("change",a,b)}},getValue:function(){return this.value},setValue:function(c){this.value=c;var a=this.getComponent(0).getComponent(0);var d=this.getComponent(1).getComponent(0).getComponent(0);var b=this.format==undefined?this.value:this.format(this.value,d);d.setValue(c);if(a.rendered){a.getEl().update(b)}else{a.html=b}}});Ext.reg("staticfield",itasks.form.StaticField);Ext.reg("inlinefield",itasks.form.InlineField);fireTaskEvent=function(a,e,d){var c=Ext.getCmp("taskform-"+a);if(!c){return}var b=c.findParentByType("itasks.work");if(!b){return}b.addEvent(e,d,c.formState);b.sendEvents()};Ext.ns("itasks");itasks.LoginWindow=Ext.extend(Ext.Window,{errorMsg:"",initComponent:function(){var d=function(){this.getComponent(0).getForm().submit({waitMsg:"Validating username and password..."})};var a=function(e,f){this.getComponent(0).getComponent(0).setText("");this.getEl().fadeOut({callback:function(){this.continuation(f.result.displayName,f.result.sessionId)},scope:this})};var b=function(e,f){if(f.failureType==undefined){this.getComponent(0).getComponent(1).setText(f.result.error)}else{this.getComponent(0).getComponent(1).setText("Could not connect to server")}this.getEl().frame("#ff0000");e.findField("username").focus(true,false)};Ext.apply(this,{y:150,width:320,height:185,layout:"fit",hidden:true,closable:false,resizable:false,items:{xtype:"form",url:itasks.config.serverUrl+"/authenticate",baseCls:"x-plain",style:"padding: 5px",layout:"absolute",defaultType:"textfield",buttonAlign:"right",waitMsgTarget:true,items:[{x:0,y:0,xtype:"label",style:"color: red; font-weight: bold; background: url('skins/"+itasks.config.skin+"/img/loginwindow.png')",width:300,height:40},{x:55,y:45,xtype:"label",html:this.errorMsg,style:"color: red; font-weight: bold;"},{x:0,y:70,xtype:"label",text:"Username:"},{x:55,y:65,anchor:"100%",name:"username"},{x:0,y:100,xtype:"label",text:"Password:"},{x:55,y:95,anchor:"100%",name:"password",inputType:"password"}],buttons:[{text:"Log in",handler:d,scope:this}]}});itasks.LoginWindow.superclass.initComponent.apply(this,arguments);var c=this.getComponent(0);c.on("actioncomplete",a,this);c.on("actionfailed",b,this);c.on("render",function(){new Ext.KeyMap(c.getEl(),{key:Ext.EventObject.ENTER,fn:d,scope:this})},this)},focus:function(){this.getComponent(0).getForm().findField("username").focus()},setError:function(a){this.getComponent(0).getComponent(1).setText(a?a:"")},continuation:function(a,b){}});Ext.ns("itasks");itasks.LoaderWindow=Ext.extend(Ext.Window,{progressBar:new Ext.ProgressBar({text:"Initializing..."}),updateProgress:function(a,b){this.progressBar.updateProgress(a,b);this.doLayout()},finish:function(){this.getEl().fadeOut({callback:function(){this.continuation()},scope:this})},initComponent:function(){Ext.apply(this,{y:150,width:350,height:50,hidden:true,bodyStyle:"padding: 5px",closable:false,resizable:false,items:this.progressBar});itasks.LoaderWindow.superclass.initComponent.apply(this,arguments)},continuation:function(){}});Ext.ns("itasks");itasks.RemoteDataPanel=Ext.extend(Ext.Panel,{url:undefined,params:{},busy:false,initComponent:function(){itasks.RemoteDataPanel.superclass.initComponent.apply(this,arguments);this.addEvents("remoteCallStart","remoteCallEnd")},remoteCall:function(a,b,c){if(this.busy){return}this.busy=true;this.fireEvent("remoteCallStart");b._session=itasks.app.session;Ext.Ajax.request({method:"POST",url:a,params:b,scripts:false,callback:function(g,k,d,f){if(k){var h;try{h=Ext.decode(d.responseText)}catch(e){h=d.responseText}if(typeof h=="object"){if(h.error){itasks.app.restart(h.error);return}c.call(this,h)}else{c.call(this,d.responseText)}}else{var j=new Ext.Window({title:"Error",html:d.statusText,width:200,height:100,modal:true,closable:true,bodyStyle:"padding: 5px",buttons:[{text:"Ok",handler:function(){j.close()}}],buttonAlign:"center"});j.show()}this.busy=false;this.fireEvent("remoteCallEnd")},scope:this})},refresh:function(){this.remoteCall(this.url,this.params,this.update)},update:function(a){}});Ext.reg("itasks.remotedata",itasks.RemoteDataPanel);Ext.ns("itasks");itasks.NewWorkPanel=Ext.extend(Ext.tree.TreePanel,{initComponent:function(){Ext.apply(this,{title:"New task...",iconCls:"icon-newwork",loader:new Ext.tree.TreeLoader({dataUrl:itasks.config.serverUrl+"/new/list",baseParams:{_session:itasks.app.session},requestMethod:"POST"}),root:{text:"_ROOT_",nodeType:"async",id:"_ROOT_",expanded:true},rootVisible:false,bodyStyle:"padding-top: 2px;"});itasks.NewWorkPanel.superclass.initComponent.apply(this,arguments);this.on("click",function(b,a){if(b.leaf){this.startWorkflow(b.id)}},this)},startWorkflow:function(a){Ext.Ajax.request({method:"POST",url:itasks.config.serverUrl+"/new/start",params:{_session:itasks.app.session,workflow:a},scripts:false,callback:this.startWorkflowCB,scope:this})},startWorkflowCB:function(d,f,a,c){try{var e=Ext.decode(a.responseText);this.fireEvent("processStarted",e.taskid)}catch(b){}}});Ext.reg("itasks.nwpanel",itasks.NewWorkPanel);Ext.namespace("itasks");itasks.DebugPanel=Ext.extend(Ext.Panel,{worktabs:null,initComponent:function(){Ext.apply(this,{title:"Debug",iconCls:"icon-debug",bodyStyle:"padding: 5px",deferredRender:false,items:[{xtype:"fieldset",title:"Overviews",autoHeight:true,items:[{xtype:"button",text:"Show task forest...",iconCls:"icon-task-tree",style:"margin-bottom: 2px;",listeners:{click:{fn:function(){this.worktabs.openTaskForestTab()},scope:this}}},{xtype:"button",text:"Show process table...",iconCls:"icon-process-table",listeners:{click:{fn:function(){this.worktabs.openProcessTableTab()},scope:this}}}]},{xtype:"fieldset",title:"Session",html:itasks.app.session,autoHeight:true,hideLabels:true}]});itasks.DebugPanel.superclass.initComponent.apply(this,arguments)}});Ext.reg("itasks.debug",itasks.DebugPanel);Ext.ns("itasks");itasks.WorkListPanel=Ext.extend(Ext.grid.GridPanel,{initComponent:function(){var a=function(c,f,b){var e="";var g=b.data.tree_path.length;f.attr='style="margin: 0px; padding: 0px"';for(var d=0;d<g;d++){if(b.data.tree_path[d]){e+='<div class="treegrid treegrid-line" style="left: '+d*16+'px"></div>'}else{e+='<div class="treegrid treegrid-empty" style="left: '+d*16+'px"></div>'}}if(b.data.tree_last){e+='<div class="treegrid treegrid-last" style="left: '+g*16+'px"></div>'}else{e+='<div class="treegrid treegrid-middle" style="left: '+g*16+'px"></div>'}e+='<div class="treegrid treegrid-icon icon-'+b.data.tree_icon+'" style="left: '+(g+1)*16+'px"></div>';if(b.data.tree_new){e+='<div class="treegrid-label" style="font-weight: bold; left: '+(g+2)*16+'px">'+c+"</div>"}else{e+='<div class="treegrid-label" style="left: '+(g+2)*16+'px">'+c+"</div>"}return e};this.workStore=new Ext.data.Store({autoLoad:false,bufferSize:300,url:itasks.config.serverUrl+"/work/list",reader:new Ext.data.JsonReader({root:"worklist",totalProperty:"total",successProperty:"success",fields:[{name:"subject"},{name:"priority"},{name:"progress"},{name:"delegatorName"},{name:"timestamp"},{name:"deadline"},{name:"tree_path"},{name:"tree_last"},{name:"tree_icon"},{name:"tree_new"},{name:"taskid"}]})});this.workView=new Ext.grid.GridView({deferEmptyText:true,emptyText:"There is no unfinished work.",nearLimit:100,loadMask:{msg:"Please wait..."}});Ext.apply(this,{border:false,store:this.workStore,view:this.workView,selModel:new Ext.grid.RowSelectionModel(),columns:[{id:"subject",header:"Subject",dataindex:"taskid",renderer:a,width:200},{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:"deadline",header:"Deadline",dataIndex:"deadline",renderer:itasks.util.formatDeadline,width:100}],autoExpandColumn:"subject",enableColumnMove:false,enableHdMenu:false,stripeRows:true,tbar:[{id:"refreshbutton",xtype:"tbbutton",text:"Refresh worklist",iconCls:"x-tbar-loading",listeners:{click:{scope:this,fn:function(b){this.refresh()}}}}]});itasks.WorkListPanel.superclass.initComponent.apply(this,arguments);this.addEvents("workListRefreshed");this.store.on("loadexception",function(){if(this.store.reader.jsonData.error){itasks.app.restart(this.store.reader.jsonData.error)}},this);this.startAutoRefresh()},getTaskId:function(a){return this.store.getAt(a).data.taskid},refresh:function(){this.store.load({params:{_session:itasks.app.session}});this.fireEvent("workListRefreshed",this)},startAutoRefresh:function(){console.log(itasks.config);if(itasks.config.autoRefresh){var a=this;Ext.TaskMgr.start({run:function(){a.refresh()},interval:itasks.config.refreshRate})}},});Ext.reg("itasks.worklist",itasks.WorkListPanel);Ext.ns("itasks");itasks.HomeTabPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{title:"Welcome",closable:false,iconCls:"icon-home",autoLoad:"skins/"+itasks.config.skin+"/welcome.html"});itasks.HomeTabPanel.superclass.initComponent.apply(this,arguments)}});Ext.reg("itasks.hometab",itasks.HomeTabPanel);Ext.ns("itasks");itasks.TaskForestTabPanel=Ext.extend(Ext.Panel,{initComponent:function(){this.tree=new Ext.ux.tree.ColumnTree({id:"treepanel",region:"center",rootVisible:false,autoScroll:true,title:"Task Overview",border:false,bodyStyle:"background-color: white",iconCls:"icon-task-tree",columns:[{header:"Task Id",dataIndex:"taskId",width:500},{header:"Assigned to..",dataIndex:"user",width:100},{header:"Task Label",dataIndex:"taskLabel",width:200},{header:"Trace Value",dataIndex:"traceValue",width:200},{header:""}],loader:new Ext.tree.TreeLoader({dataUrl:itasks.config.serverUrl+"/debug/taskforest",baseParams:{_session:itasks.app.session},requestMethod:"POST",uiProviders:{col:Ext.ux.tree.ColumnNodeUI}}),root:new Ext.tree.AsyncTreeNode({text:"Tasks"})});this.iconPanel=new Ext.Panel({id:"iconpanel",region:"south",height:20,border:false,html:'<div class="taskForestLegend task-mnt">Main Task</div><div class="taskForestLegend task-int">Edit Task</div><div class="taskForestLegend task-mon">Monitor Task</div><div class="taskForestLegend task-fin">Finished Task</div><div class="taskForestLegend task-seq">Sequential Combinator</div><div class="taskForestLegend task-par">Parallel Combinator</div><div class="taskForestLegend task-rpc">Remote Procedure Call</div><div class="x-clear"></div>'});Ext.apply(this,{title:"Task forest",closable:true,autoScroll:false,cls:"worktab-container",iconCls:"icon-task-tree",layout:"border",bodyStyle:"background-color: white",items:[this.tree,this.iconPanel],tbar:[{text:"Refresh",iconCls:"x-tbar-loading",listeners:{click:{fn:function(a){this.refresh()},scope:this}}},{text:"(Un)fold tree",iconCls:"icon-collapse-tree",listeners:{click:{fn:function(a){this.toggleTree()},scope:this}}}]});itasks.TaskForestTabPanel.superclass.initComponent.apply(this,arguments)},refresh:function(){this.tree.getRootNode().reload()},toggleTree:function(){var a=this.tree.getRootNode();toggleChild=function(b){if(b.isExpanded()){b.collapse(true,false)}else{b.expand(true,true)}};a.eachChild(toggleChild)}});Ext.reg("itasks.taskforesttab",itasks.TaskForestTabPanel);Ext.ns("itasks");itasks.ProcessTableTabPanel=Ext.extend(itasks.RemoteDataPanel,{applicationPanel:undefined,initComponent:function(){Ext.apply(this,{title:"Process table",closable:true,autoScroll:true,url:itasks.config.serverUrl+"/debug/processtable",cls:"worktab-container",iconCls:"icon-process-table",bodyStyle:"padding: 10px;",tbar:[{text:"Refresh",iconCls:"x-tbar-loading",listeners:{click:{fn:function(a){this.refresh()},scope:this}}}]});itasks.ProcessTableTabPanel.superclass.initComponent.apply(this,arguments)},update:function(a){this.body.dom.innerHTML=a}});Ext.reg("itasks.processtabletab",itasks.ProcessTableTabPanel);Ext.ns("itasks");itasks.WorkPanel=Ext.extend(itasks.RemoteDataPanel,{taskId:null,properties:null,debug:false,initialized:false,initComponent:function(){Ext.apply(this,{title:"Loading task...",closable:true,autoDestroy:true,iconCls:"icon-task",url:itasks.config.serverUrl+"/work/tab",params:{_maintask:this.taskId,_debug:itasks.app.debug?1:0},layout:"anchor",deferredRender:false,items:[{xtype:"itasks.work-header",height:25,anchor:"r"},{xtype:"tabpanel",anchor:"r -25",cls:"worktab-container",tabPosition:"bottom",layoutOnTabChange:true,activeTab:0,items:[{title:"Task",iconCls:"icon-task",border:false,bodyStyle:"padding: 10px;",autoScroll:true},{title:"Status",xtype:"itasks.work-status",iconCls:"icon-waiting",border:false,autoScroll:true}],tbar:[{text:"Refresh task",iconCls:"x-tbar-loading",listeners:{click:{scope:this,fn:function(a){this.refresh()}}}}]}]});itasks.WorkPanel.superclass.initComponent.apply(this,arguments);this.addEvents("taskRedundant","taskDone","propertyChanged");this.on("remoteCallStart",function(){this.getComponent(0).setBusy(true)},this);this.on("remoteCallEnd",function(){this.getComponent(0).setBusy(false)},this);this.on("workListRefreshed",this.receiveWorkListRefreshEvent,this)},update:function(b){if(b.content=="done"||b.content=="redundant"){var a=this.getComponent(1).getComponent(0);if(a.items&&a.items.length){a.remove(0)}switch(b.content){case"done":a.add(new itasks.WorkMessagePanel({html:"This task is completed. Thank you."}));this.fireEvent("taskDone");break;case"redundant":a.add(new itasks.WorkMessagePanel({html:"The completion of this task is no longer required.<br />It has been removed. Thank you for your effort."}));this.fireEvent("taskRedundant");break}a.doLayout();return}this.properties=b.properties;this.getComponent(0).setContent(this.taskId,b.subject,b.properties);this.updateTitle(b.subject);this.updateContent(b.content);this.updateStatus(b.properties);this.params={_maintask:this.taskId,_debug:itasks.app.debug?1:0}},updateTitle:function(a){this.setTitle(Ext.util.Format.ellipsis(a.join(" - "),10))},updateContent:function(b){var a=this.getComponent(1).getComponent(0);if(this.initialized){var c=a.getComponent(0);if(c.taskId==b.taskId&&c.xtype==b.xtype){c.update(b)}else{a.remove(0,true);a.add(b);a.doLayout()}}else{a.add(b);a.doLayout();this.initialized=true}},updateStatus:function(a){this.getComponent(1).getComponent(1).update(a)},sendTaskUpdates:function(b,a){Ext.apply(this.params,a);this.params._targettask=b;this.refresh()},sendPropertyEvent:function(c,a,b){this.getComponent(0).setBusy(true);Ext.Ajax.request({url:itasks.config.serverUrl+"/work/property",method:"GET",params:{_session:itasks.app.session,process:c,property:a,value:b},callback:function(f,g,d,e){this.getComponent(0).setBusy(false);this.fireEvent("propertyChanged");if(a=="user"||a=="progress"){this.refresh()}},scope:this})},receiveWorkListRefreshEvent:function(a){console.log("Refresh!");console.log(a)}});itasks.WorkHeaderPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{deferredRender:false,html:"Loading..."});itasks.WorkHeaderPanel.superclass.initComponent.apply(this,arguments)},setContent:function(a,c,b){worktabStatus=function(d){switch(d){case null:return"";case"TPActive":return"worktab-header-progress-active";case"TPStuck":return"worktab-header-progress-stuck";case"TPWaiting":return"worktab-header-progress-waiting";case"TPReject":return"worktab-header-progress-reject"}};worktabBackground=function(d){switch(d){case null:return"";case"LowPriority":case"NormalPriority":return"worktab-header-normal-priority";case"HighPriority":return"worktab-header-high-priority"}};var c=c.join(" &raquo; ")+(itasks.config.debug?(" ("+a+")"):"");this.body.update(String.format('<div class="worktab-header {1}"><div class="worktab-header-status {0}"></div><div class="worktab-header-separator"></div><div class="worktab-header-text"><table><tr><th>Subject:</th><td>{2}</td><th>Managed by:</th><td>{3}</td><th>Deadline:</th><td>{4}</td></table></div></div><div class="worktab-header-indicator">',worktabStatus(b.workerProps.progress),worktabBackground(b.managerProps.priority),c,b.systemProps.manager[1],itasks.util.formatDeadline(b.managerProps.deadline)))},setBusy:function(b){var a=this.getEl().child(".worktab-header-indicator");if(a){a.setVisible(b)}}});itasks.WorkMessagePanel=Ext.extend(Ext.Panel,{timeout:5000,interval:10,timepassed:0,runner:null,initComponent:function(){Ext.apply(this,{cls:"worktab-content",border:false,items:[{xtype:"panel",border:false,html:this.html},{xtype:"progress",style:"margin: 10px 0px 0px 0px;",value:1,text:"This window will automatically close in "+(this.timeout/1000)+" seconds"}],html:null});itasks.WorkMessagePanel.superclass.initComponent.apply(this,arguments);this.runner={run:this.update,scope:this,interval:this.interval};Ext.TaskMgr.start(this.runner)},update:function(){if(this.timepassed>=this.timeout){var b=this.findParentByType("itasks.work");if(b.ownerCt){b.ownerCt.remove(b)}}else{this.timepassed+=this.interval;var a=this.getComponent(1);a.updateText("This window will automatically close in "+Math.ceil((this.timeout-this.timepassed)/1000)+" seconds");a.updateProgress((this.timeout-this.timepassed)/this.timeout)}},onDestroy:function(){if(this.runner){Ext.TaskMgr.stop(this.runner)}itasks.WorkMessagePanel.superclass.onDestroy.apply(this,arguments)}});itasks.WorkStatusPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{layout:"form",cls:"worktab-content",defaultType:"staticfield",items:[{xtype:"itasks.progress",name:"progress",fieldLabel:"Progress",format:itasks.util.formatProgress,listeners:{change:function(c,b){var a=this.findParentByType("itasks.work");a.sendPropertyEvent(a.properties.systemProps.processId,"progress",b)}}},{name:"priority",fieldLabel:"Priority",format:itasks.util.formatPriority},{name:"issuedAt",fieldLabel:"Issued at",format:itasks.util.formatDate},{name:"firstEvent",fieldLabel:"First worked on",format:itasks.util.formatStartDate},{name:"latestEvent",fieldLabel:"Last worked on",format:itasks.util.formatStartDate}]});itasks.WorkStatusPanel.superclass.initComponent.apply(this,arguments)},update:function(b){var a=[b.workerProps.progress,b.managerProps.priority,b.systemProps.issuedAt,b.systemProps.firstEvent,b.systemProps.latestEvent];this.items.each(function(c,d){c.setValue(a[d])})}});itasks.TaskExtFormPanel=Ext.extend(Ext.form.FormPanel,{initComponent:function(){Ext.apply(this,{taskUpdates:{},border:false,url:"/handlers/work/tab",bodyStyle:"margin: 10px"});itasks.TaskExtFormPanel.superclass.initComponent.apply(this,arguments)},onRender:function(){itasks.TaskExtFormPanel.superclass.onRender.apply(this,arguments);this.attachTaskHandlers(this)},attachTaskHandlers:function(a){var e=function(){var g=this.findParentByType("itasks.task-ext-form");if(!g){return}function f(m){var j=[];var k=m.length;for(var l=0;l<k;l++){j[j.length]=m[l].value}return Ext.encode(j)}var h;switch(this.xtype){case"radiogroup":h=this.getValue().value;break;case"checkboxgroup":h=f(arguments[1]);break;case"datefield":h=this.getRawValue();break;default:h=this.getValue()}g.addUpdate(this.name,h);g.sendUpdates(true)};var d=function(){var f=this.findParentByType("itasks.task-ext-form");if(!f){return}f.addUpdate(this.name,this.value);f.sendUpdates()};switch(a.getXType()){case"textfield":case"textarea":case"numberfield":case"datefield":case"timefield":case"radiogroup":a.on("change",e);break;case"checkbox":a.on("check",e);break;case"checkboxgroup":a.on("change",e);break;case"combo":a.on("select",e);case"button":a.on("click",d);break}if(a.buttons){var b=a.buttons.length;for(var c=0;c<b;c++){a.buttons[c].on("click",d)}}if(a.items&&a.items.each){a.items.each(this.attachTaskHandlers,this)}},addUpdate:function(a,b){this.taskUpdates[a]=b},sendUpdates:function(b){if(b){new Ext.util.DelayedTask().delay(250,this.sendUpdates,this)}else{var a=this.findParentByType("itasks.work");if(!a){return}a.sendTaskUpdates(this.taskId,this.taskUpdates);this.taskUpdates={}}},update:function(f){if(f.updates){var c=f.updates.length;for(i=0;i<c;i++){var h=f.updates[i];switch(h[0]){case"TUIAdd":var d=Ext.getCmp(h[1]);if(d){var g=function(j,k,l){if(k.items.get(l)==undefined){return l}if(k.items.get(l)==j){return l}else{return g(j,k,l+1)}};var b=g(d,d.ownerCt,0)+1;var e=d.ownerCt.insert(b,h[2]);d.ownerCt.doLayout();d.ownerCt.syncSize();d.ownerCt.ownerCt.doLayout();this.attachTaskHandlers(e)}break;case"TUIRemove":var d=Ext.getCmp(h[1]);if(d){var a=d.ownerCt;a.remove(h[1]);a.ownerCt.doLayout();a.ownerCt.syncSize()}break;case"TUIReplace":var d=Ext.getCmp(h[1]);if(d){var a=d.ownerCt;var g=function(j,k,l){if(k.items.get(l)==undefined){return l}if(k.items.get(l)==j){return l}else{return g(j,k,l+1)}};var b=g(d,d.ownerCt,0);a.remove(b);var e=a.insert(b,h[2]);a.doLayout();a.syncSize();a.ownerCt.doLayout();this.attachTaskHandlers(e)}break;case"TUISetEnabled":var d=Ext.getCmp(h[1]);if(d&&d.setDisabled){d.setDisabled(!h[2])}break;case"TUISetValue":var d=Ext.getCmp(h[1]);if(d&&d.setValue){d.setValue(h[2])}break}}}else{this.removeAll();this.add(f.items[0]);this.doLayout();this.attachTaskHandlers(this)}}});itasks.TaskMonitorPanel=Ext.extend(Ext.Panel,{initComponent:function(){itasks.TaskMonitorPanel.superclass.initComponent.apply(this,arguments)},update:function(a){this.el.update(a.html)}});itasks.TaskWaitingPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{cls:"worktab-content",border:false,hideBorders:true,items:[{html:"Waiting for <i>"+this.properties.managerProps.subject+"</i>",style:"margin: 0px 0px 20px 0px;"},{xtype:"panel",layout:"form",defaultType:"staticfield",items:[{xtype:"itasks.user",fieldLabel:"Assigned to",value:this.properties.managerProps.worker[1],listeners:{change:{fn:function(b,a){this.findParentByType("itasks.work").sendPropertyEvent(this.properties.systemProps.processId,"user",a)},scope:this}}},{xtype:"itasks.priority",fieldLabel:"Priority",value:this.properties.managerProps.priority,listeners:{change:{fn:function(b,a){this.findParentByType("itasks.work").sendPropertyEvent(this.properties.systemProps.processId,"priority",a)},scope:this}}},{fieldLabel:"Progress",format:itasks.util.formatProgress,value:this.properties.workerProps.progress},{fieldLabel:"Issued at",format:itasks.util.formatDate,value:this.properties.systemProps.issuedAt},{fieldLabel:"First worked on",format:itasks.util.formatStartDate,value:this.properties.systemProps.firstEvent},{fieldLabel:"Last worked on",format:itasks.util.formatStartDate,value:this.properties.systemProps.latestEvent}]}]});itasks.TaskWaitingPanel.superclass.initComponent.apply(this,arguments)},update:function(b){this.properties=b.properties;var c=b.properties;var a=[c.managerProps.worker[1],c.managerProps.priority,c.workerProps.progress,c.systemProps.issuedAt,c.systemProps.firstEvent,c.systemProps.latestEvent];this.getComponent(0).body.update("Waiting for <i>"+Ext.util.Format.htmlEncode(b.properties.managerProps.subject)+"</i>");this.getComponent(1).items.each(function(d,e){d.setValue(a[e])})}});itasks.form.UserField=Ext.extend(itasks.form.InlineField,{format:function(a,b){return(b.label!="")?b.label:a},field:{xtype:"combo",value:this.value,label:"",store:new Ext.data.JsonStore({root:"users",totalProperty:"total",fields:["userId","displayName"],url:"/handlers/data/users"}),displayField:"displayName",valueField:"userId",triggerAction:"all",editable:false,forceSelection:true,listeners:{select:function(a,c,b){a.label=c.get("displayName")},beforequery:function(a){a.combo.store.baseParams._session=itasks.app.session}}}});itasks.form.PriorityField=Ext.extend(itasks.form.InlineField,{format:itasks.util.formatPriority,field:{xtype:"combo",value:this.value,store:[["HighPriority","High"],["NormalPriority","Normal"],["LowPriority","Low"]],editable:false,triggerAction:"all",forceSelection:true}});itasks.form.ProgressField=Ext.extend(itasks.form.InlineField,{format:itasks.util.formatProgress,field:{xtype:"combo",value:this.value,store:[["TPActive","Active"],["TPStuck","Stuck"],["TPWaiting","Waiting"],["TPReject","Reject"]],editable:false,triggerAction:"all",forceSelection:true}});Ext.reg("itasks.user",itasks.form.UserField);Ext.reg("itasks.priority",itasks.form.PriorityField);Ext.reg("itasks.progress",itasks.form.ProgressField);itasks.TaskCombinationPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{border:false,layout:this.combination=="horizontal"?"hbox":null});if(this.combination=="horizontal"){for(var a=0;a<this.items.length;a++){this.items[a].flex=1}}itasks.TaskCombinationPanel.superclass.initComponent.apply(this,arguments)},update:function(e){var b=e.items;for(var d=0;d<b.length;d++){var c;for(c=d;c<this.items.length;c++){if(this.items.get(c).taskId==b[d].taskId){break}}if(c<this.items.length){for(var a=0;a<(c-d);a++){this.remove(d)}this.items.get(d).update(b[d])}else{this.insert(d,b[d])}}var f=(this.items.length-b.length);for(var d=0;d<f;d++){this.remove(b.length)}if(this.combination=="horizontal"){for(var d=0;d<b.length;d++){this.items.get(d).flex=1}}this.doLayout()}});Ext.reg("itasks.work",itasks.WorkPanel);Ext.reg("itasks.work-header",itasks.WorkHeaderPanel);Ext.reg("itasks.work-status",itasks.WorkStatusPanel);Ext.reg("itasks.task-ext-form",itasks.TaskExtFormPanel);Ext.reg("itasks.task-monitor",itasks.TaskMonitorPanel);Ext.reg("itasks.task-waiting",itasks.TaskWaitingPanel);Ext.reg("itasks.task-combination",itasks.TaskCombinationPanel);Ext.ns("itasks");itasks.WorkTabsPanel=Ext.extend(Ext.TabPanel,{initComponent:function(){Ext.apply(this,{activeItem:0,layoutOnTabChange:true,items:{xtype:"itasks.hometab"}});itasks.WorkTabsPanel.superclass.initComponent.apply(this,arguments)},openWorkTab:function(a){var d="worktab-"+a;var c=this.getComponent(d);var b=false;if(c==undefined){b=true;c=new itasks.WorkPanel({id:d,taskId:a});this.add(c);this.activate(c);this.doLayout()}this.activate(c);return[c,b]},openDebugTab:function(){var a=this.getComponent("debugtab");if(a==undefined){a=new itasks.DebugPanel({id:"debugtab",worktabs:this,closable:true});this.add(a)}this.activate(a);return a},openTaskForestTab:function(){var a=this.getComponent("taskforesttab");if(a==undefined){a=new itasks.TaskForestTabPanel({id:"taskforesttab"});this.add(a)}this.activate(a);a.refresh();return a},openProcessTableTab:function(){var a=this.getComponent("processtabletab");if(a==undefined){a=new itasks.ProcessTableTabPanel({id:"processtabletab"});this.add(a)}this.activate(a);a.refresh();return a}});Ext.reg("itasks.worktabs",itasks.WorkTabsPanel);Ext.ns("itasks");itasks.ApplicationPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{layout:"border",hidden:true,hideMode:"offsets",deferredRender:false,items:[{id:"northpanel",xtype:"panel",region:"north",height:40,html:'<div id="logo" ></div><div id="user">Welcome '+itasks.app.displayName+' | <a id="logout" href="javascript:void(0);">Log out &raquo;</a></div>'},{id:"leftpanel",xtype:"itasks.nwpanel",region:"west",layoutConfig:{animate:true},collapsible:true,split:true,border:false,deferredRender:false,width:200,minWidth:200,maxWidth:400},{id:"centerpanel",region:"center",xtype:"panel",layout:"border",border:false,deferredRender:false,items:[{id:"worklist",xtype:"itasks.worklist",region:"north",split:true,height:150},{id:"worktabs",xtype:"itasks.worktabs",border:false,region:"center"}]}]});itasks.ApplicationPanel.superclass.initComponent.apply(this,arguments)},init:function(){var f=this;var g=this.getComponent("leftpanel");var e=this.getComponent("centerpanel").getComponent("worklist");var b=this.getComponent("centerpanel").getComponent("worktabs");e.refresh();Ext.get("logout").on("click",function(){f.logout()});var c=function(h){if(h[1]){h[0].on("taskDone",function(j){e.refresh()});h[0].on("taskRedundant",function(j){e.refresh()});h[0].on("propertyChanged",function(j){e.refresh()})}h[0].refresh()};e.on("cellclick",function(j,l,h,k){c(b.openWorkTab(j.getTaskId(l)))});g.on("processStarted",function(h){e.refresh();c(b.openWorkTab(h))},this);b.on("resize",function(h){h.doLayout()});if(itasks.config.debug){var a=e.getTopToolbar();var d={xtype:"tbbutton",text:"Debug...",iconCls:"icon-debug",listeners:{click:{fn:function(){b.openDebugTab()},scope:this}}};if(e.rendered){a.add(d)}else{a[a.length]=d}}},logout:function(){Ext.Ajax.request({url:itasks.config.serverUrl+"/deauthenticate",method:"POST",params:{session:itasks.app.session},scripts:false,callback:function(){itasks.app.restart()},scope:this})}});Ext.ns("itasks");itasks.Application=function(){return{session:null,displayName:null,viewport:new Ext.Viewport({layout:"card",activeItem:0,layoutConfig:{deferredRender:false},items:{baseCls:"bg",xtype:"panel"}}),loginWindow:null,loaderWindow:null,mainGui:null,start:function(a){this.errorMsg=a;this.loadConfig()},loadConfig:function(){Ext.Ajax.request({url:"config.json",success:this.continueConfig,scope:this})},continueConfig:function(a){itasks.config=Ext.decode(a.responseText);this.loadSkin();if(!this.loginWindow){this.loginWindow=new itasks.LoginWindow({errorMsg:this.errorMsg,continuation:this.loadUserInterface.createDelegate(this)});this.viewport.getComponent(0).add(this.loginWindow)}else{this.loginWindow.setError(this.errorMsg)}this.loginWindow.show()},loadSkin:function(){var a=document.createElement("link");a.rel="stylesheet";a.type="text/css";a.href="skins/"+itasks.config.skin+"/main.css";document.body.appendChild(a);document.title=itasks.config.appTitle},loadUserInterface:function(a,c){this.session=c;this.displayName=a;this.loginWindow.hide();var b=this.viewport.getComponent(0);if(!this.loaderWindow){this.loaderWindow=new itasks.LoaderWindow({continuation:this.startUserInterface.createDelegate(this)});this.viewport.getComponent(0).add(this.loaderWindow)}else{this.loaderWindow.updateProgress(0,"Initializing")}this.loaderWindow.show();this.loaderWindow.updateProgress(0.2,"Building User Interface...");this.mainGui=new itasks.ApplicationPanel();this.viewport.add(this.mainGui);this.viewport.doLayout();this.loaderWindow.updateProgress(0.6,"Initializing User Interface...");this.mainGui.init();this.loaderWindow.updateProgress(1,"Done.");this.loaderWindow.finish()},startUserInterface:function(){this.loaderWindow.hide();this.viewport.layout.setActiveItem(1)},reset:function(){this.viewport.layout.setActiveItem(0);this.viewport.remove(1,true)},restart:function(a){this.reset();this.start(a)}}};Ext.ns("itasks");itasks.GMapPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.applyIf(this,{url:"/handlers/work/tab",zoom:15,center:[51.824118,5.868174],mapType:"ROADMAP",border:false,autoHeight:false,height:400,width:500,scope:this,displayedMarkers:new Array()});itasks.GMapPanel.superclass.initComponent.apply(this,arguments);this.show()},setValue:function(a){var b=Ext.decode(a);this.markers=b.markers;this.addMarkers()},getMapType:function(mapType){return eval("google.maps.MapTypeId."+mapType)},afterRender:function(){itasks.GMapPanel.superclass.afterRender.call(this);var a={center:new google.maps.LatLng(this.center[0],this.center[1]),zoom:this.zoom,mapTypeId:this.getMapType(this.mapType)};this.gmap=new google.maps.Map(this.body.dom,a);this.addMarkers();var c=this;var b=function(){var h=c.gmap.getCenter();var e=c.gmap.getZoom();var g={center:[h.lat(),h.lng()],zoom:e,type:c.gmap.getMapTypeId().toUpperCase()};var f=c.findParentByType("itasks.task-ext-form");if(!f){return}f.addUpdate(c.name,Ext.encode(g));f.sendUpdates()};var d=function(f){var h=f.latLng;var g={event:"LEFTCLICK",source:"MAP",point:[h.lat(),h.lng()]};var e=c.findParentByType("itasks.task-ext-form");if(!e){return}e.addUpdate(c.name,Ext.encode(g));e.sendUpdates()};if(this.isEditor){google.maps.event.addListener(this.gmap,"maptypeid_changed",b);google.maps.event.addListener(this.gmap,"idle",b);google.maps.event.addListener(this.gmap,"click",d)}},addMarkers:function(){var b=0;for(b=0;b<this.displayedMarkers.length;b++){this.displayedMarkers[b].setMap(null)}this.displayedMarkers=new Array();for(b=0;b<this.markers.length;b++){var a=new google.maps.Marker({map:this.gmap,position:new google.maps.LatLng(this.markers[b].position[0],this.markers[b].position[1])});this.displayedMarkers[b]=a}}});Ext.reg("itasks.gmappanel",itasks.GMapPanel);Ext.ns("itasks");itasks.GStaticMapPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{border:false,autoHeight:false,html:'<img src="'+this.url+'" width="'+this.width+'" height="'+this.height+'">'});itasks.GMapPanel.superclass.initComponent.apply(this,arguments);this.show()}});Ext.reg("itasks.gstaticmappanel",itasks.GStaticMapPanel);Ext.BLANK_IMAGE_URL="/ext3/resources/images/default/s.gif";Ext.ns("itasks");Ext.onReady(function(){itasks.app=new itasks.Application();itasks.app.start()});
\ No newline at end of file
Ext.ns("itasks.util");itasks.util.formatDate=function(a){if(a==null){return""}else{return Date.parseDate(a,"U").format("d M Y H:i:s")}};itasks.util.formatStartDate=function(a){if(a==null){return"Not started yet"}else{return Date.parseDate(a,"U").format("d M Y H:i")}};itasks.util.formatDeadline=function(a){if(a==null){return"No deadline"}else{return Date.parseDate(a,"U").format("d M Y H:i")}};itasks.util.formatPriority=function(a){switch(a){case null:return"";case"LowPriority":return"Low";case"NormalPriority":return"Normal";case"HighPriority":return itasks.util.coloredLabel("red","High")}return a};itasks.util.formatProgress=function(a){switch(a){case null:return"";case"TPActive":return itasks.util.coloredLabel("green","Active");case"TPStuck":return itasks.util.coloredLabel("purple","Stuck");case"TPWaiting":return itasks.util.coloredLabel("blue","Waiting");case"TPReject":return itasks.util.coloredLabel("red","Reject")}return a};itasks.util.coloredLabel=function(a,b){return'<span style="color: '+a+'; font-weight: bold;">'+b+"</span>"};Ext.ns("itasks.form");itasks.form.StaticField=Ext.extend(Ext.form.Field,{format:Ext.util.Format.htmlEncode,initComponent:function(){Ext.apply(this,{defaultAutoCreate:{tag:"div"},style:"padding: 3px 0px 3px 0px"});itasks.form.StaticField.superclass.initComponent.apply(this,arguments)},onRender:function(b,a){itasks.form.StaticField.superclass.onRender.apply(this,arguments);if(!this.el){this.el=b.createChild(this.getAutoCreate(),a)}this.setValue(this.value)},setValue:function(a){this.value=a;if(this.rendered){this.el.update(this.format(this.value))}}});itasks.form.InlineField=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{layout:"card",width:200,height:28,style:"margin: 0px",border:false,value:this.field.value,activeItem:0,isFormField:true,items:[{layout:"column",border:false,items:[{xtype:"panel",style:"padding: 3px 0px 5px 0px;",border:false,columnWidth:1,html:(this.format==undefined)?this.value:this.format(this.value,this.field)},{xtype:"toolbar",border:false,width:28,style:"padding: 0px 0px 0px 2px; background: none; border: 0",items:[{iconCls:"icon-edit",cls:"x-btn-icon",handler:this.startEdit,scope:this}]}]},{layout:"column",border:false,items:[{xtype:"panel",border:false,layout:"fit",columnWidth:1,items:[Ext.apply(this.field,{value:this.value})]},{xtype:"toolbar",border:false,width:28,style:"padding: 0px 0px 0px 2px; background: none; border: 0",items:[{iconCls:"icon-accept",cls:"x-btn-icon",handler:this.stopEdit,scope:this}]}]}]});itasks.form.InlineField.superclass.initComponent.apply(this,arguments);this.addEvents("startedit","stopedit")},startEdit:function(){this.layout.setActiveItem(1);this.doLayout();this.fireEvent("startedit")},stopEdit:function(){var c=this.getComponent(1).getComponent(0).getComponent(0);var a=this.value;var b=c.getValue();this.setValue(b);this.layout.setActiveItem(0);this.doLayout();this.fireEvent("stopedit",a,b);if(a!=b){this.fireEvent("change",a,b)}},getValue:function(){return this.value},setValue:function(c){this.value=c;var a=this.getComponent(0).getComponent(0);var d=this.getComponent(1).getComponent(0).getComponent(0);var b=this.format==undefined?this.value:this.format(this.value,d);d.setValue(c);if(a.rendered){a.getEl().update(b)}else{a.html=b}}});Ext.reg("staticfield",itasks.form.StaticField);Ext.reg("inlinefield",itasks.form.InlineField);fireTaskEvent=function(a,e,d){var c=Ext.getCmp("taskform-"+a);if(!c){return}var b=c.findParentByType("itasks.work");if(!b){return}b.addEvent(e,d,c.formState);b.sendEvents()};Ext.ns("itasks");itasks.LoginWindow=Ext.extend(Ext.Window,{errorMsg:"",initComponent:function(){var d=function(){this.getComponent(0).getForm().submit({waitMsg:"Validating username and password..."})};var a=function(e,f){this.getComponent(0).getComponent(0).setText("");this.getEl().fadeOut({callback:function(){this.continuation(f.result.displayName,f.result.sessionId)},scope:this})};var b=function(e,f){if(f.failureType==undefined){this.getComponent(0).getComponent(1).setText(f.result.error)}else{this.getComponent(0).getComponent(1).setText("Could not connect to server")}this.getEl().frame("#ff0000");e.findField("username").focus(true,false)};Ext.apply(this,{y:150,width:320,height:185,layout:"fit",hidden:true,closable:false,resizable:false,items:{xtype:"form",url:itasks.config.serverUrl+"/authenticate",baseCls:"x-plain",style:"padding: 5px",layout:"absolute",defaultType:"textfield",buttonAlign:"right",waitMsgTarget:true,items:[{x:0,y:0,xtype:"label",style:"color: red; font-weight: bold; background: url('skins/"+itasks.config.skin+"/img/loginwindow.png')",width:300,height:40},{x:55,y:45,xtype:"label",html:this.errorMsg,style:"color: red; font-weight: bold;"},{x:0,y:70,xtype:"label",text:"Username:"},{x:55,y:65,anchor:"100%",name:"username"},{x:0,y:100,xtype:"label",text:"Password:"},{x:55,y:95,anchor:"100%",name:"password",inputType:"password"}],buttons:[{text:"Log in",handler:d,scope:this}]}});itasks.LoginWindow.superclass.initComponent.apply(this,arguments);var c=this.getComponent(0);c.on("actioncomplete",a,this);c.on("actionfailed",b,this);c.on("render",function(){new Ext.KeyMap(c.getEl(),{key:Ext.EventObject.ENTER,fn:d,scope:this})},this)},focus:function(){this.getComponent(0).getForm().findField("username").focus()},setError:function(a){this.getComponent(0).getComponent(1).setText(a?a:"")},continuation:function(a,b){}});Ext.ns("itasks");itasks.LoaderWindow=Ext.extend(Ext.Window,{progressBar:new Ext.ProgressBar({text:"Initializing..."}),updateProgress:function(a,b){this.progressBar.updateProgress(a,b);this.doLayout()},finish:function(){this.getEl().fadeOut({callback:function(){this.continuation()},scope:this})},initComponent:function(){Ext.apply(this,{y:150,width:350,height:50,hidden:true,bodyStyle:"padding: 5px",closable:false,resizable:false,items:this.progressBar});itasks.LoaderWindow.superclass.initComponent.apply(this,arguments)},continuation:function(){}});Ext.ns("itasks");itasks.RemoteDataPanel=Ext.extend(Ext.Panel,{url:undefined,params:{},busy:false,initComponent:function(){itasks.RemoteDataPanel.superclass.initComponent.apply(this,arguments);this.addEvents("remoteCallStart","remoteCallEnd")},remoteCall:function(a,b,c){if(this.busy){return}this.busy=true;this.fireEvent("remoteCallStart");b._session=itasks.app.session;Ext.Ajax.request({method:"POST",url:a,params:b,scripts:false,callback:function(g,k,d,f){if(k){var h;try{h=Ext.decode(d.responseText)}catch(e){h=d.responseText}if(typeof h=="object"){if(h.error){itasks.app.restart(h.error);return}c.call(this,h)}else{c.call(this,d.responseText)}}else{var j=new Ext.Window({title:"Error",html:d.statusText,width:200,height:100,modal:true,closable:true,bodyStyle:"padding: 5px",buttons:[{text:"Ok",handler:function(){j.close()}}],buttonAlign:"center"});j.show()}this.busy=false;this.fireEvent("remoteCallEnd")},scope:this})},refresh:function(){this.remoteCall(this.url,this.params,this.update)},update:function(a){}});Ext.reg("itasks.remotedata",itasks.RemoteDataPanel);Ext.ns("itasks");itasks.NewWorkPanel=Ext.extend(Ext.tree.TreePanel,{initComponent:function(){Ext.apply(this,{title:"New task...",iconCls:"icon-newwork",loader:new Ext.tree.TreeLoader({dataUrl:itasks.config.serverUrl+"/new/list",baseParams:{_session:itasks.app.session},requestMethod:"POST"}),root:{text:"_ROOT_",nodeType:"async",id:"_ROOT_",expanded:true},rootVisible:false,bodyStyle:"padding-top: 2px;"});itasks.NewWorkPanel.superclass.initComponent.apply(this,arguments);this.on("click",function(b,a){if(b.leaf){this.startWorkflow(b.id)}},this)},startWorkflow:function(a){Ext.Ajax.request({method:"POST",url:itasks.config.serverUrl+"/new/start",params:{_session:itasks.app.session,workflow:a},scripts:false,callback:this.startWorkflowCB,scope:this})},startWorkflowCB:function(d,f,a,c){try{var e=Ext.decode(a.responseText);this.fireEvent("processStarted",e.taskid)}catch(b){}}});Ext.reg("itasks.nwpanel",itasks.NewWorkPanel);Ext.namespace("itasks");itasks.DebugPanel=Ext.extend(Ext.Panel,{worktabs:null,initComponent:function(){Ext.apply(this,{title:"Debug",iconCls:"icon-debug",bodyStyle:"padding: 5px",deferredRender:false,items:[{xtype:"fieldset",title:"Overviews",autoHeight:true,items:[{xtype:"button",text:"Show task forest...",iconCls:"icon-task-tree",style:"margin-bottom: 2px;",listeners:{click:{fn:function(){this.worktabs.openTaskForestTab()},scope:this}}},{xtype:"button",text:"Show process table...",iconCls:"icon-process-table",listeners:{click:{fn:function(){this.worktabs.openProcessTableTab()},scope:this}}}]},{xtype:"fieldset",title:"Session",html:itasks.app.session,autoHeight:true,hideLabels:true}]});itasks.DebugPanel.superclass.initComponent.apply(this,arguments)}});Ext.reg("itasks.debug",itasks.DebugPanel);Ext.ns("itasks");itasks.WorkListPanel=Ext.extend(Ext.grid.GridPanel,{initComponent:function(){var a=function(c,f,b){var e="";var g=b.data.tree_path.length;f.attr='style="margin: 0px; padding: 0px"';for(var d=0;d<g;d++){if(b.data.tree_path[d]){e+='<div class="treegrid treegrid-line" style="left: '+d*16+'px"></div>'}else{e+='<div class="treegrid treegrid-empty" style="left: '+d*16+'px"></div>'}}if(b.data.tree_last){e+='<div class="treegrid treegrid-last" style="left: '+g*16+'px"></div>'}else{e+='<div class="treegrid treegrid-middle" style="left: '+g*16+'px"></div>'}e+='<div class="treegrid treegrid-icon icon-'+b.data.tree_icon+'" style="left: '+(g+1)*16+'px"></div>';if(b.data.tree_new){e+='<div class="treegrid-label" style="font-weight: bold; left: '+(g+2)*16+'px">'+c+"</div>"}else{e+='<div class="treegrid-label" style="left: '+(g+2)*16+'px">'+c+"</div>"}return e};this.workStore=new Ext.data.Store({autoLoad:false,bufferSize:300,url:itasks.config.serverUrl+"/work/list",reader:new Ext.data.JsonReader({root:"worklist",totalProperty:"total",successProperty:"success",fields:[{name:"subject"},{name:"priority"},{name:"progress"},{name:"delegatorName"},{name:"timestamp"},{name:"latestExtEvent"},{name:"deadline"},{name:"tree_path"},{name:"tree_last"},{name:"tree_icon"},{name:"tree_new"},{name:"taskid"}]})});this.workView=new Ext.grid.GridView({deferEmptyText:true,emptyText:"There is no unfinished work.",nearLimit:100,loadMask:{msg:"Please wait..."}});Ext.apply(this,{border:false,store:this.workStore,view:this.workView,selModel:new Ext.grid.RowSelectionModel(),columns:[{id:"subject",header:"Subject",dataindex:"taskid",renderer:a,width:200},{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: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",enableColumnMove:false,enableHdMenu:false,stripeRows:true,tbar:[{id:"refreshbutton",xtype:"tbbutton",text:"Refresh worklist",iconCls:"x-tbar-loading",listeners:{click:{scope:this,fn:function(b){this.refresh()}}}}]});itasks.WorkListPanel.superclass.initComponent.apply(this,arguments);this.addEvents("workListRefreshed");this.store.on("loadexception",function(){if(this.store.reader.jsonData.error){itasks.app.restart(this.store.reader.jsonData.error)}},this);this.startAutoRefresh()},getTaskId:function(a){return this.store.getAt(a).data.taskid},refresh:function(){if(this.store!=null){this.store.load({params:{_session:itasks.app.session}});this.fireEvent("workListRefreshed",this)}},startAutoRefresh:function(){if(itasks.config.autoRefresh){var a=this;Ext.TaskMgr.start({run:function(){a.refresh()},interval:itasks.config.refreshRate})}},});Ext.reg("itasks.worklist",itasks.WorkListPanel);Ext.ns("itasks");itasks.HomeTabPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{title:"Welcome",closable:false,iconCls:"icon-home",autoLoad:"skins/"+itasks.config.skin+"/welcome.html"});itasks.HomeTabPanel.superclass.initComponent.apply(this,arguments)}});Ext.reg("itasks.hometab",itasks.HomeTabPanel);Ext.ns("itasks");itasks.TaskForestTabPanel=Ext.extend(Ext.Panel,{initComponent:function(){this.tree=new Ext.ux.tree.ColumnTree({id:"treepanel",region:"center",rootVisible:false,autoScroll:true,title:"Task Overview",border:false,bodyStyle:"background-color: white",iconCls:"icon-task-tree",columns:[{header:"Task Id",dataIndex:"taskId",width:500},{header:"Assigned to..",dataIndex:"user",width:100},{header:"Task Label",dataIndex:"taskLabel",width:200},{header:"Trace Value",dataIndex:"traceValue",width:200},{header:""}],loader:new Ext.tree.TreeLoader({dataUrl:itasks.config.serverUrl+"/debug/taskforest",baseParams:{_session:itasks.app.session},requestMethod:"POST",uiProviders:{col:Ext.ux.tree.ColumnNodeUI}}),root:new Ext.tree.AsyncTreeNode({text:"Tasks"})});this.iconPanel=new Ext.Panel({id:"iconpanel",region:"south",height:20,border:false,html:'<div class="taskForestLegend task-mnt">Main Task</div><div class="taskForestLegend task-int">Edit Task</div><div class="taskForestLegend task-mon">Monitor Task</div><div class="taskForestLegend task-fin">Finished Task</div><div class="taskForestLegend task-seq">Sequential Combinator</div><div class="taskForestLegend task-par">Parallel Combinator</div><div class="taskForestLegend task-rpc">Remote Procedure Call</div><div class="x-clear"></div>'});Ext.apply(this,{title:"Task forest",closable:true,autoScroll:false,cls:"worktab-container",iconCls:"icon-task-tree",layout:"border",bodyStyle:"background-color: white",items:[this.tree,this.iconPanel],tbar:[{text:"Refresh",iconCls:"x-tbar-loading",listeners:{click:{fn:function(a){this.refresh()},scope:this}}},{text:"(Un)fold tree",iconCls:"icon-collapse-tree",listeners:{click:{fn:function(a){this.toggleTree()},scope:this}}}]});itasks.TaskForestTabPanel.superclass.initComponent.apply(this,arguments)},refresh:function(){this.tree.getRootNode().reload()},toggleTree:function(){var a=this.tree.getRootNode();toggleChild=function(b){if(b.isExpanded()){b.collapse(true,false)}else{b.expand(true,true)}};a.eachChild(toggleChild)}});Ext.reg("itasks.taskforesttab",itasks.TaskForestTabPanel);Ext.ns("itasks");itasks.ProcessTableTabPanel=Ext.extend(itasks.RemoteDataPanel,{applicationPanel:undefined,initComponent:function(){Ext.apply(this,{title:"Process table",closable:true,autoScroll:true,url:itasks.config.serverUrl+"/debug/processtable",cls:"worktab-container",iconCls:"icon-process-table",bodyStyle:"padding: 10px;",tbar:[{text:"Refresh",iconCls:"x-tbar-loading",listeners:{click:{fn:function(a){this.refresh()},scope:this}}}]});itasks.ProcessTableTabPanel.superclass.initComponent.apply(this,arguments)},update:function(a){this.body.dom.innerHTML=a}});Ext.reg("itasks.processtabletab",itasks.ProcessTableTabPanel);Ext.ns("itasks");itasks.WorkPanel=Ext.extend(itasks.RemoteDataPanel,{taskId:null,properties:null,debug:false,initialized:false,initComponent:function(){Ext.apply(this,{title:"Loading task...",closable:true,autoDestroy:true,iconCls:"icon-task",url:itasks.config.serverUrl+"/work/tab",params:{_maintask:this.taskId,_debug:itasks.app.debug?1:0},layout:"anchor",deferredRender:false,items:[{xtype:"itasks.work-header",height:25,anchor:"r"},{xtype:"tabpanel",anchor:"r -25",cls:"worktab-container",tabPosition:"bottom",layoutOnTabChange:true,activeTab:0,items:[{title:"Task",iconCls:"icon-task",border:false,bodyStyle:"padding: 10px;",autoScroll:true},{title:"Status",xtype:"itasks.work-status",iconCls:"icon-waiting",border:false,autoScroll:true}],tbar:[{text:"Refresh task",iconCls:"x-tbar-loading",listeners:{click:{scope:this,fn:function(a){this.refresh()}}}}]}]});itasks.WorkPanel.superclass.initComponent.apply(this,arguments);this.addEvents("taskRedundant","taskDone","propertyChanged");this.on("remoteCallStart",function(){this.getComponent(0).setBusy(true)},this);this.on("remoteCallEnd",function(){this.getComponent(0).setBusy(false)},this)},update:function(b){if(b.content=="done"||b.content=="redundant"){var a=this.getComponent(1).getComponent(0);if(a.items&&a.items.length){a.remove(0)}switch(b.content){case"done":a.add(new itasks.WorkMessagePanel({html:"This task is completed. Thank you."}));this.fireEvent("taskDone");break;case"redundant":a.add(new itasks.WorkMessagePanel({html:"The completion of this task is no longer required.<br />It has been removed. Thank you for your effort."}));this.fireEvent("taskRedundant");break}a.doLayout();return}this.properties=b.properties;this.getComponent(0).setContent(this.taskId,b.subject,b.properties);this.updateTitle(b.subject);this.updateContent(b.content);this.updateStatus(b.properties);this.params={_maintask:this.taskId,_debug:itasks.app.debug?1:0}},updateTitle:function(a){this.setTitle(Ext.util.Format.ellipsis(a.join(" - "),10))},updateContent:function(b){var a=this.getComponent(1).getComponent(0);if(this.initialized){var c=a.getComponent(0);if(c.taskId==b.taskId&&c.xtype==b.xtype){c.update(b)}else{a.remove(0,true);a.add(b);a.doLayout()}}else{a.add(b);a.doLayout();this.initialized=true}},updateStatus:function(a){this.getComponent(1).getComponent(1).update(a)},sendTaskUpdates:function(b,a){Ext.apply(this.params,a);this.params._targettask=b;this.refresh()},sendPropertyEvent:function(c,a,b){this.getComponent(0).setBusy(true);Ext.Ajax.request({url:itasks.config.serverUrl+"/work/property",method:"GET",params:{_session:itasks.app.session,process:c,property:a,value:b},callback:function(f,g,d,e){this.getComponent(0).setBusy(false);this.fireEvent("propertyChanged");if(a=="user"||a=="progress"){this.refresh()}},scope:this})}});itasks.WorkHeaderPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{deferredRender:false,html:"Loading..."});itasks.WorkHeaderPanel.superclass.initComponent.apply(this,arguments)},setContent:function(a,c,b){worktabStatus=function(d){switch(d){case null:return"";case"TPActive":return"worktab-header-progress-active";case"TPStuck":return"worktab-header-progress-stuck";case"TPWaiting":return"worktab-header-progress-waiting";case"TPReject":return"worktab-header-progress-reject"}};worktabBackground=function(d){switch(d){case null:return"";case"LowPriority":case"NormalPriority":return"worktab-header-normal-priority";case"HighPriority":return"worktab-header-high-priority"}};var c=c.join(" &raquo; ")+(itasks.config.debug?(" ("+a+")"):"");this.body.update(String.format('<div class="worktab-header {1}"><div class="worktab-header-status {0}"></div><div class="worktab-header-separator"></div><div class="worktab-header-text"><table><tr><th>Subject:</th><td>{2}</td><th>Managed by:</th><td>{3}</td><th>Deadline:</th><td>{4}</td></table></div></div><div class="worktab-header-indicator">',worktabStatus(b.workerProps.progress),worktabBackground(b.managerProps.priority),c,b.systemProps.manager[1],itasks.util.formatDeadline(b.managerProps.deadline)))},setBusy:function(b){var a=this.getEl().child(".worktab-header-indicator");if(a){a.setVisible(b)}}});itasks.WorkMessagePanel=Ext.extend(Ext.Panel,{timeout:5000,interval:10,timepassed:0,runner:null,initComponent:function(){Ext.apply(this,{cls:"worktab-content",border:false,items:[{xtype:"panel",border:false,html:this.html},{xtype:"progress",style:"margin: 10px 0px 0px 0px;",value:1,text:"This window will automatically close in "+(this.timeout/1000)+" seconds"}],html:null});itasks.WorkMessagePanel.superclass.initComponent.apply(this,arguments);this.runner={run:this.update,scope:this,interval:this.interval};Ext.TaskMgr.start(this.runner)},update:function(){if(this.timepassed>=this.timeout){var b=this.findParentByType("itasks.work");if(b.ownerCt){b.ownerCt.remove(b)}}else{this.timepassed+=this.interval;var a=this.getComponent(1);a.updateText("This window will automatically close in "+Math.ceil((this.timeout-this.timepassed)/1000)+" seconds");a.updateProgress((this.timeout-this.timepassed)/this.timeout)}},onDestroy:function(){if(this.runner){Ext.TaskMgr.stop(this.runner)}itasks.WorkMessagePanel.superclass.onDestroy.apply(this,arguments)}});itasks.WorkStatusPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{layout:"form",cls:"worktab-content",defaultType:"staticfield",items:[{xtype:"itasks.progress",name:"progress",fieldLabel:"Progress",format:itasks.util.formatProgress,listeners:{change:function(c,b){var a=this.findParentByType("itasks.work");a.sendPropertyEvent(a.properties.systemProps.processId,"progress",b)}}},{name:"priority",fieldLabel:"Priority",format:itasks.util.formatPriority},{name:"issuedAt",fieldLabel:"Issued at",format:itasks.util.formatDate},{name:"firstEvent",fieldLabel:"First worked on",format:itasks.util.formatStartDate},{name:"latestEvent",fieldLabel:"Last worked on",format:itasks.util.formatStartDate}]});itasks.WorkStatusPanel.superclass.initComponent.apply(this,arguments)},update:function(b){var a=[b.workerProps.progress,b.managerProps.priority,b.systemProps.issuedAt,b.systemProps.firstEvent,b.systemProps.latestEvent];this.items.each(function(c,d){c.setValue(a[d])})}});itasks.TaskExtFormPanel=Ext.extend(Ext.form.FormPanel,{initComponent:function(){Ext.apply(this,{taskUpdates:{},border:false,url:"/handlers/work/tab",bodyStyle:"margin: 10px"});itasks.TaskExtFormPanel.superclass.initComponent.apply(this,arguments)},onRender:function(){itasks.TaskExtFormPanel.superclass.onRender.apply(this,arguments);this.attachTaskHandlers(this)},attachTaskHandlers:function(a){var e=function(){var g=this.findParentByType("itasks.task-ext-form");if(!g){return}function f(m){var j=[];var k=m.length;for(var l=0;l<k;l++){j[j.length]=m[l].value}return Ext.encode(j)}var h;switch(this.xtype){case"radiogroup":h=this.getValue().value;break;case"checkboxgroup":h=f(arguments[1]);break;case"datefield":h=this.getRawValue();break;default:h=this.getValue()}g.addUpdate(this.name,h);g.sendUpdates(true)};var d=function(){var f=this.findParentByType("itasks.task-ext-form");if(!f){return}f.addUpdate(this.name,this.value);f.sendUpdates()};switch(a.getXType()){case"textfield":case"textarea":case"numberfield":case"datefield":case"timefield":case"radiogroup":a.on("change",e);break;case"checkbox":a.on("check",e);break;case"checkboxgroup":a.on("change",e);break;case"combo":a.on("select",e);case"button":a.on("click",d);break}if(a.buttons){var b=a.buttons.length;for(var c=0;c<b;c++){a.buttons[c].on("click",d)}}if(a.items&&a.items.each){a.items.each(this.attachTaskHandlers,this)}},addUpdate:function(a,b){this.taskUpdates[a]=b},sendUpdates:function(b){if(b){new Ext.util.DelayedTask().delay(250,this.sendUpdates,this)}else{var a=this.findParentByType("itasks.work");if(!a){return}a.sendTaskUpdates(this.taskId,this.taskUpdates);this.taskUpdates={}}},update:function(f){if(f.updates){var c=f.updates.length;for(i=0;i<c;i++){var h=f.updates[i];switch(h[0]){case"TUIAdd":var d=Ext.getCmp(h[1]);if(d){var g=function(j,k,l){if(k.items.get(l)==undefined){return l}if(k.items.get(l)==j){return l}else{return g(j,k,l+1)}};var b=g(d,d.ownerCt,0)+1;var e=d.ownerCt.insert(b,h[2]);d.ownerCt.doLayout();d.ownerCt.syncSize();d.ownerCt.ownerCt.doLayout();this.attachTaskHandlers(e)}break;case"TUIRemove":var d=Ext.getCmp(h[1]);if(d){var a=d.ownerCt;a.remove(h[1]);a.ownerCt.doLayout();a.ownerCt.syncSize()}break;case"TUIReplace":var d=Ext.getCmp(h[1]);if(d){var a=d.ownerCt;var g=function(j,k,l){if(k.items.get(l)==undefined){return l}if(k.items.get(l)==j){return l}else{return g(j,k,l+1)}};var b=g(d,d.ownerCt,0);a.remove(b);var e=a.insert(b,h[2]);a.doLayout();a.syncSize();a.ownerCt.doLayout();this.attachTaskHandlers(e)}break;case"TUISetEnabled":var d=Ext.getCmp(h[1]);if(d&&d.setDisabled){d.setDisabled(!h[2])}break;case"TUISetValue":var d=Ext.getCmp(h[1]);if(d&&d.setValue){d.setValue(h[2])}break}}}else{this.removeAll();this.add(f.items[0]);this.doLayout();this.attachTaskHandlers(this)}}});itasks.TaskMonitorPanel=Ext.extend(Ext.Panel,{initComponent:function(){itasks.TaskMonitorPanel.superclass.initComponent.apply(this,arguments)},update:function(a){this.el.update(a.html)}});itasks.TaskWaitingPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{cls:"worktab-content",border:false,hideBorders:true,items:[{html:"Waiting for <i>"+this.properties.managerProps.subject+"</i>",style:"margin: 0px 0px 20px 0px;"},{xtype:"panel",layout:"form",defaultType:"staticfield",items:[{xtype:"itasks.user",fieldLabel:"Assigned to",value:this.properties.managerProps.worker[1],listeners:{change:{fn:function(b,a){this.findParentByType("itasks.work").sendPropertyEvent(this.properties.systemProps.processId,"user",a)},scope:this}}},{xtype:"itasks.priority",fieldLabel:"Priority",value:this.properties.managerProps.priority,listeners:{change:{fn:function(b,a){this.findParentByType("itasks.work").sendPropertyEvent(this.properties.systemProps.processId,"priority",a)},scope:this}}},{fieldLabel:"Progress",format:itasks.util.formatProgress,value:this.properties.workerProps.progress},{fieldLabel:"Issued at",format:itasks.util.formatDate,value:this.properties.systemProps.issuedAt},{fieldLabel:"First worked on",format:itasks.util.formatStartDate,value:this.properties.systemProps.firstEvent},{fieldLabel:"Last worked on",format:itasks.util.formatStartDate,value:this.properties.systemProps.latestEvent}]}]});itasks.TaskWaitingPanel.superclass.initComponent.apply(this,arguments)},update:function(b){this.properties=b.properties;var c=b.properties;var a=[c.managerProps.worker[1],c.managerProps.priority,c.workerProps.progress,c.systemProps.issuedAt,c.systemProps.firstEvent,c.systemProps.latestEvent];this.getComponent(0).body.update("Waiting for <i>"+Ext.util.Format.htmlEncode(b.properties.managerProps.subject)+"</i>");this.getComponent(1).items.each(function(d,e){d.setValue(a[e])})}});itasks.form.UserField=Ext.extend(itasks.form.InlineField,{format:function(a,b){return(b.label!="")?b.label:a},field:{xtype:"combo",value:this.value,label:"",store:new Ext.data.JsonStore({root:"users",totalProperty:"total",fields:["userId","displayName"],url:"/handlers/data/users"}),displayField:"displayName",valueField:"userId",triggerAction:"all",editable:false,forceSelection:true,listeners:{select:function(a,c,b){a.label=c.get("displayName")},beforequery:function(a){a.combo.store.baseParams._session=itasks.app.session}}}});itasks.form.PriorityField=Ext.extend(itasks.form.InlineField,{format:itasks.util.formatPriority,field:{xtype:"combo",value:this.value,store:[["HighPriority","High"],["NormalPriority","Normal"],["LowPriority","Low"]],editable:false,triggerAction:"all",forceSelection:true}});itasks.form.ProgressField=Ext.extend(itasks.form.InlineField,{format:itasks.util.formatProgress,field:{xtype:"combo",value:this.value,store:[["TPActive","Active"],["TPStuck","Stuck"],["TPWaiting","Waiting"],["TPReject","Reject"]],editable:false,triggerAction:"all",forceSelection:true}});Ext.reg("itasks.user",itasks.form.UserField);Ext.reg("itasks.priority",itasks.form.PriorityField);Ext.reg("itasks.progress",itasks.form.ProgressField);itasks.TaskCombinationPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{border:false,layout:this.combination=="horizontal"?"hbox":null});if(this.combination=="horizontal"){for(var a=0;a<this.items.length;a++){this.items[a].flex=1}}itasks.TaskCombinationPanel.superclass.initComponent.apply(this,arguments)},update:function(e){var b=e.items;for(var d=0;d<b.length;d++){var c;for(c=d;c<this.items.length;c++){if(this.items.get(c).taskId==b[d].taskId){break}}if(c<this.items.length){for(var a=0;a<(c-d);a++){this.remove(d)}this.items.get(d).update(b[d])}else{this.insert(d,b[d])}}var f=(this.items.length-b.length);for(var d=0;d<f;d++){this.remove(b.length)}if(this.combination=="horizontal"){for(var d=0;d<b.length;d++){this.items.get(d).flex=1}}this.doLayout()}});Ext.reg("itasks.work",itasks.WorkPanel);Ext.reg("itasks.work-header",itasks.WorkHeaderPanel);Ext.reg("itasks.work-status",itasks.WorkStatusPanel);Ext.reg("itasks.task-ext-form",itasks.TaskExtFormPanel);Ext.reg("itasks.task-monitor",itasks.TaskMonitorPanel);Ext.reg("itasks.task-waiting",itasks.TaskWaitingPanel);Ext.reg("itasks.task-combination",itasks.TaskCombinationPanel);Ext.ns("itasks");itasks.WorkTabsPanel=Ext.extend(Ext.TabPanel,{initComponent:function(){Ext.apply(this,{activeItem:0,layoutOnTabChange:true,items:{xtype:"itasks.hometab"}});itasks.WorkTabsPanel.superclass.initComponent.apply(this,arguments)},openWorkTab:function(a){var d="worktab-"+a;var c=this.getComponent(d);var b=false;if(c==undefined){b=true;c=new itasks.WorkPanel({id:d,taskId:a});this.add(c);this.activate(c);this.doLayout()}this.activate(c);return[c,b]},openDebugTab:function(){var a=this.getComponent("debugtab");if(a==undefined){a=new itasks.DebugPanel({id:"debugtab",worktabs:this,closable:true});this.add(a)}this.activate(a);return a},openTaskForestTab:function(){var a=this.getComponent("taskforesttab");if(a==undefined){a=new itasks.TaskForestTabPanel({id:"taskforesttab"});this.add(a)}this.activate(a);a.refresh();return a},openProcessTableTab:function(){var a=this.getComponent("processtabletab");if(a==undefined){a=new itasks.ProcessTableTabPanel({id:"processtabletab"});this.add(a)}this.activate(a);a.refresh();return a}});Ext.reg("itasks.worktabs",itasks.WorkTabsPanel);Ext.ns("itasks");itasks.ApplicationPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{layout:"border",hidden:true,hideMode:"offsets",deferredRender:false,items:[{id:"northpanel",xtype:"panel",region:"north",height:40,html:'<div id="logo" ></div><div id="user">Welcome '+itasks.app.displayName+' | <a id="logout" href="javascript:void(0);">Log out &raquo;</a></div>'},{id:"leftpanel",xtype:"itasks.nwpanel",region:"west",layoutConfig:{animate:true},collapsible:true,split:true,border:false,deferredRender:false,width:200,minWidth:200,maxWidth:400},{id:"centerpanel",region:"center",xtype:"panel",layout:"border",border:false,deferredRender:false,items:[{id:"worklist",xtype:"itasks.worklist",region:"north",split:true,height:150},{id:"worktabs",xtype:"itasks.worktabs",border:false,region:"center"}]}]});itasks.ApplicationPanel.superclass.initComponent.apply(this,arguments)},init:function(){var f=this;var g=this.getComponent("leftpanel");var e=this.getComponent("centerpanel").getComponent("worklist");var b=this.getComponent("centerpanel").getComponent("worktabs");e.refresh();Ext.get("logout").on("click",function(){f.logout()});var c=function(h){if(h[1]){h[0].on("taskDone",function(j){e.refresh()});h[0].on("taskRedundant",function(j){e.refresh()});h[0].on("propertyChanged",function(j){e.refresh()})}h[0].refresh()};e.on("cellclick",function(j,l,h,k){c(b.openWorkTab(j.getTaskId(l)))});e.on("workListRefreshed",function(h){h.workStore.each(function(){var l=b.getComponent("worktab-"+this.data.taskid);var j=this.data.latestExtEvent;if(l!=null){var k=l.properties.systemProps.latestEvent;if(j>k){l.refresh()}}})});g.on("processStarted",function(h){e.refresh();c(b.openWorkTab(h))},this);b.on("resize",function(h){h.doLayout()});if(itasks.config.debug){var a=e.getTopToolbar();var d={xtype:"tbbutton",text:"Debug...",iconCls:"icon-debug",listeners:{click:{fn:function(){b.openDebugTab()},scope:this}}};if(e.rendered){a.add(d)}else{a[a.length]=d}}},logout:function(){Ext.Ajax.request({url:itasks.config.serverUrl+"/deauthenticate",method:"POST",params:{session:itasks.app.session},scripts:false,callback:function(){itasks.app.restart()},scope:this})}});Ext.ns("itasks");itasks.Application=function(){return{session:null,displayName:null,viewport:new Ext.Viewport({layout:"card",activeItem:0,layoutConfig:{deferredRender:false},items:{baseCls:"bg",xtype:"panel"}}),loginWindow:null,loaderWindow:null,mainGui:null,start:function(a){this.errorMsg=a;this.loadConfig()},loadConfig:function(){Ext.Ajax.request({url:"config.json",success:this.continueConfig,scope:this})},continueConfig:function(a){itasks.config=Ext.decode(a.responseText);this.loadSkin();if(!this.loginWindow){this.loginWindow=new itasks.LoginWindow({errorMsg:this.errorMsg,continuation:this.loadUserInterface.createDelegate(this)});this.viewport.getComponent(0).add(this.loginWindow)}else{this.loginWindow.setError(this.errorMsg)}this.loginWindow.show()},loadSkin:function(){var a=document.createElement("link");a.rel="stylesheet";a.type="text/css";a.href="skins/"+itasks.config.skin+"/main.css";document.body.appendChild(a);document.title=itasks.config.appTitle},loadUserInterface:function(a,c){this.session=c;this.displayName=a;this.loginWindow.hide();var b=this.viewport.getComponent(0);if(!this.loaderWindow){this.loaderWindow=new itasks.LoaderWindow({continuation:this.startUserInterface.createDelegate(this)});this.viewport.getComponent(0).add(this.loaderWindow)}else{this.loaderWindow.updateProgress(0,"Initializing")}this.loaderWindow.show();this.loaderWindow.updateProgress(0.2,"Building User Interface...");this.mainGui=new itasks.ApplicationPanel();this.viewport.add(this.mainGui);this.viewport.doLayout();this.loaderWindow.updateProgress(0.6,"Initializing User Interface...");this.mainGui.init();this.loaderWindow.updateProgress(1,"Done.");this.loaderWindow.finish()},startUserInterface:function(){this.loaderWindow.hide();this.viewport.layout.setActiveItem(1)},reset:function(){this.viewport.layout.setActiveItem(0);this.viewport.remove(1,true)},restart:function(a){this.reset();this.start(a)}}};Ext.ns("itasks");itasks.GMapPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.applyIf(this,{url:"/handlers/work/tab",zoom:15,center:[51.824118,5.868174],mapType:"ROADMAP",border:false,autoHeight:false,height:400,width:500,scope:this,displayedMarkers:new Array()});itasks.GMapPanel.superclass.initComponent.apply(this,arguments);this.show()},setValue:function(a){var b=Ext.decode(a);this.markers=b.markers;this.addMarkers()},getMapType:function(mapType){return eval("google.maps.MapTypeId."+mapType)},afterRender:function(){itasks.GMapPanel.superclass.afterRender.call(this);var a={center:new google.maps.LatLng(this.center[0],this.center[1]),zoom:this.zoom,mapTypeId:this.getMapType(this.mapType)};this.gmap=new google.maps.Map(this.body.dom,a);this.addMarkers();var c=this;var b=function(){var h=c.gmap.getCenter();var e=c.gmap.getZoom();var g={center:[h.lat(),h.lng()],zoom:e,type:c.gmap.getMapTypeId().toUpperCase()};var f=c.findParentByType("itasks.task-ext-form");if(!f){return}f.addUpdate(c.name,Ext.encode(g));f.sendUpdates()};var d=function(f){var h=f.latLng;var g={event:"LEFTCLICK",source:"MAP",point:[h.lat(),h.lng()]};var e=c.findParentByType("itasks.task-ext-form");if(!e){return}e.addUpdate(c.name,Ext.encode(g));e.sendUpdates()};if(this.isEditor){google.maps.event.addListener(this.gmap,"maptypeid_changed",b);google.maps.event.addListener(this.gmap,"idle",b);google.maps.event.addListener(this.gmap,"click",d)}},addMarkers:function(){var b=0;for(b=0;b<this.displayedMarkers.length;b++){this.displayedMarkers[b].setMap(null)}this.displayedMarkers=new Array();for(b=0;b<this.markers.length;b++){var a=new google.maps.Marker({map:this.gmap,position:new google.maps.LatLng(this.markers[b].position[0],this.markers[b].position[1])});this.displayedMarkers[b]=a}}});Ext.reg("itasks.gmappanel",itasks.GMapPanel);Ext.ns("itasks");itasks.GStaticMapPanel=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{border:false,autoHeight:false,html:'<img src="'+this.url+'" width="'+this.width+'" height="'+this.height+'">'});itasks.GMapPanel.superclass.initComponent.apply(this,arguments);this.show()}});Ext.reg("itasks.gstaticmappanel",itasks.GStaticMapPanel);Ext.BLANK_IMAGE_URL="/ext3/resources/images/default/s.gif";Ext.ns("itasks");Ext.onReady(function(){itasks.app=new itasks.Application();itasks.app.start()});
\ No newline at end of file
......@@ -27,8 +27,6 @@ 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
......@@ -50,6 +48,6 @@ where
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
= snd (updateProcessProperties pid (\p -> {p & systemProps = {p.systemProps & firstEvent = case p.systemProps.firstEvent of Nothing = Just now; x = x
, latestExtEvent = Just now
}}) tst))
}}) tst)
definition module RPCStubs
import google_maps_services
import geonames_webservices
implementation module RPCStubs
\ No newline at end of file
definition module geonames_webservices
import iTasks
ocean_names :: Real Real (String -> String) -> Task String
country_code :: Real Real String (String -> String) -> Task String
implementation module geonames_webservices
import JSON
import RPC
import TSt
ocean_names :: Real Real (String -> String) -> Task String
ocean_names lat lng parsefun = mkRpcTask "Ocean Names"
{ RPCExecute
| taskId = ""
, interface = { RPCInterface | protocol = HTTP GET, type = JSONRPC }
, operation = { RPCOperation | name = "Ocean Names", parameters = [{ RPCParam | name = "lat", type = RPCReal }, { RPCParam | name = "lng", type = RPCReal }], location = "http://ws.geonames.org/oceanJSON", callType = RequestResponse, returnType = "String" }
, paramValues = [{ RPCParamValue | name="lat", serializedValue = toString lat},{ RPCParamValue | name="lng", serializedValue = toString lng}]
, status = ""
} parsefun
country_code :: Real Real String (String -> String) -> Task String
country_code lat lng type parsefun = mkRpcTask "Country Code"
{ RPCExecute
| taskId = ""
, interface = { RPCInterface | protocol = HTTP GET, type = JSONRPC }
, operation = { RPCOperation | name = "Country Code", parameters = [{ RPCParam | name = "lat", type = RPCReal }, { RPCParam | name = "lng", type = RPCReal }, { RPCParam | name = "type", type = RPCString }], location = "http://ws.geonames.org/countryCode", callType = RequestResponse, returnType = "String" }
, paramValues = [{ RPCParamValue | name="lat", serializedValue = toString lat},{ RPCParamValue | name="lng", serializedValue = toString lng},{ RPCParamValue | name="type", serializedValue = toString type}]
, status = ""
} parsefun
definition module google_maps_services
import iTasks
reverse_geocoding :: String String Bool String (String -> String) -> Task String
implementation module google_maps_services
import JSON
import RPC
import TSt
reverse_geocoding :: String String Bool String (String -> String) -> Task String
reverse_geocoding q output sensor api_key parsefun = mkRpcTask "Reverse Geocoding"
{ RPCExecute
| taskId = ""
, interface = { RPCInterface | protocol = HTTP GET, type = JSONRPC }
, operation = { RPCOperation | name = "Reverse Geocoding", parameters = [{ RPCParam | name = "q", type = RPCString }, { RPCParam | name = "output", type = RPCString }, { RPCParam | name = "sensor", type = RPCBool }, { RPCParam | name = "api_key", type = RPCString }], location = "http://maps.google.com/maps/geo", callType = RequestResponse, returnType = "String" }
, paramValues = [{ RPCParamValue | name="q", serializedValue = toString q},{ RPCParamValue | name="output", serializedValue = toString output},{ RPCParamValue | name="sensor", serializedValue = toString sensor},{ RPCParamValue | name="api_key", serializedValue = toString api_key}]
, status = ""
} parsefun
This diff was suppressed by a .gitattributes entry.
......@@ -122,7 +122,7 @@ where
instance toString RPCParam
where
toString x = "{ RPCParamValue | name=\""+++x.RPCParam.name+++"\", serializedValue = toJSON "+++x.RPCParam.name+++"}"
toString x = "{ RPCParamValue | name=\""+++x.RPCParam.name+++"\", serializedValue = toString "+++x.RPCParam.name+++"}"
writeDCL :: !RPCDescription !Path !*World -> *World
writeDCL rpcd wpath world
......@@ -173,7 +173,7 @@ writeWrapper rpcds wpath world
= world
where
writeImports [] f = f
writeImports [x:xs] f = writeImports xs ( fwrites ("import "+++(prepName x.service.RPCService.name)) f)
writeImports [x:xs] f = writeImports xs ( fwrites ("import "+++(prepName x.service.RPCService.name)+++"\n") f)
//=== UTILITY =====================================================================
......
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