Skip to content

Commit

Permalink
Administration page, add a offer page and get token
Browse files Browse the repository at this point in the history
  • Loading branch information
LoghanRamassamy committed May 26, 2018
1 parent 733f029 commit 7bdb2ab
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 68 deletions.
124 changes: 82 additions & 42 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<script src="vendor/js/custom.js"></script>
<script src="vendor/js/translate.js"></script>
<script src="vendor/js/authentification.js"></script>
</head>

<body>
Expand Down Expand Up @@ -78,9 +79,11 @@
<div class="dropdown">
<a class="nav-link dropdown-toggle" role="button" id="dropdownMenuUser" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Loghan</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuUser">
<div class="dropdown-item tradUserSetting" id="goUser">Account setting</div>
<div class="dropdown-item tradFavorite" id="goFavorite">Favorite</div>
<div class="dropdown-item tradLogout" id="logout">Logout</div>
<div class="dropdown-item cursorAsPointer tradUserSetting" id="goUser">Account setting</div>
<div class="dropdown-item cursorAsPointer tradAdministration" id="goAdministration">Administration</div>
<div class="dropdown-item cursorAsPointer tradAddOffer" id="goAddOffer">Add offer</div>
<div class="dropdown-item cursorAsPointer tradFavorite" id="goFavorite">Favorite</div>
<div class="dropdown-item cursorAsPointer tradLogout" id="logout">Logout</div>
</div>
</div>
</li>
Expand Down Expand Up @@ -196,40 +199,6 @@ <h5 class="modal-title textBold tradCreateAccount" id="registerModalLabel">Creat
<!-- Article page -->
<div id="articlePage">
<div class="row my-4">
<!--<div class="col-lg-3">
<!-- Filter --
<h1 class="alignCenter tradFilter">Filter</h1>
<div class="form-group">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="checkStore" value="store">
<label class="form-check-label tradAvailable" for="checkStore">Available in store</label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="checkFavorite" value="favorite">
<label class="form-check-label tradFavorite" for="checkFavorite">Favorite</label>
</div>
</div>
<div class="form-group">
<select class="form-control form-control-sm" id="selectFormOrder">
<optgroup class="tradOrder" label="Order by">
<option class="tradPrice" value="price">Price</option>
<option class="tradAdditionDate" value="addition_date">Addition date</option>
<option class="tradLikeDislike" value="like">Like / Dislike</option>
</optgroup>
</select>
</div>
<div class="form-group">
<select class="form-control form-control-sm" id="selectFormSort">
<optgroup class="tradSort" label="Sort by">
<option class="tradAsc" value="growing">Growing</option>
<option class="tradDesc" value="decreasing">Decreasing</option>
</optgroup>
</select>
</div>
<!-- Ads --
<img src="http://placehold.it/300x200">
</div>-->

<div class="col-lg-12">
<!-- Ads -->
<div id="carouselAdsIndicatorsTop" class="carousel slide mb-4" data-ride="carousel">
Expand Down Expand Up @@ -281,15 +250,15 @@ <h1 class="alignCenter tradFilter">Filter</h1>
<input type="email" class="form-control" id="inputMailSetting" value="" placeholder="loghan.r@gmail.com" required>
</div>
<div class="form-group">
<label for="inputUsername">Username</label>
<label class="tradUsername" for="inputUsername">Username</label>
<input type="text" class="form-control" id="inputUsernameSetting" value="" placeholder="Loghan RAMASSAMY">
</div>
<div class="form-group">
<label for="inputBirthSetting">Date of birth</label>
<label class="tradBirth" for="inputBirthSetting">Date of birth</label>
<input type="date" class="form-control" id="inputBirthSetting" value="1994-03-01">
</div>
<button type="button" class="btn btn-primary alignRight" id="updateUser">Update</button>
<button type="button" class="btn btn-secondary alignRight">Reset</button>
<button type="button" class="btn btn-primary alignRight tradUpdate" id="updateUser">Update</button>
<button type="button" class="btn btn-secondary alignRight tradCancel">Reset</button>
</div>
</div>
</form>
Expand All @@ -316,7 +285,7 @@ <h3 class="alignCenter tradPartner">Our partner</h3>
<!-- Favorite page -->
<div id="favoritePage">
<div class="my-4">
<h3 class="alignCenter">Favorite</h3>
<h3 class="alignCenter tradFavorite">Favorite</h3>
<img class="col-lg-1" src="vendor/img/profilPicture.png" alt="">
<img class="col-lg-1" src="vendor/img/profilPicture.png" alt="">
<img class="col-lg-1" src="vendor/img/profilPicture.png" alt="">
Expand Down Expand Up @@ -353,6 +322,77 @@ <h5 class="col-lg-12">+33 (0) 768 329 294</h5>
</div>
</div>

