Exemple #1
0
def zsetRange():
    """
    show the list of item from zst
    :return:
    """
    set_name = request.args.get('name')
    start = request.args.get('start', "")
    page_num = request.args.get('page_num', 1)
    page_size = request.args.get('page_size')
    if not page_size:
        page_size = request.cookies.get('SIZE', 10)

    db_object = SSDBClient(request)
    item_total = db_object.zsetSize(set_name)
    page_count, page_num = getPagingTabsInfo(item_total, page_num, page_size)
    offset = (page_num - 1) * int(page_size)
    if start:
        rank = db_object.zsetRank(set_name, start)
        if rank:
            page_num = getPageNumberInfo(rank, page_count, page_size)
            offset = (page_num - 1) * int(page_size)

    item_list = db_object.zsetRange(set_name, offset=offset, limit=page_size)
    select_arg = {'page_size': int(page_size)}
    resp = make_response(
        render_template('zset/zset_range.html',
                        item_list=item_list,
                        name=set_name,
                        page_num=int(page_num),
                        page_count=page_count,
                        select_arg=select_arg,
                        start=start,
                        active='zset'))
    resp.set_cookie('SIZE', str(page_size), httponly=True, samesite='Lax')
    return resp
Exemple #2
0
def hashScan():
    """
    show the list of hash item
    :return:
    """
    name = request.args.get('name')
    key_start = request.args.get('start', '')
    page_size = request.args.get('page_size')
    page_number = int(request.args.get('page_num', 1))
    if not page_size:
        page_size = request.cookies.get('SIZE', 10)
    db_client = SSDBClient(request)
    limit = int(page_size) * page_number
    item_list = db_client.hashScan(name, key_start, "", limit=limit + 1)
    if len(item_list) > limit:
        has_next = True
        item_list = item_list[-int(page_size) - 1:-1]
    else:
        has_next = False
        item_list = item_list[-int(page_size):]
    select_arg = {'page_size': int(page_size), 'start': key_start}
    resp = make_response(
        render_template('hash/hash_scan.html',
                        item_list=item_list,
                        page_num=page_number,
                        key_start=key_start,
                        name=name,
                        has_next=has_next,
                        has_prev=page_number > 1,
                        select_arg=select_arg,
                        active='hash'))
    resp.set_cookie('SIZE', str(page_size), httponly=True, samesite='Lax')
    return resp
Exemple #3
0
def zsetLists():
    """
    show the items of zset
    :return:
    """
    page_num = int(request.args.get('page_num', 1))
    page_size = request.args.get('page_size')
    if not page_size:
        page_size = request.cookies.get('SIZE', 20)
    start = request.args.get('start', '')
    db_client = SSDBClient(request)
    zset_list, has_next = db_client.zsetList(start=start,
                                             page_num=page_num,
                                             page_size=int(page_size))
    select_arg = {'start': start, 'page_size': int(page_size)}
    resp = make_response(
        render_template('zset/zset.html',
                        zset_list=zset_list,
                        has_next=has_next,
                        has_prev=page_num > 1,
                        page_num=page_num,
                        select_arg=select_arg,
                        active='zset'))
    resp.set_cookie('SIZE',
                    str(page_size),
                    secure=True,
                    httponly=True,
                    samesite='Lax')
    return resp
Exemple #4
0
def kvScan():
    """
    show the list of kv item
    """
    key_start = request.args.get('start', '')
    page_size = request.args.get('page_size')
    page_number = int(request.args.get('page_num', 1))
    if not page_size:
        page_size = request.cookies.get('SIZE', 10)
    db_client = SSDBClient(request)
    limit = int(page_size) * page_number
    item_list = db_client.kvScan(key_start, "", limit=limit + 1)
    if len(item_list) > limit:
        has_next = True
        item_list = item_list[-int(page_size) - 1:-1]
    else:
        has_next = False
        item_list = item_list[-int(page_size):]
    select_arg = {'page_size': int(page_size), 'start': key_start}
    resp = make_response(
        render_template('kv/kv_scan.html',
                        item_list=item_list,
                        page_num=page_number,
                        key_start=key_start,
                        has_next=has_next,
                        has_prev=page_number > 1,
                        select_arg=select_arg,
                        active='kv'))
    resp.set_cookie('SIZE', str(page_size))
    return resp
