Skip to content

Commit

Permalink
Update reload system (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
babeuloula authored Sep 3, 2019
1 parent d6aede5 commit a7bbee5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ GITHUB_BRANCH_DEFAULT_COLOR=danger
###< knplabs/github-api ###

ENABLE_DARK_THEME=0
RELOAD_ON_FOCUS=1
# Relaod time in ms
RELOAD_EVERY=0
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ GITHUB_LABELS_ACCEPTED='["Accepted"]'
GITHUB_LABELS_WIP='["WIP", "Pending answer"]'
GITHUB_BRANCHS_COLORS='[{"master": "warning"}, {"develop": "success"}, {"feature-*": "primary"}, {"release*": "info"}, , {"hotfix-*": "danger"}]'
GITHUB_BRANCH_DEFAULT_COLOR=danger
ENABLE_DARK_THEME=1
RELOAD_ON_FOCUS=0
# Reload time is ms
RELOAD_EVERY=60000
```

If you don't want to reload on focus and reload every x ms, you just need to set `RELOAD_ON_FOCUS=0` and `RELOAD_EVERY=0`.

## Installation

Install composer and assets:
Expand Down
4 changes: 3 additions & 1 deletion config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
globals:
darkTheme: '%env(bool:ENABLE_DARK_THEME)%'
enableDarkTheme: '%env(bool:ENABLE_DARK_THEME)%'
reloadOnFocus: '%env(bool:RELOAD_ON_FOCUS)%'
reloadEvery: '%env(int:RELOAD_EVERY)%'
2 changes: 1 addition & 1 deletion templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% block stylesheets %}
<link title="defaut" type="text/css" rel="stylesheet" href="/css/base.css" media="screen">
<link title="defaut" type="text/css" rel="stylesheet" href="/css/pull-request.css" media="screen">
{% if darkTheme %}
{% if enableDarkTheme %}
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/darkly/bootstrap.min.css" rel="stylesheet" integrity="sha384-w+8Gqjk9Cuo6XH9HKHG5t5I1VR4YBNdPt/29vwgfZR485eoEJZ8rJRbm3TR32P6k" crossorigin="anonymous">
{% else %}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
Expand Down
13 changes: 11 additions & 2 deletions templates/github/pull-request/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@

<script type="text/javascript">
jQuery(function($){
let reloadOnFocus = {{ reloadOnFocus ? 'true' : 'false' }};
let reloadEvery = {{ reloadEvery }};
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
let newRepo = $.trim($(e.target).text());
let oldRepo = $.trim($(e.relatedTarget).text());
Expand All @@ -102,14 +105,20 @@
$title.text(title);
});
$(window).on('focus', function () {
window.showWaitModal = function () {
modals(null, $("<p/>").text("Please be patient while loading the pull requests ..."), {
modalId: "reload-pull-requrests-modal",
buttons: null
}, function () {
location.reload();
});
});
};
if (reloadOnFocus) {
$(window).on('focus', showWaitModal);
} else if(reloadEvery > 0) {
window.setInterval(showWaitModal, reloadEvery);
}
});
</script>
{% endblock %}

0 comments on commit a7bbee5

Please sign in to comment.