import logging from temboardui.web import Blueprint, anonymous_allowed from temboardui.toolkit.configuration import OptionSpec blueprint = Blueprint() logger = logging.getLogger(__name__) @blueprint.route("/sample/", json=True) @anonymous_allowed def get_sample(request): logger.debug("GET /sample/") return { "message": "Sample response.", "sample": True, "option": request.config.sample.option, } class SamplePlugin(object): def __init__(self, app, **kw): self.app = app self.app.config.add_specs([OptionSpec('sample', 'option')]) logger.info("Plugin sample initialized.") def load(self): logger.info("Plugin sample loaded.") self.app.webapp.add_rules(blueprint.rules)
import logging from os.path import realpath import tornado.web from tornado.escape import json_encode from temboardui.temboardclient import TemboardError from temboardui.web import ( Blueprint, TemplateRenderer, ) blueprint = Blueprint() blueprint.generic_proxy(r"/dashboard") logger = logging.getLogger(__name__) plugin_path = realpath(__file__ + '/..') render_template = TemplateRenderer(plugin_path + '/templates') PLUGIN_NAME = 'dashboard' def configuration(config): return {} def get_routes(config): routes = blueprint.rules + [ (r"/js/dashboard/(.*)", tornado.web.StaticFileHandler, { 'path': plugin_path + "/static/js" }), ]
from os import path import tornado.web from temboardui.web import ( Blueprint, TemplateRenderer, ) PLUGIN_NAME = 'activity' blueprint = Blueprint() blueprint.generic_proxy(r'/activity/kill', methods=['POST']) plugin_path = path.dirname(path.realpath(__file__)) render_template = TemplateRenderer(plugin_path + '/templates') def configuration(config): return {} def get_routes(config): routes = blueprint.rules + [ (r"/js/activity/(.*)", tornado.web.StaticFileHandler, { 'path': plugin_path + "/static/js" }), ] return routes def get_agent_username(request): try: return request.instance.get_profile()['username']
from os import path import tornado.web from temboardui.web import ( Blueprint, TemplateRenderer, ) blueprint = Blueprint() blueprint.generic_proxy( r'/maintenance/.*/schema/.*/table/.*/' '(?:vacuum|analyze)', methods=['POST']) blueprint.generic_proxy(r'/maintenance/.*/schema/.*/index/.*/(?:reindex)', methods=['POST']) blueprint.generic_proxy(r'/maintenance/reindex/.*', methods=['DELETE']) blueprint.generic_proxy(r'/maintenance/(?:vacuum|analyze)/.*', methods=['DELETE']) blueprint.generic_proxy(r'/maintenance/.*') blueprint.generic_proxy(r'/maintenance') plugin_path = path.dirname(path.realpath(__file__)) render_template = TemplateRenderer(plugin_path + '/templates') def configuration(config): return {} def get_routes(config): routes = blueprint.rules + [ (r"/js/maintenance/(.*)", tornado.web.StaticFileHandler, {
import logging from os import path import tornado.web from tornado.escape import url_escape, url_unescape from temboardui.web import ( Blueprint, HTTPError, Redirect, TemplateRenderer, ) PLUGIN_NAME = 'pgconf' logger = logging.getLogger(__name__) blueprint = Blueprint() blueprint.generic_proxy("/pgconf/configuration", methods=["POST"]) plugin_path = path.dirname(path.realpath(__file__)) render_template = TemplateRenderer(plugin_path + "/templates") def configuration(config): return {} def get_routes(config): routes = blueprint.rules + [ (r"/js/pgconf/(.*)", tornado.web.StaticFileHandler, { 'path': plugin_path + "/static/js" }), (r"/css/pgconf/(.*)", tornado.web.StaticFileHandler, { 'path': plugin_path + "/static/css"