Ejemplo n.º 1
0
from flask import Blueprint, render_template

from tango import menus, Menu

from tango.login import login_required, current_user

from fault import Event

homepage = Blueprint('home', __name__)

@homepage.route('/dashboard')
@login_required
def dashboard():
    #current_user.profiles
    return render_template('/dashboard.html')

@homepage.route('/timeline')
@login_required
def timeline():
    events = get_events(current_user)
    return render_template('/timeline.html', events=events)

def get_events(user):
    nids = [node.id for node in user.nodes]
    q = Event.query.filter(Event.node_id.in_(nids))
    return q.order_by("raised_at desc").limit(50).all()

menus.append(Menu('dashboard', u'首页', '/dashboard'))

Ejemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Blueprint, request, session, url_for, \
    redirect, render_template, g, flash

from tango import menus, Menu

perfview = Blueprint('perf', __name__, url_prefix="/perf")

@perfview.route('/')
def index():
    return render_template("perf/index.html")

menus.append(Menu('perf', u'性能', '/perf'))
Ejemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Blueprint, request, session, url_for, \
    redirect, render_template, g, flash

from tango.login import login_required

from tango import menus, Menu

from fault.models import Event

faultview = Blueprint("fault", __name__, url_prefix='/fault')

@faultview.route('/')
@login_required
def index():
    return render_template("/fault/index.html")

menus.append(Menu('fault', u'故障', '/fault'))

Ejemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Blueprint, request, session, url_for, \
    redirect, render_template, g, flash

from tango import menus, Menu

from tango.login import current_user, login_required

nodeview = Blueprint('nodes', __name__)

@nodeview.route('/nodes')
@login_required
def nodes():
    nodes = get_nodes(current_user)
    return render_template('nodes/index.html', nodes = nodes)

def get_nodes(user):
    return user.nodes

menus.append(Menu('nodes', u'资源', '/nodes'))
Ejemplo n.º 5
0
@userview.route('/users')
@login_required
def users():
    users = User.query.all()
    return render_template("users/index.html", users = users)

@userview.route('/users/search', methods=['POST'])
def search():
    username = request.form['search']
    users = User.query.filter_by(username=username).all()
    return render_template('users/index.html', menuid = 'users', submenuid = 'users', users=users)
    
@userview.route('/users/new', methods=['GET', 'POST'])
def create():
    form = SignupForm(request.form)
    if request.method == 'POST' and form.validate():
        username = form.username.data
        user = User.query.filter_by(username=username).first()
        if user is None:
            hash_passwd = md5(form.password.data).hexdigest()
            user = User(form.username.data, form.email.data, password=hash_passwd)
            db.session.add(user)
            db.session.commit()
            flash(u'添加用户成功', 'info')
            return redirect(url_for('users'))
        flash(u'用户名已存在', 'error')
    return render_template('users/new.html', form=form)

menus.append(Menu('users', u'用户', '/users'))

Ejemplo n.º 6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Blueprint, request, session, url_for, \
    redirect, render_template, g, flash

from tango.login import login_required

from tango import menus, Menu

sysview = Blueprint('system', __name__)

@sysview.route('/system')
def index():
    return render_template("system/index.html")

menus.append(Menu('system', u'系统', '/system'))

Ejemplo n.º 7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Blueprint, request, session, url_for, \
    redirect, render_template, g, flash

from tango import menus, Menu

reportview = Blueprint('report', __name__, url_prefix='/report')

@reportview.route('/')
def index():
    return render_template("report/index.html")

menus.append(Menu('report', u'报表', '/report'))


Ejemplo n.º 8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Blueprint, request, session, url_for, \
    redirect, render_template, g, flash

from tango import menus, Menu

topoview = Blueprint('topo', __name__, url_prefix='/topo')

@topoview.route('/')
def index():
    return render_template("topo/index.html", menuid = 'topo')

menus.append(Menu('topo', u'拓扑', 'topo'))