angular.module("c8y.parts.kpi").controller("kpiConfigCtrl",["$scope","$location","$routeParams",function(n,e,a){var a=a.deviceId,t=[{value:void 0,name:"No aggregation"},{value:"HOURLY",name:"Hourly"},{value:"DAILY",name:"Daily"}],g=[{timeIntervalValue:"minutes",aggregationType:void 0},{timeIntervalValue:"hours",aggregationType:void 0},{timeIntervalValue:"days",aggregationType:"HOURLY"},{timeIntervalValue:"weeks",aggregationType:"HOURLY"},{timeIntervalValue:"months",aggregationType:"DAILY"}];n.deviceId=a,n.timeIntervals=[{value:"minutes",name:"Last minute"},{value:"hours",name:"Last hour"},{value:"days",name:"Last day"},{value:"weeks",name:"Last week"},{value:"months",name:"Last month"}],n.aggregationTypes=t,n.onAggregationTypeChangedManually=function(){n.config.aggregationTypeChangedManually=!0},n.$watch("config.timeInterval",function(a){!n.config.aggregationTypeChangedManually&&a&&_.forEach(g,function(e){a===e.timeIntervalValue&&(n.config.aggregationType=e.aggregationType)})})}]);