@c8y/ng1-modules 1017.66.0 → 1017.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/core/services/measurements.js +1 -1
- package/core/ui/controllers/eventList.js +1 -1
- package/core/ui/directives/eventList.js +1 -1
- package/core/ui/views/eventList.html +1 -1
- package/eventList/eventList.controller.js +1 -1
- package/eventList/index.js +1 -1
- package/eventList/views/eventList.html +7 -1
- package/eventList/views/eventListConfig.html +38 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(){function e(u,l,p,c,
|
|
1
|
+
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(){function e(u,l,p,c,g,e,i,t){var v=window.c8y_testing?1:500,m=2083,a=g.clean,d="measurement/measurements",o={headers:g.contentHeaders("measurement")},f=t.getUnitHeaders(),n={status:"DEPLOYED",name:"c8yui_measurements",body:'insert into SendNotification\n select\n measurement as payload,\n "c8yui/measurements" as channelName\n from MeasurementCreated;'},h=1440,s=_.once(function(){var e=g.url(d),t={params:{pageSize:1,dateFrom:moment(0).toISOString(),dateTo:moment().toISOString(),revert:!0},headers:{Accept:b.stream.value},silentError:!0};if(window.c8y_testing)return l.when();return u.get(e,t).catch(function(e){b.stream.notAcceptable=406===e.status})});function y(e){var t=e.id||e;return"".concat(g.url(d),"/").concat(t)}var b=g.createEnum([{name:"stream",value:"application/json-stream"},{name:"csv",value:"text/csv"},{name:"xlsx",value:"application/vnd.ms-excel"}]);function F(e,t){var n,r=g.url(d),a=_.assign({},g.todayFilter({}),{pageSize:h},e),o={params:a};return n=t?(o.responseType="blob",function(e){return e.data}):g.cleanListCallback("measurements",F,a),function(e){return s().then(function(){return e&&_(b).reject("notAcceptable").map("value").includes(e.value)?e.value:"application/json"})}(t||b.stream).then(function(t){return f.then(function(e){return o.headers=_.assign({},e,{Accept:t}),u.get(r,o).then(function(e){return 202===e.status?l.reject({async:!0,data:e.data}):e})})}).then(n)}function S(e){var t=h,n=g.url("".concat(d,"/series")),r=g.todayFilter(_.assign({pageSize:t,revert:!0},e||{}));r.dateFrom&&(r.dateFrom=moment(r.dateFrom).format(g.dateFullFormat)),r.dateTo&&(r.dateTo=moment(r.dateTo).format(g.dateFullFormat));var a={params:r},o=function(e){return e.data},i=_.findIndex(S._cacheFilter,_.partial(_.isEqual,r)),s=0<=i?S._cacheRequest[i]:null;return r.dateFrom&&(r.dateFrom=moment(r.dateFrom).format(g.dateFullFormat)),r.dateTo&&(r.dateTo=moment(r.dateTo).format(g.dateFullFormat)),function(e,t){return"".concat(g.absoluteUrl(e),"?").concat(c(t)).length>m}(n,r)&&_.unset(r,"series"),f.then(function(e){if(_.assign(a,{headers:e}),!s){s=u.get(n,a).then(o);var t=_.cloneDeep(r);S._cacheFilter.push(_.cloneDeep(t)),S._cacheRequest.push(s),moment(r.dateTo).isAfter(moment())&&setTimeout(function(){!function(e,t){_.remove(S._cacheFilter,e),_.remove(S._cacheRequest,t)}(t,s)},3e3)}return s})}function r(e){var t=g.url(d),n=e,r=_.cloneDeep(o);if(!n.source)throw new Error("c8yMeasurement: source must be defined");return u.post(t,n,r)}function w(e){var t=y(e),n=a(e),r=_.cloneDeep(o);return u.put(t,n,r)}S._cacheFilter=[],S._cacheRequest=[];var T=[];return{format:b,list:F,listPaged:function(e){var r=l.defer(),a=_.assign(e||{},{pageSize:1e3,withTotalPages:!0}),o=!1;return _.assign(r.promise,{cancel:function(){o=!0,r.reject("canceled")}}),F(a).then(function e(t){var n=!_.isUndefined(t.paging.next)&&t.length>=a.pageSize;return r.notify(t),n||r.resolve(!0),!!o||!n||t.paging.next().then(e)}),r.promise},listSeries:S,listSeriesPaged:function(e){var n=l.defer(),t=_.assign({revert:!0},e||{},{pageSize:1e3,withTotalPages:!0}),r=!1;return _.assign(n.promise,{cancel:function(){r=!0,n.reject("canceled")}}),S(t).then(function e(t){return n.notify(t),t.paging.next||n.resolve(!0),!!r||!t.paging.next||t.paging.next().then(e)}),n.promise},detail:function(e){var t=y(e);return u.get(t)},create:r,update:w,save:function(e){return e.id?w(e):r(e)},remove:function(e){var t=y(e);return u.delete(t)},activateCep:function(){return e.createOrDeploy(n)},latest:function(){var r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=1<arguments.length?arguments[1]:void 0,a={};if(!r.device)throw new Error("filter.device must be defined");if(!r.fragment)throw new Error("filter.fragment must be defined");if(!r.series)throw new Error("filter.series must be defined");var t=F(_.assign(g.timeOrderFilter(),{revert:!0,valueFragmentType:r.fragment,valueFragmentSeries:r.series,source:r.device,pageSize:1,dateTo:void 0})).then(function(e){return _.assign(a,_.first(e)||{}),a});if(e){var n={ops:"CREATE",channel:"/measurements/".concat(r.device),onUpdate:function(e,t){var n=t[r.fragment];n&&n[r.series]&&_.assign(a,t)}},o=i.watch(n);t.stop=_.bind(o.stop,o)}return t},listForDataPoint:function(e,t,n,r,a){var o=T;"object"===_typeof(a)&&(o=a._cachedRequests||[],a._cachedRequests=o);var i=t,s=n,u=e.__target.id,c=("NONE"!==r?r:0)||void 0;if(i){switch(i=moment(i),r){case"HOURLY":i.subtract(1,"hour").startOf("hour");break;case"DAILY":i.subtract(1,"day").startOf("day");break;default:i.subtract(1,"minute").startOf("minute")}i=i.format(g.dateFullFormat)}if(s){switch(s=moment(s),r){case"HOURLY":s.add(1,"hour").startOf("hour");break;case"DAILY":s.add(1,"days").startOf("day");break;default:s.add(1,"minute").startOf("minute")}s=s.format(g.dateFullFormat)}var m={dateFrom:i,dateTo:s,source:u,aggregationType:c},d=_.find(o,function(e){return _.isMatch(e.filters,m)});d||(d={deferred:l.defer(),sendDebounced:function(){return d._sendDebounced(),d.deferred.promise},_sendDebounced:_.debounce(function(){S(d.filters).then(_.unary(d.deferred.resolve))},v),filters:m},o.push(d));var f=[e.fragment,e.series].join(".");return d.filters.series=_.uniq((d.filters.series||[]).concat([f])),p(function(){return d.sendDebounced().then(function(t){return function(e){var n=_.findIndex(e.series,function(e){return e.name===t.series&&e.type===t.fragment}),r=[];return-1<n&&_.forEach(e.values,function(e,t){_.isObjectLike(e[n])&&r.push({time:t,min:e[n].min&&Number(e[n].min),max:e[n].max&&Number(e[n].max)})}),{dataPoint:t,values:r,truncated:e.truncated}}}(e)).then(function(e){return e.aggregation=r,e.dateFrom=i,e.dateTo=s,e}).finally(function(){_.remove(o,d)})},5)},rtMeasurementForDatapoint:function(o){return function(e){var t=o.__target.id,n=o.fragment,r=o.series,a=_.get(e,[n,r]);return e.source.id===t&&!!a&&{dataPoint:o,values:[{time:e.time,min:a.value,max:a.value}]}}}}}e.$inject=["$http","$q","$timeout","$httpParamSerializer","c8yBase","c8yCepModule","c8yRealtime","c8yMeasurementUnits"],angular.module("c8y.core").factory("c8yMeasurements",e)}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(){function e(a,i,n,r,t,o,d,s){var l=this;l.datePickerOptionsFrom={},l.datePickerOptionsTo={},a.refreshLoading=!1;var c=[],f=!0;function u(e,t){(!a.events||a.refreshLoading||t)&&(a.events=[],a.refreshLoading=!1),a.ordering="".concat(f?"-":"","dateTime"),a.events=_.uniqBy(a.events.concat(e),"id"),_.forEach(a.events,function(e){e.dateTime=new Date(e.time)}),a.paging=e.paging,T(a.events.length),a.onEventLoaded({qty:a.events.length})}function e(){!function(){var e=a.realtimeChannel;b(),t.getStatus(a.$id,e)&&e!==a.realtimeChannel&&(w(),function(e){t.stop(a.$id,e)}(e),E())}(),a.refreshLoading=!0,m(),T()}function m(e){var t=function(e){var i=e||{};
|
|
1
|
+
"use strict";!function(){function e(a,i,n,r,t,o,d,s){var l=this;l.datePickerOptionsFrom={},l.datePickerOptionsTo={},a.refreshLoading=!1;var c=[],f=!0;function u(e,t){(!a.events||a.refreshLoading||t)&&(a.events=[],a.refreshLoading=!1),a.ordering="".concat(f?"-":"","dateTime"),a.events=_.uniqBy(a.events.concat(e),"id"),_.forEach(a.events,function(e){e.dateTime=new Date(e.time)}),a.paging=e.paging,T(a.events.length),a.onEventLoaded({qty:a.events.length})}function e(){!function(){var e=a.realtimeChannel;b(),t.getStatus(a.$id,e)&&e!==a.realtimeChannel&&(w(),function(e){t.stop(a.$id,e)}(e),E())}(),a.refreshLoading=!0,m(),T()}function m(e){var t=function(e){var i=e||{};_.assign(i,a.filters),_.forOwn(i,function(e,t){e||delete i[t]}),(i.source||i.deviceId)&&(i.source=i.source||i.deviceId,delete i.deviceId,i.withSourceDevices=!0,i.withSourceAssets=!0),_.isUndefined(i.pageSize)&&(i.pageSize=10);var t=a.timeRangeUnit||"day";return i.dateFrom&&(i.dateFrom=moment(i.dateFrom).startOf(t).format(r.dateFullFormat)),i.dateTo&&(i.dateTo=moment(i.dateTo).endOf(t).format(r.dateFullFormat)),i}(e);return n.list(t).then(u)}function g(){a.refreshLoading=!0,f?(f=!1,y().finally(function(){a.refreshLoading=!1})):a.paging.refresh().then(_.partialRight(u,!0))}function v(e){return c.indexOf(e)}function h(e){return-1<v(e)}function y(){f=!f,a.recentFirstActive=f;var e=a.paging.statistics.totalPages,t=f?void 0:{currentPage:e};return a.refreshLoading=!0,m(t)}function p(e,t,i){var n={};e&&(n.dateFrom=moment(e).format(r.dateFullFormat)),t&&(n.dateTo=moment(t).format(r.dateFullFormat)),i?n.type=i:(delete n.type,delete a.filters.type),_.merge(a.filters,n)}function F(e){a.dateTo=void 0,a.dateFrom=void 0,l.dateTo=a.dateTo,l.dateFrom=a.dateFrom,a.filters.dateTo=void 0,a.filters.dateFrom=void 0,l.eventType=void 0,p(a.dateFrom,a.dateTo,e)}function T(e){a.filters.source||(a.title=d("Events"),a.subtitle=e?s.getString("{{qty}} loaded",{qty:e}):""),a.showPageTitles&&(a.filters.deviceId||o.changeTitle({title:d("Events"),subtitle:e?s.getString("{{qty}} loaded",{qty:e}):""}))}function $(e,t){if(!_.some(a.events,{id:t.id})){t.dateTime=new Date(t.time);var i=t.dateTime;a.filters.dateFrom&&i<moment(a.filters.dateFrom).startOf("day")||a.filters.dateTo&&i>moment(a.filters.dateTo).endOf("day")||a.filters.type&&a.filters.type!==t.type||a.events.push(t)}}function L(e,t){_.remove(a.events,{id:t.id})}function S(e,t){var i=_.findIndex(a.events,{id:t.id});a.events[i]=t}function C(){a.refreshLoading=!0,m(),T()}function E(){t.start(a.$id,a.realtimeChannel)}function w(){t.addListener(a.$id,a.realtimeChannel,"".concat(a.$id,"-subscribed"),C),t.addListener(a.$id,a.realtimeChannel,"CREATE",$),t.addListener(a.$id,a.realtimeChannel,"UPDATE",S),t.addListener(a.$id,a.realtimeChannel,"DELETE",L)}function b(){var e=a.filters.deviceId||a.filters.source;a.realtimeChannel="/eventsWithChildren/".concat(e||"*")}function O(){return r.checkIfModulesExist(["c8y.eventsBinary"])}a.$watch(function(){return l.dateFrom},function(e){l.datePickerOptionsTo={minDate:e}}),a.$watch(function(){return l.dateTo},function(e){l.datePickerOptionsFrom={maxDate:e}}),l.subscriberId=a.$id,l.filters=a.filters,l.filter=p,l.clearFilter=F,a.isEventsBinaryModuleAvailable=O,a.displayEventsBinary=function(e){return O()&&e.c8y_IsBinary},a.refresh=g,a.loadNext=function(e){if(a.paging.loading=!0,e)a.refreshLoading=!0,m({pageSize:e}).finally(function(){a.refreshLoading=!1});else{var t=f?"next":"prev";a.paging[t]().then(u).finally(function(){a.paging.loading=!1})}},a.isOpen=h,a.toggle=function(e){h(e)?c.splice(v(e),1):c.push(e)},a.filters=a.filters||{},a.getStandardKeys=n.getStandardKeys,a.getNonStandardKeys=function(e){return _.without(n.getNonStandardKeys(e),"dateTime")},a.recentFirst=y,a.filter=p,a.clearFilter=F;var R,I={};a.absolute=function(e){var t=I[e.id];return t||(t=i("absoluteDate")(e.time),I[e.id]=t),t},a.$watch("realtime",function(){a.realtime!==t.getStatus(a.$id,a.realtimeChannel)&&t.switchRealtime(a.$id,a.realtimeChannel)}),a.$on("eventListRefresh",g),a.$on("$destroy",function(){t.removeSubscriber(a.$id,a.realtimeChannel)}),a.$watch("filters",e,!0),b(),w(),a.initialRealtimeState=(R=[a.initialRealtimeState,a.realtime],_.head(_.reject(R,_.isUndefined))),a.initialRealtimeState&&(a.realtime=a.initialRealtimeState,E())}e.$inject=["$scope","$filter","c8yEvents","c8yBase","c8yRealtime","c8yTitle","gettext","gettextCatalog"],angular.module("c8y.ui").controller("eventList",e)}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";angular.module("c8y.ui").directive("c8yEventList",function(){return{restrict:"EA",templateUrl:":::PLUGIN_PATH:::/ui/views/eventList.html",controller:"eventList",controllerAs:"ctrl",scope:{title:"=?",subtitle:"=?",filters:"=?",initialRealtimeState:"=?",realtime:"=?",hideHeaderActions:"=?",showPageTitles:"=?",onEventLoaded:"&",refreshLoading:"=?",hideDevice:"<?"}}});
|
|
1
|
+
"use strict";angular.module("c8y.ui").directive("c8yEventList",function(){return{restrict:"EA",templateUrl:":::PLUGIN_PATH:::/ui/views/eventList.html",controller:"eventList",controllerAs:"ctrl",scope:{title:"=?",subtitle:"=?",filters:"=?",initialRealtimeState:"=?",realtime:"=?",hideHeaderActions:"=?",hideWidgetActions:"=?",showPageTitles:"=?",onEventLoaded:"&",refreshLoading:"=?",hideDevice:"<?",timeRangeUnit:"=?"}}});
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
</c8y-breadcrumbs-set>
|
|
73
73
|
|
|
74
74
|
<!-- check if it is inside a widget -->
|
|
75
|
-
<div class="card-navbar navbar-default" ng-if="$parent.child.templateUrl">
|
|
75
|
+
<div class="card-navbar navbar-default" ng-if="$parent.child.templateUrl && !hideWidgetActions">
|
|
76
76
|
<div class="navbar-nav navbar-right">
|
|
77
77
|
<c8y-realtime-btn subscriber-id="ctrl.subscriberId"></c8y-realtime-btn>
|
|
78
78
|
<button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";angular.module("c8y.eventList").controller("EventListCtrl",["$scope",function(
|
|
1
|
+
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?Object(arguments[t]):{},i=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&i.push.apply(i,Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})),i.forEach(function(t){_defineProperty(e,t,o[t])})}return e}function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0===o)return("string"===e?String:Number)(t);var i=o.call(t,e||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}angular.module("c8y.eventList").controller("EventListCtrl",["$scope",function(e){var o=this;function i(t){o.options=_.cloneDeep(t)||{},o.options.source=e.child.config.device&&e.child.config.device.id,e.child.config.widgetInstanceGlobalTimeContext&&(e.child.config.canDecoupleGlobalTimeContext=!1,o.timeRangeUnit="minute")}e.$watch("child.config.options",function(t,e){t&&!_.isEqual(t,e)&&i(t)}),e.$watch("child.config.device",function(t){t&&i(e.child.config.options)},!0),e.$watch("child.config.date",function(){if(e.child.config.widgetInstanceGlobalTimeContext){var t=_objectSpread({},e.child.config.options,{dateFrom:e.child.config.date[0].toISOString(),dateTo:e.child.config.date[1].toISOString()});i(t)}}),i(e.child.config.options)}]);
|
package/eventList/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(){function e(e,t){e.add({name:"Event list",nameDisplay:t("Event list"),description:t("Displays the list of events for selected device."),templateUrl:":::PLUGIN_PATH:::/views/eventList.html",configTemplateUrl:":::PLUGIN_PATH:::/views/eventListConfig.html",previewImage:":::PLUGIN_PATH:::/img/events-list-widget-pr.png",options:{groupsSelectable:!0}})}e.$inject=["c8yComponentsProvider","gettext"],angular.module("c8y.eventList",[]).config(e)}();
|
|
1
|
+
"use strict";!function(){function e(e,t){e.add({name:"Event list",nameDisplay:t("Event list"),description:t("Displays the list of events for selected device."),templateUrl:":::PLUGIN_PATH:::/views/eventList.html",configTemplateUrl:":::PLUGIN_PATH:::/views/eventListConfig.html",previewImage:":::PLUGIN_PATH:::/img/events-list-widget-pr.png",options:{groupsSelectable:!0},displaySettings:{globalTimeContext:!0}})}e.$inject=["c8yComponentsProvider","gettext"],angular.module("c8y.eventList",[]).config(e)}();
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
<div ng-controller="EventListCtrl as eventList">
|
|
2
|
-
<c8y-event-list
|
|
2
|
+
<c8y-event-list
|
|
3
|
+
filters="eventList.options"
|
|
4
|
+
initial-realtime-state="!child.config.widgetInstanceGlobalTimeContext"
|
|
5
|
+
realtime="!child.config.widgetInstanceGlobalTimeContext"
|
|
6
|
+
hide-widget-actions="child.config.widgetInstanceGlobalTimeContext"
|
|
7
|
+
time-range-unit="eventList.timeRangeUnit">
|
|
8
|
+
</c8y-event-list>
|
|
3
9
|
</div>
|
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
<div class="form-group p-t-8">
|
|
2
|
+
|
|
3
|
+
<div class="form-group m-b-0 p-b-16">
|
|
4
|
+
<label for="dateSelection">
|
|
5
|
+
{{ 'Date selection' | translate }}
|
|
6
|
+
<button
|
|
7
|
+
type="button"
|
|
8
|
+
class="btn-help btn-help--sm"
|
|
9
|
+
aria-label="{{ 'Help' | translate }}"
|
|
10
|
+
uib-popover-html="'Choose how to select a date range, the available options are:<ul class=\'m-l-0 p-l-8 m-t-8 m-b-0\'><li><b>Widget configuration:</b> restricts the date selection only to the widget configuration</li><li><b>Dashboard time range:</b> restricts date selection to the global dashboard configuration only </li></ul>' | translate"
|
|
11
|
+
popover-placement="right"
|
|
12
|
+
popover-trigger="'focus'"
|
|
13
|
+
popover-append-to-body="true"
|
|
14
|
+
></button>
|
|
15
|
+
</label>
|
|
16
|
+
<div class="c8y-select-wrapper">
|
|
17
|
+
<select
|
|
18
|
+
id="dateSelection"
|
|
19
|
+
class="form-control"
|
|
20
|
+
title="{{ 'Date selection' | translate }}"
|
|
21
|
+
aria-label="{{ 'Date selection' | translate }}"
|
|
22
|
+
ng-model="config.widgetInstanceGlobalTimeContext"
|
|
23
|
+
>
|
|
24
|
+
<option
|
|
25
|
+
title="{{ 'Widget configuration' | translate }}"
|
|
26
|
+
value="{{ undefined }}"
|
|
27
|
+
>
|
|
28
|
+
{{ 'Widget configuration' | translate }}
|
|
29
|
+
</option>
|
|
30
|
+
<option
|
|
31
|
+
title="{{ 'Dashboard time range' | translate }}"
|
|
32
|
+
value="{{ true }}"
|
|
33
|
+
>
|
|
34
|
+
{{ 'Dashboard time range' | translate }}
|
|
35
|
+
</option>
|
|
36
|
+
</select>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
2
40
|
<label>Type</label>
|
|
3
41
|
<input type="text" class="form-control" ng-model="config.options.type">
|
|
4
42
|
</div>
|