Commit 5e2582e0 authored by Tristan Cavelier's avatar Tristan Cavelier

Adding application "workinprogress" to OfficeJS that shows the on going tasks.

parent 5644e5b4
...@@ -44,6 +44,15 @@ ...@@ -44,6 +44,15 @@
New Spreadsheet New Spreadsheet
</a> </a>
</li> </li>
<li class="spreadsheet left-nav-tools">
<a href="#/workinprogress"
onclick="javascript:
OfficeJS.open({app:'workinprogress'});
return false;">
<i class="icon-tasks"></i>
Show Activity
</a>
</li>
<!-- <li class="editpreferences left-nav-tools"> --> <!-- <li class="editpreferences left-nav-tools"> -->
<!-- <a href="#/edit_preferences" --> <!-- <a href="#/edit_preferences" -->
<!-- onclick="javascript: --> <!-- onclick="javascript: -->
......
...@@ -6,20 +6,13 @@ ...@@ -6,20 +6,13 @@
<div class="controls docs-input-sizes"> <div class="controls docs-input-sizes">
<input class="input-xlarge" <input class="input-xlarge"
type="text" name="JSONstorage" id="input_json_storage" type="text" name="JSONstorage" id="input_json_storage"
value="{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;tristan&quot;}" value="{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;dummyall3tries&quot;,&quot;a&quot;:&quot;b&quot;},{&quot;type&quot;:&quot;dummyall3tries&quot;,&quot;c&quot;:&quot;d&quot;}]}"
placeholder="storage" /> placeholder="storage" />
<!-- value="{&quot;type&quot;:&quot;dav&quot;,&quot;userName&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;location&quot;:&quot;http://localhost:80&quot;}" --> <!-- value="{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;dummyallfail&quot;,&quot;username&quot;:&quot;1&quot;},{&quot;type&quot;:&quot;dummyall3tries&quot;,&quot;username&quot;:&quot;2&quot;}]},{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;dummyallfail&quot;,&quot;username&quot;:&quot;3&quot;},{&quot;type&quot;:&quot;dummyall3tries&quot;,&quot;username&quot;:&quot;4&quot;}]}]}" -->
<!-- value="{&quot;type&quot;:&quot;replicate&quot;,&quot;storageArray&quot;:[{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;tristan&quot;},{&quot;type&quot;:&quot;dav&quot;,&quot;userName&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;location&quot;:&quot;http://localhost:80&quot;}]}" --> <!-- value="{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;dummyallfail&quot;},{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;dummyall3tries&quot;,&quot;username&quot;:&quot;1&quot;},{&quot;type&quot;:&quot;dummyallfail&quot;,&quot;username&quot;:&quot;2&quot;}]},{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;dummyallnotfound&quot;,&quot;username&quot;:&quot;3&quot;}]}]}" -->
</div> <!-- value="{&quot;type&quot;:&quot;local&quot;,&quot;username&quot;:&quot;tristan&quot;,&quot;applicationname&quot;:&quot;jiotests&quot;}" -->
<label class="control-label" <!-- value="{&quot;type&quot;:&quot;dav&quot;,&quot;username&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;url&quot;:&quot;http://localhost:80&quot;}" -->
for="JSONapplicantID"> <!-- value="{&quot;type&quot;:&quot;replicate&quot;,&quot;storagelist&quot;:[{&quot;type&quot;:&quot;local&quot;,&quot;username&quot;:&quot;tristan&quot;},{&quot;type&quot;:&quot;dav&quot;,&quot;username&quot;:&quot;tristan&quot;,&quot;password&quot;:&quot;mdp&quot;,&quot;url&quot;:&quot;http://localhost:80&quot;}]}" -->
JSON Applicant
</label>
<div class="controls docs-input-sizes">
<input class="input-xlarge"
type="text" name="JSONapplicant" id="input_json_applicant"
value="{&quot;ID&quot;:&quot;jiotests&quot;}"
placeholder="applicant" />
</div> </div>
</div> </div>
<button type="submit" <button type="submit"
......
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Activities</h2>
<div id="workinprogress"></div>
<script type="text/javascript">
<!--
(function() {
var id;
if (!window.workinprogress) {
id = null;
window.workinprogress = {
start:function(){
if (id === null) {
var update = function () {
var act = OfficeJS.getActivity(), i, str = '';
for (i = 0; i < act.length; i+= 1) {
str += act[i] + '<br />';
}
if (str === '') {
str = 'There is no on going tasks.';
}
document.querySelector('#workinprogress').innerHTML=str;
};
update();
id = setInterval (update, 200);
}
},
stop:function(){
if (id !== null) {
clearInterval(id);
id = null;
}
}
};
}
}());
//-->
</script>
</body>
</html>
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
<script type="text/javascript" src="lib/renderjs/renderjs.js"></script> <script type="text/javascript" src="lib/renderjs/renderjs.js"></script>
<script type="text/javascript" src="src/localorcookiestorage.js"></script> <script type="text/javascript" src="src/localorcookiestorage.js"></script>
<script type="text/javascript" src="src/jio.js"></script> <script type="text/javascript" src="lib/jio/jio.js"></script>
<script type="text/javascript" src="lib/base64/base64.js"></script> <script type="text/javascript" src="lib/base64/base64.js"></script>
<script type="text/javascript" src="lib/sjcl/sjcl.min.js"></script> <script type="text/javascript" src="lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript" src="src/jio.storage.js"></script> <script type="text/javascript" src="lib/jio/jio.storage.js"></script>
<script type="text/javascript" src="src/jio.dummystorages.js"></script>
</head> </head>
<body> <body>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
return file_name; return file_name;
} }
}; };
var JIO = jio;
/** /**
* OfficeJS Object * OfficeJS Object
...@@ -174,6 +175,25 @@ ...@@ -174,6 +175,25 @@
update: function () { update: function () {
OfficeJS.open({app:'document_lister',force:true}); OfficeJS.open({app:'document_lister',force:true});
} }
},
workinprogress: {
type:'viewer',
path:'component/workinprogress.html',
gadget_id:'page-content',
onload: function () {
var i = null, wait = function() {
// wait for workinprogress initialization end.
if (window.workinprogress) {
window.workinprogress.start();
clearInterval(i);
}
}
i = setInterval (wait,100);
},
onunload: function () {
window.workinprogress.stop();
return true;
}
} }
}; };
priv.mime_object = { priv.mime_object = {
...@@ -227,7 +247,7 @@ ...@@ -227,7 +247,7 @@
end_getlist:function(){this.end_main('getlist');this.end_spin();}, end_getlist:function(){this.end_main('getlist');this.end_spin();},
end_remove:function(){this.end_main('remove');this.end_spin();} end_remove:function(){this.end_main('remove');this.end_spin();}
}; };
priv.lastfailure = {};
// Initializer // // Initializer //
priv.init = function() { priv.init = function() {
}; };
...@@ -384,7 +404,7 @@ ...@@ -384,7 +404,7 @@
return; return;
} }
// if there is not any jio created // if there is not any jio created
priv.jio = JIO.newJio (storage,applicant); priv.jio = JIO.newJio (JSON.parse(storage));
// update left nav bar // update left nav bar
leftnavbar = priv.getRealApplication ('leftnavbar'); leftnavbar = priv.getRealApplication ('leftnavbar');
if (typeof leftnavbar.update !== 'undefined') { if (typeof leftnavbar.update !== 'undefined') {
...@@ -405,18 +425,21 @@ ...@@ -405,18 +425,21 @@
return; return;
} }
priv.loading_object.getlist(); priv.loading_object.getlist();
priv.jio.getDocumentList({ priv.jio.getDocumentList(
'sort':{'last_modified':'descending', '.',
'name':'ascending'}, {sort:{last_modified:'descending',
'limit':{begin:0,end:50}, name:'ascending'},
// 'search':{name:'a'}, limit:{begin:0,end:50},
'maxtries':3, // search:{name:'a'},
'onResponse':function (result) { max_retry:3,
if (result.status === 'done') { onResponse:function (result) {
priv.data_object.documentList = result.return_value; if (result.status.isDone()) {
priv.data_object.documentList = result.value;
priv.showDocumentListInsideLeftNavBar(); priv.showDocumentListInsideLeftNavBar();
} else { } else {
console.error (result.message); priv.lastfailure.path = '.';
priv.lastfailure.method = 'getDocumentList';
console.error (result.error.message);
} }
priv.loading_object.end_getlist(); priv.loading_object.end_getlist();
if (typeof callback !== 'undefined') { if (typeof callback !== 'undefined') {
...@@ -443,17 +466,18 @@ ...@@ -443,17 +466,18 @@
return; return;
} }
priv.loading_object.save(); priv.loading_object.save();
priv.jio.saveDocument({ priv.jio.saveDocument(
'name':basename+'.'+current_editor.ext, basename+'.'+current_editor.ext,
'content':current_editor.getContent(), current_editor.getContent(),
'onResponse':function (result) { {onResponse:function (result) {
if (result.status === 'fail') { if (!result.status.isDone()) {
console.error (result.message); priv.lastfailure.path = basename;
priv.lastfailure.method = 'saveDocument';
console.error (result.error.message);
} }
priv.loading_object.end_save(); priv.loading_object.end_save();
that.getList(); that.getList();
} }});
});
}; };
/** /**
...@@ -468,19 +492,20 @@ ...@@ -468,19 +492,20 @@
return; return;
} }
priv.loading_object.load(); priv.loading_object.load();
priv.jio.loadDocument({ priv.jio.loadDocument(
'name':basename+'.'+current_editor.ext, basename+'.'+current_editor.ext,
'maxtries':3, {max_retry:3,
'onResponse':function (result) { onResponse:function (result) {
if (result.status === 'fail') { if (!result.status.isDone()) {
console.error (result.message); console.error (result.error.message);
priv.lastfailure.path = basename;
priv.lastfailure.method = 'loadDocument';
} else { } else {
current_editor.setContent( current_editor.setContent(
result.return_value.content); result.value.content);
} }
priv.loading_object.end_load(); priv.loading_object.end_load();
} }});
});
}; };
/** /**
...@@ -494,16 +519,17 @@ ...@@ -494,16 +519,17 @@
return; return;
} }
priv.loading_object.remove(); priv.loading_object.remove();
priv.jio.removeDocument({ priv.jio.removeDocument(
'name':name, name,
'onResponse':function (result) { {onResponse:function (result) {
if (result.status === 'fail') { if (!result.status.isDone()) {
console.error (result.message); console.error (result.error.message);
priv.lastfailure.path = name;
priv.lastfailure.method = 'removeDocument';
} }
priv.loading_object.end_remove(); priv.loading_object.end_remove();
that.getList(); that.getList();
} }});
});
}; };
/** /**
...@@ -519,9 +545,9 @@ ...@@ -519,9 +545,9 @@
} }
for (i = 0, l = documentarray.length; i < l; i+= 1) { for (i = 0, l = documentarray.length; i < l; i+= 1) {
priv.loading_object.remove(); priv.loading_object.remove();
priv.jio.removeDocument({ priv.jio.removeDocument(
name:documentarray[i], documentarray[i],
onResponse:function (result) { {onResponse:function (result) {
cpt += 1; cpt += 1;
if (cpt === l) { if (cpt === l) {
if (typeof current_editor.update !== 'undefined') { if (typeof current_editor.update !== 'undefined') {
...@@ -533,6 +559,60 @@ ...@@ -533,6 +559,60 @@
} }
}; };
that.getActivity = function () {
var activity = priv.jio.getJobArray ();
var lastfailure = that.getLastFailure();
var res = [], i;
for (i = 0; i < activity.length; i+= 1) {
switch (activity[i].command.label) {
case 'saveDocument':
res.push('Saving "' + activity[i].command.path + '",');
break;
case 'loadDocument':
res.push('Loading "' + activity[i].command.path + '".');
break;
case 'removeDocument':
res.push('Removing "' + activity[i].command.path + '".');
break;
case 'getDocumentList':
res.push('Get document list' +
' at "' + activity[i].command.path + '".');
break;
default:
res.push('Unknown action.');
break;
}
}
if (lastfailure.method) {
switch (lastfailure.method) {
case 'saveDocument':
res.push('<span style="color:red;">LastFailure: '+
'Fail to save "'+ lastfailure.path + '"</span>');
break;
case 'loadDocument':
res.push('<span style="color:red;">LastFailure: '+
'Fail to load "'+ lastfailure.path + '"</span>');
break;
case 'removeDocument':
res.push('<span style="color:red;">LastFailure: '+
'Fail to remove "'+ lastfailure.path + '"</span>');
break;
case 'getDocumentList':
res.push('<span style="color:red;">LastFailure: '+
'Fail to retreive list from ' +
' at "' + lastfailure.path + '"</span>');
break;
default:
break;
}
}
return res;
};
that.getLastFailure = function () {
return priv.lastfailure;
};
// End of class // // End of class //
priv.init(); priv.init();
return that; return that;
......
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