mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-24 20:21:49 +00:00
Added dev notes
This commit is contained in:
1 parent
b43988ad20
commit
cab8ccddea
4 files changed
+78
-17
No files matched your search
@@ -23,6 +23,9 @@ dashboard.html.c: dashboard.html
|
|||||||
node $(MONGOOSE_DIR)/resources/pack.js dashboard.html::gzip > $@
|
node $(MONGOOSE_DIR)/resources/pack.js dashboard.html::gzip > $@
|
||||||
@echo "On-flash size: `grep -oE '[0-9]+' $@ | wc -l`"
|
@echo "On-flash size: `grep -oE '[0-9]+' $@ | wc -l`"
|
||||||
|
|
||||||
|
purge:
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/cesanta/mongoose@master/resources/dashboard.js
|
||||||
|
|
||||||
# For development: rebuild and restart if any of the sources change
|
# For development: rebuild and restart if any of the sources change
|
||||||
watch:
|
watch:
|
||||||
watchexec -r -w main.c -w mongoose_dashboard.c -w $(MONGOOSE_DIR)/mongoose.h -w web_root -e c,h,html,css,js,svg,png -- make
|
watchexec -r -w main.c -w mongoose_dashboard.c -w $(MONGOOSE_DIR)/mongoose.h -w web_root -e c,h,html,css,js,svg,png -- make
|
||||||
|
|||||||
@@ -32,13 +32,12 @@ static void sync_leds(bool is_write) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read-only device Metrics
|
// Read-only device Metrics
|
||||||
static int s_ram = 32, s_cpu = 7, s_humidity = 59;
|
static int s_ram = 32, s_cpu = 7;
|
||||||
static double s_temperature = 24.8;
|
static double s_temperature = 24.8;
|
||||||
|
|
||||||
static struct mg_field fields_metrics[] = {
|
static struct mg_field fields_metrics[] = {
|
||||||
{"ram", MG_VAL_INT, &s_ram, sizeof(s_ram)},
|
{"ram", MG_VAL_INT, &s_ram, sizeof(s_ram)},
|
||||||
{"cpu", MG_VAL_INT, &s_cpu, sizeof(s_cpu)},
|
{"cpu", MG_VAL_INT, &s_cpu, sizeof(s_cpu)},
|
||||||
{"humidity", MG_VAL_INT, &s_humidity, sizeof(s_humidity)},
|
|
||||||
{"temperature", MG_VAL_DBL, &s_temperature, sizeof(s_temperature)},
|
{"temperature", MG_VAL_DBL, &s_temperature, sizeof(s_temperature)},
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
chart1: {data: []},
|
chart1: {data: []},
|
||||||
leds: { led1: true, led2: false, led3: false },
|
leds: { led1: true, led2: false, led3: false },
|
||||||
settings: { volume: 12, log_level: 3, name: 'Galway' },
|
settings: { volume: 12, log_level: 3, name: 'Galway' },
|
||||||
metrics: { temperature: 1.2, humidity: 3, cpu: 4, ram: 5 },
|
metrics: { temperature: 1.2, cpu: 4, ram: 5 },
|
||||||
files: {data: [{name: 'device-log-2026-04-25.txt', size: 8625563}]},
|
files: {data: [{name: 'device-log-2026-04-25.txt', size: 8625563}]},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -101,16 +101,6 @@
|
|||||||
<span class="metric-status metric-status-good">ok</span>
|
<span class="metric-status metric-status-good">ok</span>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<article class="metric-tile">
|
|
||||||
<div class="metric-label">Humidity</div>
|
|
||||||
<div class="metric-value-row">
|
|
||||||
<div class="metric-value">
|
|
||||||
<span class="metric-number" data-bind="metrics.humidity">51</span>
|
|
||||||
<span class="metric-unit">%</span>
|
|
||||||
</div>
|
|
||||||
<span class="metric-status metric-status-good">ok</span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
<article class="metric-tile metric-tile-warning">
|
<article class="metric-tile metric-tile-warning">
|
||||||
<div class="metric-label">CPU Load</div>
|
<div class="metric-label">CPU Load</div>
|
||||||
<div class="metric-value-row">
|
<div class="metric-value-row">
|
||||||
@@ -142,6 +132,12 @@
|
|||||||
<span class="metric-status metric-status-good">ok</span>
|
<span class="metric-status metric-status-good">ok</span>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
<article class="metric-tile note">
|
||||||
|
<div>
|
||||||
|
To tailor this dashboard to your firmware, follow
|
||||||
|
<a target="_blank" href="https://mongoose.ws/docs/guides/web-dashboard-guide/#dashboard-example">this guide</a>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="detail-row">
|
<div class="detail-row">
|
||||||
@@ -161,7 +157,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Controls Panel -->
|
<!-- Controls Panel -->
|
||||||
<div class="panel controls-panel">
|
<div class="panel">
|
||||||
<div class="panel-title">LED Control</div>
|
<div class="panel-title">LED Control</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
@@ -176,12 +172,21 @@
|
|||||||
<div class="field-label">LED3</div>
|
<div class="field-label">LED3</div>
|
||||||
<input type="checkbox" data-bind="leds.led3" data-autosave="1" class="toggle" />
|
<input type="checkbox" data-bind="leds.led3" data-autosave="1" class="toggle" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="note">
|
||||||
|
To attach these LED controls to your hardware,
|
||||||
|
modify mongoose_dashboard.c :: sync_leds() function.
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
<section id="settings" class="tab-panel" role="tabpanel" aria-labelledby="tab-settings" hidden>
|
<section id="settings" class="tab-panel" role="tabpanel" aria-labelledby="tab-settings" hidden>
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
<div class="panel" style="width: 22rem;">
|
<div class="panel" style="width: 22rem;">
|
||||||
<div class="panel-title">Device settings</div>
|
<div class="panel-title">Device settings</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@@ -222,10 +227,30 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="note" style="width: 44rem;">
|
||||||
|
<p>This settings panel is backed by the "settings" dashboard object
|
||||||
|
see Dashboard.init call at the top of index.html - and, consequently,
|
||||||
|
by the "settings" fieldset in mongoose_dashboard.c. </p>
|
||||||
|
<p>Fields are bound to the dashboard object via the data-bind attribute,
|
||||||
|
e.g. data-bind="setttings.name"</p>
|
||||||
|
<p>When you save changed fields, the changes are saved to the device.</p>
|
||||||
|
<p> The "NAME" field
|
||||||
|
has data-autosave="1", so it is autosaved when user types text.</p>
|
||||||
|
<p>The other fields are not auto-saved, so when they are changed,
|
||||||
|
dashboard.js automatically applies CSS class "edited" to them to
|
||||||
|
indicate they were changed but not saved.</p>
|
||||||
|
<p>The cancel and save buttons are attached to the settings object
|
||||||
|
via the data-cancel and data-save attributes. Those buttons
|
||||||
|
get automatically enabled or disabled based on editing status.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section id="firmware" class="tab-panel" role="tabpanel" aria-labelledby="tab-firmware" hidden></section>
|
<section id="firmware" class="tab-panel" role="tabpanel" aria-labelledby="tab-firmware" hidden></section>
|
||||||
<section id="files" class="tab-panel" role="tabpanel" aria-labelledby="tab-files" hidden>
|
<section id="files" class="tab-panel" role="tabpanel" aria-labelledby="tab-files" hidden>
|
||||||
<div class="panel" style="max-width: 40rem;">
|
<div class="row">
|
||||||
|
<div class="panel" style="width: 40rem;">
|
||||||
<div class="panel-title">
|
<div class="panel-title">
|
||||||
<span>
|
<span>
|
||||||
<span>File Manager</span>
|
<span>File Manager</span>
|
||||||
@@ -278,6 +303,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="note" style="max-width: 40em;">
|
||||||
|
<p>The two default files are fake - you can delete them</p>
|
||||||
|
<p>However the manager works - you can upload new files. They
|
||||||
|
are uploaded to /tmp/ directory on the device.
|
||||||
|
This requires stdio (fopen/fread/...) implemeneted.</p>
|
||||||
|
<p>The easiest way to implement it is to use a filesystem like
|
||||||
|
LittleFS on your internal or external flash
|
||||||
|
and retarget the standard library to use it.</p>
|
||||||
|
<p>See <a href="https://github.com/cpq/bare-metal-programming-guide/tree/main/templates/lfs/nucleo-h563zi">this example</a> on how LittleFS can be implemented on
|
||||||
|
Nucleo-H563ZI internal flash partition.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ body {
|
|||||||
color: var(--color-text-strong);
|
color: var(--color-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a, a:visited, a:link { text-decoration: none; }
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
z-index: 50;
|
z-index: 50;
|
||||||
}
|
}
|
||||||
@@ -311,7 +313,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.field-input.edited, .select.edited, .slider.edited>* {
|
.field-input.edited, .select.edited, .slider.edited>* {
|
||||||
border-color: #00502040;
|
border-color: #00500040 !important;
|
||||||
background: #00ff0020;
|
background: #00ff0020;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +407,25 @@ body {
|
|||||||
transform: none;
|
transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Detail row (chart + controls) ─────────────────────────────── */
|
.note {
|
||||||
|
color: #075985;
|
||||||
|
background: #e0f2fe;
|
||||||
|
border: 1px solid #7dd3fc;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.75rem 0.9rem;
|
||||||
|
font-size: 0.86rem;
|
||||||
|
line-height: 1.55;
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.detail-row {
|
.detail-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
Reference in new issue
Block a user