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 | 15 | <body> |
16 | 16 | |
17 | 17 | <div class="container"> |
18 | - | |
18 | + <div id="menu"></div> | |
19 | 19 | <form class="well" role="form"> |
20 | 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 | 22 | <input id="id" type="hidden"> |
24 | 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 | 27 | <input id="description" type="text" class="form-control"> |
29 | 28 | <div id="description-message" class="label label-danger"></div> |
30 | 29 | </div> |
31 | - | |
30 | + | |
32 | 31 | <div class="form-group"> |
33 | - <label for="link">Link</label> | |
32 | + <label for="link">Link</label> | |
34 | 33 | <input id="link" type="text" class="form-control"> |
35 | 34 | <div id="link-message" class="label label-danger"></div> |
36 | 35 | </div> |
37 | - | |
36 | + | |
38 | 37 | <div class="form-group"> |
39 | 38 | <button id="save" class="btn btn-primary">Salvar</button> |
40 | 39 | <button id="delete" class="btn btn-danger" hidden="true">Excluir</button> |
41 | 40 | <button id="back" class="btn btn-warning">Voltar</button> |
42 | 41 | </div> |
43 | 42 | </form> |
44 | - | |
45 | - </div> <!-- /container --> | |
43 | + | |
44 | + </div> | |
45 | + <!-- /container --> | |
46 | 46 | |
47 | 47 | <script src="js/lib/jquery-2.1.0.min.js" type="text/javascript"></script> |
48 | 48 | <script src="js/lib/bootstrap.min.js" type="text/javascript"></script> |
... | ... | @@ -50,4 +50,6 @@ |
50 | 50 | <script src="js/proxy/auth.js" type="text/javascript"></script> |
51 | 51 | <script src="js/proxy/bookmark.js" type="text/javascript"></script> |
52 | 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 | 55 | </body> |
54 | 56 | \ No newline at end of file | ... | ... |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js
1 | 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 | 15 | $("#delete").hide(); |
3 | 16 | $("#description").focus(); |
4 | 17 | |
... | ... | @@ -95,4 +108,4 @@ function saveFailed(request) { |
95 | 108 | |
96 | 109 | function removeOk(data) { |
97 | 110 | location.href = 'bookmark-list.html'; |
98 | 111 | -} |
112 | +} | |
99 | 113 | \ No newline at end of file | ... | ... |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/home.js
1 | 1 | $(function() { |
2 | 2 | |
3 | - $("#menu").load("menu.html"); | |
4 | - | |
5 | -}); | |
6 | 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 | 2 | $("#username").html(data.username); |
7 | 3 | } |
8 | 4 | |
9 | -function getUserFailed(request){ | |
5 | +function getUserFailed(request) { | |
10 | 6 | switch (request.status) { |
11 | 7 | case 401: |
12 | 8 | location.href = "login.html"; |
... | ... | @@ -15,4 +11,14 @@ function getUserFailed(request){ |
15 | 11 | console.log(request.statusText); |
16 | 12 | break; |
17 | 13 | } |
18 | -} | |
19 | 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 | 18 | url : this.url, |
19 | 19 | type : "DELETE", |
20 | 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 | 38 | }); |
35 | 39 | }; |
36 | 40 | |
37 | -AuthProxy.getCredentials = function(){ | |
41 | +AuthProxy.getCredentials = function() { | |
38 | 42 | return sessionStorage.getItem('credentials'); |
39 | 43 | } |
40 | 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 | 25 | </ul> |
26 | 26 | <ul class="nav navbar-nav navbar-right"> |
27 | 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 | 29 | </ul> |
30 | 30 | </div><!-- /.navbar-collapse --> |
31 | 31 | </div><!-- /.container-fluid --> | ... | ... |