<!-- Administration page -->
<div id="administrationPage">
<div class="row my-4">
<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">ID user</th>
<th scope="col">Username</th>
<th scope="col">Password</th>
<th scope="col">Password Hash</th>
<th scope="col">Sign up</th>
<th scope="col">Picture</th>
<th scope="col">Admin</th>
<th scope="col"> </th>
</tr>
</thead>
<tbody id="userTable">

</tbody>
</table>
</div>

<div class="row my-4">
<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">ID offer</th>
<th scope="col">Name</th>
<th scope="col">Created</th>
<th scope="col">Updated</th>
<th scope="col">Description</th>
<th scope="col">Price</th>
<th scope="col">Picture</th>
<th scope="col"> </th>
</tr>
</thead>
<tbody id="offerTable">

</tbody>
</table>
</div>
</div>

<!-- Offer add page -->
<div id="addOfferPage">
<form>
<div class="row my-4">
<div class="col-lg-2">
<img class="img-profil" src="vendor/img/profilPicture.png" alt="">
</div>
<div class="col-lg-10">
<div class="form-group">
<label class="tradName">Name</label>
<input type="text" class="form-control" value="" placeholder="" required>
</div>
<div class="form-group">
<label>Description</label>
<input type="text" class="form-control" value="" placeholder="" required>
</div>
<div class="form-group">
<label class="tradPrice">Price</label>(<span class="tradMoneyLogo"></span>)
<input type="number" class="form-control" value="" required>
</div>
<button type="button" class="btn btn-primary alignRight tradAdd" >Add</button>
<button type="button" class="btn btn-secondary alignRight tradCancel">Reset</button>
</div>
</div>
</form>
</div>

<!-- Footer -->
<footer class="py-3 bg-dark">
<div class="container">
<p class="m-0 text-center text-white">Copyright &copy; IDeal 2018</p>
Expand Down
16 changes: 7 additions & 9 deletions src/vendor/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* IDeal */

html,
body {
height: 100%;
font-family: "Century Gothic";
}
body { height: 100% }

body { padding-top: 54px }
body { background-color: #f5f5f5 }
Expand Down Expand Up @@ -38,12 +35,13 @@ img {
margin: 0 auto 15px;
}

.alignTextCenter{
text-align: center;
}

.alignTextCenter { text-align: center }
.textBold { font-weight: bold }
.cursorAsPointer { cursor:pointer }

#userPage { display: none; }
#partnerPage { display: none; }
#favoritePage { display: none; }
#favoritePage { display: none; }
#administrationPage { display: none; }
#addOfferPage { display: none; }

79 changes: 68 additions & 11 deletions src/vendor/js/authentification.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
* Create form to request access token from Google's OAuth 2.0 server.
*/

$(function(){

$('#loginButtonTest').click(function() {
alert("Je lance la function");
getToken('user@mail.com', 'password');
});


});

function getToken(aMail, aPassword){
function getToken2(aMail, aPassword){
alert("Je suis dans la function");
$.post("http://localhost:8888/oauth2/token",
{
Expand Down Expand Up @@ -41,6 +31,8 @@ function oauthSignIn() {
'include_granted_scopes': 'true',
'state': 'pass-through value'};



// Add form parameters as hidden input values.
for (var p in params) {
var input = document.createElement('input');
Expand All @@ -55,3 +47,68 @@ function oauthSignIn() {
form.submit();
}


function getToken(aMail, aPassword){
//var signin = function() {

var tokenUrl = "http://localhost:8888/oauth2/token";

var params = {"grant_type":"password",
"client_id":"",
"username":aMail,
"password":aPassword,
"secret":"secret_",
"scope":"nimportequoi"
};

$.post(tokenUrl, params).then(doneCallbacksTest, failCallbacksTest);
//window.localStorage.setItem('theToken', $.post(tokenUrl, params).then(doneCallbacksTest, failCallbacksTest));
//var signin = $.post(tokenUrl, params).then(doneCallbacksTest, failCallbacksTest);
//alert(signin);
/*
$.post(tokenUrl, params)
.done(function( data ) {
alert( "Data Loaded: " + data );
});
*/

//alert(signin);

}
function doneCallbacksTest(){
alert("Token is generate !");
//alert(window.localStorage);
//alert(window.localStorage.getItem('theToken'));

var url = "http://localhost:8888/user/1"
$.support.cors = true;
$.getJSON(
url,
function(data){
alert(data.id + data.mail + data.password + data.psw_hash + data.inscription + data.admin);
/*if (data.length > 1) {
$.each(data, function (key, val) {
alert(val.id + val.mail + val.password + val.psw_hash + val.inscription + val.admin);
});
}*/
}
);
}
function failCallbacksTest(){
alert("FAIL !");
//alert(window.localStorage.getItem('theToken'));
}


//window.localStorage.setItem(key, value);
//window.localStorage.getItem(key);


/*
var params = {"grant_type":"password",
"client_id":"acme1",
"username":aMail,
"password":aPassword,
"secret":"secret_",
"scope":"nimportequoi"};
*/

0 comments on commit 7bdb2ab

Please sign in to comment.