This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General layout for the whitelist section, will be adding tests in the…
… subsequents commits for the section
- Loading branch information
1 parent
954fd25
commit d3d1d8f
Showing
8 changed files
with
235 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# acts as the homepage for the dashboard | ||
### istanbul ignore next ### | ||
module.exports = exports = (app) -> | ||
|
||
# required modules | ||
async = require('async') | ||
S = require('string') | ||
fs = require('fs') | ||
uuid = require('node-uuid') | ||
|
||
# the homepage for load balancer | ||
app.get '/whitelist/create', (req, res) -> | ||
|
||
# get all the groups | ||
app.get('models').groups.findAll().then (group_objs) -> | ||
|
||
# render the create page | ||
res.render 'whitelist/create', { | ||
|
||
title: 'Create a Whitelist Item', | ||
group_objs: group_objs | ||
|
||
} | ||
|
||
# the homepage for load balancer | ||
app.post '/whitelist/create', (req, res) -> | ||
|
||
# get the params | ||
param_name_str = req.body.name | ||
param_domain_str = req.body.domain | ||
param_group_int = req.body.group | ||
|
||
# output | ||
whitelist_obj = app.get('models').whitelist.build({ | ||
|
||
name: param_name_str, | ||
domain: param_domain_str, | ||
groupId: param_group_int | ||
|
||
}) | ||
|
||
# run it | ||
whitelist_obj.save().then -> res.redirect '/whitelist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# loads all the modules and the subdirs for the app | ||
### istanbul ignore next ### | ||
module.exports = exports = (app) -> | ||
|
||
# load in our modules | ||
require('./list')(app) | ||
require('./create')(app) | ||
require('./view')(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module.exports = exports = (app) -> | ||
|
||
# the homepage for load balancer | ||
app.get '/tokens', app.get('middleware').checkLoggedIn, app.get('middleware').handlePagination, (req, res) -> | ||
|
||
# search params | ||
filter_params = {} | ||
|
||
# was the search given ? | ||
if req.query.q | ||
filter_params = { name: { like: '%' + req.query.q + '%' } } | ||
|
||
# get all the nodes | ||
app.get('models').whitelist.findAndCountAll( | ||
|
||
offset: req.requesting_pagination_offset, | ||
limit: req.requesting_pagination_limit, | ||
where: filter_params | ||
|
||
).then((result) -> | ||
|
||
# render them out | ||
res.render 'whitelist/list', { | ||
|
||
title: 'Domains users are allowed to browse', | ||
description: 'Domains users are allowed to browse', | ||
items: result.rows, | ||
limit: req.requesting_pagination_limit, | ||
offset: req.requesting_pagination_offset, | ||
total_count: result.count, | ||
current_page: req.requesting_pagination_page, | ||
pages: Math.ceil( result.count / req.requesting_pagination_limit ) | ||
|
||
} | ||
|
||
).catch((err) -> | ||
|
||
# render them out | ||
res.render 'whitelist/list', { | ||
|
||
title: 'Domains users are allowed to browse', | ||
items: [], | ||
limit: req.requesting_pagination_limit, | ||
offset: req.requesting_pagination_offset, | ||
total_count: 0, | ||
current_page: req.requesting_pagination_page, | ||
pages: 0 | ||
|
||
} | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# acts as the homepage for the dashboard | ||
### istanbul ignore next ### | ||
module.exports = exports = (app) -> | ||
|
||
# required modules | ||
S = require('string') | ||
|
||
# the homepage for load balancer | ||
app.get '/whitelist/:whitelistid', app.get('middleware').checkLoggedIn, (req, res) -> | ||
|
||
# get all the groups | ||
app.get('models').groups.findAll().then (group_objs) -> | ||
|
||
app.get('models').whitelist.find(req.params.whitelistid).then((item_obj) -> | ||
if not item_obj | ||
res.redirect '/whitelist' | ||
return | ||
|
||
item_obj = item_obj.get() | ||
res.render 'whitelist/view', { | ||
|
||
title: item_obj.name, | ||
item_obj: item_obj, | ||
group_objs: group_objs | ||
|
||
} | ||
) | ||
|
||
# the homepage for load balancer | ||
app.post '/whitelist/:whitelistid', app.get('middleware').checkLoggedIn, (req, res) -> | ||
|
||
app.get('models').whitelist.find(req.params.whitelistid).then((item_obj) -> | ||
if not item_obj | ||
res.redirect '/whitelist' | ||
return | ||
|
||
item_obj.name = req.body.name | ||
item_obj.domain = req.body.domain | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extends ../layout | ||
|
||
block content | ||
.row | ||
.col-md-6.col-md-offset-3 | ||
br | ||
br | ||
br | ||
br | ||
form.form(action="/whitelist/create",method="post") | ||
.form-group | ||
label(for="") Friendly Name | ||
input.form-control(name="name",type="text") | ||
.form-group | ||
label(for="group") Group | ||
select.form-control(name="group") | ||
option(value="none") None | ||
-each group_obj in group_objs | ||
option(value=group_obj.id,selected=post_params.group==group_obj.id) #{group_obj.name} | ||
.form-group | ||
label(for="") Domain | ||
input.form-control(name="domain",type="text") | ||
|
||
|
||
button.btn.btn-primary.btn-lg CREATE | ||
br | ||
br | ||
br | ||
br |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
extends ../layout | ||
|
||
block content | ||
.row | ||
.col-md-12 | ||
table.table | ||
thead | ||
tr | ||
th | ||
th(style="width:40%;") | ||
tbody | ||
-each item_obj in items | ||
tr | ||
td | ||
p(style="margin:0;margin-bottom:5px;font-size: 16px;") | ||
a(href="/whitelist/" + item_obj.id) #{item_obj.name} | ||
p(style="margin:0;font-size: 11px;") #{item_obj.description} | ||
td | ||
.pull-right | ||
a.btn.btn-default(style="margin-left: 10px;",href="/whitelist/#{item_obj.id}") Manage | ||
.clearfix | ||
|
||
.row | ||
.col-md-12 | ||
.pull-right | ||
nav | ||
ul.pagination | ||
-if(current_page > 1) | ||
li | ||
a(href="/whitelist?q=" + (post_params.q ? post_params.q : '') + "&limit=" + limit + "&page=" + (current_page-1)) | ||
span Back | ||
-if(current_page < pages) | ||
li | ||
a(href="/whitelist?q=" + (post_params.q ? post_params.q : '') + "&limit=" + limit + "&page=" + (current_page+1)) | ||
span Next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
extends ../layout | ||
|
||
block content | ||
.row | ||
.col-md-6.col-md-offset-3 | ||
br | ||
br | ||
br | ||
br | ||
form.form(action="/whitelist/" + item_obj.id,method="post") | ||
.form-group | ||
label(for="") Friendly Name | ||
input.form-control(name="name",type="text",value=post_params.name || item_obj.name) | ||
.form-group | ||
label(for="group") Group | ||
select.form-control(name="group") | ||
option(value="none") None | ||
-each group_obj in group_objs | ||
option(value=group_obj.id,selected=item_obj.groupId==group_obj.id) #{group_obj.name} | ||
.form-group | ||
label(for="") Domain | ||
input.form-control(name="key",type="text",value=post_params.domain || item_obj.domain) | ||
|
||
button.btn.btn-primary.btn-lg UPDATE | ||
br | ||
br | ||
br | ||
br |