UNPKG

iot-dashboard

Version:

A generic dashboard application based on JavaScript, HTML and CSS. http://iot-dashboard.org

351 lines (350 loc) 12.5 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for src/widgets/widgetConfig.js</title> <meta charset="utf-8" /> <link rel="stylesheet" href="../../prettify.css" /> <link rel="stylesheet" href="../../base.css" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style type='text/css'> .coverage-summary .sorter { background-image: url(../../sort-arrow-sprite.png); } </style> </head> <body> <div class='wrapper'> <div class='pad1'> <h1> <a href="../../index.html">all files</a> / <a href="index.html">src/widgets/</a> widgetConfig.js </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">43.18% </span> <span class="quiet">Statements</span> <span class='fraction'>19/44</span> </div> <div class='fl pad1y space-right2'> <span class="strong">20% </span> <span class="quiet">Branches</span> <span class='fraction'>3/15</span> </div> <div class='fl pad1y space-right2'> <span class="strong">11.11% </span> <span class="quiet">Functions</span> <span class='fraction'>1/9</span> </div> <div class='fl pad1y space-right2'> <span class="strong">41.86% </span> <span class="quiet">Lines</span> <span class='fraction'>18/43</span> </div> </div> </div> <div class='status-line low'></div> <pre><table class="coverage"> <tr><td class="line-count quiet">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes">43×</span> <span class="cline-any cline-yes">43×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">43×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; var Widgets = require("./widgets"); var actionNames_1 = require("../actionNames"); var Modal = require("../modal/modalDialog"); var ModalIds = require("../modal/modalDialogIds.ts"); var initialState = { type: null, name: null, settings: {} }; /** * Triggered when the user intends to create a widget of a certain type */ <span class="fstat-no" title="function not covered" >function createWidget(type) {</span> <span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >function (dispatch, getState) {</span></span> <span class="cstat-no" title="statement not covered" > var state = getState();</span> <span class="cstat-no" title="statement not covered" > var widgetPlugin = state.widgetPlugins[type];</span> <span class="cstat-no" title="statement not covered" > if (!widgetPlugin.typeInfo.settings &amp;&amp; widgetPlugin.typeInfo.settings.length &gt; 0) {</span> <span class="cstat-no" title="statement not covered" > dispatch(Widgets.createWidget(type));</span> <span class="cstat-no" title="statement not covered" > return;</span> } <span class="cstat-no" title="statement not covered" > dispatch(openWidgetCreateDialog(type));</span> }; } exports.createWidget = createWidget; /** * Creates or updates an actual widget */ <span class="fstat-no" title="function not covered" >function createOrUpdateWidget(id, type, settings) {</span> <span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >function (dispatch, getState) {</span></span> <span class="cstat-no" title="statement not covered" > var state = getState();</span> <span class="cstat-no" title="statement not covered" > var widget = state.widgets[id];</span> <span class="cstat-no" title="statement not covered" > if (widget &amp;&amp; widget.type !== type) {</span> <span class="cstat-no" title="statement not covered" > throw new Error("Can not update widget of type " + widget.type + " with props of type " + type);</span> } <span class="cstat-no" title="statement not covered" > if (widget) {</span> <span class="cstat-no" title="statement not covered" > dispatch(Widgets.updateWidgetSettings(id, settings));</span> } else { <span class="cstat-no" title="statement not covered" > dispatch(Widgets.createWidget(type, settings));</span> } }; } exports.createOrUpdateWidget = createOrUpdateWidget; <span class="fstat-no" title="function not covered" >function openWidgetCreateDialog(type) {</span> <span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >function (dispatch) {</span></span> <span class="cstat-no" title="statement not covered" > dispatch({</span> type: actionNames_1.START_CREATE_WIDGET, widgetType: type }); <span class="cstat-no" title="statement not covered" > dispatch(Modal.showModal(ModalIds.WIDGET_CONFIG));</span> }; } exports.openWidgetCreateDialog = openWidgetCreateDialog; /** * Open the dialog with the settings and values of the given widget */ <span class="fstat-no" title="function not covered" >function openWidgetConfigDialog(id) {</span> <span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >function (dispatch, getState) {</span></span> <span class="cstat-no" title="statement not covered" > var state = getState();</span> <span class="cstat-no" title="statement not covered" > var widget = state.widgets[id];</span> <span class="cstat-no" title="statement not covered" > dispatch({</span> type: actionNames_1.START_CONFIGURE_WIDGET, widget: widget }); <span class="cstat-no" title="statement not covered" > dispatch(Modal.showModal(ModalIds.WIDGET_CONFIG));</span> }; } exports.openWidgetConfigDialog = openWidgetConfigDialog; function widgetConfigDialog(state, action) { if (state === void 0) { state = initialState; } switch (action.type) { <span class="branch-0 cbranch-no" title="branch not covered" > case actionNames_1.START_CREATE_WIDGET:</span> <span class="cstat-no" title="statement not covered" > return Object.assign({}, state, {</span> type: action.widgetType, id: null, name: action.widgetType, settings: {} }); <span class="branch-1 cbranch-no" title="branch not covered" > case actionNames_1.START_CONFIGURE_WIDGET:</span> <span class="cstat-no" title="statement not covered" > return Object.assign({}, state, {</span> type: action.widget.type, id: action.widget.id, name: action.widget.name, settings: action.widget.settings }); default: return state; } } exports.widgetConfigDialog = widgetConfigDialog; &nbsp; &nbsp;</pre></td></tr> </table></pre> <div class='push'></div><!-- for sticky footer --> </div><!-- /wrapper --> <div class='footer quiet pad2 space-top1 center small'> Code coverage generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Nov 04 2016 11:23:08 GMT+0000 (UTC) </div> </div> <script src="../../prettify.js"></script> <script> window.onload = function () { if (typeof prettyPrint === 'function') { prettyPrint(); } }; </script> <script src="../../sorter.js"></script> </body> </html>