mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-09-03 20:52:57 -05:00
Add support for creating dialogs, and add an About dialog.
This adds bootstrap-dialog to help with creation of nice dialogs, and adds the ability for modules to render Javascript into the browser, and specify onclick handlers in the menu system. Also add a basic About dialog, using the new infrastructure and showing some useful info about the application.
This commit is contained in:
@@ -9,10 +9,19 @@
|
||||
|
||||
"""Browser integration functions for the About module."""
|
||||
|
||||
from flask import url_for
|
||||
from flask import render_template, url_for
|
||||
|
||||
import config
|
||||
|
||||
def get_help_menu_items():
|
||||
"""Return a (set) of dicts of help menu items, with name, priority and URL."""
|
||||
return [{'name': 'About %s' % (config.APP_NAME), 'priority': 999, 'url': url_for('about.index')}]
|
||||
"""Return a (set) of dicts of help menu items, with name, priority, URL and
|
||||
onclick code."""
|
||||
return [{'name': 'About %s' % (config.APP_NAME),
|
||||
'priority': 999,
|
||||
'url': "#",
|
||||
'onclick': "about_show()"}]
|
||||
|
||||
def get_javascript_code():
|
||||
"""Render from the template and return any Javascript code snippets required
|
||||
in the browser"""
|
||||
return render_template("about/browser.js")
|
||||
@@ -0,0 +1,16 @@
|
||||
{#
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2014, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
#}
|
||||
|
||||
function about_show() {
|
||||
BootstrapDialog.show({
|
||||
title: 'About {{ config.APP_NAME }}',
|
||||
message: $('<div></div>').load('{{ url_for('about.index') }}')});
|
||||
}
|
||||
@@ -1 +1,28 @@
|
||||
About {{ config.APP_NAME }}
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><b>Version</b></div>
|
||||
<div class="col-sm-9">{{ config.APP_VERSION }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><b>Copyright</b></div>
|
||||
<div class="col-sm-9">{{ config.APP_COPYRIGHT }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><b>Python Version</b></div>
|
||||
<div class="col-sm-9">{{ info.python_version }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><b>Flask Version</b></div>
|
||||
<div class="col-sm-9">{{ info.flask_version }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><b>Application Mode</b></div>
|
||||
<div class="col-sm-9">{{ info.app_mode }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><b>Current User</b></div>
|
||||
<div class="col-sm-9">{{ info.current_user }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3 pull-right"><img src="{{ url_for('static', filename='img/logo-right-128.png') }}" alt="{{ config.APP_NAME }}"></div>
|
||||
</div>
|
||||
@@ -10,9 +10,12 @@
|
||||
"""A blueprint module implementing the about box."""
|
||||
MODULE_NAME = 'about'
|
||||
|
||||
from flask import Blueprint, current_app, render_template, __version__
|
||||
from flask.ext.security import current_user, login_required
|
||||
|
||||
import sys
|
||||
|
||||
import config
|
||||
from flask import Blueprint, current_app, render_template
|
||||
from flask.ext.security import login_required
|
||||
|
||||
# Initialise the module
|
||||
blueprint = Blueprint(MODULE_NAME, __name__, static_folder='static', static_url_path='', template_folder='templates', url_prefix='/' + MODULE_NAME)
|
||||
@@ -24,4 +27,13 @@ blueprint = Blueprint(MODULE_NAME, __name__, static_folder='static', static_url
|
||||
@login_required
|
||||
def index():
|
||||
"""Render the about box."""
|
||||
return render_template(MODULE_NAME + '/index.html')
|
||||
info = { }
|
||||
info['python_version'] = sys.version
|
||||
info['flask_version'] = __version__
|
||||
if config.SERVER_MODE == True:
|
||||
info['app_mode'] = 'Server'
|
||||
else:
|
||||
info['app_mode'] = 'Desktop'
|
||||
info['current_user'] = current_user.email
|
||||
|
||||
return render_template(MODULE_NAME + '/index.html', info=info)
|
||||
|
||||
Reference in New Issue
Block a user