Spaces:
Sleeping
Sleeping
Javier Montalvo commited on
Commit ·
9b858f8
1
Parent(s): 70158ca
Updated example
Browse files
frontend/dist/assets/{index-o2IMYFSK.js → index-BNhsKA1b.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/dist/index.html
CHANGED
|
@@ -16,7 +16,7 @@
|
|
| 16 |
href="https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap"
|
| 17 |
rel="stylesheet"
|
| 18 |
/>
|
| 19 |
-
<script type="module" crossorigin src="/assets/index-
|
| 20 |
<link rel="stylesheet" crossorigin href="/assets/index-DpGaJEG3.css">
|
| 21 |
</head>
|
| 22 |
<body>
|
|
|
|
| 16 |
href="https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap"
|
| 17 |
rel="stylesheet"
|
| 18 |
/>
|
| 19 |
+
<script type="module" crossorigin src="/assets/index-BNhsKA1b.js"></script>
|
| 20 |
<link rel="stylesheet" crossorigin href="/assets/index-DpGaJEG3.css">
|
| 21 |
</head>
|
| 22 |
<body>
|
frontend/src/lib/dashboard.tsx
CHANGED
|
@@ -19,20 +19,20 @@ import type {
|
|
| 19 |
ValidationResult,
|
| 20 |
} from "./types"
|
| 21 |
|
| 22 |
-
const DEFAULT_CLASSES = "person,
|
| 23 |
|
| 24 |
const DEFAULT_RULES = `rules:
|
| 25 |
-
- name: person-
|
| 26 |
when:
|
| 27 |
all:
|
| 28 |
- present: {label: person, min_count: 1}
|
| 29 |
-
|
|
|
|
| 30 |
gate:
|
| 31 |
enabled: true
|
| 32 |
-
cooldown: {key: turn-on-pc, minutes: 5}
|
| 33 |
then:
|
| 34 |
- type: simulate
|
| 35 |
-
name: turn on
|
| 36 |
`
|
| 37 |
|
| 38 |
const DEFAULT_PARAMS: DetectParams = {
|
|
@@ -140,9 +140,11 @@ export function DashboardProvider({ children }: { children: ReactNode }) {
|
|
| 140 |
api
|
| 141 |
.loadRules()
|
| 142 |
.then((r) => {
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
| 144 |
})
|
| 145 |
-
.catch(() => void 0)
|
| 146 |
}, [applyRulesText])
|
| 147 |
|
| 148 |
const setParam = useCallback(
|
|
|
|
| 19 |
ValidationResult,
|
| 20 |
} from "./types"
|
| 21 |
|
| 22 |
+
const DEFAULT_CLASSES = "person, cat, dog, car, chair, cup"
|
| 23 |
|
| 24 |
const DEFAULT_RULES = `rules:
|
| 25 |
+
- name: example-person-enters-lights
|
| 26 |
when:
|
| 27 |
all:
|
| 28 |
- present: {label: person, min_count: 1}
|
| 29 |
+
trigger:
|
| 30 |
+
on: enter
|
| 31 |
gate:
|
| 32 |
enabled: true
|
|
|
|
| 33 |
then:
|
| 34 |
- type: simulate
|
| 35 |
+
name: turn on lights
|
| 36 |
`
|
| 37 |
|
| 38 |
const DEFAULT_PARAMS: DetectParams = {
|
|
|
|
| 140 |
api
|
| 141 |
.loadRules()
|
| 142 |
.then((r) => {
|
| 143 |
+
void applyRulesText(r.rules_text || DEFAULT_RULES)
|
| 144 |
+
})
|
| 145 |
+
.catch(() => {
|
| 146 |
+
void applyRulesText(DEFAULT_RULES)
|
| 147 |
})
|
|
|
|
| 148 |
}, [applyRulesText])
|
| 149 |
|
| 150 |
const setParam = useCallback(
|
frontend/src/modules/detector/DetectorPanel.tsx
CHANGED
|
@@ -104,7 +104,7 @@ export function DetectorPanel() {
|
|
| 104 |
value={params.classes}
|
| 105 |
onChange={(e) => setParam("classes", e.target.value)}
|
| 106 |
className="min-h-16 font-mono text-xs leading-relaxed"
|
| 107 |
-
placeholder="person,
|
| 108 |
/>
|
| 109 |
</div>
|
| 110 |
|
|
|
|
| 104 |
value={params.classes}
|
| 105 |
onChange={(e) => setParam("classes", e.target.value)}
|
| 106 |
className="min-h-16 font-mono text-xs leading-relaxed"
|
| 107 |
+
placeholder="person, cat, dog, car, chair, cup…"
|
| 108 |
/>
|
| 109 |
</div>
|
| 110 |
|
frontend/src/modules/rules/RuleStudioPanel.tsx
CHANGED
|
@@ -32,7 +32,7 @@ export function RuleStudioPanel() {
|
|
| 32 |
compiling,
|
| 33 |
} = useDashboard()
|
| 34 |
const [instruction, setInstruction] = useState(
|
| 35 |
-
"
|
| 36 |
)
|
| 37 |
const [armedDelete, setArmedDelete] = useState<string | null>(null)
|
| 38 |
|
|
@@ -143,6 +143,7 @@ export function RuleStudioPanel() {
|
|
| 143 |
)}
|
| 144 |
/>
|
| 145 |
<span className="truncate font-mono text-sm text-foreground">{r.name}</span>
|
|
|
|
| 146 |
<Badge variant="default">{r.trigger}</Badge>
|
| 147 |
</div>
|
| 148 |
<div className="mt-1 pl-3.5 text-xs text-muted-foreground">
|
|
|
|
| 32 |
compiling,
|
| 33 |
} = useDashboard()
|
| 34 |
const [instruction, setInstruction] = useState(
|
| 35 |
+
"When a cat appears in the image, notify me.",
|
| 36 |
)
|
| 37 |
const [armedDelete, setArmedDelete] = useState<string | null>(null)
|
| 38 |
|
|
|
|
| 143 |
)}
|
| 144 |
/>
|
| 145 |
<span className="truncate font-mono text-sm text-foreground">{r.name}</span>
|
| 146 |
+
{r.name.startsWith("example-") && <Badge variant="default">example</Badge>}
|
| 147 |
<Badge variant="default">{r.trigger}</Badge>
|
| 148 |
</div>
|
| 149 |
<div className="mt-1 pl-3.5 text-xs text-muted-foreground">
|