Commit 32936e5f9886a21e4faed9acc54b30ae0dcbdbf2
1 parent
42b970f5
Exists in
master
Ajuste no layout. Colocado o menu em todas as páginas.
Showing
7 changed files
with
61 additions
and
26 deletions
Show diff stats
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-edit.html
| @@ -15,34 +15,34 @@ | @@ -15,34 +15,34 @@ | ||
| 15 | <body> | 15 | <body> |
| 16 | 16 | ||
| 17 | <div class="container"> | 17 | <div class="container"> |
| 18 | - | 18 | + <div id="menu"></div> |
| 19 | <form class="well" role="form"> | 19 | <form class="well" role="form"> |
| 20 | <div id="id-row" hidden="true" class="form-group"> | 20 | <div id="id-row" hidden="true" class="form-group"> |
| 21 | - <label for="id">ID</label> | ||
| 22 | - <span id="id-text" class="form-control-static"></span> | 21 | + <label for="id">ID</label> <span id="id-text" class="form-control-static"></span> |
| 23 | <input id="id" type="hidden"> | 22 | <input id="id" type="hidden"> |
| 24 | </div> | 23 | </div> |
| 25 | - | ||
| 26 | - <div class="form-group"> | ||
| 27 | - <label for="description">Description</label> | 24 | + |
| 25 | + <div class="form-group"> | ||
| 26 | + <label for="description">Description</label> | ||
| 28 | <input id="description" type="text" class="form-control"> | 27 | <input id="description" type="text" class="form-control"> |
| 29 | <div id="description-message" class="label label-danger"></div> | 28 | <div id="description-message" class="label label-danger"></div> |
| 30 | </div> | 29 | </div> |
| 31 | - | 30 | + |
| 32 | <div class="form-group"> | 31 | <div class="form-group"> |
| 33 | - <label for="link">Link</label> | 32 | + <label for="link">Link</label> |
| 34 | <input id="link" type="text" class="form-control"> | 33 | <input id="link" type="text" class="form-control"> |
| 35 | <div id="link-message" class="label label-danger"></div> | 34 | <div id="link-message" class="label label-danger"></div> |
| 36 | </div> | 35 | </div> |
| 37 | - | 36 | + |
| 38 | <div class="form-group"> | 37 | <div class="form-group"> |
| 39 | <button id="save" class="btn btn-primary">Salvar</button> | 38 | <button id="save" class="btn btn-primary">Salvar</button> |
| 40 | <button id="delete" class="btn btn-danger" hidden="true">Excluir</button> | 39 | <button id="delete" class="btn btn-danger" hidden="true">Excluir</button> |
| 41 | <button id="back" class="btn btn-warning">Voltar</button> | 40 | <button id="back" class="btn btn-warning">Voltar</button> |
| 42 | </div> | 41 | </div> |
| 43 | </form> | 42 | </form> |
| 44 | - | ||
| 45 | - </div> <!-- /container --> | 43 | + |
| 44 | + </div> | ||
| 45 | + <!-- /container --> | ||
| 46 | 46 | ||
| 47 | <script src="js/lib/jquery-2.1.0.min.js" type="text/javascript"></script> | 47 | <script src="js/lib/jquery-2.1.0.min.js" type="text/javascript"></script> |
| 48 | <script src="js/lib/bootstrap.min.js" type="text/javascript"></script> | 48 | <script src="js/lib/bootstrap.min.js" type="text/javascript"></script> |
| @@ -50,4 +50,6 @@ | @@ -50,4 +50,6 @@ | ||
| 50 | <script src="js/proxy/auth.js" type="text/javascript"></script> | 50 | <script src="js/proxy/auth.js" type="text/javascript"></script> |
| 51 | <script src="js/proxy/bookmark.js" type="text/javascript"></script> | 51 | <script src="js/proxy/bookmark.js" type="text/javascript"></script> |
| 52 | <script src="js/controller/bookmark-edit.js" type="text/javascript"></script> | 52 | <script src="js/controller/bookmark-edit.js" type="text/javascript"></script> |
| 53 | + <script src="js/controller/menu.js" type="text/javascript"></script> | ||
| 54 | + | ||
| 53 | </body> | 55 | </body> |
| 54 | \ No newline at end of file | 56 | \ No newline at end of file |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js
| 1 | $(function() { | 1 | $(function() { |
| 2 | + | ||
| 3 | + // Carregando o menu na página home | ||
| 4 | + $("#menu").load("menu.html", function() { | ||
| 5 | + | ||
| 6 | + AuthProxy.getUser(getUserOk, getUserFailed); | ||
| 7 | + | ||
| 8 | + $("#logout").on("click", function() { | ||
| 9 | + sessionStorage.removeItem('credentials'); | ||
| 10 | + location.href = "home.html"; | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + }); | ||
| 14 | + | ||
| 2 | $("#delete").hide(); | 15 | $("#delete").hide(); |
| 3 | $("#description").focus(); | 16 | $("#description").focus(); |
| 4 | 17 | ||
| @@ -95,4 +108,4 @@ function saveFailed(request) { | @@ -95,4 +108,4 @@ function saveFailed(request) { | ||
| 95 | 108 | ||
| 96 | function removeOk(data) { | 109 | function removeOk(data) { |
| 97 | location.href = 'bookmark-list.html'; | 110 | location.href = 'bookmark-list.html'; |
| 98 | -} | 111 | -} |
| 112 | +} | ||
| 99 | \ No newline at end of file | 113 | \ No newline at end of file |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/home.js
| 1 | $(function() { | 1 | $(function() { |
| 2 | 2 | ||
| 3 | - $("#menu").load("menu.html"); | ||
| 4 | - | ||
| 5 | -}); | ||
| 6 | \ No newline at end of file | 3 | \ No newline at end of file |
| 4 | + // Carregando o menu na página home | ||
| 5 | + $("#menu").load("menu.html", function() { | ||
| 6 | + | ||
| 7 | + AuthProxy.getUser(getUserOk, getUserFailed); | ||
| 8 | + | ||
| 9 | + $("#logout").on("click", function() { | ||
| 10 | + sessionStorage.removeItem('credentials'); | ||
| 11 | + location.href = "home.html"; | ||
| 12 | + }); | ||
| 13 | + | ||
| 14 | + }); | ||
| 15 | + | ||
| 16 | +}); |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/menu.js
| 1 | -$(function() { | ||
| 2 | - AuthProxy.getUser(getUserOk, getUserFailed); | ||
| 3 | -}); | ||
| 4 | - | ||
| 5 | -function getUserOk(data){ | 1 | +function getUserOk(data) { |
| 6 | $("#username").html(data.username); | 2 | $("#username").html(data.username); |
| 7 | } | 3 | } |
| 8 | 4 | ||
| 9 | -function getUserFailed(request){ | 5 | +function getUserFailed(request) { |
| 10 | switch (request.status) { | 6 | switch (request.status) { |
| 11 | case 401: | 7 | case 401: |
| 12 | location.href = "login.html"; | 8 | location.href = "login.html"; |
| @@ -15,4 +11,14 @@ function getUserFailed(request){ | @@ -15,4 +11,14 @@ function getUserFailed(request){ | ||
| 15 | console.log(request.statusText); | 11 | console.log(request.statusText); |
| 16 | break; | 12 | break; |
| 17 | } | 13 | } |
| 18 | -} | ||
| 19 | \ No newline at end of file | 14 | \ No newline at end of file |
| 15 | +} | ||
| 16 | + | ||
| 17 | +function logoutOk(data) { | ||
| 18 | + sessionStorage.removeItem('credentials'); | ||
| 19 | + location.href = "home.html"; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +function logoutFailed(data) { | ||
| 23 | + console.log('Falha no logout'); | ||
| 24 | + console.log(data); | ||
| 25 | +} |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/auth.js
| @@ -18,7 +18,11 @@ AuthProxy.logout = function($success, $error) { | @@ -18,7 +18,11 @@ AuthProxy.logout = function($success, $error) { | ||
| 18 | url : this.url, | 18 | url : this.url, |
| 19 | type : "DELETE", | 19 | type : "DELETE", |
| 20 | success : $success, | 20 | success : $success, |
| 21 | - error : $error | 21 | + error : $error, |
| 22 | + beforeSend : function(xhr) { | ||
| 23 | + console.log(AuthProxy.getCredentials()); | ||
| 24 | + xhr.setRequestHeader("Authorization", AuthProxy.getCredentials()); | ||
| 25 | + } | ||
| 22 | }); | 26 | }); |
| 23 | }; | 27 | }; |
| 24 | 28 | ||
| @@ -34,6 +38,6 @@ AuthProxy.getUser = function($success, $error) { | @@ -34,6 +38,6 @@ AuthProxy.getUser = function($success, $error) { | ||
| 34 | }); | 38 | }); |
| 35 | }; | 39 | }; |
| 36 | 40 | ||
| 37 | -AuthProxy.getCredentials = function(){ | 41 | +AuthProxy.getCredentials = function() { |
| 38 | return sessionStorage.getItem('credentials'); | 42 | return sessionStorage.getItem('credentials'); |
| 39 | } | 43 | } |
| 40 | \ No newline at end of file | 44 | \ No newline at end of file |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.html
| @@ -25,7 +25,7 @@ | @@ -25,7 +25,7 @@ | ||
| 25 | </ul> | 25 | </ul> |
| 26 | <ul class="nav navbar-nav navbar-right"> | 26 | <ul class="nav navbar-nav navbar-right"> |
| 27 | <li><a id="username" href="#"></a></li> | 27 | <li><a id="username" href="#"></a></li> |
| 28 | - <li><a href="#">Sair</a></li> | 28 | + <li><a id="logout" href="#">Sair</a></li> |
| 29 | </ul> | 29 | </ul> |
| 30 | </div><!-- /.navbar-collapse --> | 30 | </div><!-- /.navbar-collapse --> |
| 31 | </div><!-- /.container-fluid --> | 31 | </div><!-- /.container-fluid --> |