コード例 #1
0
def oplogs():
    query = OperationLog.query
    filterForm = OplogFilterForm(formdata=request.args)
    keyword = filterForm.keyword.data
    if keyword and keyword != '':
        keyword = keyword.strip()
        query = query.filter(db.or_(
                        OperationLog.terminal_ip.ilike('%'+keyword+'%'),
                        OperationLog.summary.ilike('%'+keyword+'%')))
    user = filterForm.uid.data
    if user :
        query = query.filter(OperationLog.uid == user.id)
    ip = filterForm.ip.data
    if ip:
        query = query.filter(OperationLog.terminal_ip == ip)
    start_date = filterForm.start_date.data
    if start_date:
        query = query.filter(OperationLog.created_at >= start_date)
    end_date = filterForm.end_date.data
    if end_date:
        query = query.filter(OperationLog.created_at <= end_date)

    table = make_table(query, OperationLogTable)
    return render_template('/system/oplogs.html', 
        table=table, filterForm=filterForm)
コード例 #2
0
ファイル: models.py プロジェクト: zzdhidden/tango
    def authenticate(clazz, login, passwd):
        user = clazz.query.filter(db.or_(User.username == login, User.email == login)).first()
        if user:
            authenticated = user.check_passwd(passwd)
        else:
            authenticated = False

        return user, authenticated
コード例 #3
0
ファイル: models.py プロジェクト: yordanomp/xiaoli
    def authenticate(clazz, login, passwd):
        user = clazz.query.filter(db.or_(User.username == login, 
                                    User.email == login)).first()
        if user:
            authenticated = user.check_passwd(passwd)
        else:
            authenticated = False

        return user, authenticated
コード例 #4
0
def classes():
    query = AlarmClass.query
    form = SearchForm(formdata=request.args)
    keyword = form.keyword.data
    if keyword and keyword != '':
        query = query.filter(db.or_(AlarmClass.name.ilike('%'+keyword+'%'),
                                    AlarmClass.alias.ilike('%'+keyword+'%')))
    table = make_table(query, AlarmClassTable)
    return render_template("/alarms/classes/index.html",
                            table=table, filterForm=form)
コード例 #5
0
ファイル: views.py プロジェクト: xuxanwan/xiaoli
def users():
    query = User.query
    form = SearchForm(formdata=request.args)
    keyword = form.keyword.data
    if keyword and keyword != '':
        kw = '%' + keyword + '%'
        query = query.filter(db.or_(User.name.ilike(kw),
                                    User.email.ilike(kw),
                                    User.role.has(Role.name.ilike(kw))))        
    table = make_table(query, UserTable)
    return render_template('users/index.html', table=table, form=form)
コード例 #6
0
def modules():
    form = SearchForm(formdata=request.args)
    cls, table_cls = Module, ModuleTable
    query = cls.query
    if form.keyword.data:
        ikeyword = '%' + form.keyword.data + '%'
        query = query.filter(db.or_(cls.name.ilike(ikeyword),
                                    cls.alias.ilike(ikeyword)))
    table = make_table(query, table_cls)
    return render_template('admin/modules/index.html',
                           table = table, form=form)
コード例 #7
0
ファイル: views.py プロジェクト: yordanomp/xiaoli
def users():
    query = User.query
    form = SearchForm(formdata=request.args)
    keyword = form.keyword.data
    if keyword and keyword != '':
        kw = '%' + keyword + '%'
        query = query.filter(
            db.or_(User.name.ilike(kw), User.email.ilike(kw),
                   User.role.has(Role.name.ilike(kw))))
    table = make_table(query, UserTable)
    return render_template('users/index.html', table=table, form=form)
コード例 #8
0
def timeperiods():
    query = TimePeriod.query
    form = SearchForm(formdata=request.args)
    keyword = form.keyword.data
    if keyword and keyword != '':
        ikeyword = '%' + keyword + '%'
        query = query.filter(db.or_(TimePeriod.name.ilike(ikeyword),
                                    TimePeriod.alias.ilike(ikeyword)))
    table = make_table(query, TimePeriodTable)
    return render_template('/system/timeperiods/index.html',
                            filterForm = form, table=table)
コード例 #9
0
def monitors():
    form = SearchForm(formdata=request.args)
    cls, table_cls = Monitor, MonitorTable
    query = cls.query
    if form.keyword.data:
        ikeyword = '%' + form.keyword.data + '%'
        query = query.filter(db.or_(cls.category.ilike(ikeyword),
                                    cls.vendor.ilike(ikeyword),
                                    cls.remark.ilike(ikeyword)))
    table = make_table(query, table_cls)
    return render_template('admin/monitors/index.html',
                           table = table, form=form)
