Skip to content

Commit c33434a

Browse files
updates to js
1 parent 9d99f73 commit c33434a

File tree

13 files changed

+4586
-90
lines changed

13 files changed

+4586
-90
lines changed

app/auth/auth.router.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ function createJwtToken(user) {
2626
});
2727
}
2828
//Login endpoint
29-
authRouter.get('/login', (req, res) => {
29+
authRouter.get('/login.html', (req, res) => {
3030

31-
res.sendFile('/Users/macBoss/Desktop/THINKFUL/Projects/Capstones/NodeJS_Capstone3/app/views/auth/login.html');
3231

33-
})
32+
});
3433
authRouter.post('/login', localPassportMiddleware, (request, response) => {
3534
const user = request.user.serialize();
3635
const jwtToken = createJwtToken(user);

app/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app.use(express.urlencoded());
4040
//ROUTER SETUP
4141
app.use('/api/auth', authRouter);
4242
app.use('/api/user', userRouter); //Redirects all calls to /api/user to userRouter
43-
app.use('/api/workout', workoutRouter);
43+
app.use('/api/home', workoutRouter);
4444

4545
app.use('*', function(req, res) {
4646
res.status(HTTP_STATUS_CODES.NOT_FOUND).json({

app/workout/workout.router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ workoutRouter.post('/', jwtPassportMiddleware, (request, response) => {
4242
})
4343
})
4444
// jwtPassportMiddleware,
45-
workoutRouter.get('/', (request, response) => {
45+
workoutRouter.get('/', jwtPassportMiddleware, (request, response) => {
4646
console.log("Your Workouts")
4747
response.sendFile(path.resolve('./app/views/auth/home.html'));
4848
// response.send('Text here')

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"express": "^4.16.4",
3030
"express-handlebars": "^3.0.0",
3131
"faker": "^4.1.0",
32+
"handlebars": "^4.0.12",
3233
"joi": "^14.0.6",
3334
"jquery": "^3.3.1",
3435
"jshint": "^2.9.6",

public/auth.page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ function onSignUpSubmit(event) {
3535
function onLoginSubmit(event) {
3636
console.log("OnLogin Running")
3737

38-
38+
event.preventDefault();
3939
const userData = {
4040
username: $('#username-txt').val(),
4141
password: $('#password-txt').val()
4242
};
43-
// event.preventDefault();
43+
4444
HTTP.loginUser({
4545
userData,
4646
onSuccess: response => {

app/views/auth/home.html renamed to public/home.html

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,16 @@
1515
</head>
1616

1717
<body>
18+
<section class="nav-bar"></section>
19+
1820
<main>
1921
<header class="header">
2022
<div class="logo">Fit-Journal</div>
2123
<nav class="nav-login"><a class="logout-btn" href="">Log Out</a> </nav>
2224
</header>
2325

26+
<section class="wo-container js-container"></section>
2427

25-
<section class="wo-container js-container">
26-
<h1>Welcome to your workouts</h1>
27-
<button class="logout-btn">Logout</button>
28-
29-
<!--Date Navigation-->
30-
<section class="date-nav">
31-
32-
<i class="fas fa-caret-left js-caretLFT"></i>
33-
<div class="date-sel js-dateSel"></div>
34-
<i class="fas fa-caret-right js-caretRT"></i>
35-
</section>
36-
37-
<section class="ex-list">
38-
<div class="log-header">
39-
<h1 class="ex-head">Exercises</h1>
40-
<div class="stat-labels">
41-
<h3 class="log-stat-lbl">Sets
42-
<h3>
43-
<h3 class="log-stat-lbl">Reps
44-
<h3>
45-
<h3 class="log-stat-lbl">Weight
46-
<h3>
47-
</div>
48-
<!--end stat-label-->
49-
<div class="delete"></div>
50-
</div>
51-
<!--end log-header-->
52-
</section>
53-
<section class="ex-list">
54-
<div class="log-header">
55-
<h3 class="ex-name js-exName">Pushups</h3>
56-
<div class="stat-labels">
57-
<p class="log-stat js-setLbl">1</p>
58-
<p class="log-stat js-repsLbl">10</p>
59-
<p class="log-stat js-weightsLbl">0</p>
60-
</div>
61-
<!--end stat-label-->
62-
<div class="delete js-delete">x</div>
63-
</div>
64-
<!--end log-header-->
65-
<h4 class="add-ex js-addEx"><a href="#">Add Exercise</a></h4>
66-
</section>
67-
<p>This will be on a modal or different page</p>
68-
<div id="the-basics">
69-
<input class="search-ex typeahead" type="text" placeholder="Search Exercises" />
70-
</div>
71-
</section>
7228
</main>
7329
<footer>
7430
<div class="foot-col">
@@ -95,13 +51,13 @@ <h4 class="add-ex js-addEx"><a href="#">Add Exercise</a></h4>
9551
</div>
9652
</footer>
9753
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
98-
54+
<script src="/moment.js"></script>
9955
<script src="/utilities/cache.module.js"></script>
10056
<!-- <script src="../utilities/render.module.js"></script> -->
10157
<script src="/utilities/http.module.js"></script>
10258
<script src="/auth.page.js"></script>
10359
<script src="/index.page.js"></script>
104-
<script src="/home.js"></script>
60+
<!-- <script src="/home.js"></script> -->
10561

10662
</body>
10763

public/home.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let STATE = {};
22
// All these modules are are defined in /public/utilities
3-
const RENDER = window.RENDER_MODULE;
4-
const HTTP = window.HTTP_MODULE;
3+
// const RENDER = window.RENDER_MODULE;
4+
// const HTTP = window.HTTP_MODULE;
55
const CACHE = window.CACHE_MODULE;
66

77
$(document).ready(onPageLoad);

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<main>
1717
<header class="header">
1818
<div class="logo">Fit-Journal</div>
19-
<nav class="nav-login"><a href="api/auth/login">Log In</a></nav>
19+
<nav class="nav-login"><a href="/login.html">Log In</a></nav>
2020
</header>
2121

2222

public/index.page.js

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
const axios = require('axios');
2-
const CACHE = window.CACHE_MODULE;
1+
// const CACHE = window.CACHE_MODULE;
32

43
function getWorkouts() {
54
CACHE.getAuthenticatedUserFromCache()
65
$.ajax({
76
type: 'GET',
8-
url: '/api/workout',
7+
url: '/api/home',
98
contentType: 'application/json',
109
dataType: 'json',
1110
data: undefined,
@@ -27,10 +26,6 @@ function clearInputs() {
2726
$('input').val("");
2827
}
2928

30-
function onPageLoad() {
31-
getWorkouts()
32-
clearInputs();
33-
};
3429

3530
var substringMatcher = function(strs) {
3631
return function findMatches(q, cb) {
@@ -56,18 +51,18 @@ var substringMatcher = function(strs) {
5651

5752

5853

59-
function typeAhead() {
60-
$('.typeahead').typeahead({
61-
hint: true,
62-
highlight: true,
63-
minLength: 1
64-
}, {
65-
name: 'exercises',
66-
source: substringMatcher(exercises)
67-
}
54+
// function typeAhead() {
55+
// $('.typeahead').typeahead({
56+
// hint: true,
57+
// highlight: true,
58+
// minLength: 1
59+
// }, {
60+
// name: 'exercises',
61+
// source: substringMatcher(exercises)
62+
// }
6863

69-
)
70-
}
64+
// )
65+
// }
7166
count = 1
7267

7368
function currentDate() {
@@ -92,10 +87,54 @@ function changeDate(count) {
9287
});
9388
}
9489

90+
91+
92+
function dateSelectTemplate() {
93+
94+
}
95+
96+
function workoutHeader() {
97+
$('.js-container').append('<p>hello there</p>');
98+
}
99+
let exHeadTemp = `<section class="ex-list">
100+
<div class="log-header">
101+
<h1 class="ex-head">Exercises</h1>
102+
<div class="stat-labels">
103+
<h3 class="log-stat-lbl">Sets</h3>
104+
<h3 class="log-stat-lbl">Reps</h3>
105+
<h3 class="log-stat-lbl">Weight</h3>
106+
</div><!--end stat-label-->
107+
<div class="delete"></div>
108+
</div><!--end log-header-->
109+
</section>`
110+
111+
let exListTemp = `<section class="ex-list">
112+
<div class="log-header">
113+
<h3 class="ex-name js-exName">Pushups</h3>
114+
<div class="stat-labels">
115+
<p class="log-stat js-setLbl">1</p>
116+
<p class="log-stat js-repsLbl">10</p>
117+
<p class="log-stat js-weightsLbl">0</p>
118+
</div><!--end stat-label-->
119+
<div class="delete js-delete">x</div>
120+
</div><!--end log-header-->
121+
<h4 class="add-ex js-addEx"><a href="#">Add Exercise</a></h4>
122+
</section>`
123+
124+
125+
let searchBar = `<p>This will be on a modal or different page</p>
126+
<div id="the-basics">
127+
<input class="search-ex typeahead" type="text" placeholder="Search Exercises"/>
128+
</div>`
129+
95130
function onPageLoad() {
96-
typeAhead();
131+
// typeAhead();
97132
currentDate();
98133
changeDate();
134+
workoutHeader()
135+
getWorkouts()
136+
clearInputs();
99137
}
100138

139+
101140
$(onPageLoad);

app/views/auth/login.html renamed to public/login.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ <h1>Sign into your account</h1>
6262

6363
<script src="/utilities/cache.module.js"></script>
6464
<!-- <script src="/utilities/render.module.js"></script> -->
65+
<script src="/utilities/http.module.js"></script>
6566
<script src="/auth.page.js"></script>
6667
<script src="/index.page.js"></script>
6768
<script src="/home.js"></script>

0 commit comments

Comments
 (0)