This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 6f6e3b902f402aa461c687d78076481ceb52ef02 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Mar 27 11:08:39 2017 +0200 Ajout d'une attente pendant les requêtes Rest --- pollen-ui-riot-js/package.json | 1 + pollen-ui-riot-js/src/main/web/css/main.css | 3 ++- pollen-ui-riot-js/src/main/web/index.html | 19 +++++++-------- pollen-ui-riot-js/src/main/web/js/FetchService.js | 4 ++++ pollen-ui-riot-js/src/main/web/js/Poll.js | 2 +- pollen-ui-riot-js/src/main/web/js/Session.js | 6 ++--- pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 4 +++- .../src/main/web/tag/PollenWaiter.tag.html | 27 ++++++++++++++++++++++ pollen-ui-riot-js/webpack.config.js | 3 ++- 9 files changed, 53 insertions(+), 16 deletions(-) diff --git a/pollen-ui-riot-js/package.json b/pollen-ui-riot-js/package.json index 0009670..d08ad45 100644 --- a/pollen-ui-riot-js/package.json +++ b/pollen-ui-riot-js/package.json @@ -38,6 +38,7 @@ "blaze": "^3.2.0", "font-awesome": "4.7.0", "moment": "^2.17.1", + "nprogress": "^0.2.0", "remarkable": "^1.7.1", "riot": "^3.0.5", "riot-route": "^2.5.0" diff --git a/pollen-ui-riot-js/src/main/web/css/main.css b/pollen-ui-riot-js/src/main/web/css/main.css index ada0e26..3f0fb9e 100644 --- a/pollen-ui-riot-js/src/main/web/css/main.css +++ b/pollen-ui-riot-js/src/main/web/css/main.css @@ -57,7 +57,8 @@ input, textarea { } .body-content { - flex-grow: 1; + flex-grow: 1; + overflow: hidden; } .body-container { diff --git a/pollen-ui-riot-js/src/main/web/index.html b/pollen-ui-riot-js/src/main/web/index.html index 877f4d1..1b1e9a3 100644 --- a/pollen-ui-riot-js/src/main/web/index.html +++ b/pollen-ui-riot-js/src/main/web/index.html @@ -22,16 +22,17 @@ <html> <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>Pollen</title> - <link href="./css/main.css" rel="stylesheet"> - <link href="./css/blaze.min.css" rel="stylesheet"> - <link href="./css/font-awesome.css" rel="stylesheet"> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Pollen</title> + <link href="./css/main.css" rel="stylesheet"> + <link href="./css/blaze.min.css" rel="stylesheet"> + <link href="./css/font-awesome.css" rel="stylesheet"> + <link href="./css/nprogress.css" rel="stylesheet"> </head> <body> -<Pollen/> -<script type="text/javascript" src="./conf.js"></script> -<script type="text/javascript" src="./pollen.js"></script> + <Pollen/> + <script type="text/javascript" src="./conf.js"></script> + <script type="text/javascript" src="./pollen.js"></script> </body> </html> diff --git a/pollen-ui-riot-js/src/main/web/js/FetchService.js b/pollen-ui-riot-js/src/main/web/js/FetchService.js index e33d46b..01604ca 100644 --- a/pollen-ui-riot-js/src/main/web/js/FetchService.js +++ b/pollen-ui-riot-js/src/main/web/js/FetchService.js @@ -33,6 +33,8 @@ class FetchService { headers["Content-Type"] = "application/json;charset=UTF-8"; } + let loadEvent = {}; + bus.trigger("loading", loadEvent); return fetch( this.endPoint + url, { headers, @@ -41,6 +43,7 @@ class FetchService { body: body instanceof FormData ? body : body && JSON.stringify(body) }) .then((response) => { + bus.trigger("loaded", loadEvent); if (response.status === 204) { return null; } @@ -67,6 +70,7 @@ class FetchService { }); }, (error) => { + bus.trigger("loaded", loadEvent); console.error(error); }); } diff --git a/pollen-ui-riot-js/src/main/web/js/Poll.js b/pollen-ui-riot-js/src/main/web/js/Poll.js index 5b5d11c..0bee740 100644 --- a/pollen-ui-riot-js/src/main/web/js/Poll.js +++ b/pollen-ui-riot-js/src/main/web/js/Poll.js @@ -189,7 +189,7 @@ class Poll { .filter(score => score.scoreOrder === order) .map(score => this.choices.find(choice => choice.id === score.choiceId)); - while (choiceCount < 3) { + while (choiceCount < 3 && index < 3) { let choices = getChoicesByScoreOrder(index); podium["step" + (choiceCount + 1)] = choices; index++; diff --git a/pollen-ui-riot-js/src/main/web/js/Session.js b/pollen-ui-riot-js/src/main/web/js/Session.js index afcb67c..5a4414f 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -37,9 +37,9 @@ class Session { this.pollenUIContext = { uiEndPoint: window.location.origin, userValidateUrl: window.location.origin + "/#signcheck/{userId}/{token}", - pollVoteUrl: window.location.origin + "/#poll/vote/{pollId}/{pollToken}", - pollVoteEditUrl: window.location.origin + "/#poll/vote/{pollId}/{pollToken}/vote/{voteToken}", - pollEditUrl: window.location.origin + "/#poll/edit/{pollId}/{pollToken}" + pollVoteUrl: window.location.origin + "/#poll/{pollId}/vote/{pollToken}", + pollVoteEditUrl: window.location.origin + "/#poll/{pollId}/vote/{pollToken}/vote/{voteToken}", + pollEditUrl: window.location.origin + "/#poll/{pollId}/edit/{pollToken}" }; // pour contenir les traductions this.i18n = require("../i18n.json"); diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html index d296472..5df1484 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html @@ -18,6 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ +require("./PollenWaiter.tag.html"); require("./PollenHeader.tag.html"); require("./PollenFooter.tag.html"); require("./SignIn.tag.html"); @@ -30,7 +31,8 @@ require("./poll/Polls.tag.html"); require("./Users.tag.html"); <Pollen class="body-wrapper"> <PollenHeader/> - <div class="body-content" ref="content"></div> + <PollenWaiter parent-id="body-content"/> + <div id="body-content" class="body-content" ref="content"></div> <PollenFooter/> <script type="es6"> diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenWaiter.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenWaiter.tag.html new file mode 100644 index 0000000..e59fd7e --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/PollenWaiter.tag.html @@ -0,0 +1,27 @@ +<PollenWaiter> + + <script> + let NProgress = require("../../../../node_modules/nprogress/nprogress.js"); + NProgress.configure({ parent: "#" + this.opts.parentId}); + let inProgress = new Set(); + + this.bus.on("loading", event => { + inProgress.add(event); + if (inProgress.size === 1) { + NProgress.start(); + } + }); + + this.bus.on("loaded", event => { + setTimeout(() => { + inProgress.delete(event); + NProgress.inc(); + if (!inProgress.size) { + NProgress.done(); + } + }, 200); + + }); + </script> + +</PollenWaiter> diff --git a/pollen-ui-riot-js/webpack.config.js b/pollen-ui-riot-js/webpack.config.js index a8ffa1a..2fb9a7b 100644 --- a/pollen-ui-riot-js/webpack.config.js +++ b/pollen-ui-riot-js/webpack.config.js @@ -44,7 +44,8 @@ module.exports = { {from: "./node_modules/scrollspy-js/js/scrollspy.js", to: "js"}, {from: "./node_modules/bootstrap/dist/js/bootstrap.js", to: "js"}, {from: "./node_modules/jquery/dist/js/jquery.js", to: "js"}, - {from: "./node_modules/blaze/dist/blaze.min.css", to: "css"} + {from: "./node_modules/blaze/dist/blaze.min.css", to: "css"}, + {from: "./node_modules/nprogress/nprogress.css", to: "css"} ]) ], -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.