Skip to content

Commit 401d64a

Browse files
committed
broken links fixed
1 parent 8dd3c76 commit 401d64a

File tree

19 files changed

+228
-119
lines changed

19 files changed

+228
-119
lines changed

controllers/adminController.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ module.exports = {
99
const count = await knex('members').count('id as total');
1010
const events = await knex('events').orderBy('id','desc').limit(5);
1111
const eventCount = await knex('events').count('id as total');
12-
const sermons = await knex('sermons').orderBy('id','desc').limit(5);
13-
response.render('admin/index',{members,count,events,eventCount,sermons});
12+
const sermons = await knex('sermons')
13+
.join('categories','categories.id','=','sermons.category_id')
14+
.select('sermons.title as title','sermons.contents as contents','categories.name as category')
15+
.orderBy('sermons.id','desc').limit(5);
16+
const sermonsCount = await knex('sermons').count('id as count')
17+
response.render('admin/index',{members,count,events,eventCount,sermons,sermonsCount:sermonsCount[0].count});
1418

1519
},
1620
//Get Registration Form

controllers/categoriesController.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@ const knexoption = require('../knexfile');
22
const knex = require('knex')(knexoption);
33
module.exports = {
44
index: async (request, response)=>{
5-
const categories = await knex('categories').select('*');
5+
6+
let categories;
7+
let pageno = 1;
8+
let offset = 0;
9+
let limit = 10;
10+
const count = await knex('categories').count('id as count');
11+
let totalpages = Math.ceil ((count[0].count)/limit);
12+
if (!request.query.page){
13+
categories = await knex('categories').select('*').offset(offset).limit(limit);
14+
}
15+
else{
16+
const {page} = request.query;
17+
const newoffset = (page-1) * 10;
18+
pageno = parseInt(page);
19+
categories = await knex('categories').select('*').offset(newoffset).limit(limit);
20+
}
21+
622
response.render('categories/index',{
7-
categories,
23+
categories,pageno,totalpages,
824
success:request.flash('success')
925
});
1026
},

controllers/eventsController.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@ const knexoption = require('../knexfile');
22
const knex = require('knex')(knexoption);
33
module.exports={
44
index:async(request,response)=>{
5-
const events = await knex('events').select('*');
6-
response.render('events/index',{events, success:request.flash('success')});
5+
6+
let events;
7+
let pageno = 1;
8+
let offset = 0;
9+
let limit = 10;
10+
const count = await knex('events').count('id as count');
11+
let totalpages = Math.ceil(count[0].count/limit);
12+
13+
if (!request.query.page){
14+
events = await knex('events').offset(offset).limit(limit);
15+
} else {
16+
const {page} = request.query;
17+
let newoffset = (page-1) * limit;
18+
pageno = parseInt(page);
19+
events = await knex('events').select('*').offset(newoffset).limit(limit);
20+
}
21+
22+
23+
response.render('events/index',{events, success:request.flash('success'),pageno,totalpages});
724
},
825

926
create:(request,response)=>{

controllers/membersController.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,25 @@ const slugify = require('slugify');
55
module.exports= {
66
index:async(request, response)=>{
77
let members;
8-
const count = await knex('members').count('id');
8+
let pageno =1;
9+
const offset =0;
10+
const limit = 3;
11+
const count = await knex('members').count('id as count');
12+
let totalpages = Math.ceil((count[0].count/limit));
13+
914
if (!request.query.page){
10-
members = await knex('members').select('*').limit(2).orderBy('id', 'desc');
15+
members = await knex('members').select('*').offset(offset).limit(limit).orderBy('id', 'desc');
1116
} else {
1217
const {page} = request.query
13-
members = await knex('members').select('*').orderBy('id', 'desc').offset(page).limit(10);
18+
const offsett = (page-1)*limit
19+
pageno = parseInt(page)
20+
members = await knex('members').select('*').orderBy('id', 'desc').offset(offsett).limit(limit);
1421
}
1522

1623
response.render('members/index',{
1724
members,
18-
count,
25+
pageno,
26+
totalpages,
1927
success:request.flash('success')});
2028

2129
},

controllers/sermonsController.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,31 @@ const knexoption = require('../knexfile');
22
const knex = require('knex')(knexoption);
33
module.exports = {
44
index: async (request,response)=>{
5-
const sermons = await knex('sermons')
6-
.select('sermons.id','sermons.title','sermons.contents','categories.name')
7-
.join('categories','sermons.category_id','=','categories.id').orderBy('sermons.id','desc');
5+
6+
let sermons;
7+
let pageno = 1;
8+
let offset = 0;
9+
let limit = 10;
10+
const count = await knex('sermons').count('id as count');
11+
let totalpages = Math.ceil ((count[0].count)/limit);
12+
if (!request.query.page){
13+
sermons = await knex('sermons')
14+
.join('categories','sermons.category_id','=','categories.id')
15+
.select('sermons.id','sermons.title','sermons.contents','categories.name')
16+
.offset(offset).limit(limit).orderBy('sermons.id','desc').orderBy('sermons.id','desc');
17+
}
18+
else{
19+
const {page} = request.query;
20+
const newoffset = (page-1) * 10;
21+
pageno = parseInt(page);
22+
sermons = await knex('sermons')
23+
.join('categories','sermons.category_id','=','categories.id').orderBy('sermons.id','desc')
24+
.select('sermons.id','sermons.title','sermons.contents','categories.name')
25+
.offset(newoffset).limit(limit);
26+
}
27+
828
response.render('sermons/index',{
9-
sermons,
29+
sermons,pageno,totalpages,
1030
success: request.flash('success')
1131
});
1232

controllers/unitsController.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,26 @@ const knexoption = require('../knexfile');
22
const knex = require('knex')(knexoption);
33
module.exports = {
44
index: async (request, response)=>{
5-
const units = await knex('units')
6-
.join('members','members.id','=','units.head')
7-
.select('units.id as id','units.name as uname','units.description as desc','members.last_name as head');
5+
6+
let units;
7+
let pageno = 1;
8+
let offset = 0;
9+
let limit = 10;
10+
const count = await knex('units').count('id as count');
11+
let totalpages = Math.ceil ((count[0].count)/limit);
12+
if (!request.query.page){
13+
units = await knex('units').join('members','members.id','=','units.head')
14+
.select('units.id as id','units.name as uname','units.description as desc','members.last_name as head').offset(offset).limit(limit);
15+
}
16+
else{
17+
const {page} = request.query;
18+
const newoffset = (page-1) * 10;
19+
pageno = parseInt(page);
20+
units = await knex('units').join('members','members.id','=','units.head')
21+
.select('units.id as id','units.name as uname','units.description as desc','members.last_name as head').offset(newoffset).limit(limit);
22+
}
823
response.render('units/index',{
9-
units,
24+
units,pageno,totalpages,
1025
success:request.flash('success')
1126
});
1227
},
File renamed without changes.

resources/views/admin/index.ejs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<h1 class="mb-1"><%= count[0].total%></h1>
5252
</div>
5353
<div class="metric-label d-inline-block float-right text-success font-weight-bold">
54-
<span class="icon-circle-small icon-box-xs text-success bg-success-light"><i class="fa fa-users"></i></span><span class="ml-1"><%= count[0].total%> Members</span>
54+
<span class="icon-circle-small icon-box-xs text-success bg-success-light"><i class="fa fa-users"></i></span><span class="ml-1">Members</span>
5555
</div>
5656
</div>
5757
</div>
@@ -65,12 +65,12 @@
6565
<div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
6666
<div class="card border-3 border-top border-left-primary">
6767
<div class="card-body">
68-
<h5 class="text-muted">Staff</h5>
68+
<h5 class="text-muted">Sermons</h5>
6969
<div class="metric-value d-inline-block">
70-
<h1 class="mb-1">1245</h1>
70+
<h1 class="mb-1"><%=sermonsCount%></h1>
7171
</div>
7272
<div class="metric-label d-inline-block float-right text-success font-weight-bold">
73-
<span class="icon-circle-small icon-box-xs text-success bg-success-light"><i class="fa fa-fw fa-arrow-up"></i></span><span class="ml-1">10%</span>
73+
<span class="icon-circle-small icon-box-xs text-success bg-success-light"><i class="fa fa-book"></i></span><span class="ml-1">Sermons</span>
7474
</div>
7575
</div>
7676
</div>
@@ -104,8 +104,8 @@
104104
<div class="metric-value d-inline-block">
105105
<h1 class="mb-1">1340</h1>
106106
</div>
107-
<div class="metric-label d-inline-block float-right text-danger font-weight-bold">
108-
<span class="icon-circle-small icon-box-xs text-danger bg-danger-light bg-danger-light "><i class="fa fa-fw fa-arrow-down"></i></span><span class="ml-1">4%</span>
107+
<div class="metric-label d-inline-block float-right text-success font-weight-bold">
108+
<span class="icon-circle-small icon-box-xs text-success bg-success-light bg-success-light "><i class="fa fa-shopping-basket"></i></span><span class="ml-1">Request(s)</span>
109109
</div>
110110
</div>
111111
</div>
@@ -196,7 +196,7 @@
196196
</tr>
197197
<%}%>
198198
<tr>
199-
<td colspan="9"><a href="" class="btn btn-outline-light float-right">All Events</a></td>
199+
<td colspan="9"><a href="/admin/events/index" class="btn btn-outline-light float-right">All Events</a></td>
200200
</tr>
201201
</tbody>
202202
</table>
@@ -222,7 +222,7 @@
222222
<tr class="border-0">
223223
<th class="border-0">Title</th>
224224
<th class="border-0">Content</th>
225-
<th class="border-0">Date</th>
225+
<th class="border-0">Category</th>
226226

227227
</tr>
228228
</thead>
@@ -231,12 +231,12 @@
231231
<tr>
232232
<td><%=sermon.title%></td>
233233
<td><%-sermon.contents.substr(0,50)+'...'%> </td>
234-
<td><%=sermon.created_at%></td>
234+
<td><%=sermon.category%></td>
235235
<!-- EDIT, VIEW AND DELETE -->
236236
</tr>
237237
<%}%>
238238
<tr>
239-
<td colspan="9"><a href="" class="btn btn-outline-light float-right">All Sermons</a></td>
239+
<td colspan="9"><a href="/admin/sermons/index" class="btn btn-outline-light float-right">All Sermons</a></td>
240240
</tr>
241241
</tbody>
242242
</table>
@@ -256,7 +256,7 @@
256256
<!-- ============================================================== -->
257257
<div class="col-xl-5 col-lg-5 col-md-12 col-sm-12 col-12">
258258
<div class="card">
259-
<h5 class="card-header">Sermons</h5>
259+
<h5 class="card-header"> <i class="fa fa-circle"></i> &emsp; Chart</h5>
260260
<div class="card-body">
261261
<div id="c3chart_category" style="height: 420px;"></div>
262262
</div>
@@ -271,13 +271,11 @@
271271

272272
<div class="col-xl-7 col-lg-7 col-md-12 col-sm-12 col-12">
273273
<div class="card">
274-
<h5 class="card-header"> Staff</h5>
275-
<div class="card-body">
276-
<div id="morris_totalrevenue"></div>
277-
</div>
278-
<div class="card-footer">
279-
<p class="display-7 font-weight-bold"><span class="text-primary d-inline-block">$26,000</span><span class="text-success float-right">+9.45%</span></p>
274+
<h5 class="card-header"> <i class="fa fa-calendar"></i> &emsp; Calendar</h5>
275+
<div class="card-body mx-auto">
276+
<div id="morris_totalrevenue" class="calendar justify-content-center text-center"></div>
280277
</div>
278+
<hr>
281279
</div>
282280
</div>
283281
</div>
@@ -297,6 +295,14 @@
297295
<%include ../partials/footer%>
298296
</div>
299297
<!-- Optional JavaScript -->
298+
<script src="/js/jquery-3.3.1.min.js"></script>
299+
<script src="/js/jquery.calendar-widget.js"></script>
300+
<script>
301+
$(".calendar").calendarWidget({
302+
month: new Date().getMonth(),
303+
year: new Date().getFullYear()
304+
});
305+
</script>
300306
<%include ../partials/javascript%>
301307
</body>
302308

resources/views/categories/create.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</div>
3535
</div>
3636
</div>
37-
<div class="col-xl-8 offset-xl-2 col-lg-8 offset-lg-2 col-md-12 col-sm-12 col-12 ">
37+
<div class="col-xl-8 offset-xl-2 col-lg-8 offset-lg-2 col-md-12 col-sm-12 col-12 mb-5 mt-5 ">
3838
<div class="card">
3939
<h5 class="card-header"><i class="fas fa-list">&emsp;</i>Add New Category </h5>
4040
<div class="card-body">

resources/views/categories/index.ejs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,33 @@
6464
</tr>
6565
<%}%>
6666
<tr>
67-
<td colspan="9"><a href="" class="btn btn-outline-light float-right">Paginations Here</a></td>
67+
<td colspan="9"></td>
6868
</tr>
6969
</tbody>
7070
</table>
7171
</div>
7272
</div>
7373
</div>
7474
</div>
75+
<section class="row justify-content-center">
76+
<nav aria-label="Page lx-auto navigation example">
77+
<ul class="pagination">
78+
<% if (pageno<=1) {%>
79+
<li class="page-item <%= 'disabled' %>"><a class="page-link" href="#">Previous</a></li>
80+
<%} else{%>
81+
<li class="page-item"><a class="page-link" href="?page=<%= pageno-1 %>">Previous</a></li>
82+
<%}%>
83+
<li class="page-item"> Showing <%=pageno%> / <%=totalpages%> Pages </li>
84+
<!-- Next -->
85+
<% if (pageno>=totalpages) {%>
86+
<li class="page-item <%= 'disabled' %>"><a class="page-link" href="#">Next</a></li>
87+
<%} else{%>
88+
<li class="page-item"><a class="page-link" href="?page=<%= (pageno+1) %>">Next</a></li>
89+
<%}%>
90+
</ul>
91+
</nav>
92+
93+
</section>
7594
</div>
7695
</div>
7796
</div>

resources/views/events/index.ejs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,33 @@
6969
</tr>
7070
<%}%>
7171
<tr>
72-
<td colspan="9"><a href="" class="btn btn-outline-light float-right">Paginations Here</a></td>
72+
<td colspan="9"></td>
7373
</tr>
7474
</tbody>
7575
</table>
7676
</div>
7777
</div>
7878
</div>
7979
</div>
80+
<section class="row justify-content-center">
81+
<nav aria-label="Page lx-auto navigation example">
82+
<ul class="pagination">
83+
<% if (pageno<=1) {%>
84+
<li class="page-item <%= 'disabled' %>"><a class="page-link" href="#">Previous</a></li>
85+
<%} else{%>
86+
<li class="page-item"><a class="page-link" href="?page=<%= pageno-1 %>">Previous</a></li>
87+
<%}%>
88+
<li class="page-item"> Showing <%=pageno%> / <%=totalpages%> Pages </li>
89+
<!-- Next -->
90+
<% if (pageno>=totalpages) {%>
91+
<li class="page-item <%= 'disabled' %>"><a class="page-link" href="#">Next</a></li>
92+
<%} else{%>
93+
<li class="page-item"><a class="page-link" href="?page=<%= (pageno+1) %>">Next</a></li>
94+
<%}%>
95+
</ul>
96+
</nav>
97+
98+
</section>
8099
</div>
81100
</div>
82101
</div>

0 commit comments

Comments
 (0)