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..
27 notifyIdle : function()
32 notify : function(commit)
34 if (this.inQuery && this.inQuery > (new Date())) {
35 // ignore the notification.. we are currently checking what the current
38 // we need to handle a WTF situation where something below failed... so
42 this.inQuery = (new Date()).add(Date.MINUTE, 5);
43 this.lastCommit = commit;
44 this.commitRepo = false;
53 // have we got the status in the last 15 mins..
54 // we should not need to get it again... - it's probably not changed.
55 if (this.curTask && !this.curTask.hasExpired()) {
59 // do the request to get the task..
60 var r = new XMLHttpRequest({
61 onreadystatechange : function() {
63 if (this.status != 4) {
68 var res = JSON.parse(this.responseText);
70 //print(JSON.stringify(res,null,4))
71 //print([ res.success , res.data.length ]);
72 _this.curTask = (res.success && res.data.length) ? (new Task(res.data[0])) : false;
73 print(JSON.stringify(_this.curTask,null,4));
78 var netrc = Netrc.forHost('git.roojs.com');
81 "http://roojs.com/admin.php/Roo/cash_invoice_entry?_current_task=1"
82 ,true, netrc.login, netrc.password );
83 //print("SEding request");
88 verifyCommit : function()
90 // using curTask + lastCommit decide what to do.
93 this.verifyTaskTime();
94 this.verifyTaskProject();
101 verifyTaskTime : function()
103 // check to see if current task is being planned for too long..
104 // you should only enter task, and allow it to span over an hour.
105 // if you do the whole day on a task, then it will need to verify with you every so often that you
106 // need to confirm that you are still working on it..
114 fetchRepo: function()
117 var repo = this.lastCommit.repo;
120 var r = new XMLHttpRequest({
121 onreadystatechange : function() {
122 print("Got result.");
123 if (this.status != 4) {
128 var res = JSON.parse(this.responseText);
130 print(JSON.stringify(res,null,4))
131 //print([ res.success , res.data.length ]);
132 _this.commitRepo = (res.success && res.data.length) ? res.data[0] : false;
133 print(JSON.stringify(_this.commitRepo))
134 _this.verifyCommit();
138 var netrc = Netrc.forHost('git.roojs.com');
141 "http://roojs.com/admin.php/Roo/mtrack_repos?shortname=" + repo.name
142 ,true, netrc.login, netrc.password );
143 //print("SEding request");
160 Task = XObject.define(
163 if (typeof(cfg) != 'object') {
164 print("CFG not oboject?");
167 XObject.extend(this,cfg);
169 // fix up the values.
170 this.action_datetime = Date.parseDate(this.action_dt,'Y-m-d H:i:s');
171 // print("ACT DT: " + this.action_dt);
177 * This is similar to the cash_invoice_entry data..
180 action_dt: '', //"2012-11-23 11:00:00"
181 description: '', //"QA on new site"
182 qtyvalue: 0, //"2.25"
184 hasExpired : function()
187 var exp = this.action_datetime.add(Date.HOUR, this.qtyvalue);
188 return (new Date()) > exp;
203 //-------------- testing
204 Gtk = imports.gi.Gtk;
206 Tasks.notify( { repo : imports.Scm.Repo.Repo.get('gitlive') } );