Skip to content

Commit

Permalink
🐛 : keep sidebar status change changing route
Browse files Browse the repository at this point in the history
resolves #82
  • Loading branch information
juwit committed Aug 30, 2019
1 parent 008a029 commit 0b1643b
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.info.InfoEndpoint;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Map;
Expand All @@ -21,4 +22,10 @@ public class DashboardControllerAdvice {
public Map<String, Object> buildInformation(){
return infoEndpoint.info();
}

@ModelAttribute("sidebar_collapsed")
public boolean sidebarCollapsed(@CookieValue(name = "sidebar_collapsed", defaultValue = "false") String cookieValue){
return Boolean.valueOf(cookieValue);
}

}
2 changes: 1 addition & 1 deletion src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/module_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/new_stack.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/stack.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/stacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="full_container">
<div class="inner_container">

<div id="sidebar-placeholder"></div>
<div id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}"></div>

<!-- right content -->
<div id="content">
Expand Down
13 changes: 9 additions & 4 deletions src/main/resources/templates/vue_templates/sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template id="sidebar-template">
<nav id="sidebar">
<nav id="sidebar" th:class="${sidebar_collapsed ? 'active' : ''}">
<div>
<div class="sidebar-part">
<div class="sidebar-header">
Expand Down Expand Up @@ -37,15 +37,20 @@
</nav>
</template>

<script type="application/ecmascript">
<script th:inline="javascript" type="application/ecmascript">
let sidebar_collapsed = [[${sidebar_collapsed}]];
new Vue({
el: "#sidebar-placeholder",
template: "#sidebar-template"
el: "#sidebar",
template: "#sidebar-template",
});
$(document).ready(function () {
/*-- sidebar js --*/
// sidebarCollapse button is in another part (header)
$('#sidebarCollapse').on('click', function () {
sidebar_collapsed = ! sidebar_collapsed;
document.cookie = `sidebar_collapsed=${sidebar_collapsed}`;
$('#sidebar').toggleClass('active');
});
});
Expand Down

0 comments on commit 0b1643b

Please sign in to comment.