Skip to content

Commit 82bc070

Browse files
committed
refactor: rename defaultCollapse to defaultGroupCollapse
1 parent 93c37f3 commit 82bc070

File tree

6 files changed

+12
-34
lines changed

6 files changed

+12
-34
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ If you want to test it locally, see [Docker](#docker).
271271
| `ui.dark-mode` | Whether to enable dark mode by default. Note that this is superseded by the user's operating system theme preferences. | `true` |
272272
| `ui.default-sort-by` | Default sorting option for endpoints in the dashboard. Can be `name`, `group`, or `health`. Note that user preferences override this. | `name` |
273273
| `ui.default-filter-by` | Default filter option for endpoints in the dashboard. Can be `none`, `failing`, or `unstable`. Note that user preferences override this. | `none` |
274+
| `ui.default-group-collapse` | Default collapse option for statuses in the dashboard. Can be either `true` or `false`. Note that user preferences override this. | `false` |
274275
| `maintenance` | [Maintenance configuration](#maintenance). | `{}` |
275276

276277
If you want more verbose logging, you may set the `GATUS_LOG_LEVEL` environment variable to `DEBUG`.

config/ui/ui.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ const (
2222

2323
var (
2424
defaultDarkMode = true
25-
defaultCollapse = true
25+
defaultGroupCollapse = true
2626

2727
ErrButtonValidationFailed = errors.New("invalid button configuration: missing required name or link")
2828
ErrInvalidDefaultSortBy = errors.New("invalid default-sort-by value: must be 'name', 'group', or 'health'")
2929
ErrInvalidDefaultFilterBy = errors.New("invalid default-filter-by value: must be 'none', 'failing', or 'unstable'")
30-
ErrInvalidDefaultCollapse = errors.New("invalid default-collapse value: must be a boolean")
30+
ErrInvalidDefaultGroupCollapse = errors.New("invalid default-group-collapse value: must be a boolean")
3131
)
3232

3333
// Config is the configuration for the UI of Gatus
@@ -42,7 +42,7 @@ type Config struct {
4242
DarkMode *bool `yaml:"dark-mode,omitempty"` // DarkMode is a flag to enable dark mode by default
4343
DefaultSortBy string `yaml:"default-sort-by,omitempty"` // DefaultSortBy is the default sort option ('name', 'group', 'health')
4444
DefaultFilterBy string `yaml:"default-filter-by,omitempty"` // DefaultFilterBy is the default filter option ('none', 'failing', 'unstable')
45-
DefaultCollapse *bool `yaml:"default-collapse,omitempty"` // DefaultCollapse is a flag to enable/disable collapsing of groups by default
45+
DefaultGroupCollapse *bool `yaml:"default-group-collapse,omitempty"` // DefaultGroupCollapse is a flag to enable/disable collapsing of groups by default
4646

4747
//////////////////////////////////////////////
4848
// Non-configurable - used for UI rendering //
@@ -83,7 +83,7 @@ func GetDefaultConfig() *Config {
8383
DarkMode: &defaultDarkMode,
8484
DefaultSortBy: defaultSortBy,
8585
DefaultFilterBy: defaultFilterBy,
86-
DefaultCollapse: &defaultCollapse,
86+
DefaultGroupCollapse: &defaultGroupCollapse,
8787
MaximumNumberOfResults: storage.DefaultMaximumNumberOfResults,
8888
}
8989
}
@@ -121,8 +121,8 @@ func (cfg *Config) ValidateAndSetDefaults() error {
121121
} else if cfg.DefaultFilterBy != "none" && cfg.DefaultFilterBy != "failing" && cfg.DefaultFilterBy != "unstable" {
122122
return ErrInvalidDefaultFilterBy
123123
}
124-
if cfg.DefaultCollapse == nil {
125-
cfg.DefaultCollapse = &defaultCollapse
124+
if cfg.DefaultGroupCollapse == nil {
125+
cfg.DefaultGroupCollapse = &defaultGroupCollapse
126126
}
127127
for _, btn := range cfg.Buttons {
128128
if err := btn.Validate(); err != nil {

web/app/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<script type="text/javascript">
6-
window.config = {logo: "{{ .UI.Logo }}", header: "{{ .UI.Header }}", link: "{{ .UI.Link }}", buttons: [], maximumNumberOfResults: "{{ .UI.MaximumNumberOfResults }}", defaultSortBy: "{{ .UI.DefaultSortBy }}", defaultFilterBy: "{{ .UI.DefaultFilterBy }}", defaultCollapse: "{{ .UI.DefaultCollapse }}"};{{- range .UI.Buttons}}window.config.buttons.push({name:"{{ .Name }}",link:"{{ .Link }}"});{{end}}
6+
window.config = {logo: "{{ .UI.Logo }}", header: "{{ .UI.Header }}", link: "{{ .UI.Link }}", buttons: [], maximumNumberOfResults: "{{ .UI.MaximumNumberOfResults }}", defaultSortBy: "{{ .UI.DefaultSortBy }}", defaultFilterBy: "{{ .UI.DefaultFilterBy }}", defaultGroupCollapse: "{{ .UI.DefaultGroupCollapse }}"};{{- range .UI.Buttons}}window.config.buttons.push({name:"{{ .Name }}",link:"{{ .Link }}"});{{end}}
77
// Initialize theme immediately to prevent flash
88
(function() {
99
const themeFromCookie = document.cookie.match(/theme=(dark|light);?/)?.[1];

web/app/src/views/Home.vue

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
<Button variant="ghost" size="icon" @click="refreshData" title="Refresh data">
2222
<RefreshCw class="h-5 w-5" />
2323
</Button>
24-
25-
<Button
26-
variant="ghost"
27-
size="icon"
28-
@click="toggleDefaultCollapse"
29-
:title="collapseByDefault ? 'Default: collapsed (click to expand by default)' : 'Default: expanded (click to collapse by default)'"
30-
>
31-
<ChevronUp v-if="collapseByDefault" class="h-5 w-5" />
32-
<ChevronDown v-else class="h-5 w-5" />
33-
</Button>
3424
</div>
3525
</div>
3626

@@ -235,16 +225,12 @@ function readBooleanFromLocalStorage(key, fallback) {
235225
const collapseByDefault = ref(
236226
readBooleanFromLocalStorage(
237227
'gatus:collapse',
238-
(typeof window !== 'undefined' && typeof window.config?.defaultCollapse !== 'undefined')
239-
? !!window.config.defaultCollapse
228+
(typeof window !== 'undefined' && typeof window.config?.defaultGroupCollapse !== 'undefined')
229+
? !!window.config.defaultGroupCollapse
240230
: true
241231
)
242232
)
243233
244-
function persistDefaultCollapse(val) {
245-
localStorage.setItem('gatus:collapse', String(val))
246-
}
247-
248234
const filteredEndpoints = computed(() => {
249235
let filtered = [...endpointStatuses.value]
250236
@@ -556,15 +542,6 @@ const initializeCollapsedGroups = () => {
556542
}
557543
}
558544
559-
const toggleDefaultCollapse = () => {
560-
const next = !collapseByDefault.value
561-
collapseByDefault.value = next
562-
persistDefaultCollapse(next)
563-
564-
localStorage.removeItem('gatus:uncollapsed-groups')
565-
initializeCollapsedGroups()
566-
}
567-
568545
watch(() => combinedGroups.value, () => {
569546
if (!localStorage.getItem('gatus:uncollapsed-groups')) {
570547
initializeCollapsedGroups()

web/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html><html lang="en" class="{{ .Theme }}"><head><meta charset="utf-8"/><script>window.config = {logo: "{{ .UI.Logo }}", header: "{{ .UI.Header }}", link: "{{ .UI.Link }}", buttons: [], maximumNumberOfResults: "{{ .UI.MaximumNumberOfResults }}", defaultSortBy: "{{ .UI.DefaultSortBy }}", defaultFilterBy: "{{ .UI.DefaultFilterBy }}", defaultCollapse: "{{ .UI.DefaultCollapse }}"};{{- range .UI.Buttons}}window.config.buttons.push({name:"{{ .Name }}",link:"{{ .Link }}"});{{end}}
1+
<!doctype html><html lang="en" class="{{ .Theme }}"><head><meta charset="utf-8"/><script>window.config = {logo: "{{ .UI.Logo }}", header: "{{ .UI.Header }}", link: "{{ .UI.Link }}", buttons: [], maximumNumberOfResults: "{{ .UI.MaximumNumberOfResults }}", defaultSortBy: "{{ .UI.DefaultSortBy }}", defaultFilterBy: "{{ .UI.DefaultFilterBy }}", defaultGroupCollapse: "{{ .UI.DefaultGroupCollapse }}"};{{- range .UI.Buttons}}window.config.buttons.push({name:"{{ .Name }}",link:"{{ .Link }}"});{{end}}
22
// Initialize theme immediately to prevent flash
33
(function() {
44
const themeFromCookie = document.cookie.match(/theme=(dark|light);?/)?.[1];

web/static/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)