iot-dashboard
Version:
A generic dashboard application based on JavaScript, HTML and CSS. http://iot-dashboard.org
351 lines (350 loc) • 12.6 kB
HTML
<html lang="en">
<head>
<title>Code coverage report for src/datasource/datasourcePluginFactory.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/datasource/</a> datasourcePluginFactory.ts
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">65.38% </span>
<span class="quiet">Statements</span>
<span class='fraction'>34/52</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">37.5% </span>
<span class="quiet">Branches</span>
<span class='fraction'>6/16</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">63.64% </span>
<span class="quiet">Functions</span>
<span class='fraction'>7/11</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">65.38% </span>
<span class="quiet">Lines</span>
<span class='fraction'>34/52</span>
</div>
</div>
</div>
<div class='status-line medium'></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"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">6×</span>
<span class="cline-any cline-yes">6×</span>
<span class="cline-any cline-yes">6×</span>
<span class="cline-any cline-yes">6×</span>
<span class="cline-any cline-yes">6×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">5×</span>
<span class="cline-any cline-yes">5×</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">5×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </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 _ = require("lodash");
var Datasource = require("./datasource");
var datasourcePluginInstance_1 = require("./datasourcePluginInstance");
/**
* Connects a datasource to the application state
*/
var DataSourcePluginFactory = (function () {
function DataSourcePluginFactory(_type, _datasource, _store) {
this._type = _type;
this._datasource = _datasource;
this._store = _store;
this._pluginInstances = {};
this._disposed = false;
//this._unsubscribe = _store.subscribe(() => this.handleStateChange());
}
Object.defineProperty(DataSourcePluginFactory.prototype, "type", {
get: function () {
return this._type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DataSourcePluginFactory.prototype, "disposed", {
get: function () {
return this._disposed;
},
enumerable: true,
configurable: true
});
DataSourcePluginFactory.prototype.getInstance = function (id) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (this._disposed === true) {
<span class="cstat-no" title="statement not covered" > throw new Error("Try to get datasource of destroyed type. " + JSON.stringify({ id: id, type: this.type }));</span>
}
<span class="missing-if-branch" title="else path not taken" >E</span>if (!this._pluginInstances[id]) {
return this.createInstance(id);
}
<span class="cstat-no" title="statement not covered" > return this._pluginInstances[id];</span>
};
DataSourcePluginFactory.prototype.dispose = function () {
this._disposed = true;
_.valuesIn(this._pluginInstances).forEach(<span class="fstat-no" title="function not covered" >function (plugin) {</span>
<span class="cstat-no" title="statement not covered" > if (_.isFunction(plugin.dispose)) {</span>
<span class="cstat-no" title="statement not covered" > try {</span>
<span class="cstat-no" title="statement not covered" > plugin.dispose();</span>
}
catch (e) {
<span class="cstat-no" title="statement not covered" > console.error("Failed to destroy Datasource instance", plugin);</span>
}
}
});
this._pluginInstances = {};
};
DataSourcePluginFactory.prototype.handleStateChange = <span class="fstat-no" title="function not covered" >function () {</span>
<span class="cstat-no" title="statement not covered" > var _this = this;</span>
<span class="cstat-no" title="statement not covered" > var state = this._store.getState();</span>
<span class="cstat-no" title="statement not covered" > if (this.oldDatasourcesState === state.datasources) {</span>
<span class="cstat-no" title="statement not covered" > return;</span>
}
<span class="cstat-no" title="statement not covered" > this.oldDatasourcesState = state.datasources;</span>
// Create Datasource instances for missing data sources in store
<span class="cstat-no" title="statement not covered" > _.valuesIn(state.datasources)</span>
.filter(<span class="fstat-no" title="function not covered" >function (dsState) {</span> <span class="cstat-no" title="statement not covered" >return dsState.type === _this.type; </span>})
.forEach(<span class="fstat-no" title="function not covered" >function (dsState) {</span>
<span class="cstat-no" title="statement not covered" > if (_this._pluginInstances[dsState.id] === undefined) {</span>
<span class="cstat-no" title="statement not covered" > _this._pluginInstances[dsState.id] = _this.createInstance(dsState.id);</span>
<span class="cstat-no" title="statement not covered" > _this._store.dispatch(Datasource.finishedLoading(dsState.id));</span>
}
});
};
DataSourcePluginFactory.prototype.createInstance = function (id) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (this._disposed === true) {
<span class="cstat-no" title="statement not covered" > throw new Error("Try to create datasource of destroyed type: " + JSON.stringify({ id: id, type: this.type }));</span>
}
<span class="missing-if-branch" title="if path not taken" >I</span>if (this._pluginInstances[id] !== undefined) {
<span class="cstat-no" title="statement not covered" > throw new Error("Can not create datasource instance. It already exists: " + JSON.stringify({</span>
id: id,
type: this.type
}));
}
var state = this._store.getState();
var dsState = state.datasources[id];
if (!dsState) {
throw new Error("Can not create instance of non existing datasource with id " + id);
}
return new datasourcePluginInstance_1.DatasourcePluginInstance(id, this._store);
};
return DataSourcePluginFactory;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = DataSourcePluginFactory;
</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>