Add user list page

This commit is contained in:
George Kaklamanos 2019-11-10 22:18:14 +02:00
parent a4f62a2b1e
commit cf7c86490e
4 changed files with 59 additions and 0 deletions

10
functions.rb Normal file
View file

@ -0,0 +1,10 @@
#!/bin/env ruby
def get_boolean(value)
if value
ret = ""
else
ret = ""
end
return ret
end

View file

@ -3,8 +3,19 @@
Bundler.require(:default, :development) Bundler.require(:default, :development)
require 'slim/include' require 'slim/include'
require './functions'
use BetterErrors::Middleware use BetterErrors::Middleware
DB = Sequel.connect('sqlite://database.db') DB = Sequel.connect('sqlite://database.db')
set :port, 8091 set :port, 8091
set :nav, [
{ title: 'Χρήστες', href: '/users' }
]
get '/users' do
l = {}
l[:users] = DB[:user].all
slim :users, locals: l
end

View file

@ -8,5 +8,8 @@ script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.m
link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"
/ Bootstrap JS / Bootstrap JS
script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous" script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"
/ Boostrap table
link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.14.2/dist/bootstrap-table.min.css"
script src="https://unpkg.com/bootstrap-table@1.14.2/dist/bootstrap-table.min.js"
/ Custom / Custom
meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"

35
views/users.slim Normal file
View file

@ -0,0 +1,35 @@
doctype html
html
head
include head
body
include nav
#main.mx-auto
table#myTable.table.table-hover.table-inverse.table-sortable data-toggle="table"
thead
tr
th data-sortable="true" Name
th data-sortable="true" Email
th data-sortable="true" Phone
th data-sortable="true" Card #
th data-sortable="true" Active
th data-sortable="true" Proedreio
th data-sortable="true" Banned
th data-sortable="true" Asylia
th data-sortable="true" Apousies
th data-sortable="true" Balance
th data-sortable="true" Telegram ID
- users.each do |u|
tr
td data-field="name"
a href="user?uid=#{u[:id]}"=u[:name]
td data-field="email"=u[:email]
td data-field="phone"=u[:phone]
td data-field="card_number"=u[:card_number]
td data-field="active"=get_boolean(u[:active])
td data-field="proedreio"=get_boolean(u[:proedreio])
td data-field="banned"=get_boolean(u[:banned])
td data-field="asylia"=get_boolean(u[:asylia])
td data-field="apousies"=u[:apousies]
td data-field="balance"=u[:balance]
td data-field="telegram-id"=u[:telegram_id]