@c8y/ng1-modules 1018.0.101 → 1018.0.103
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(){function e(i,n,o,e,s,
|
|
1
|
+
"use strict";!function(){function e(i,n,o,e,t,s,a,l,r,c,u,d,f,g,m){var y=this,p="YYYY-MM-DDTHH:mm:ssZZ",h={EVENT:"logsViewer",LOGS:{ACTIONS:{REQUEST:"request",DELETE:"delete",CANCEL:"cancel",DOWNLOAD:"download"}}};function L(){i.filters={dateFrom:moment().subtract(1,"day"),dateTo:moment(),logFile:i.logTypes[0]&&i.logTypes[0].name||null,maximumLines:1e3},y.filters=i.filters}function v(e){var t=_.assign({deviceId:n.deviceId,fragmentType:"c8y_LogfileRequest",dateFrom:new Date(0).toISOString(),revert:!0,withTotalPages:!0},e);return l.list(t).then(E)}function E(e,t){i.operations&&!t||(i.operations=[]),e.forEach(function(e){i.operations.push(e)}),i.paging=e.paging}function C(){_.get(i.paging,"refresh")&&(i.realtimeAnimation=!1,i.refreshLoading=!0,i.paging.refresh().then(_.partialRight(E,!0)).finally(function(){i.refreshLoading=!1}),i.paging=null)}function T(e){if(e.c8y_LogfileRequest.file){var t=s.getIdFromUrl(e.c8y_LogfileRequest.file);if(t)return s.removeBinary(t)}return!1}function R(e){var t={id:e.id,status:e.status,c8y_LogfileRequest:null};return l.save(t)}function S(e){D(e)?i.selectedLog=e:i.selectedLog=void 0}function D(e){return e.c8y_LogfileRequest&&e.c8y_LogfileRequest.file}function q(e){return e&&"SUCCESSFUL"===e.status}function F(e){return e&&"FAILED"===e.status}function I(e,t){t&&!e?(y.shouldClose="disabled",o(function(){y.shouldClose="outsideClick"})):y.shouldClose="outsideClick"}i.PRODUCT_EXPERIENCE=h,i.requestLogfile=function(e){var t={deviceId:n.deviceId,description:d("Log file request"),c8y_LogfileRequest:{dateFrom:moment(e.dateFrom).format(p),dateTo:moment(e.dateTo).format(p),logFile:e.logFile,searchText:e.searchText||"",maximumLines:e.maximumLines}};l.createWithNotifications(t).then(function(e){e.created.then(C),e.completed.then(function(e){e.status===l.status.SUCCESSFUL?(_.assign(t,e),S(t)):e.status===l.status.FAILED&&"Operation cancelled by user."!==e.failureReason&&(e.failureReason?u.danger(f('Could not load file: "{{failureReason | translate}}".',e)):u.danger(d("Could not load file.")))},_.noop,function(e){_.assign(t,e),S(t)}).then(C)})},i.hasLogFile=D,i.selectLogfile=S,i.isBinary=function(e){return e&&e.c8y_LogfileRequest&&e.c8y_LogfileRequest.file&&(!!s.getIdFromUrl(e.c8y_LogfileRequest.file)||t.isEventBinary(e.c8y_LogfileRequest.file))},i.download=g.download,i.cancel=function(e){return"PENDING"===e.status&&l.cancel(e).then(function(){return u.success(d("Log file request cancelled."))}).then(C)},i.remove=function(e){return c({title:d("Delete log file"),body:d("You are about to delete this log file. Do you want to proceed?"),status:"danger",labels:{ok:d("Delete")}}).then(_.partial(T,e)).then(_.partial(R,e)).then(function(){m.triggerEvent(h.EVENT,{action:h.LOGS.ACTIONS.DELETE}),u.success(d("Log file deleted."))}).then(C)},i.statusIcon=function(e){return l.getStyle(e).icon},i.statusClass=function(e){return l.getStyle(e).cls},i.isSuccessful=q,i.isPending=function(e){return e&&"PENDING"===e.status},i.isFailed=F,i.isCompleted=function(e){return q(e)||F(e)},i.refresh=C,i.loadNext=function(e){i.paging.loading=!0,(e?v({pageSize:e}):i.paging.next().then(E)).finally(function(){i.paging.loading=!1})},i.getOperationDesc=function(e){return e.description||d("no description available")},i.$watch("vm.datePickerToOpen",I),i.$watch("vm.datePickerFromOpen",I),i.$watch("vm.logtypeSelect.open",function(e){e||(y.shouldClose="disabled",o(function(){y.shouldClose="outsideClick"}))}),y.shouldClose="outsideClick",y.datePickerToOpen=!1,y.datePickerFromOpen=!1,a.detail(n.deviceId).then(e.getResData).then(function(e){i.logTypes=_.map(e.c8y_SupportedLogs,function(e){return{name:e}}),y.logTypes=i.logTypes}).then(L),v();var O=i.$id,w="/operations/".concat(n.deviceId),N=r.realtimeActions();_.forOwn(N,function(e){r.addListener(O,w,e,function(e,t){if(_.has(t,"c8y_LogfileRequest")){C();var n=i.selectedLog;n&&n.id===t.id&&e===N.UPDATE&&(n.c8y_LogfileRequest=t.c8y_LogfileRequest)}})}),r.start(O,w),i.$on("$destroy",function(){r.stop(O,w),r.destroySubscription(O,w)})}e.$inject=["$scope","$routeParams","$timeout","c8yBase","c8yEvents","c8yBinary","c8yDevices","c8yDeviceControl","c8yRealtime","c8yModal","c8yAlert","gettext","gettextCatalog","logViewer","c8yGainsightService"],angular.module("c8y.logViewer").controller("logViewerCtrl",e)}();
|