UNPKG

iot-dashboard

Version:

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

267 lines (266 loc) 9.44 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for src/dashboard/import.ts</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/dashboard/</a> import.ts </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">48.48% </span> <span class="quiet">Statements</span> <span class='fraction'>16/33</span> </div> <div class='fl pad1y space-right2'> <span class="strong">25% </span> <span class="quiet">Branches</span> <span class='fraction'>1/4</span> </div> <div class='fl pad1y space-right2'> <span class="strong">14.29% </span> <span class="quiet">Functions</span> <span class='fraction'>1/7</span> </div> <div class='fl pad1y space-right2'> <span class="strong">48.48% </span> <span class="quiet">Lines</span> <span class='fraction'>16/33</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</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-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-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-yes"></span> <span class="cline-any cline-yes">41×</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-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">41×</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-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-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-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-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 Action = require("../actionNames"); var actionNames_1 = require("../actionNames"); var layouts_js_1 = require("../layouts/layouts.js"); var _ = require("lodash"); var dashboard_1 = require("../dashboard"); /** * To extend the import/export by another property you just need to add the property to the exported data * See: serialize() * * If there are any action needed after a property got imported, call them after the import. * See: afterImport() */ <span class="fstat-no" title="function not covered" >function serialize(state) {</span> <span class="cstat-no" title="statement not covered" > return JSON.stringify({</span> widgets: state.widgets, datasources: state.datasources, datasourcePlugins: state.datasourcePlugins, widgetPlugins: state.widgetPlugins }); } exports.serialize = serialize; <span class="fstat-no" title="function not covered" >function afterImport(dispatch, getState) {</span> <span class="cstat-no" title="statement not covered" > var oldDashboard = dashboard_1.default.getInstance();</span> <span class="cstat-no" title="statement not covered" > oldDashboard.dispose();</span> <span class="cstat-no" title="statement not covered" > var newDashboard = new dashboard_1.default(oldDashboard.store);</span> <span class="cstat-no" title="statement not covered" > newDashboard.init();</span> } function importReducer(state, action) { switch (action.type) { <span class="branch-0 cbranch-no" title="branch not covered" > case Action.DASHBOARD_IMPORT:</span> <span class="cstat-no" title="statement not covered" > var newState = _.assign({}, state, action.state);</span> <span class="cstat-no" title="statement not covered" > console.log("new State:", state, action.state, newState);</span> <span class="cstat-no" title="statement not covered" > return newState;</span> default: return state; } } exports.importReducer = importReducer; <span class="fstat-no" title="function not covered" >function deserialize(data) {</span> <span class="cstat-no" title="statement not covered" > if (typeof data === "string") {</span> <span class="cstat-no" title="statement not covered" > return JSON.parse(data);</span> } else { <span class="cstat-no" title="statement not covered" > throw new Error("Dashboard data for import must be of type string but is " + typeof data);</span> } } exports.deserialize = deserialize; <span class="fstat-no" title="function not covered" >function doImport(data) {</span> <span class="cstat-no" title="statement not covered" > var state = deserialize(data);</span> <span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >function (dispatch, getState) {</span></span> // Bad hack to force the grid layout to update correctly <span class="cstat-no" title="statement not covered" > dispatch(layouts_js_1.loadEmptyLayout());</span> <span class="cstat-no" title="statement not covered" > setTimeout(<span class="fstat-no" title="function not covered" >function () {</span></span> <span class="cstat-no" title="statement not covered" > dispatch({</span> type: actionNames_1.DASHBOARD_IMPORT, state: state }); <span class="cstat-no" title="statement not covered" > afterImport(dispatch, getState);</span> }, 0); }; } exports.doImport = doImport; &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>