コード例 #10
0
def permissions():
    form = SearchForm(formdata=request.args)
    cls, table_cls = Permission, PermissionTable
    query = cls.query
    if form.keyword.data:
        ikeyword = '%' + form.keyword.data + '%'
        query = query.filter(db.or_(cls.endpoint.ilike(ikeyword),
                                    cls.name.ilike(ikeyword),
                                    cls.operation.ilike(ikeyword)))
    table = make_table(query, table_cls)
    return render_template('admin/permissions/index.html',
                           table = table, form=form)
コード例 #11
0
def seclogs():
    query = SecurityLog.query
    form = SearchForm(formdata=request.args)
    keyword = form.keyword.data
    if keyword and keyword != '':
        keyword = keyword.strip()
        query = query.filter(db.or_(
            SecurityLog.terminal_ip.ilike('%'+keyword+'%'),
            SecurityLog.user.has(User.username.ilike('%'+keyword+'%'))))
    table = make_table(query, SecurityLogTable)
    return render_template('/system/seclogs.html',
                            filterForm=form, table=table)
コード例 #12
0
def metrics():
    query = Metric.query
    form = SearchForm(formdata=request.args)
    keyword = form.keyword.data
    if keyword and keyword != '':
        ikeyword = '%' + keyword + '%'
        query = query.filter(db.or_(Metric.name.ilike(ikeyword),
                                    Metric.grp.ilike(ikeyword),
                                    Metric.alias.ilike(ikeyword)))
    table = make_table(query, MetricTable)
    return render_template('system/metrics/index.html',
                            filterForm=form, table=table)
コード例 #13
0
def sysoids():
    form = SearchForm(formdata=request.args)
    cls, table_cls = SysOid, SysOidTable
    query = cls.query
    if form.keyword.data:
        ikeyword = '%' + form.keyword.data + '%'
        query = query.filter(db.or_(cls.sysoid.ilike(ikeyword),
                                    cls.disco.ilike(ikeyword),
                                    cls.mib.ilike(ikeyword),
                                    cls.remark.ilike(ikeyword)))
    table = make_table(query, table_cls)
    return render_template('admin/sysoids/index.html',
                           table = table, form=form)
コード例 #14
0
def thresholds():
    query = Threshold.query
    form = SearchForm(formdata=request.args)
    keyword = form.keyword.data
    if keyword and keyword != '':
        ikeyword = '%' + keyword + '%'
        query = query.filter(db.or_(Threshold.name.ilike(ikeyword),
                                    Threshold.alias.ilike(ikeyword),
                                    Threshold.category.has(Category.alias.ilike(ikeyword)),
                                    Threshold.summary.ilike(ikeyword)))
    table = make_table(query, ThresholdTable)
    return render_template("system/thresholds/index.html",
                            filterForm = form, table=table)
コード例 #15
0
def miboids(mib=None):
    form = SearchForm(formdata=request.args)
    cls, table_cls = Miboid, MiboidTable
    mib = cls.query.first().mib if not mib else mib
    if not mib:
        abort(404)
    query = cls.query.filter_by(mib=mib)
    
    if form.keyword.data:
        ikeyword = '%' + form.keyword.data + '%'
        query = query.filter(db.or_(cls.name.ilike(ikeyword),
                                    cls.alias.ilike(ikeyword)))
    table = make_table(query, table_cls)
    kwargs = {
        'menuid' : mib,
        'form'   : form,
        'table'  : table,
        'mib'    : mib,
    }
    return render_template("admin/miboids/index.html", **kwargs)
コード例 #16
0
def alarm_filter(cls, query, form):
    """告警过滤"""
    severity = form.alarm_severity.data
    if severity is not None:
        query = query.filter(cls.severity == severity.id)
    alarm_class = form.alarm_class.data
    if alarm_class:
        query = query.filter(cls.class_id == alarm_class.id)
    start_date = form.start_date.data
    if start_date:
        query = query.filter(cls.first_occurrence >= start_date)
    end_date = form.end_date.data
    if end_date:
        query = query.filter(cls.first_occurrence <= end_date)
    keyword = form.keyword.data
    if keyword and keyword != '':
        query = query.filter(db.or_(
                    cls.alarm_alias.ilike('%'+keyword+'%'),
                    cls.node.has(Node.addr.ilike('%'+keyword+'%')),
                    cls.node.has(Node.alias.ilike('%'+keyword+'%'))))
    return query