appenlight-header.js
56 lines
| 2.1 KiB
| application/javascript
|
JavascriptLexer
r112 | // Copyright 2010 - 2017 RhodeCode GmbH and the AppEnlight project authors | |||
// | ||||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||||
// you may not use this file except in compliance with the License. | ||||
// You may obtain a copy of the License at | ||||
// | ||||
// http://www.apache.org/licenses/LICENSE-2.0 | ||||
// | ||||
// Unless required by applicable law or agreed to in writing, software | ||||
// distributed under the License is distributed on an "AS IS" BASIS, | ||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
// See the License for the specific language governing permissions and | ||||
// limitations under the License. | ||||
r0 | ||||
r71 | angular.module('appenlight.components.appenlightHeader', []) | |||
.component('appenlightHeader', { | ||||
r72 | templateUrl: 'components/appenlight-header/appenlight-header.html', | |||
r71 | controller: AppEnlightHeaderController | |||
}); | ||||
r0 | ||||
r71 | ChannelstreamController.$inject = ['$state', 'stateHolder', 'AeConfig']; | |||
r0 | ||||
r147 | function AppEnlightHeaderController($state, stateHolder, AeConfig) { | |||
r0 | var vm = this; | |||
r147 | vm.$onInit = function () { | |||
vm.AeConfig = AeConfig; | ||||
vm.stateHolder = stateHolder; | ||||
vm.assignedReports = stateHolder.AeUser.assigned_reports; | ||||
vm.latestEvents = stateHolder.AeUser.latest_events; | ||||
vm.activeEvents = 0; | ||||
_.each(vm.latestEvents, function (event) { | ||||
if (event.status === 1 && event.end_date === null) { | ||||
vm.activeEvents += 1; | ||||
} | ||||
}); | ||||
} | ||||
vm.clickedEvent = function (event) { | ||||
r0 | // exception reports | |||
r147 | if (_.contains([1, 2], event.event_type)) { | |||
$state.go('report.list', {resource: event.resource_id, start_date: event.start_date}); | ||||
r0 | } | |||
// slowness reports | ||||
r147 | else if (_.contains([3, 4], event.event_type)) { | |||
$state.go('report.list_slow', {resource: event.resource_id, start_date: event.start_date}); | ||||
r0 | } | |||
// uptime reports | ||||
r147 | else if (_.contains([7, 8], event.event_type)) { | |||
$state.go('uptime', {resource: event.resource_id, start_date: event.start_date}); | ||||
} else { | ||||
r0 | console.log('other'); | |||
} | ||||
} | ||||
} | ||||