@larva.io/webcomponents
Version:
Fentrica SmartUnits WebComponents package
146 lines (140 loc) • 7.25 kB
JavaScript
/*!
* (C) Fentrica http://fentrica.com - Seee LICENSE.md
*/
import { r as registerInstance, c as createEvent, h } from './index-C4h1muVj.js';
import { R as ReportCodesHelpers, d as distExports } from './report-codes-helper-BN3DZ42s.js';
import { h as hooks } from './moment-DAuPur-P.js';
import { h as has } from './has-Bk4NAWiJ.js';
import { a as arrayFilter } from './_getAllKeys-C08dM1uK.js';
import { b as baseEach, a as baseIteratee } from './_baseMap-kP2T3hT_.js';
import { i as isArray } from './isArray-C_HhfJYh.js';
import { f as forOwn, s as sortBy } from './sortBy-CwYoYzqo.js';
import { b as config } from './config-Bt4QT_oL.js';
import './_hasPath-BgJxJEDp.js';
import './isObjectLike-CIR68wtF.js';
import './global-C56buD75.js';
import './_isIndex-DgTx77bC.js';
import './isLength-BBM_tGdM.js';
import './isObject-C7eoH3L1.js';
import './_getTag-CFse-dEC.js';
import './_setToString-CpaW37bP.js';
import './_defineProperty-CWEcucM9.js';
/**
* The base implementation of `_.filter` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
*/
function baseFilter(collection, predicate) {
var result = [];
baseEach(collection, function(value, index, collection) {
if (predicate(value, index, collection)) {
result.push(value);
}
});
return result;
}
/**
* Iterates over elements of `collection`, returning an array of all elements
* `predicate` returns truthy for. The predicate is invoked with three
* arguments: (value, index|key, collection).
*
* **Note:** Unlike `_.remove`, this method returns a new array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.reject
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false }
* ];
*
* _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // The `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.filter(users, ['active', false]);
* // => objects for ['fred']
*
* // The `_.property` iteratee shorthand.
* _.filter(users, 'active');
* // => objects for ['barney']
*
* // Combining several predicates using `_.overEvery` or `_.overSome`.
* _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
* // => objects for ['fred', 'barney']
*/
function filter(collection, predicate) {
var func = isArray(collection) ? arrayFilter : baseFilter;
return func(collection, baseIteratee(predicate));
}
const areaTroublesCss = "slot-fb[hidden],slot[hidden]{display:initial !important}lar-list-item{background-color:var(--lar-background-color-step-100, rgb(25.5, 25.5, 25.5)) !important;color:var(--lar-text-color, #fff) !important}.circle{background-color:var(--lar-background-color-step-200, #333333) !important;border-radius:50%;display:inline-block;padding:0.5rem;width:2rem;height:2rem;margin-right:1rem}.circle lar-icon{display:block;width:100%;height:100%}h4{margin:0;padding:0}h4 lar-badge{margin-top:0.2rem;margin-right:0.3rem;font-weight:normal}lar-button{--lar-button-font-size-small:.95rem;--lar-button-padding-top-small:.4rem;--lar-button-padding-bottom-small:.4rem;--lar-button-padding-left-small:.4rem;--lar-button-padding-right-small:.4rem}";
const AreaTroubleList = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.output = createEvent(this, "output");
this.config = config;
}
acktrouble(trouble) {
this.output.emit({ command: 'ack_trouble', trouble_id: trouble.id });
}
render() {
const troubleList = JSON.parse(this.troubles);
if (troubleList.length === 0) {
this.modal.dismiss();
return;
}
const troubles = [];
const formatDateTime = this.config.get('formatDateTime', 'DD.MM.YYYY HH:mm');
const zoneTroubles = filter(troubleList, t => has(t, 'zone') && t.type_id !== 0 && t.type_id !== 3);
const alarms = filter(troubleList, t => t.type_id === 0 || t.type_id === 3);
const systemTroubles = filter(troubleList, t => !has(t, 'zone'));
const groupedTroubles = {
'area.alarmsTroubles': alarms,
'area.systemTroubles': systemTroubles,
'area.zoneTroubles': zoneTroubles,
};
forOwn(groupedTroubles, (groupTroubles, group) => {
if (groupTroubles.length > 0) {
troubles.push(h("lar-list-header", null, h("lar-translate", { t: group })));
}
groupTroubles = sortBy(groupTroubles, 'created');
groupTroubles.forEach(trouble => {
let text = h("lar-translate", { t: 'area.trouble_code_messages.' + trouble.type_id, fallback: trouble.text });
// tslint:disable-next-line: strict-boolean-conditions
if ((trouble.type_id === 0 || trouble.type_id === 3) && trouble.zone && trouble.zone.reportcode && ReportCodesHelpers.isSecurityEvent(trouble.zone.reportcode)) {
const message = distExports.getEventMessage(trouble.zone.reportcode);
text = h("lar-translate", { t: 'log_entries.' + trouble.zone.reportcode, fallback: message });
}
troubles.push(h("lar-list-item", null, h("div", { slot: "start", class: "circle" }, trouble.zone
&&
h("lar-icon", { icon: trouble.zone.type, color: group === 'area.alarmsTroubles' ? 'danger' : 'warning' }), !trouble.zone
&&
h("lar-icon", { icon: "device", color: "warning" })), h("div", null, h("h4", null, trouble.zone
&&
h("span", null, h("lar-translate", { t: trouble.zone.name }), " - "), text), h("small", null, hooks(trouble.created).format(formatDateTime)), trouble.resolved !== null && trouble.resolved !== undefined
&&
h("small", null, h("br", null), hooks(trouble.resolved).format(formatDateTime), "\u00A0", h("lar-badge", { color: "success" }, h("lar-translate", { t: 'log.resolved' }))), trouble.overridden &&
h("span", null, "\u00A0", h("lar-badge", { color: "danger" }, h("lar-translate", { t: 'area.zone_state.bypassed' })))), h("div", { slot: "end" }, trouble.resolved !== null && trouble.resolved !== undefined &&
h("lar-button", { size: "small", onClick: () => { this.acktrouble(trouble); }, outline: true, color: this.colorInputs }, h("lar-translate", { t: "area.clear" })))));
});
});
return h("lar-list", { class: "trouble-list" }, troubles);
}
};
AreaTroubleList.style = areaTroublesCss;
export { AreaTroubleList as lar_area_troubles };
//# sourceMappingURL=lar-area-troubles.entry.js.map