js tweaks

This commit is contained in:
ziirish 2018-01-10 17:35:52 +01:00
parent 5fd3fbd835
commit 84a4ffcb43
No known key found for this signature in database
GPG key ID: 72DB229A64B54E46
9 changed files with 107 additions and 93 deletions

View file

@ -10,7 +10,7 @@
<li><a href="{{ url_for('view.client', name=cname, server=server) }}">{{ _('%(client)s overview', client=cname) }}</a></li>
<li class="active">{{ _('Backup n°%(number)s overview', number=mypad(nbackup)) }}</li>
{% else -%}
<li><a href="{{ url_for('view.home') }}">Home</a></li>
<li><a href="{{ url_for('view.home') }}">{{ _('Home') }}</a></li>
<li><a href="{{ url_for('view.client', name=cname) }}">{{ _('%(client)s overview', client=cname) }}</a></li>
<li class="active">{{ _('Backup n°%(number)s overview', number=mypad(nbackup)) }}</li>
{% endif -%}

View file

@ -171,36 +171,36 @@ var myFail = function(xhr, stat, err) {
notif(NOTIF_ERROR, msg);
};
{% if config.WITH_CELERY %}
{% if config.WITH_CELERY -%}
{% set api_running_backup = "api.async_running_backup" %}
{% else %}
{% else -%}
{% set api_running_backup = "api.running_backup" %}
{% endif %}
{% if not login %}
{% endif -%}
{% if not login -%}
var _last_running_status = undefined;
var _last_call = 0;
var _check_running = function() {
{% if server %}
{% if server -%}
var url = '{{ url_for(api_running_backup, server=server) }}';
{% else %}
{% else -%}
var url = '{{ url_for(api_running_backup) }}';
{% endif %}
{% endif -%}
var now = Date.now();
if ((now - _last_call) < 5*1000) {
return;
}
_last_call = now;
$.getJSON(url, function(data) {
{% if clients and overview %}
{% if clients and overview -%}
if (_last_running_status != data.running) {
$( document ).trigger('refreshClientsStatesEvent', data.running);
}
{% endif %}
{% if client and overview %}
{% endif -%}
{% if client and overview -%}
if (_last_running_status != data.running) {
$( document ).trigger('refreshClientStatusEvent', data.running);
}
{% endif %}
{% endif -%}
if (data.running) {
$('#toblink').addClass('blink');
} else {
@ -209,9 +209,9 @@ var _check_running = function() {
_last_running_status = data.running;
});
};
{% endif %}
{% endif -%}
{% if not login %}
{% if not login -%}
var substringMatcher = function(objs) {
return function findMatches(q, cb) {
@ -237,7 +237,7 @@ var substringMatcher = function(objs) {
var _clients_all = [];
{% if config.STANDALONE %}
{% if config.STANDALONE -%}
$.get("{{ url_for('api.clients_all') }}")
.done(function (data) {
@ -259,13 +259,13 @@ $.get("{{ url_for('api.clients_all') }}")
});
{% else %}
{% else -%}
{% for srv in config.SERVERS %}
{% for srv in config.SERVERS -%}
var _clients_{{ srv|regex_replace("[^a-z0-9_]", "_") }} = [];
{% endfor %}
{% endfor -%}
$.get("{{ url_for('api.clients_all') }}")
.done(function (data) {
@ -279,7 +279,7 @@ $.get("{{ url_for('api.clients_all') }}")
$('#input-client').typeahead({
highlight: true
},
{% for srv in config.SERVERS %}
{% for srv in config.SERVERS -%}
{
name: '{{ srv }}',
displayKey: 'name',
@ -287,74 +287,74 @@ $('#input-client').typeahead({
templates: {
header: '<h3 class="server-name">{{ srv }}</h3>'
}
{% if loop.last %}
{% if loop.last -%}
}
{% else %}
{% else -%}
},
{% endif %}
{% endfor %}
{% endif -%}
{% endfor -%}
).on('typeahead:selected', function(obj, datum) {
window.location = '{{ url_for("view.client") }}?name='+datum.name+'&serverName='+datum.agent;
});
{% endif %}
{% endif %}
{% endif -%}
{% endif -%}
{% if servers and overview %}
{% if servers and overview -%}
{% include "js/servers.js" %}
{% endif %}
{% endif -%}
{% if servers and report %}
{% if servers and report -%}
{% include "js/servers-report.js" %}
{% endif %}
{% endif -%}
{% if clients and overview %}
{% if clients and overview -%}
{% include "js/clients.js" %}
{% endif %}
{% endif -%}
{% if clients and report %}
{% if clients and report -%}
{% include "js/clients-report.js" %}
{% endif %}
{% endif -%}
{% if client and overview %}
{% if client and overview -%}
{% include "js/client.js" %}
{% set is_client_func = True %}
{% endif %}
{% set is_client_func = True -%}
{% endif -%}
{% if backup and report and client %}
{% if backup and report and client -%}
{% include "js/backup-report.js" %}
{% set is_client_func = True %}
{% endif %}
{% set is_client_func = True -%}
{% endif -%}
{% if not backup and report and client %}
{% if not backup and report and client -%}
{% include "js/client-report.js" %}
{% set is_client_func = True %}
{% endif %}
{% set is_client_func = True -%}
{% endif -%}
{% if live %}
{% if live -%}
{% include "js/live-monitor.js" %}
{% endif %}
{% endif -%}
{% if settings %}
{% if settings -%}
{% include "js/settings.js" %}
{% endif %}
{% endif -%}
{% if about %}
{% if about -%}
{% include "js/about.js" %}
{% endif %}
{% endif -%}
{% if calendar %}
{% if calendar -%}
{% include "js/calendar.js" %}
{% endif %}
{% endif -%}
{% if tree %}
{% if tree -%}
{% include "js/client-browse.js" %}
{% endif %}
{% endif -%}
{% if me %}
{% if me -%}
{% include "js/user.js" %}
{% endif %}
{% endif -%}
var _fit_menu = function() {
size = $(window).width();
@ -400,21 +400,21 @@ $(function() {
*/
$('#refresh').on('click', function(e) {
e.preventDefault();
{% if clients %}
{% if clients -%}
_clients();
{% endif %}
{% if client and is_client_func %}
{% endif -%}
{% if client and is_client_func -%}
_client();
{% endif %}
{% if not login %}
{% endif -%}
{% if not login -%}
_check_running();
{% endif %}
{% if servers %}
{% endif -%}
{% if servers -%}
_servers();
{% endif %}
{% if me %}
{% endif -%}
{% if me -%}
_sessions();
{% endif %}
{% endif -%}
});
/***
@ -443,53 +443,53 @@ $(function() {
/***
* initialize our page if needed
*/
{% if not login %}
{% if not login -%}
_check_running();
{% endif %}
{% if clients %}
{% endif -%}
{% if clients -%}
_clients();
{% endif %}
{% if client and is_client_func %}
{% endif -%}
{% if client and is_client_func -%}
_client();
{% endif %}
{% if servers %}
{% endif -%}
{% if servers -%}
_servers();
{% endif %}
{% if me %}
{% endif -%}
{% if me -%}
_sessions();
{% endif %}
{% endif -%}
{% if not report and not login %}
{% if not report and not login -%}
/***
* auto-refresh our page if needed
*/
{% set autorefresh = config.REFRESH %}
{% set autorefresh = config.REFRESH -%}
var auto_refresh = setInterval(function() {
{% if clients %}
{% if clients -%}
_clients();
{% endif %}
{% if client and not settings %}
{% endif -%}
{% if client and not settings -%}
_client();
{% endif %}
{% if servers and overview %}
{% endif -%}
{% if servers and overview -%}
_servers();
{% endif %}
{% endif -%}
return;
}, {{ autorefresh * 1000 }});
{% endif %}
{% endif -%}
{% if not login %}
{% if not config.WS_AVAILABLE or not config.WITH_CELERY %}
{% if not login -%}
{% if not config.WS_AVAILABLE or not config.WITH_CELERY -%}
/***
* Javascript Loop
*/
var refresh_running = setInterval(function () {
_check_running();
}, {{ config.LIVEREFRESH * 1000 }});
{% endif %}
{% endif %}
{% endif -%}
{% endif -%}
});
{% if not login and config.WS_AVAILABLE %}
{% if not login and config.WS_AVAILABLE -%}
{% include "js/websocket.js" %}
{% endif %}
{% endif -%}

View file

@ -43,6 +43,7 @@ $( document ).ready(function() {
selectMode: 3,
extensions: ["glyph", "table", "gridnav", "filter"],
glyph: {
preset: "bootstrap3",
map: {
doc: "glyphicon glyphicon-file",
docOpen: "glyphicon glyphicon-file",
@ -62,6 +63,14 @@ $( document ).ready(function() {
loading: "glyphicon glyphicon-refresh glyphicon-spin"
}
},
persist: {
expandLazy: false,
overrideSource: false,
store: "cookie",
cookie: {
path: '{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}',
},
},
source: function() {
{% if edit and edit.found -%}
url = '{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server, root=edit.roots, recursive=True, selected=True) }}';
@ -81,7 +90,7 @@ $( document ).ready(function() {
p = node.key;
if (p !== "/") p += '/';
p = encodeURIComponent(p);
data.result = { url: '{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}?root='+p, debugDelay: 500 };
data.result = $.getJSON('{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}?root='+p);
},
loadChildren: function(event, data) {
// This is a hack to select all children of a selected node after

View file

@ -62,6 +62,7 @@ var _client_table = $('#table-client').DataTable( {
{{ macros.translate_datatable() }}
{{ macros.get_page_length() }}
responsive: true,
processing: true,
ajax: {
url: '{{ url_for("api.client_stats", name=cname, server=server) }}',
headers: { 'X-From-UI': true },

View file

@ -59,6 +59,7 @@ var _clients_table = $('#table-clients').DataTable( {
{{ macros.translate_datatable() }}
{{ macros.get_page_length() }}
responsive: true,
processing: true,
ajax: {
url: '{{ url_for("api.clients_stats", server=server) }}',
dataSrc: function (data) {

View file

@ -13,6 +13,7 @@ var _servers_table = $('#table-servers').DataTable( {
{{ macros.translate_datatable() }}
{{ macros.get_page_length() }}
responsive: true,
processing: true,
ajax: {
url: '{{ url_for("api.servers_stats") }}',
dataSrc: function (data) {
@ -20,7 +21,7 @@ var _servers_table = $('#table-servers').DataTable( {
},
error: myFail,
},
destroy: true,
rowId: 'name',
rowCallback: function( row, data ) {
if (!data.alive) {
row.className += ' danger';

View file

@ -167,6 +167,7 @@ var _sessions_table = $('#table-sessions').DataTable( {
{{ macros.translate_datatable() }}
{{ macros.get_page_length() }}
responsive: true,
processing: true,
select: {
style: 'os',
},
@ -237,7 +238,7 @@ var _sessions_table = $('#table-sessions').DataTable( {
}
],
order: [[1, 'desc']],
destroy: true,
rowId: 'uuid',
columns: [
{ data: 'ip' },
{

View file

@ -103,6 +103,7 @@
{% if tree -%}
<!-- Fancytree Javascript
================================================== -->
{# <script src="{{ url_for('bower.static', filename='js-cookie/src/js.cookie.js') }}"></script> -#}
<script src="{{ url_for('bower.static', filename='jquery.fancytree/dist/jquery.fancytree-all.min.js') }}"></script>
<!-- FileDownload Javascript
================================================== -->

View file

@ -123,7 +123,7 @@ $(document).ready(function() {
select: {
rows: {
_: '{{ _("You have selected %%d rows") }}',
0: '{{ _("Click a row to select it (hold ctrl to select several)") }}',
0: '<br />{{ _("Click a row to select it (hold ctrl to select several)") }}',
1: '{{ _("You have selected 1 row") }}'
},
},