# Device dashboard This is the AI specification file for the Mongoose based Web device dashboard functionality Mongoose-base device dashboard requires following files: - mongoose.h - mongoose.c - dashboard.c - file_data.c The `file_data.c` is a generated file from `dashboard.html` using Nodejs: ```sh node html2c.js dashboard.html -o file_data.c ``` The `html2c.js` file can be taken from https://github.com/cesanta/mongoose/blob/master/resources/html2c.js ## General rules Your goal is to produce a dashboard.c and dashboard.html files If your project does not yet have those, fetch from here: https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/minimal/dashboard.c https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/minimal/dashboard.html If your project already has dashboard.c and dashboard.html, do NOT fetch anything. The C API header file is at https://github.com/cesanta/mongoose/blob/master/src/dash.h The minimal reference project is at https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/minimal/ The full reference project is at https://github.com/cesanta/mongoose/blob/master/tutorials/device-dashboard/full/ ## dashboard.html The `dashboard.html` file has to use `dashboard.js`, for example: ```html ``` The `Dashboard.init()` call should be the only direct `Dashboard` API usage. Do not generate anything that uses other `Dashboard` API - treat it as a black box. The `Dashboard.init()` call has an argument that is a settings object which should be edited. The `data` attrubute specifies device state representation, and it is used in the expression evaluation and `data-*` attributes described below. For editing dashboard.html, use only Mongoose `data-bind` and `${...}` template syntax No vanilla JS event listeners, no fetch calls, no custom reactive logic. Do not make any changes to dashboard.html unless asked by a user. - checkboxes, inputs, selects: add `data-bind="FIELDSET.FIELD"` to to bind them to a specific field. Optionally, specify `data-autosave="1"` to send a change immediately after modification, without pressing a "save" button - any other element: add `data-bind="FIELDSET.FIELD"` to replace its contents with the curent value of the field. You can achieve the same with the `${...}` expression - buttons: add `data-save="FIELDSET"` to create a "save" button for a given field set. If any value in the field set is edited by the bound control, a button would activate, otherwise it'll stay disabled - buttons: add `data-cancel="FIELDSET"` to create a "cancel" button, similar to "save" - `${...}` expressions: add those anywhere Here is the example of binding a toggle button to a device variable: ```html ``` Here is the example of using `${...}` expressions: ```html