From 32936e5f9886a21e4faed9acc54b30ae0dcbdbf2 Mon Sep 17 00:00:00 2001 From: lusabo Date: Fri, 4 Jul 2014 12:10:32 -0300 Subject: [PATCH] Ajuste no layout. Colocado o menu em todas as páginas. --- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-edit.html | 24 +++++++++++++----------- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js | 15 ++++++++++++++- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/home.js | 16 +++++++++++++--- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js | 2 +- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/menu.js | 20 +++++++++++++------- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/auth.js | 8 ++++++-- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.html | 2 +- 7 files changed, 61 insertions(+), 26 deletions(-) diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-edit.html b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-edit.html index e6e5512..0de9654 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-edit.html +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-edit.html @@ -15,34 +15,34 @@
- +
- -
- + +
+
- +
- +
- +
- -
+ +
+ @@ -50,4 +50,6 @@ + + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js index eb2fc64..6f60d61 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js @@ -1,4 +1,17 @@ $(function() { + + // Carregando o menu na página home + $("#menu").load("menu.html", function() { + + AuthProxy.getUser(getUserOk, getUserFailed); + + $("#logout").on("click", function() { + sessionStorage.removeItem('credentials'); + location.href = "home.html"; + }); + + }); + $("#delete").hide(); $("#description").focus(); @@ -95,4 +108,4 @@ function saveFailed(request) { function removeOk(data) { location.href = 'bookmark-list.html'; -} +} \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/home.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/home.js index 591a910..e6c25d7 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/home.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/home.js @@ -1,5 +1,15 @@ $(function() { - $("#menu").load("menu.html"); - -}); \ No newline at end of file + // Carregando o menu na página home + $("#menu").load("menu.html", function() { + + AuthProxy.getUser(getUserOk, getUserFailed); + + $("#logout").on("click", function() { + sessionStorage.removeItem('credentials'); + location.href = "home.html"; + }); + + }); + +}); diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js index 9e37c0a..adfa578 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js @@ -57,4 +57,4 @@ function loginFail(request) { }); break; } -} +} \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/menu.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/menu.js index e7e8be6..688630f 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/menu.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/menu.js @@ -1,12 +1,8 @@ -$(function() { - AuthProxy.getUser(getUserOk, getUserFailed); -}); - -function getUserOk(data){ +function getUserOk(data) { $("#username").html(data.username); } -function getUserFailed(request){ +function getUserFailed(request) { switch (request.status) { case 401: location.href = "login.html"; @@ -15,4 +11,14 @@ function getUserFailed(request){ console.log(request.statusText); break; } -} \ No newline at end of file +} + +function logoutOk(data) { + sessionStorage.removeItem('credentials'); + location.href = "home.html"; +} + +function logoutFailed(data) { + console.log('Falha no logout'); + console.log(data); +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/auth.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/auth.js index 2504cca..7c6677f 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/auth.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/auth.js @@ -18,7 +18,11 @@ AuthProxy.logout = function($success, $error) { url : this.url, type : "DELETE", success : $success, - error : $error + error : $error, + beforeSend : function(xhr) { + console.log(AuthProxy.getCredentials()); + xhr.setRequestHeader("Authorization", AuthProxy.getCredentials()); + } }); }; @@ -34,6 +38,6 @@ AuthProxy.getUser = function($success, $error) { }); }; -AuthProxy.getCredentials = function(){ +AuthProxy.getCredentials = function() { return sessionStorage.getItem('credentials'); } \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.html b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.html index e71bc52..5cae00f 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.html +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/menu.html @@ -25,7 +25,7 @@ -- libgit2 0.21.2