Exemple #5
0
def queueLists():
    """
    show the items of queue/list
    :return:
    """
    page_num = int(request.args.get('page_num', 1))
    page_size = request.args.get('page_size')
    if not page_size:
        page_size = request.cookies.get('SIZE', 10)
    start = request.args.get('start', '')
    end = request.args.get('end', '')

    db_client = SSDBClient(request)
    queue_list, has_next = db_client.queueList(name_start=start,
                                               name_end=end,
                                               page_num=page_num,
                                               page_size=int(page_size))
    select_arg = {'start': start, 'end': end, 'page_size': int(page_size)}
    resp = make_response(
        render_template('queue/queue.html',
                        queue_list=queue_list,
                        has_next=has_next,
                        has_prev=page_num > 1,
                        page_num=page_num,
                        select_arg=select_arg,
                        active='queue'))
    resp.set_cookie("SIZE", str(page_size))
    return resp
Exemple #6
0
def hashLists():
    """
    show the list of hash
    :return:
    """
    page_num = int(request.args.get('page_num', 1))
    page_size = request.args.get('page_size')
    if not page_size:
        page_size = request.cookies.get('SIZE', 10)
    start = request.args.get('start', '')
    end = request.args.get('end', '')

    db_client = SSDBClient(request)
    hash_list, has_next = db_client.hashList(name_start=start,
                                             name_end=end,
                                             page_num=page_num,
                                             page_size=int(page_size))
    select_arg = {'start': start, 'end': end, 'page_size': int(page_size)}
    resp = make_response(
        render_template('hash/hash.html',
                        hash_list=hash_list,
                        has_next=has_next,
                        has_prev=page_num > 1,
                        page_num=page_num,
                        select_arg=select_arg,
                        active='hash'))
    resp.set_cookie("SIZE", str(page_size), httponly=True, samesite='Lax')
    return resp
Exemple #7
0
def queueGet():
    """
    show an item info from queue
    :return:
    """
    queue_name = request.args.get('name')
    index = request.args.get('index')
    item = SSDBClient(request).queueGet(queue_name, index)
    return render_template('queue/queueGet.html', name=queue_name, item=item, index=index, active='queue')
Exemple #8
0
def index():
    host, port = getSAServer(request)
    server_info = SSDBClient(request).serverInfo()
    resp = make_response(render_template('index.html',
                                         server_info=server_info))
    resp.set_cookie('SSDBADMINSERVER',
                    '{host}:{port}'.format(host=host, port=port),
                    httponly=True,
                    samesite='Lax')
    return resp
Exemple #9
0
def index():
    host, port, password = getSAServer(request)
    server_info = SSDBClient(request).serverInfo()
    resp = make_response(render_template('index.html',
                                         server_info=server_info))
    resp.set_cookie(
        'SSDBADMINSERVER',
        '{host}:{port}:{password}'.format(host=host,
                                          port=port,
                                          password=password))
    return resp
Exemple #10
0
def queueClear():
    """
    delete the specified queue
    :return:
    """
    if request.method == 'POST':
        queue_name = request.form.get('name')
        SSDBClient(request).queueClear(queue_name)
        return redirect(url_for('queueLists'))
    else:
        queue_name = request.args.get('name')
        return render_template('queue/queue_clear.html', name=queue_name, active='queue')
Exemple #11
0
def kvGet():
    """
    show a kv info
    """
    key = request.args.get('key')
    value, ttl = SSDBClient(request).kvGet(key)
    return render_template('kv/kv_get.html',
                           key=key,
                           value=value,
                           ttl=ttl,
                           active='kv')
    pass
Exemple #12
0
def hashGet():
    """
    show an item info from hash
    :return:
    """
    name = request.args.get('name')
    key = request.args.get('key')
    value = SSDBClient(request).hashGet(name, key)
    return render_template('hash/hash_get.html',
                           name=name,
                           value=value,
                           key=key,
                           active='hash')
Exemple #13
0
def queueRange():
    """
    show the list of item from queue
    :return:
    """
    queue_name = request.args.get('name')
    start = request.args.get('start')
    page_num = request.args.get('page_num', 1)
    page_size = request.args.get('page_size')
    if not page_size:
        page_size = request.cookies.get('SIZE', "10")

    db_object = SSDBClient(request)
    item_total = db_object.queueSize(queue_name)
    page_count, page_num = getPagingTabsInfo(item_total, page_num, page_size)
    offset = (page_num - 1) * int(page_size)
    if start and start.isdigit():
        page_num = getPageNumberInfo(int(start), page_count, page_size)
        offset = (page_num - 1) * int(page_size)
    else:
        start = offset

    item_list = db_object.queueRange(queue_name,
                                     offset=offset,
                                     limit=page_size)
    select_arg = {'page_size': int(page_size)}
    resp = make_response(
        render_template('queue/queue_range.html',
                        item_list=item_list,
                        name=queue_name,
                        page_num=int(page_num),
                        page_count=page_count,
                        select_arg=select_arg,
                        start_index=offset,
                        start=start,
                        data_total=item_total,
                        active='queue'))
    resp.set_cookie('SIZE', page_size, httponly=True, samesite='Lax')
    return resp
