2 XObject = imports.XObject.XObject;
3 XMLHttpRequest = imports.XMLHttpRequest.XMLHttpRequest;
4 Netrc = imports.Netrc.Netrc;
5 Date = imports.Date.Date;
13 * => Tasks.notify(commit)
23 commitRepo : false, // the DB version of repo info..
26 nextPrompt : false, // time when the system last prompted a confirmation that a task is being worked on.
29 notifyIdle : function()
34 notify : function(commit)
36 if (this.inQuery && this.inQuery > (new Date())) {
37 // ignore the notification.. we are currently checking what the current
40 // we need to handle a WTF situation where something below failed... so
44 this.inQuery = (new Date()).add(Date.MINUTE, 5);
45 this.lastCommit = commit;
46 this.commitRepo = false;
55 // have we got the status in the last 15 mins..
56 // we should not need to get it again... - it's probably not changed.
57 if (this.curTask && !this.curTask.hasExpired()) {
61 // do the request to get the task..
62 var r = new XMLHttpRequest({
63 onreadystatechange : function() {
65 if (this.status != 4) {
70 var res = JSON.parse(this.responseText);
72 //print(JSON.stringify(res,null,4))
73 //print([ res.success , res.data.length ]);
74 _this.curTask = (res.success && res.data.length) ? (new Task(res.data[0])) : false;
75 print(JSON.stringify(_this.curTask,null,4));
80 var netrc = Netrc.forHost('git.roojs.com');
83 "http://roojs.com/admin.php/Roo/cash_invoice_entry?_current_task=1"
84 ,true, netrc.login, netrc.password );
85 //print("SEding request");
94 var repo = this.lastCommit.repo;
97 var r = new XMLHttpRequest({
98 onreadystatechange : function() {
100 if (this.status != 4) {
105 var res = JSON.parse(this.responseText);
107 print(JSON.stringify(res,null,4))
108 //print([ res.success , res.data.length ]);
109 _this.commitRepo = (res.success && res.data.length) ? res.data[0] : false;
110 print(JSON.stringify(_this.commitRepo))
111 _this.verifyCommit();
115 var netrc = Netrc.forHost('git.roojs.com');
118 "http://roojs.com/admin.php/Roo/mtrack_repos?shortname=" + repo.name
119 ,true, netrc.login, netrc.password );
120 //print("SEding request");
126 //---------- end fetching - now verifying..
130 verifyCommit : function()
132 // using curTask + lastCommit decide what to do.
135 this.verifyTaskTime();
136 this.verifyTaskProject();
143 verifyTaskTime : function()
145 // check to see if current task is being planned for too long..
146 // you should only enter task, and allow it to span over an hour.
147 // if you do the whole day on a task, then it will need to verify with you every so often that you
148 // need to confirm that you are still working on it..
154 Start at 10am, marked working on it till 3pm.
157 at 11am, the system will pop up a warning - are you still working on it?
158 -> if yes pressed, then next warning will be at 11pm
162 if (!this.nextPrompt || (this.nextPrompt < (new Date())) {
164 this.promptForTask();
168 if (this.nextPrompt < (new Date())) {
169 this.promptForTask();
177 //---------- end verifying - now prompting..
179 promptForTask : function()
182 this.nextPrompt = (new Date()).add(Date.MINUTE, 60);
195 Task = XObject.define(
198 if (typeof(cfg) != 'object') {
199 print("CFG not oboject?");
202 XObject.extend(this,cfg);
204 // fix up the values.
205 this.action_datetime = Date.parseDate(this.action_dt,'Y-m-d H:i:s');
206 // print("ACT DT: " + this.action_dt);
212 * This is similar to the cash_invoice_entry data..
215 action_dt: '', //"2012-11-23 11:00:00"
216 description: '', //"QA on new site"
217 qtyvalue: 0, //"2.25"
219 hasExpired : function()
222 var exp = this.action_datetime.add(Date.HOUR, this.qtyvalue);
223 return (new Date()) > exp;
238 //-------------- testing
239 Gtk = imports.gi.Gtk;
241 Tasks.notify( { repo : imports.Scm.Repo.Repo.get('gitlive') } );