Commit c22bb2a4 authored by Alain Takoudjou's avatar Alain Takoudjou

erp5_web_mynij_search: show building progress bar when index build start

parent faae774a
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.16121.1326.57685</string> </value> <value> <string>987.31511.24484.17578</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1603297250.59</float> <float>1603442016.65</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -109,6 +109,9 @@ ...@@ -109,6 +109,9 @@
.allowPublicAcquisition("save_index", function (args) { .allowPublicAcquisition("save_index", function (args) {
return this.props.model_gadget.save_index(args[0]); return this.props.model_gadget.save_index(args[0]);
}) })
.allowPublicAcquisition('getParentElement', function () {
return this.element.querySelector(".ui-content");
})
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.29116.51782.25139</string> </value> <value> <string>987.31529.454.41710</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1603354044.58</float> <float>1603443338.99</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -6,6 +6,17 @@ ...@@ -6,6 +6,17 @@
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_mynij_parser.js" type="text/javascript"></script> <script src="gadget_mynij_parser.js" type="text/javascript"></script>
<script src="mynij_rss-parser.min.js" type="text/javascript"></script> <script src="mynij_rss-parser.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="mynij-style.css">
<script id="panel-template-progress" type="text/x-handlebars-template">
<p>Building <span class="build-title">{{title}} ...</span></p>
<div class="anbar bar1"></div>
<div class="anbar bar2"></div>
<div class="anbar bar3"></div>
<div class="anbar bar4"></div>
<div class="anbar bar5"></div>
</script>
</head> </head>
<body> <body>
</body> </body>
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>985.52218.28049.9915</string> </value> <value> <string>987.31553.14164.37563</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1597156386.4</float> <float>1603444183.66</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80*/ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80*/
/*global window, RSVP, rJS, jIO*/ /*global window, RSVP, rJS, jIO, Handlebars*/
(function (window, RSVP, rJS, jIO) { (function (window, RSVP, rJS, jIO, Handlebars) {
"use strict"; "use strict";
var concurrent_requests = 3, var gadget_klass = rJS(window),
proxies = [ template_element = gadget_klass.__template_element,
concurrent_requests = 3,
proxies = [
"https://softinst116265.host.vifib.net/erp5/ERP5Site_getHTTPResource", "https://softinst116265.host.vifib.net/erp5/ERP5Site_getHTTPResource",
"https://softinst116446.host.vifib.net/erp5/ERP5Site_getHTTPResource" "https://softinst116446.host.vifib.net/erp5/ERP5Site_getHTTPResource"
]; ],
panel_template_progress = Handlebars.compile(template_element
.getElementById("panel-template-progress")
.innerHTML);
function get_random_id() { function get_random_id() {
return '_' + Math.random().toString(36).substr(2, 9); return '_' + Math.random().toString(36).substr(2, 9);
...@@ -17,7 +22,7 @@ ...@@ -17,7 +22,7 @@
console.log(error_message); console.log(error_message);
} }
rJS(window) gadget_klass
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
...@@ -33,10 +38,12 @@ ...@@ -33,10 +38,12 @@
.declareAcquiredMethod("add_to_index", "add_to_index") .declareAcquiredMethod("add_to_index", "add_to_index")
.declareAcquiredMethod("save_index", "save_index") .declareAcquiredMethod("save_index", "save_index")
.declareAcquiredMethod("getParentElement", "getParentElement")
//declare service to build index in background //declare service to build index in background
.declareService(function () { .declareService(function () {
var gadget = this; var gadget = this,
parent_content;
function build() { function build() {
var entry; var entry;
...@@ -45,13 +52,20 @@ ...@@ -45,13 +52,20 @@
return gadget.getSetting('build_list'); return gadget.getSetting('build_list');
}) })
.push(function (build_list) { .push(function (build_list) {
var link_list; var link_list,
tmp_element;
if (!build_list || !build_list.length) if (!build_list || !build_list.length)
// wait 5s and check again if there is something to build // wait 5s and check again if there is something to build
return RSVP.delay(5000); return RSVP.delay(5000);
else { else {
entry = build_list[0]; entry = build_list[0];
link_list = entry.links.split("\n").filter(l => l.length > 0); link_list = entry.links.split("\n").filter(l => l.length > 0);
tmp_element = document.createElement('div');
tmp_element.className = 'building';
tmp_element.innerHTML = panel_template_progress({
title: entry.index_name
})
parent_content.appendChild(tmp_element);
return gadget.build_index(link_list, entry.index_name) return gadget.build_index(link_list, entry.index_name)
.push(function (result) { .push(function (result) {
console.log("done building index"); console.log("done building index");
...@@ -72,6 +86,9 @@ ...@@ -72,6 +86,9 @@
}); });
}) })
.push(function () { .push(function () {
var indicator = parent_content.querySelector('.building');
if (indicator)
parent_content.removeChild(indicator);
return gadget.getSetting('build_list'); return gadget.getSetting('build_list');
}) })
.push(function (current) { .push(function (current) {
...@@ -88,7 +105,11 @@ ...@@ -88,7 +105,11 @@
}); });
} }
return build(); return gadget.getParentElement()
.push(function (element) {
parent_content = element;
return build();
})
}) })
/*.declareMethod("parse_user_entry_list", function (list, index_name) { /*.declareMethod("parse_user_entry_list", function (list, index_name) {
...@@ -262,4 +283,4 @@ ...@@ -262,4 +283,4 @@
return gadget.add_to_index(result, index_name); return gadget.add_to_index(result, index_name);
}); });
}(window, RSVP, rJS, jIO)); }(window, RSVP, rJS, jIO, Handlebars));
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.29976.13991.60689</string> </value> <value> <string>987.31551.51611.38178</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1603350351.31</float> <float>1603444202.17</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -492,3 +492,69 @@ input[type="button"]:hover{ ...@@ -492,3 +492,69 @@ input[type="button"]:hover{
} }
} }
/** END Tabs CSS **/ /** END Tabs CSS **/
/* Building indicator */
.building {
margin: 10px;
}
.building:after {
content: "";
clear: both;
}
.build-title {
display: inline;
text-align: left;
font-weight: 700;
}
.anbar {
background-color: #83da41;
background-image: linear-gradient(45deg, #71e721 25%, #cbecc5);
border-left: 1px solid #175f05;
border-top: 1px solid #35a21a;
border-right: 1px solid #35a21a;
border-bottom: 1px solid #35a21a;
width: 10px;
height: 10px;
margin: 10px 0;
float: left;
margin-left: 5px;
opacity: 0.1;
transform: scale(0.7);
animation: move 1s infinite linear;
}
.bar1 {
animation-delay: .4s;
}
.bar2 {
animation-delay: .3s;
}
.bar3 {
animation-delay: .2s;
}
.bar4 {
animation-delay: .3s;
}
.bar5 {
animation-delay: .4s;
}
@keyframes move {
0% {
transform: scale(1.2);
opacity: 1;
}
100% {
transform: scale(0.7);
opacity: 0.1;
}
}
/* END Building indicator */
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.27174.65288.50875</string> </value> <value> <string>987.31506.15184.56388</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1603184533.69</float> <float>1603444297.3</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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