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 @@
New Spreadsheet
</a>
</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"> -->
<!-- <a href="#/edit_preferences" -->
<!-- onclick="javascript: -->
......
......@@ -6,20 +6,13 @@
<div class="controls docs-input-sizes">
<input class="input-xlarge"
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" />
<!-- 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;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;}]}" -->
</div>
<label class="control-label"
for="JSONapplicantID">
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" />
<!-- 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;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;}]}]}" -->
<!-- value="{&quot;type&quot;:&quot;local&quot;,&quot;username&quot;:&quot;tristan&quot;,&quot;applicationname&quot;:&quot;jiotests&quot;}" -->
<!-- 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;}" -->
<!-- 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;}]}" -->
</div>
</div>
<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 @@
<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/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/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>
<body>
......
......@@ -9,6 +9,7 @@
return file_name;
}
};
var JIO = jio;
/**
* OfficeJS Object
......@@ -174,6 +175,25 @@
update: function () {
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 = {
......@@ -227,7 +247,7 @@
end_getlist:function(){this.end_main('getlist');this.end_spin();},
end_remove:function(){this.end_main('remove');this.end_spin();}
};
priv.lastfailure = {};
// Initializer //
priv.init = function() {
};
......@@ -384,7 +404,7 @@
return;
}
// if there is not any jio created
priv.jio = JIO.newJio (storage,applicant);
priv.jio = JIO.newJio (JSON.parse(storage));
// update left nav bar
leftnavbar = priv.getRealApplication ('leftnavbar');
if (typeof leftnavbar.update !== 'undefined') {
......@@ -405,18 +425,21 @@
return;
}
priv.loading_object.getlist();
priv.jio.getDocumentList({
'sort':{'last_modified':'descending',
'name':'ascending'},
'limit':{begin:0,end:50},
// 'search':{name:'a'},
'maxtries':3,
'onResponse':function (result) {
if (result.status === 'done') {
priv.data_object.documentList = result.return_value;
priv.jio.getDocumentList(
'.',
{sort:{last_modified:'descending',
name:'ascending'},
limit:{begin:0,end:50},
// search:{name:'a'},
max_retry:3,
onResponse:function (result) {
if (result.status.isDone()) {
priv.data_object.documentList = result.value;
priv.showDocumentListInsideLeftNavBar();
} else {
console.error (result.message);
priv.lastfailure.path = '.';
priv.lastfailure.method = 'getDocumentList';
console.error (result.error.message);
}
priv.loading_object.end_getlist();
if (typeof callback !== 'undefined') {
......@@ -443,17 +466,18 @@
return;
}
priv.loading_object.save();
priv.jio.saveDocument({
'name':basename+'.'+current_editor.ext,
'content':current_editor.getContent(),
'onResponse':function (result) {
if (result.status === 'fail') {
console.error (result.message);
priv.jio.saveDocument(
basename+'.'+current_editor.ext,
current_editor.getContent(),
{onResponse:function (result) {
if (!result.status.isDone()) {
priv.lastfailure.path = basename;
priv.lastfailure.method = 'saveDocument';
console.error (result.error.message);
}
priv.loading_object.end_save();
that.getList();
}
});
}});
};
/**
......@@ -468,19 +492,20 @@
return;
}
priv.loading_object.load();
priv.jio.loadDocument({
'name':basename+'.'+current_editor.ext,
'maxtries':3,
'onResponse':function (result) {
if (result.status === 'fail') {
console.error (result.message);
priv.jio.loadDocument(
basename+'.'+current_editor.ext,
{max_retry:3,
onResponse:function (result) {
if (!result.status.isDone()) {
console.error (result.error.message);
priv.lastfailure.path = basename;
priv.lastfailure.method = 'loadDocument';
} else {
current_editor.setContent(
result.return_value.content);
result.value.content);
}
priv.loading_object.end_load();
}
});
}});
};
/**
......@@ -494,16 +519,17 @@
return;
}
priv.loading_object.remove();
priv.jio.removeDocument({
'name':name,
'onResponse':function (result) {
if (result.status === 'fail') {
console.error (result.message);
priv.jio.removeDocument(
name,
{onResponse:function (result) {
if (!result.status.isDone()) {
console.error (result.error.message);
priv.lastfailure.path = name;
priv.lastfailure.method = 'removeDocument';
}
priv.loading_object.end_remove();
that.getList();
}
});
}});
};
/**
......@@ -519,9 +545,9 @@
}
for (i = 0, l = documentarray.length; i < l; i+= 1) {
priv.loading_object.remove();
priv.jio.removeDocument({
name:documentarray[i],
onResponse:function (result) {
priv.jio.removeDocument(
documentarray[i],
{onResponse:function (result) {
cpt += 1;
if (cpt === l) {
if (typeof current_editor.update !== 'undefined') {
......@@ -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 //
priv.init();
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