{{what}}
{{^data}}No sensors found{{/data}}-
{{#data}}
- {{0}} -- {{1}} {{unit}} {{/data}}
var state = {}; var localstate = { manual: {}, recipe: 0, page: ['General', 'Dashboard'], maxpoints: 1000 }; var menu_items = [ {name: "General", subitems:[ {name: "Dashboard"}, {name: "Sensors & Plots"} ] }, {name: "Recipes", subitems:[ {name: "Recipes Editor", link: 'recipe-editor'}, {name: "New Recipe"} ] }, {name: "Configuration", subitems:[ {name: "Settings"} ] } ]; function applyState(newstate) { if (newstate !== undefined) { state = JSON.parse(JSON.stringify(newstate)); } // preprocess state.manual["dismissed"] = localstate.manual["dismissed"]; let selected_recipe = null; for (let i = 0; i < state.recipes.length; i++) { state.recipes[i].idx = i; if (localstate.recipe == i) selected_recipe = state.recipes[i]; state.recipes[i].selected = localstate.recipe == i; } state.selected_recipe = JSON.parse(JSON.stringify(selected_recipe)); for (let i = 0; i < menu_items.length; i++) { let group_match = menu_items[i].name == localstate.page[0]; for (let sub = 0; sub < menu_items[i].subitems.length; sub++) { let sub_match = menu_items[i].subitems[sub].name == localstate.page[1]; menu_items[i].subitems[sub].current = group_match && sub_match; menu_items[i].subitems[sub].path = JSON.stringify([ menu_items[i].name, menu_items[i].subitems[sub].name]); } } state.menu_items = menu_items; console.log('Apply state '+JSON.stringify(state)); // apply render_sidebar(state); manual_modal(state.manual); current_recipe(state.recipe); render_load_recipe(state); render_plot(); } var enable_draw = true; var plot_data = {}; function add_plot_data(newpoints, render=true) { for (var i = 0; i < newpoints.length; ++i) { let point = newpoints[i] let key = point[0]; if (!(key in plot_data)) { plot_data[key] = { x: [], y: [], type: 'scatter', name: key } } plot_data[key].x.push(point[1]); plot_data[key].y.push(point[2]); if (plot_data[key].x.length > localstate.maxpoints) { plot_data[key].x.shift(); plot_data[key].y.shift(); } } if (render) render_plot(); } function render_plot() { if (enable_draw && document.getElementById("data-plot") !== null) { Plotly.newPlot('data-plot', Object.values(plot_data)); } } function render_sensors(sensordata) { let html = document.getElementById("sensor-list"); if (state.sensors === undefined || html === null) return; let template = `
Load Recipe
Active Recipe: {{name}}
Manual Intervention Required