Compare commits
No commits in common. "17e555e7fcd4de7e8742b739243dd7727fad59cd" and "fe48cf780e663de075de7e26ad8382157cb7e205" have entirely different histories.
17e555e7fc
...
fe48cf780e
2
main.go
2
main.go
@ -29,7 +29,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v36"
|
const VERSION = "v35"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#datapoints-filter.invalid-regex {
|
|
||||||
background-color: #ffd5d5;
|
|
||||||
}
|
|
||||||
#datapoints {
|
#datapoints {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(6, min-content);
|
grid-template-columns: repeat(6, min-content);
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#datapoints-filter.invalid-regex {
|
|
||||||
background-color: #ffd5d5;
|
|
||||||
}
|
|
||||||
#datapoints {
|
#datapoints {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(6, min-content);
|
grid-template-columns: repeat(6, min-content);
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
@import "theme-@{THEME}.less";
|
@import "theme-@{THEME}.less";
|
||||||
|
|
||||||
#datapoints-filter.invalid-regex {
|
|
||||||
background-color: #ffd5d5;
|
|
||||||
}
|
|
||||||
|
|
||||||
#datapoints {
|
#datapoints {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(6, min-content);
|
grid-template-columns: repeat(6, min-content);
|
||||||
|
@ -3,46 +3,6 @@
|
|||||||
{{ $theme := .CONFIG.THEME }}
|
{{ $theme := .CONFIG.THEME }}
|
||||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/{{ .CONFIG.THEME }}/datapoints.css">
|
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/{{ .CONFIG.THEME }}/datapoints.css">
|
||||||
<script type="text/javascript" defer>
|
<script type="text/javascript" defer>
|
||||||
|
|
||||||
function validateRegex(rxp) {
|
|
||||||
try {
|
|
||||||
''.match(rxp)
|
|
||||||
return true
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showDatapoints(id) {
|
|
||||||
if (!id)
|
|
||||||
document
|
|
||||||
.querySelectorAll(`[x-datapoint-id]`)
|
|
||||||
.forEach(matchedDP=>matchedDP.classList.remove('hidden'))
|
|
||||||
else
|
|
||||||
document
|
|
||||||
.querySelectorAll(`[x-datapoint-id="${id}"]`)
|
|
||||||
.forEach(matchedDP=>matchedDP.classList.remove('hidden'))
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideDatapoints(id) {
|
|
||||||
if (!id)
|
|
||||||
document.querySelectorAll(`[x-datapoint-id]`).forEach(matchedDP=>
|
|
||||||
matchedDP.classList.add('hidden')
|
|
||||||
)
|
|
||||||
else
|
|
||||||
document.querySelectorAll(`[x-datapoint-id="${id}"]`).forEach(matchedDP=>
|
|
||||||
matchedDP.classList.add('hidden')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateRegexValidatedStatus(validated) {
|
|
||||||
const inputFilter = document.getElementById('datapoints-filter')
|
|
||||||
if (validated)
|
|
||||||
inputFilter.classList.remove('invalid-regex')
|
|
||||||
else
|
|
||||||
inputFilter.classList.add('invalid-regex')
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterDatapoints(inputFilter) {
|
function filterDatapoints(inputFilter) {
|
||||||
const filter = inputFilter.value.toLowerCase()
|
const filter = inputFilter.value.toLowerCase()
|
||||||
const datapoints = document.querySelectorAll('#datapoints .name')
|
const datapoints = document.querySelectorAll('#datapoints .name')
|
||||||
@ -50,25 +10,25 @@
|
|||||||
|
|
||||||
// Shortcut to show everything if a filter is not given.
|
// Shortcut to show everything if a filter is not given.
|
||||||
if (filter == '') {
|
if (filter == '') {
|
||||||
showDatapoints()
|
document.querySelectorAll(`[x-datapoint-id]`).forEach(matchedDP=>
|
||||||
|
matchedDP.classList.remove('hidden')
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show nothing if the regex is invalid and can't matching anything.
|
|
||||||
if (!validateRegex(filter)) {
|
|
||||||
hideDatapoints()
|
|
||||||
updateRegexValidatedStatus(false)
|
|
||||||
return
|
|
||||||
} else
|
|
||||||
updateRegexValidatedStatus(true)
|
|
||||||
|
|
||||||
datapoints.forEach(dp=>{
|
datapoints.forEach(dp=>{
|
||||||
const dpName = dp.getAttribute('x-datapoint-name')
|
const dpName = dp.getAttribute('x-datapoint-name')
|
||||||
|
if (dpName.toLowerCase().includes(filter)) {
|
||||||
datapointID = dp.getAttribute('x-datapoint-id')
|
datapointID = dp.getAttribute('x-datapoint-id')
|
||||||
if (dpName.toLowerCase().match(filter))
|
document.querySelectorAll(`[x-datapoint-id="${datapointID}"]`).forEach(matchedDP=>
|
||||||
showDatapoints(datapointID)
|
matchedDP.classList.remove('hidden')
|
||||||
else
|
)
|
||||||
hideDatapoints(datapointID)
|
} else {
|
||||||
|
datapointID = dp.getAttribute('x-datapoint-id')
|
||||||
|
document.querySelectorAll(`[x-datapoint-id="${datapointID}"]`).forEach(matchedDP=>
|
||||||
|
matchedDP.classList.add('hidden')
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +49,7 @@
|
|||||||
<a href="/datapoint/edit/0">Create</a>
|
<a href="/datapoint/edit/0">Create</a>
|
||||||
|
|
||||||
<div style="margin-top: 16px">
|
<div style="margin-top: 16px">
|
||||||
<input id="datapoints-filter" type="text" placeholder="Filter (regexp)" style="width: 320px;" oninput="filterDatapoints(this)">
|
<input id="datapoints-filter" type="text" placeholder="Filter" style="width: 320px;" oninput="filterDatapoints(this)">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="datapoints">
|
<div id="datapoints">
|
||||||
|
Loading…
Reference in New Issue
Block a user