Commit 271aa951 authored by Benjamin "Ziirish" SANS's avatar Benjamin "Ziirish" SANS
Browse files

improve notifications management

parent 3b4493ca
......@@ -27,6 +27,7 @@ bui = BurpUI(app)
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'
login_manager.login_message_category = 'info'
# Then we load our routes
import burpui.routes
......@@ -20,23 +20,17 @@ def login():
form = LoginForm(request.form)
if form.validate_on_submit():
user = bui.uhandler.user(form.username.data)
app.logger.info('%s active: %s', form.username.data, user.active)
if user.active and user.login(form.username.data, passwd=form.password.data):
login_user(user, remember=form.remember.data)
flash('Logged in successfully.')
return redirect(url_for('test_login'))
flash('Logged in successfully', 'success')
return redirect(request.args.get("next") or url_for('home'))
return render_template('login.html', form=form, login=True)
@app.route('/logout')
@login_required
def logout():
logout_user()
return redirect(url_for('login'))
@app.route('/test_login')
@login_required
def test_login():
return render_template('test-login.html', login=True, user=current_user.name)
return redirect(url_for('home'))
"""
Here is the API
......@@ -245,7 +239,7 @@ def live_monitor(name=None):
Live status monitor view
"""
if not bui.cli.running:
flash('Sorry, there are no running backups')
flash('Sorry, there are no running backups', 'warning')
return redirect(url_for('home'))
return render_template('live-monitor.html', live=True, cname=name)
......
{% extends "layout.html" %}
{% block body %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
<div id="bui-notifications">
</div>
</div>
{% include "notifications.html" %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{% include "small_topbar.html" %}
<ul class="breadcrumb" style="margin-bottom: 5px;">
......
{% extends "layout.html" %}
{% block body %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
<div id="bui-notifications">
</div>
</div>
{% include "notifications.html" %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{% include "small_topbar.html" %}
<ul class="breadcrumb" style="margin-bottom: 5px;">
......
{% extends "layout.html" %}
{% block body %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
<div id="bui-notifications">
</div>
</div>
{% include "notifications.html" %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{% include "small_topbar.html" %}
<ul class="breadcrumb" style="margin-bottom: 5px;">
......
{% extends "layout.html" %}
{% block body %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
<div id="bui-notifications">
</div>
</div>
{% include "notifications.html" %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{% include "small_topbar.html" %}
<ul class="breadcrumb" style="margin-bottom: 5px;">
......
{% extends "layout.html" %}
{% block body %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
<div id="bui-notifications">
</div>
</div>
{% include "notifications.html" %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{% include "small_topbar.html" %}
<ul class="breadcrumb" style="margin-bottom: 5px;">
......
{% extends "layout.html" %}
{% block body %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
<div id="bui-notifications">
</div>
</div>
{% include "notifications.html" %}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{% include "small_topbar.html" %}
<ul class="breadcrumb" style="margin-bottom: 5px;">
......
var pad = function(num, size) {
var s = "0000000" + num;
return s.substr(s.length-size);
......@@ -32,7 +33,7 @@ var notif = function(type, message) {
e.animate({opacity:1}, 5000, 'linear', function() { e.animate({opacity:0}, 2000, 'linear', function() {e.remove(); }); });
};
{% if not login %}
{% if not login -%}
var _check_running = function() {
url = '{{ url_for("backup_running") }}';
$.getJSON(url, function(data) {
......@@ -43,7 +44,7 @@ var _check_running = function() {
}
});
};
{% endif %}
{% endif -%}
/***
* _clients_bh: Bloodhound object used for the autocompletion of the input field
......@@ -75,29 +76,29 @@ $('#input-client').typeahead(null, {
});
{% if clients and overview %}
{% if clients and overview -%}
{% include "js/home.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" %}
{% endif %}
{% endif -%}
{% if backup and report and client %}
{% if backup and report and client -%}
{% include "js/backup-report.js" %}
{% endif %}
{% endif -%}
{% if not backup and report and client %}
{% if not backup and report and client -%}
{% include "js/client-report.js" %}
{% endif %}
{% endif -%}
{% if live %}
{% if live -%}
{% include "js/live-report.js" %}
{% endif %}
{% endif -%}
var _async_ajax = function(b) {
$.ajaxSetup({
......@@ -112,27 +113,41 @@ $(function() {
* Show the notifications
*/
$('#bui-notifications > div').each(function() {
e = $(this);
var e = $(this);
e.animate({opacity:1}, 5000, 'linear', function() { e.animate({opacity:0}, 2000, 'linear', function() {e.remove(); }); });
});
/***
* show details in topbar
*/
$('li.detail').hover(
// mouse in
function() {
$(this).find('.dtl').show();
},
// mouse out
function() {
$(this).find('.dtl').hide();
}
);
/***
* Action on the 'refresh' button
*/
$('#refresh').on('click', function(e) {
e.preventDefault();
{% if clients %}
{% if clients -%}
_clients();
{% endif %}
{% if client %}
{% endif -%}
{% if client -%}
_client();
{% endif %}
{% if live %}
{% endif -%}
{% if live -%}
_live();
{% endif %}
{% if not login %}
{% endif -%}
{% if not login -%}
_check_running();
{% endif %}
{% endif -%}
});
/***
......@@ -155,44 +170,44 @@ $(function() {
/***
* initialize our page if needed
*/
{% if not login %}
{% if not login -%}
_check_running();
{% endif %}
{% if clients %}
{% endif -%}
{% if clients -%}
_clients();
{% endif %}
{% if client %}
{% endif -%}
{% if client -%}
_client();
{% endif %}
{% if live %}
{% endif -%}
{% if live -%}
_live();
{% endif %}
{% endif -%}
{% if not report %}
{% if not report and not login -%}
/***
* auto-refresh our page if needed
*/
var auto_refresh = setInterval(function() {
{% if clients %}
{% if clients -%}
_clients();
{% endif %}
{% if client %}
{% endif -%}
{% if client -%}
_client();
{% endif %}
{% if live %}
{% endif -%}
{% if live -%}
_live();
{% endif %}
{% endif -%}
return;
}, {{ config.REFRESH * 1000 }});
{% endif %}
{% endif -%}
{% if not login %}
{% if not login -%}
var refresh_running = setInterval(function () {
_check_running();
}, {{ config.REFRESH * 1000 }});
{% endif %}
{% endif -%}
{% if tree %}
{% if tree -%}
{% include "js/client-browse.js" %}
{% endif %}
{% endif -%}
});
{% extends "layout.html" %}
{% block body %}
<div class="main">
<h1 class="page-header">Yo</h1>
What's up {{ user }}?!
</div>
{% endblock %}
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