Exemple #14
0
def zset_zget():
    """
    show item info from zset
    :return:
    """
    name = request.args.get('name')
    key = request.args.get('key')
    score = SSDBClient(request).zsetGet(name, key)
    return render_template('zset/zset_get.html',
                           name=name,
                           score=score,
                           key=key,
                           active='zset')
Exemple #15
0
def queuePop():
    """
    pop item(s) from queue (support back/front type)
    :return:
    """
    if request.method == 'GET':
        queue_name = request.args.get('name')
        return render_template('queue/queue_pop.html', queue_name=queue_name, active='queue')
    else:
        queue_name = request.form.get('name')
        pop_type = request.form.get('type')
        number = request.form.get('number')
        SSDBClient(request).queuePop(queue_name, number, pop_type)
        return redirect(url_for('queueRange', name=queue_name))
Exemple #16
0
def zsetClear():
    """
    delete  the specified zset data
    :return:
    """
    if request.method == 'POST':
        name = request.form.get('name')
        SSDBClient(request).zsetClear(name)
        return redirect(url_for('zsetLists'))
    else:
        queue_name = request.args.get('name')
        return render_template('zset/zset_clear.html',
                               name=queue_name,
                               active='zset')
Exemple #17
0
def queuePush():
    """
    add item to queue(support back/front type)
    Returns:
    """
    if request.method == 'GET':
        queue_name = request.args.get('name')
        return render_template('queue/queue_push.html', queue_name=queue_name, active='queue')
    elif request.method == "POST":
        queue_name = request.form.get('queue_name')
        push_type = request.form.get('type')
        item = request.form.get('item')
        SSDBClient(request).queuePush(queue_name, item, push_type)
        return redirect(url_for('queueRange', name=queue_name))
Exemple #18
0
def kvDel():
    """
    remove keys from kv
    :return:
    """
    if request.method == 'GET':
        key = request.args.get('key')
        keys = request.args.getlist('keys')
        if key:
            keys.append(key)
        return render_template('kv/kv_del.html', keys=keys, active='kv')
    else:
        keys = request.form.getlist('key')
        SSDBClient(request).kvDel(*keys)
        return redirect(url_for('kvScan'))
Exemple #19
0
def hashClear():
    """
    delete  the specified hash data
    :return:
    """
    if request.method == 'POST':
        name = request.form.get('name')
        SSDBClient(request).hashClear(name)
        return redirect(url_for('hashLists'))
    else:
        name = request.args.get('name')
        return render_template('hash/hash_clear.html',
                               name=name,
                               active='hash')
    pass
Exemple #20
0
def kvSet():
    """
    add item to kv
    """
    if request.method == 'GET':
        key = request.args.get('key', '')
        value = request.args.get('value', '')
        return render_template('kv/kv_set.html',
                               key=key,
                               value=value,
                               active='kv')
    else:
        key = request.form.get('key')
        value = request.form.get('value')
        SSDBClient(request).kvSet(key, value)
        return redirect(url_for('kvScan'))
Exemple #21
0
def hashDel():
    """
    remove keys from zset_name
    :return:
    """
    if request.method == 'GET':
        name = request.args.get('name')
        key = request.args.get('key')
        keys = request.args.getlist('keys')
        if key:
            keys.append(key)
        return render_template('hash/hash_del.html',
                               keys=keys,
                               name=name,
                               active='hash')
    else:
        keys = request.form.getlist('key')
        name = request.form.get('name')
        SSDBClient(request).hashDel(name, *keys)
        return redirect(url_for('hashScan', name=name))
Exemple #22
0
def hashSet():
    """
    Set the value of key within the hash_name
    :return:
    """
    if request.method == 'GET':
        name = request.args.get('name')
        key = request.args.get('key', '')
        value = request.args.get('value', '')
        return render_template('hash/hash_set.html',
                               name=name,
                               key=key,
                               value=value,
                               active='hash')
    else:
        name = request.form.get('name')
        key = request.form.get('key')
        value = request.form.get('value')
        SSDBClient(request).hashSet(name, key, value)
        return redirect(url_for('hashScan', name=name))
    pass
Exemple #23
0
def zsetSet():
    """
    add item to zset
    :return:
    """
    if request.method == 'GET':
        name = request.args.get('name')
        key = request.args.get('key', '')
        score = request.args.get('score', '')
        return render_template('zset/zset_set.html',
                               name=name,
                               key=key,
                               score=score,
                               active='zset')
    else:
        name = request.form.get('name')
        key = request.form.get('key')
        score = request.form.get('score')
        try:
            score = int(score)
        except ValueError:
            score = 0
        SSDBClient(request).zsetSet(name, key, score)
        return redirect(url_for('zsetRange', name=name))