Exemplo n.º 1
0
def bioses_rigs(bios_name):
    if not is_bios_exist(bios_name):
        abort(404)
    return render_template('dashboard/dashboard_technical_info.html',
                           tech_dash=BiosesRigDashboard(bios_name),
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 2
0
def index():
    if current_user.is_authenticated:
        # if user is logged in we get out of here
        return redirect(url_for('dashboard.index'))
    return render_template('main/index.html',
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 3
0
def login():
    """Log in an existing user."""
    if current_user.is_authenticated:
        # if user is logged in we get out of here
        return redirect(url_for('dashboard.index'))
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user is not None and user.password_hash is not None and \
                user.verify_password(form.password.data) \
                and user.verify_totp(form.token.data):
            login_user(user, form.remember_me.data)
            flash('You are now logged in. Welcome back!', 'success')
            save_action(current_user, request, " Successfully  authenticated")
            return redirect(
                request.args.get('next') or url_for('dashboard.index'))
        else:
            save_action(current_user, request,
                        "Inserted wrong username or password")
            flash('Invalid username,password or token.', 'error')
            flash('Invalid username,password or token.', 'form-error')
    return render_template('account/login.html',
                           form=form,
                           header_nav_info=HeaderNavbarInfo(),
                           sidebar_info=SidebarInfo())
Exemplo n.º 4
0
def manage():
    """Display a user's account information."""
    return render_template('account/manage.html',
                           user=current_user,
                           form=None,
                           header_nav_info=HeaderNavbarInfo(),
                           sidebar_info=SidebarInfo())
Exemplo n.º 5
0
def log_page():
    """View log"""
    try:
        search = False
        q = request.args.get('q')
        if q:
            search = True
        page = request.args.get(get_page_parameter(), type=int, default=1)
        rev = []
        length = 0
        log_text = ""
        with open("log/pow_log.txt", "r") as custom_log:
            lines = custom_log.readlines()
            lines.reverse()
            length = (len(lines) // 100) + 1
        if lines:
            for x, line in enumerate(lines):
                if page == 1:
                    if x <= 100:
                        log_text += line.replace('\n', '<br>')
                else:
                    line_a = (100 * (page - 1))
                    line_b = (page * 100)
                    if x >= line_a and x <= line_b:
                        log_text += line.replace('\n', '<br>')

        if length != 0:
            pagination = Pagination(page=page,
                                    total=length,
                                    search=search,
                                    record_name='Logging information',
                                    css_framework='foundation',
                                    per_page=1)

            return render_template('admin/log_page.html',
                                   log_text=log_text,
                                   sidebar_info=SidebarInfo(),
                                   header_nav_info=HeaderNavbarInfo(),
                                   pagination=pagination)
    except Exception as e:
        print(e)
        print("Exception occurred loading this page")

        return render_template('admin/log_page.html',
                               sidebar_info=SidebarInfo(),
                               header_nav_info=HeaderNavbarInfo())
        pass
Exemplo n.º 6
0
def nanopool_wallet_info(proxywallet):
    if not is_nanopool_wallet_exists(proxywallet):
        abort(404)
    return render_template(
        'admin/nanopool_wallet_info.html',
        nanopool_wallet_info=NanopoolDashboardWallet(proxywallet=proxywallet),
        sidebar_info=SidebarInfo(),
        header_nav_info=HeaderNavbarInfo())
Exemplo n.º 7
0
def delete_user_request(user_id):
    """Request deletion of a user's account."""
    user = User.query.filter_by(id=user_id).first()
    if user is None:
        abort(404)
    return render_template('admin/manage_user_delete_user_request.html',
                           user=user,
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 8
0
def user_info(user_id):
    """View a user's profile."""
    user = User.query.filter_by(id=user_id).first()
    if user is None:
        abort(404)
    return render_template('admin/manage_user.html',
                           user=user,
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 9
0
def registered_users():
    """View all registered users."""
    users = User.query.all()
    roles = Role.query.all()
    return render_template('admin/registered_users.html',
                           users=users,
                           roles=roles,
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 10
0
def two_factor_setup(user_id):
    """Setup two factor authentication"""
    user = User.query.filter_by(id=user_id).first()
    if user is None:
        abort(404)
    if user.is_otp_seen:
        abort(403)
    is_otp_seen_set.apply_async(args=[user_id], expires=600, countdown=120)
    return render_template('admin/two_factor.html',
                           user=user,
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 11
0
def transactions_for_day(proxywallet, date):
    json_str_all_payments = redis_store.get(
        "nanopool_wallet_info:{}:all_payments".format(str(proxywallet)))
    all_payments = json.loads(json_str_all_payments)
    if not is_nanopool_wallet_exists(proxywallet):
        abort(404)
    if date not in all_payments:
        abort(404)
    return render_template(
        'admin/nanopool_transactions_for_day.html',
        nanopool_wallet_info=NanopoolDashboardWalletPaymentsForDate(
            proxywallet=proxywallet, date=date),
        sidebar_info=SidebarInfo(),
        header_nav_info=HeaderNavbarInfo())
Exemplo n.º 12
0
def change_account_type(user_id):
    """Change a user's account type."""
    if current_user.id == user_id:
        flash(
            'You cannot change the type of your own account. Please ask '
            'another administrator to do this.', 'error')
        save_action(current_user, request,
                    "Tried to change Account type of Own Account.")
        return redirect(
            url_for('admin.user_info',
                    user_id=user_id,
                    sidebar_info=SidebarInfo(),
                    header_nav_info=HeaderNavbarInfo()))

    user = User.query.get(user_id)
    if user is None:
        abort(404)
    form = ChangeAccountTypeForm()
    if form.validate_on_submit():
        user.role = form.role.data
        db.session.add(user)
        db.session.commit()
        flash(
            'Role for user {} successfully changed to {}.'.format(
                user.full_name(), user.role.name), 'form-success')
        flash(
            'Role for user {} successfully changed to {}.'.format(
                user.full_name(), user.role.name), 'success')
        save_action(
            current_user, request,
            'Role for user {} successfully changed to {}.'.format(
                user.full_name(), user.role.name))
    return render_template('admin/manage_user_change_account_type.html',
                           user=user,
                           form=form,
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 13
0
def new_user():
    """Create a new user."""
    form = NewUserForm()
    if form.validate_on_submit():
        user = User(role=form.role.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('User {} successfully created'.format(user.full_name()),
              'form-success')
        save_action(
            current_user, request, "Added new user" + form.username.data +
            "with " + form.role.data.name + " role.")
    return render_template('admin/new_user.html',
                           form=form,
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 14
0
def change_password():
    """Change an existing user's password."""
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.new_password.data
            db.session.add(current_user)
            db.session.commit()
            flash('Your password has been updated.', 'success')
            flash('Your password has been updated.', 'form-success')
            save_action(current_user, request, "Changed Password")
            return redirect(url_for('main.index'))
        else:
            save_action(
                current_user, request,
                "Inserted wrong password while trying to change password")
            flash('Original password is invalid.', 'error')
            flash('Original password is invalid.', 'form-error')
    return render_template('account/change_password.html',
                           form=form,
                           user=current_user,
                           header_nav_info=HeaderNavbarInfo(),
                           sidebar_info=SidebarInfo())
Exemplo n.º 15
0
def index():
    return render_template('dashboard/dashboard_index.html',
                           main_dash=MainDashboard(),
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 16
0
def panel_dash_rig(panel_name, rig_name):
    form = ManagementRigsForm()
    if not is_panel_exist(panel_name=panel_name):
        abort(404)
    else:
        if form.validate_on_submit():

            user = User.query.filter_by(username=form.username.data).first()
            if user is not None and user.password_hash is not None and \
                    user.verify_password(form.password.data):
                hosts = request.form.get('selectedHosts[]')
                hosts = ast.literal_eval(hosts)
                hosts = [n.strip() for n in hosts]
                commands = {
                    'clear_thermals': form.clear_thermals.data,
                    'put_conf': form.put_conf.data,
                    'reboot': form.reboot_task.data,
                    "update_miners": form.update_miners.data,
                    "allow_command": form.allow_command.data,
                    "update_miner_with_name": form.update_miner_with_name.data,
                    "change_password": form.change_password.data,
                    "execute_custom_command": form.execute_custom_command.data
                }

                # hostnames = request.form.get('selectedHostnames[]')
                if hosts and form.ssh_username.data and form.ssh_password.data \
                        and (
                        form.clear_thermals.data or form.put_conf.data
                        or form.reboot_task.data or form.update_miners.data
                        or form.allow_command.data or form.update_miner_with_name.data
                        or form.change_password.data or form.execute_custom_command.data):

                    results = execute_commands_on_multiple_rigs.apply_async(
                        args=[],
                        kwargs={
                            "panel_name": panel_name,
                            "hosts": hosts,
                            "commands": commands,
                            "username": form.ssh_username.data,
                            "password": form.ssh_password.data,
                            "miner_name": form.miner_name.data,
                            "new_password": form.new_password.data,
                            "custom_command": form.custom_command.data
                        },
                        expires=60)

                    # task = execute_rig_reboot.apply_async(args=[hosts[0], form.ssh_username.data,
                    # form.ssh_password.data])
                    flash('Commands have been sent to selected rigs.',
                          'success')
                    act_list = ([
                        str(k) for k, v in commands.items() if v == True
                    ])
                    act_str = ""
                    if act_list:
                        for s in act_list:
                            act_str += " " + s

                    action = "Sent " + act_str + " to " + str(hosts)
                    save_action(current_user, request, action)
                else:
                    flash('No hosts selected,or ssh fields are empty.',
                          'error')
                return render_template('dashboard/dashboard_panel.html',
                                       panel_dash=PanelDashboard(
                                           panel_name, rig_name=rig_name),
                                       sidebar_info=SidebarInfo(),
                                       header_nav_info=HeaderNavbarInfo(),
                                       form=form)
                # return redirect(request.args.get('next') or url_for('dashboard.index'))
            else:
                flash('Invalid username or password.', 'form-error')
                flash('Invalid username or password.', 'error')
                return render_template('dashboard/dashboard_panel.html',
                                       panel_dash=PanelDashboard(
                                           panel_name, rig_name=rig_name),
                                       sidebar_info=SidebarInfo(),
                                       header_nav_info=HeaderNavbarInfo(),
                                       form=form)
        else:
            return render_template('dashboard/dashboard_panel.html',
                                   panel_dash=PanelDashboard(
                                       panel_name, rig_name=rig_name),
                                   sidebar_info=SidebarInfo(),
                                   header_nav_info=HeaderNavbarInfo(),
                                   form=form)
Exemplo n.º 17
0
def technical_information():
    return render_template('dashboard/dashboard_technical_info.html',
                           tech_dash=TechnicalInfoDashboard(),
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 18
0
def heat_chart():
    return render_template('dashboard/dashboard_heat_chart.html',
                           heat_dash=HeatDashboard(),
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 19
0
def admin_dashboard():
    return render_template('admin/admin_main_dashboard.html',
                           sidebar_info=SidebarInfo(),
                           admin_dash=AdminMainDashboard(),
                           header_nav_info=HeaderNavbarInfo())
Exemplo n.º 20
0
def nanopool_wallets_dash():
    return render_template('admin/nanopool_wallets.html',
                           nano_pool_main=NanopoolDashboardMain(),
                           sidebar_info=SidebarInfo(),
                           header_nav_info=HeaderNavbarInfo())