-
-
Notifications
You must be signed in to change notification settings - Fork 592
feat: add configureable default for collapsing statuses #1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
93c37f3
82bc070
76002fd
a04f7fb
dc80ac5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,16 @@ | |
<Activity v-if="showAverageResponseTime" class="h-5 w-5" /> | ||
<Timer v-else class="h-5 w-5" /> | ||
</Button> | ||
|
||
<Button variant="ghost" size="icon" @click="refreshData" title="Refresh data"> | ||
<RefreshCw class="h-5 w-5" /> | ||
</Button> | ||
</div> | ||
</div> | ||
|
||
<!-- Announcement Banner --> | ||
<AnnouncementBanner :announcements="props.announcements" /> | ||
|
||
<!-- Search bar --> | ||
<SearchBar | ||
@search="handleSearch" | ||
|
@@ -178,7 +181,7 @@ | |
|
||
<script setup> | ||
/* eslint-disable no-undef */ | ||
import { ref, computed, onMounted } from 'vue' | ||
import { ref, computed, onMounted, watch } from 'vue' | ||
import { Activity, Timer, RefreshCw, AlertCircle, ChevronLeft, ChevronRight, ChevronDown, ChevronUp, CheckCircle } from 'lucide-vue-next' | ||
import { Button } from '@/components/ui/button' | ||
import EndpointCard from '@/components/EndpointCard.vue' | ||
|
@@ -211,6 +214,23 @@ const groupByGroup = ref(false) | |
const sortBy = ref(localStorage.getItem('gatus:sort-by') || 'name') | ||
const uncollapsedGroups = ref(new Set()) | ||
|
||
function readBooleanFromLocalStorage(key, fallback) { | ||
const v = localStorage.getItem(key) | ||
if (v === null) return fallback | ||
if (v === 'true' || v === '1') return true | ||
if (v === 'false' || v === '0') return false | ||
return fallback | ||
} | ||
|
||
const collapseByDefault = ref( | ||
readBooleanFromLocalStorage( | ||
'gatus:collapse', | ||
(typeof window !== 'undefined' && typeof window.config?.defaultGroupCollapse !== 'undefined') | ||
? !!window.config.defaultGroupCollapse | ||
: true | ||
) | ||
) | ||
|
||
const filteredEndpoints = computed(() => { | ||
let filtered = [...endpointStatuses.value] | ||
|
||
|
@@ -503,21 +523,32 @@ const toggleGroupCollapse = (groupName) => { | |
} | ||
|
||
const initializeCollapsedGroups = () => { | ||
// Get saved uncollapsed groups from localStorage | ||
try { | ||
const saved = localStorage.getItem('gatus:uncollapsed-groups') | ||
if (saved) { | ||
uncollapsedGroups.value = new Set(JSON.parse(saved)) | ||
return | ||
} | ||
// If no saved state, uncollapsedGroups stays empty (all collapsed by default) | ||
} catch (e) { | ||
console.warn('Failed to parse saved uncollapsed groups:', e) | ||
localStorage.removeItem('gatus:uncollapsed-groups') | ||
// On error, uncollapsedGroups stays empty (all collapsed by default) | ||
} | ||
|
||
if (!collapseByDefault.value) { | ||
const groups = Object.keys(combinedGroups.value || {}) | ||
uncollapsedGroups.value = new Set(groups) // expanded by default | ||
} else { | ||
uncollapsedGroups.value = new Set() // collapsed by default | ||
} | ||
Comment on lines
-506
to
542
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add some comments here? I see you removed all comments, it's a little hard to follow what the code is doing. |
||
} | ||
|
||
watch(() => combinedGroups.value, () => { | ||
if (!localStorage.getItem('gatus:uncollapsed-groups')) { | ||
initializeCollapsedGroups() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this ( |
||
} | ||
}) | ||
|
||
onMounted(() => { | ||
fetchData() | ||
}) | ||
</script> | ||
</script> |
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.