##// END OF EJS Templates
log browser: turn into component
ergo -
Show More
This diff has been collapsed as it changes many lines, (1434 lines changed) Show them Hide them
@@ -2679,7 +2679,8 b" angular.module('appenlight.components', ["
2679 2679 'appenlight.components.channelstream',
2680 2680 'appenlight.components.appenlightApp',
2681 2681 'appenlight.components.appenlightHeader',
2682 'appenlight.components.indexDashboardView'
2682 'appenlight.components.indexDashboardView',
2683 'appenlight.components.logsBrowserView',
2683 2684 ]);
2684 2685 angular.module('appenlight.directives', [
2685 2686 'appenlight.directives.c3chart',
@@ -3303,6 +3304,106 b' function kickstartAE(initialUserData) {'
3303 3304 );
3304 3305
3305 3306
3307 $templateCache.put('components/views/logs-browser/logs-browser.html',
3308 "<ng-include src=\"'templates/loader.html'\" ng-if=\"$ctrl.isLoading.logs\"></ng-include>\n" +
3309 "\n" +
3310 "<div ng-if=\"$ctrl.isLoading.logs === false\">\n" +
3311 "\n" +
3312 " <p class=\"search-params\">\n" +
3313 " <strong>Search params:</strong>\n" +
3314 " <span ng-repeat=\"tag in $ctrl.searchParams.tags\" class=\"tag\">\n" +
3315 " <strong>{{tag.type}}</strong>\n" +
3316 " {{ tag.type == 'resource' ? $ctrl.applications[tag.value].resource_name : tag.value }}\n" +
3317 "\n" +
3318 " <a ng-click=\"$ctrl.removeSearchTag(tag)\"><span class=\"fa fa-times\"></span></a>\n" +
3319 " </span>\n" +
3320 " </p>\n" +
3321 "\n" +
3322 " <p>\n" +
3323 "\n" +
3324 " <script type=\"text/ng-template\" id=\"SearchTypeAheadUrl.html\">\n" +
3325 "\n" +
3326 " </script>\n" +
3327 "\n" +
3328 " <form class=\"form\">\n" +
3329 " <div class=\"typeahead-tags\">\n" +
3330 " <input type=\"text\" id=\"typeAhead\" ng-model=\"$ctrl.filterTypeAhead\" placeholder=\"Start typing to filter logs for events, filter by servers, namespaces, levels.\"\n" +
3331 " ng-keydown=\"$ctrl.typeAheadTag($event)\"\n" +
3332 " uib-typeahead=\"tag as tag.text for tag in $ctrl.filterTypeAheadOptions | filter:$viewValue:$ctrl.aheadFilter\"\n" +
3333 " typeahead-min-length=\"1\" class=\"form-control\"\n" +
3334 " typeahead-template-url=\"templates/directives/search_type_ahead.html\">\n" +
3335 " </div>\n" +
3336 " </form>\n" +
3337 "\n" +
3338 " <div class=\"well animate-show position-absolute increse-zindex\" ng-if=\"$ctrl.showDatePicker\" ng-model=\"$ctrl.pickerDate\" ng-change=\"$ctrl.pickerDateChanged()\">\n" +
3339 " <uib-datepicker></uib-datepicker>\n" +
3340 " </div>\n" +
3341 "\n" +
3342 " </p>\n" +
3343 "\n" +
3344 " <div class=\"panel\">\n" +
3345 "\n" +
3346 " <div class=\"panel-body\">\n" +
3347 " <c3chart data-domid=\"log_events_chart\" data-data=\"$ctrl.logEventsChartData\" data-config=\"$ctrl.logEventsChartConfig\">\n" +
3348 " </c3chart>\n" +
3349 " </div>\n" +
3350 " </div>\n" +
3351 "\n" +
3352 "\n" +
3353 " <div class=\"text-center\">\n" +
3354 " <uib-pagination total-items=\"$ctrl.itemCount\" items-per-page=\"$ctrl.itemsPerPage\" ng-model=\"$ctrl.page\" max-size=\"10\"\n" +
3355 " ng-change=\"$ctrl.paginationChange()\"\n" +
3356 " class=\"pagination pagination-sm\" boundary-links=\"true\" direction-links=\"false\"></uib-pagination>\n" +
3357 " </div>\n" +
3358 "\n" +
3359 " <div class=\"panel panel-default\">\n" +
3360 "\n" +
3361 " <table class=\"table table-striped log-list\">\n" +
3362 " <caption>Logs</caption>\n" +
3363 " <thead>\n" +
3364 " <tr>\n" +
3365 " <th class=\"c1 resource\">Application</th>\n" +
3366 " <th class=\"c2 message\">Message</th>\n" +
3367 " <th class=\"c3 when\">When</th>\n" +
3368 " </tr>\n" +
3369 " </thead>\n" +
3370 " <tbody>\n" +
3371 " <tr ng-repeat=\"log in $ctrl.logsPage track by log.log_id\" class=\"{{$odd ? 'odd' : 'even'}}\">\n" +
3372 " <td class=\"c1\">\n" +
3373 " <a class=\"tag application\" ng-click=\"$ctrl.addSearchTag({type:'resource', value:log.resource_id})\">\n" +
3374 " <span class=\"name\">{{log.resource_name}}</span></a>\n" +
3375 " </td>\n" +
3376 " <td class=\"c2\">\n" +
3377 " <a class=\"tag {{log.log_level|lowercase}}\" ng-click=\"$ctrl.addSearchTag({type:'level', value:log.log_level})\">\n" +
3378 " <span class=\"name\">level:</span> {{log.log_level}}</a>\n" +
3379 " <a class=\"tag\" ng-click=\"$ctrl.addSearchTag({type:'namespace', value:log.namespace})\">\n" +
3380 " <span class=\"name\">namespace:</span> {{log.namespace}}</a>\n" +
3381 " <a ng-repeat=\"(tag, value) in log.tags\" class=\"tag\" ng-click=\"$ctrl.addSearchTag({type:tag, value:value})\">\n" +
3382 " <span class=\"name\">{{tag}}:</span> {{value}}</a>\n" +
3383 " <div class=\"log\">{{log.message}}</div>\n" +
3384 " </td>\n" +
3385 " <td class=\"c3 when\">\n" +
3386 " <a ng-click=\"$ctrl.filterId(log)\" data-uib-tooltip=\"{{log.timestamp}}\">\n" +
3387 " <iso-to-relative-time time=\"{{log.timestamp}}\"/>\n" +
3388 " </a>\n" +
3389 " </td>\n" +
3390 " </tr>\n" +
3391 "\n" +
3392 " </tbody>\n" +
3393 " </table>\n" +
3394 "\n" +
3395 " </div>\n" +
3396 "\n" +
3397 " <div class=\"text-center\">\n" +
3398 " <uib-pagination total-items=\"$ctrl.itemCount\" items-per-page=\"$ctrl.itemsPerPage\" ng-model=\"$ctrl.page\" max-size=\"10\"\n" +
3399 " ng-change=\"$ctrl.paginationChange()\"\n" +
3400 " class=\"pagination pagination-sm\" boundary-links=\"true\" direction-links=\"false\"></uib-pagination>\n" +
3401 " </div>\n" +
3402 "\n" +
3403 "</div>\n"
3404 );
3405
3406
3306 3407 $templateCache.put('directives/permissions/permissions.html',
3307 3408 "<div class=\"panel panel-default\">\n" +
3308 3409 " <div class=\"panel-heading\">\n" +
@@ -5782,106 +5883,6 b' function kickstartAE(initialUserData) {'
5782 5883 );
5783 5884
5784 5885
5785 $templateCache.put('templates/logs.html',
5786 "<ng-include src=\"'templates/loader.html'\" ng-if=\"logs.isLoading.logs\"></ng-include>\n" +
5787 "\n" +
5788 "<div ng-if=\"logs.isLoading.logs === false\">\n" +
5789 "\n" +
5790 " <p class=\"search-params\">\n" +
5791 " <strong>Search params:</strong>\n" +
5792 " <span ng-repeat=\"tag in logs.searchParams.tags\" class=\"tag\">\n" +
5793 " <strong>{{tag.type}}</strong>\n" +
5794 " {{ tag.type == 'resource' ? logs.applications[tag.value].resource_name : tag.value }}\n" +
5795 "\n" +
5796 " <a ng-click=\"logs.removeSearchTag(tag)\"><span class=\"fa fa-times\"></span></a>\n" +
5797 " </span>\n" +
5798 " </p>\n" +
5799 "\n" +
5800 " <p>\n" +
5801 "\n" +
5802 " <script type=\"text/ng-template\" id=\"SearchTypeAheadUrl.html\">\n" +
5803 "\n" +
5804 " </script>\n" +
5805 "\n" +
5806 " <form class=\"form\">\n" +
5807 " <div class=\"typeahead-tags\">\n" +
5808 " <input type=\"text\" id=\"typeAhead\" ng-model=\"logs.filterTypeAhead\" placeholder=\"Start typing to filter logs for events, filter by servers, namespaces, levels.\"\n" +
5809 " ng-keydown=\"logs.typeAheadTag($event)\"\n" +
5810 " uib-typeahead=\"tag as tag.text for tag in logs.filterTypeAheadOptions | filter:$viewValue:logs.aheadFilter\"\n" +
5811 " typeahead-min-length=\"1\" class=\"form-control\"\n" +
5812 " typeahead-template-url=\"templates/directives/search_type_ahead.html\">\n" +
5813 " </div>\n" +
5814 " </form>\n" +
5815 "\n" +
5816 " <div class=\"well animate-show position-absolute increse-zindex\" ng-if=\"logs.showDatePicker\" ng-model=\"logs.pickerDate\" ng-change=\"logs.pickerDateChanged()\">\n" +
5817 " <uib-datepicker></uib-datepicker>\n" +
5818 " </div>\n" +
5819 "\n" +
5820 " </p>\n" +
5821 "\n" +
5822 " <div class=\"panel\">\n" +
5823 "\n" +
5824 " <div class=\"panel-body\">\n" +
5825 " <c3chart data-domid=\"log_events_chart\" data-data=\"logs.logEventsChartData\" data-config=\"logs.logEventsChartConfig\">\n" +
5826 " </c3chart>\n" +
5827 " </div>\n" +
5828 " </div>\n" +
5829 "\n" +
5830 "\n" +
5831 " <div class=\"text-center\">\n" +
5832 " <uib-pagination total-items=\"logs.itemCount\" items-per-page=\"logs.itemsPerPage\" ng-model=\"logs.page\" max-size=\"10\"\n" +
5833 " ng-change=\"logs.paginationChange()\"\n" +
5834 " class=\"pagination pagination-sm\" boundary-links=\"true\" direction-links=\"false\"></uib-pagination>\n" +
5835 " </div>\n" +
5836 "\n" +
5837 " <div class=\"panel panel-default\">\n" +
5838 "\n" +
5839 " <table class=\"table table-striped log-list\">\n" +
5840 " <caption>Logs</caption>\n" +
5841 " <thead>\n" +
5842 " <tr>\n" +
5843 " <th class=\"c1 resource\">Application</th>\n" +
5844 " <th class=\"c2 message\">Message</th>\n" +
5845 " <th class=\"c3 when\">When</th>\n" +
5846 " </tr>\n" +
5847 " </thead>\n" +
5848 " <tbody>\n" +
5849 " <tr ng-repeat=\"log in logs.logsPage track by log.log_id\" class=\"{{$odd ? 'odd' : 'even'}}\">\n" +
5850 " <td class=\"c1\">\n" +
5851 " <a class=\"tag application\" ng-click=\"logs.addSearchTag({type:'resource', value:log.resource_id})\">\n" +
5852 " <span class=\"name\">{{log.resource_name}}</span></a>\n" +
5853 " </td>\n" +
5854 " <td class=\"c2\">\n" +
5855 " <a class=\"tag {{log.log_level|lowercase}}\" ng-click=\"logs.addSearchTag({type:'level', value:log.log_level})\">\n" +
5856 " <span class=\"name\">level:</span> {{log.log_level}}</a>\n" +
5857 " <a class=\"tag\" ng-click=\"logs.addSearchTag({type:'namespace', value:log.namespace})\">\n" +
5858 " <span class=\"name\">namespace:</span> {{log.namespace}}</a>\n" +
5859 " <a ng-repeat=\"(tag, value) in log.tags\" class=\"tag\" ng-click=\"logs.addSearchTag({type:tag, value:value})\">\n" +
5860 " <span class=\"name\">{{tag}}:</span> {{value}}</a>\n" +
5861 " <div class=\"log\">{{log.message}}</div>\n" +
5862 " </td>\n" +
5863 " <td class=\"c3 when\">\n" +
5864 " <a ng-click=\"logs.filterId(log)\" data-uib-tooltip=\"{{log.timestamp}}\">\n" +
5865 " <iso-to-relative-time time=\"{{log.timestamp}}\"/>\n" +
5866 " </a>\n" +
5867 " </td>\n" +
5868 " </tr>\n" +
5869 "\n" +
5870 " </tbody>\n" +
5871 " </table>\n" +
5872 "\n" +
5873 " </div>\n" +
5874 "\n" +
5875 " <div class=\"text-center\">\n" +
5876 " <uib-pagination total-items=\"logs.itemCount\" items-per-page=\"logs.itemsPerPage\" ng-model=\"logs.page\" max-size=\"10\"\n" +
5877 " ng-change=\"logs.paginationChange()\"\n" +
5878 " class=\"pagination pagination-sm\" boundary-links=\"true\" direction-links=\"false\"></uib-pagination>\n" +
5879 " </div>\n" +
5880 "\n" +
5881 "</div>\n"
5882 );
5883
5884
5885 5886 $templateCache.put('templates/quickstart.html',
5886 5887 "<h2>AppEnlight quickstart</h2>\n" +
5887 5888 "\n" +
@@ -7996,108 +7997,407 b' function IndexDashboardController($rootScope, $scope, $location, $cookies, $inte'
7996 7997 // # services, and proprietary license terms, please see
7997 7998 // # https://rhodecode.com/licenses/
7998 7999
7999 var aeconfig = angular.module('appenlight.config', []);
8000 aeconfig.factory('AeConfig', function () {
8001 var obj = {};
8002 obj.flashMessages = decodeEncodedJSON(window.AE.flash_messages);
8003 obj.timeOptions = decodeEncodedJSON(window.AE.timeOptions);
8004 obj.plugins = decodeEncodedJSON(window.AE.plugins);
8005 obj.topNav = decodeEncodedJSON(window.AE.topNav);
8006 obj.ws_url = window.AE.ws_url;
8007 obj.urls = window.AE.urls;
8008 // set keys on values because we wont be able to retrieve them everywhere
8009 for (var key in obj.timeOptions) {
8010 obj.timeOptions[key]['key'] = key;
8011 }
8012 console.info('config', obj);
8013 return obj;
8014 });
8015
8016 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
8017 // #
8018 // # This program is free software: you can redistribute it and/or modify
8019 // # it under the terms of the GNU Affero General Public License, version 3
8020 // # (only), as published by the Free Software Foundation.
8021 // #
8022 // # This program is distributed in the hope that it will be useful,
8023 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
8024 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8025 // # GNU General Public License for more details.
8026 // #
8027 // # You should have received a copy of the GNU Affero General Public License
8028 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
8029 // #
8030 // # This program is dual-licensed. If you wish to learn more about the
8031 // # AppEnlight Enterprise Edition, including its added features, Support
8032 // # services, and proprietary license terms, please see
8033 // # https://rhodecode.com/licenses/
8034
8035 angular.module('appenlight.controllers').controller('AdminApplicationsListController', AdminApplicationsListController);
8036
8037 AdminApplicationsListController.$inject = ['applicationsResource'];
8038
8039 function AdminApplicationsListController(applicationsResource) {
8040
8041 var vm = this;
8042 vm.loading = {applications: true};
8043
8044 vm.applications = applicationsResource.query({
8045 root_list: true,
8046 resource_type: 'application'
8047 }, function (data) {
8048 vm.loading = {applications: false};
8000 angular.module('appenlight.components.logsBrowserView', [])
8001 .component('logsBrowserView', {
8002 templateUrl: 'components/views/logs-browser/logs-browser.html',
8003 controller: LogsBrowserController
8049 8004 });
8050 };
8051
8052 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
8053 // #
8054 // # This program is free software: you can redistribute it and/or modify
8055 // # it under the terms of the GNU Affero General Public License, version 3
8056 // # (only), as published by the Free Software Foundation.
8057 // #
8058 // # This program is distributed in the hope that it will be useful,
8059 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
8060 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8061 // # GNU General Public License for more details.
8062 // #
8063 // # You should have received a copy of the GNU Affero General Public License
8064 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
8065 // #
8066 // # This program is dual-licensed. If you wish to learn more about the
8067 // # AppEnlight Enterprise Edition, including its added features, Support
8068 // # services, and proprietary license terms, please see
8069 // # https://rhodecode.com/licenses/
8070 8005
8071 angular.module('appenlight.controllers').controller('ConfigsListController', ConfigsListController);
8072
8073 ConfigsListController.$inject = ['configsResource', 'configsNoIdResource'];
8006 LogsBrowserController.$inject = ['$location', 'stateHolder', 'typeAheadTagHelper', 'logsNoIdResource', 'sectionViewResource'];
8074 8007
8075 function ConfigsListController(configsResource, configsNoIdResource) {
8008 function LogsBrowserController($location, stateHolder, typeAheadTagHelper, logsNoIdResource, sectionViewResource) {
8076 8009 var vm = this;
8077 vm.loading = {config: true};
8078
8079 var filters = [
8080 'template_footer_html:global',
8081 'list_groups_to_non_admins:global',
8082 'per_application_reports_rate_limit:global',
8083 'per_application_logs_rate_limit:global',
8084 'per_application_metrics_rate_limit:global',
8085 ];
8086
8087 vm.configs = {};
8088
8089 vm.configList = configsResource.query({filter: filters},
8090 function (data) {
8091 vm.loading = {config: false};
8092 _.each(data, function (item) {
8093 if (vm.configs[item.section] === undefined) {
8094 vm.configs[item.section] = {};
8095 }
8096 vm.configs[item.section][item.key] = item;
8097 });
8098 });
8099
8100 vm.save = function () {
8010 vm.logEventsChartConfig = {
8011 data: {
8012 json: [],
8013 xFormat: '%Y-%m-%dT%H:%M:%S'
8014 },
8015 color: {
8016 pattern: ['#6baed6', '#e6550d', '#74c476', '#fdd0a2', '#8c564b']
8017 },
8018 axis: {
8019 x: {
8020 type: 'timeseries',
8021 tick: {
8022 format: '%Y-%m-%d'
8023 }
8024 },
8025 y: {
8026 tick: {
8027 count: 5,
8028 format: d3.format('.2s')
8029 }
8030 }
8031 },
8032 subchart: {
8033 show: true,
8034 size: {
8035 height: 20
8036 }
8037 },
8038 size: {
8039 height: 250
8040 },
8041 zoom: {
8042 rescale: true
8043 },
8044 grid: {
8045 x: {
8046 show: true
8047 },
8048 y: {
8049 show: true
8050 }
8051 },
8052 tooltip: {
8053 format: {
8054 title: function (d) {
8055 return '' + d;
8056 },
8057 value: function (v) {
8058 return v
8059 }
8060 }
8061 }
8062 };
8063 vm.logEventsChartData = {};
8064 stateHolder.section = 'logs';
8065 vm.today = function () {
8066 vm.pickerDate = new Date();
8067 };
8068 vm.today();
8069
8070 vm.applications = stateHolder.AeUser.applications_map;
8071 vm.logsPage = [];
8072 vm.itemCount = 0;
8073 vm.itemsPerPage = 250;
8074 vm.page = 1;
8075 vm.$location = $location;
8076 vm.isLoading = {
8077 logs: true,
8078 series: true
8079 };
8080 vm.filterTypeAheadOptions = [
8081 {
8082 type: 'message',
8083 text: 'message:',
8084 'description': 'Full-text search in your logs',
8085 tag: 'Message',
8086 example: 'message:text-im-looking-for'
8087 },
8088 {
8089 type: 'namespace',
8090 text: 'namespace:',
8091 'description': 'Query logs from specific namespace',
8092 tag: 'Namespace',
8093 example: "namespace:module.foo"
8094 },
8095 {
8096 type: 'resource',
8097 text: 'resource:',
8098 'description': 'Restrict resultset to application',
8099 tag: 'Application',
8100 example: "resource:ID"
8101 },
8102 {
8103 type: 'request_id',
8104 text: 'request_id:',
8105 'description': 'Show logs with specific request id',
8106 example: "request_id:883143dc572e4c38aceae92af0ea5ae0",
8107 tag: 'Request ID'
8108 },
8109 {
8110 type: 'level',
8111 text: 'level:',
8112 'description': 'Show entries with specific log level',
8113 example: 'level:warning',
8114 tag: 'Level'
8115 },
8116 {
8117 type: 'server_name',
8118 text: 'server_name:',
8119 'description': 'Show entries tagged with this key/value pair',
8120 example: 'server_name:hostname',
8121 tag: 'Tag'
8122 },
8123 {
8124 type: 'start_date',
8125 text: 'start_date:',
8126 'description': 'Show results newer than this date (press TAB for dropdown)',
8127 example: 'start_date:2014-08-15T13:00',
8128 tag: 'Start Date'
8129 },
8130 {
8131 type: 'end_date',
8132 text: 'end_date:',
8133 'description': 'Show results older than this date (press TAB for dropdown)',
8134 example: 'start_date:2014-08-15T23:59',
8135 tag: 'End Date'
8136 },
8137 {type: 'level', value: 'debug', text: 'level:debug'},
8138 {type: 'level', value: 'info', text: 'level:info'},
8139 {type: 'level', value: 'warning', text: 'level:warning'},
8140 {type: 'level', value: 'critical', text: 'level:critical'}
8141 ];
8142 vm.filterTypeAhead = null;
8143 vm.showDatePicker = false;
8144 vm.manualOpen = false;
8145 vm.aheadFilter = typeAheadTagHelper.aheadFilter;
8146 vm.removeSearchTag = function (tag) {
8147 $location.search(tag.type, null);
8148 vm.refresh();
8149 };
8150 vm.addSearchTag = function (tag) {
8151 $location.search(tag.type, tag.value);
8152 vm.refresh();
8153 };
8154
8155 vm.paginationChange = function(){
8156 $location.search('page', vm.page);
8157 vm.refresh();
8158 };
8159
8160
8161 _.each(vm.applications, function (item) {
8162 vm.filterTypeAheadOptions.push({
8163 type: 'resource',
8164 text: 'resource:' + item.resource_id + ':' + item.resource_name,
8165 example: 'resource:' + item.resource_id,
8166 'tag': item.resource_name,
8167 'description': 'Restrict resultset to this application'
8168 });
8169 });
8170
8171 vm.typeAheadTag = function (event) {
8172 var text = vm.filterTypeAhead;
8173 if (_.isObject(vm.filterTypeAhead)) {
8174 text = vm.filterTypeAhead.text;
8175 };
8176 if (!vm.filterTypeAhead) {
8177 return
8178 }
8179 var parsed = text.split(':');
8180 var tag = {'type': null, 'value': null};
8181 // app tags have : twice
8182 if (parsed.length > 2 && parsed[0] == 'resource') {
8183 tag.type = 'resource';
8184 tag.value = parsed[1];
8185 }
8186 // normal tag:value
8187 else if (parsed.length > 1) {
8188 tag.type = parsed[0];
8189 tag.value = parsed.slice(1).join(':');
8190 }
8191 else {
8192 tag.type = 'message';
8193 tag.value = parsed.join(':');
8194 }
8195
8196 // set datepicker hour based on type of field
8197 if ('start_date:' == text) {
8198 vm.showDatePicker = true;
8199 vm.filterTypeAhead = 'start_date:' + moment(vm.pickerDate).utc().format();
8200 }
8201 else if ('end_date:' == text) {
8202 vm.showDatePicker = true;
8203 vm.filterTypeAhead = 'end_date:' + moment(vm.pickerDate).utc().hour(23).minute(59).format();
8204 }
8205
8206 if (event.keyCode != 13 || !tag.type || !tag.value) {
8207 return
8208 }
8209 vm.showDatePicker = false;
8210 // aka we selected one of main options
8211 vm.addSearchTag({type: tag.type, value: tag.value});
8212 // clear typeahead
8213 vm.filterTypeAhead = undefined;
8214 };
8215
8216
8217 vm.pickerDateChanged = function(){
8218 if (vm.filterTypeAhead.indexOf('start_date:') == '0') {
8219 vm.filterTypeAhead = 'start_date:' + moment(vm.pickerDate).utc().format();
8220 }
8221 else if (vm.filterTypeAhead.indexOf('end_date:') == '0') {
8222 vm.filterTypeAhead = 'end_date:' + moment(vm.pickerDate).utc().hour(23).minute(59).format();
8223 }
8224 vm.showDatePicker = false;
8225 };
8226
8227 vm.fetchLogs = function (searchParams) {
8228 vm.isLoading.logs = true;
8229 logsNoIdResource.query(searchParams, function (data, getResponseHeaders) {
8230 vm.isLoading.logs = false;
8231 var headers = getResponseHeaders();
8232 vm.logsPage = data;
8233 vm.itemCount = headers['x-total-count'];
8234 vm.itemsPerPage = headers['x-items-per-page'];
8235 }, function () {
8236 vm.isLoading.logs = false;
8237 });
8238 };
8239
8240 vm.fetchSeriesData = function (searchParams) {
8241 searchParams['section'] = 'logs_section';
8242 searchParams['view'] = 'fetch_series';
8243 vm.isLoading.series = true;
8244 sectionViewResource.query(searchParams, function (data) {
8245
8246 vm.logEventsChartData = {
8247 json: data,
8248 xFormat: '%Y-%m-%dT%H:%M:%S',
8249 keys: {
8250 x: 'x',
8251 value: ["logs"]
8252 },
8253 names: {
8254 logs: 'Log events'
8255 },
8256 type: 'bar'
8257 };
8258 vm.isLoading.series = false;
8259 }, function () {
8260 vm.isLoading.series = false;
8261 });
8262 };
8263
8264 vm.filterId = function (log) {
8265 $location.search('request_id', log.request_id);
8266 vm.refresh();
8267 };
8268
8269 vm.refresh = function(){
8270 vm.searchParams = parseSearchToTags($location.search());
8271 vm.page = Number(vm.searchParams.page) || 1;
8272 var params = parseTagsToSearch(vm.searchParams);
8273 vm.fetchLogs(params);
8274 vm.fetchSeriesData(params);
8275 };
8276 console.info('page load');
8277 vm.refresh();
8278 }
8279
8280 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
8281 // #
8282 // # This program is free software: you can redistribute it and/or modify
8283 // # it under the terms of the GNU Affero General Public License, version 3
8284 // # (only), as published by the Free Software Foundation.
8285 // #
8286 // # This program is distributed in the hope that it will be useful,
8287 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
8288 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8289 // # GNU General Public License for more details.
8290 // #
8291 // # You should have received a copy of the GNU Affero General Public License
8292 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
8293 // #
8294 // # This program is dual-licensed. If you wish to learn more about the
8295 // # AppEnlight Enterprise Edition, including its added features, Support
8296 // # services, and proprietary license terms, please see
8297 // # https://rhodecode.com/licenses/
8298
8299 var aeconfig = angular.module('appenlight.config', []);
8300 aeconfig.factory('AeConfig', function () {
8301 var obj = {};
8302 obj.flashMessages = decodeEncodedJSON(window.AE.flash_messages);
8303 obj.timeOptions = decodeEncodedJSON(window.AE.timeOptions);
8304 obj.plugins = decodeEncodedJSON(window.AE.plugins);
8305 obj.topNav = decodeEncodedJSON(window.AE.topNav);
8306 obj.ws_url = window.AE.ws_url;
8307 obj.urls = window.AE.urls;
8308 // set keys on values because we wont be able to retrieve them everywhere
8309 for (var key in obj.timeOptions) {
8310 obj.timeOptions[key]['key'] = key;
8311 }
8312 console.info('config', obj);
8313 return obj;
8314 });
8315
8316 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
8317 // #
8318 // # This program is free software: you can redistribute it and/or modify
8319 // # it under the terms of the GNU Affero General Public License, version 3
8320 // # (only), as published by the Free Software Foundation.
8321 // #
8322 // # This program is distributed in the hope that it will be useful,
8323 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
8324 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8325 // # GNU General Public License for more details.
8326 // #
8327 // # You should have received a copy of the GNU Affero General Public License
8328 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
8329 // #
8330 // # This program is dual-licensed. If you wish to learn more about the
8331 // # AppEnlight Enterprise Edition, including its added features, Support
8332 // # services, and proprietary license terms, please see
8333 // # https://rhodecode.com/licenses/
8334
8335 angular.module('appenlight.controllers').controller('AdminApplicationsListController', AdminApplicationsListController);
8336
8337 AdminApplicationsListController.$inject = ['applicationsResource'];
8338
8339 function AdminApplicationsListController(applicationsResource) {
8340
8341 var vm = this;
8342 vm.loading = {applications: true};
8343
8344 vm.applications = applicationsResource.query({
8345 root_list: true,
8346 resource_type: 'application'
8347 }, function (data) {
8348 vm.loading = {applications: false};
8349 });
8350 };
8351
8352 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
8353 // #
8354 // # This program is free software: you can redistribute it and/or modify
8355 // # it under the terms of the GNU Affero General Public License, version 3
8356 // # (only), as published by the Free Software Foundation.
8357 // #
8358 // # This program is distributed in the hope that it will be useful,
8359 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
8360 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8361 // # GNU General Public License for more details.
8362 // #
8363 // # You should have received a copy of the GNU Affero General Public License
8364 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
8365 // #
8366 // # This program is dual-licensed. If you wish to learn more about the
8367 // # AppEnlight Enterprise Edition, including its added features, Support
8368 // # services, and proprietary license terms, please see
8369 // # https://rhodecode.com/licenses/
8370
8371 angular.module('appenlight.controllers').controller('ConfigsListController', ConfigsListController);
8372
8373 ConfigsListController.$inject = ['configsResource', 'configsNoIdResource'];
8374
8375 function ConfigsListController(configsResource, configsNoIdResource) {
8376 var vm = this;
8377 vm.loading = {config: true};
8378
8379 var filters = [
8380 'template_footer_html:global',
8381 'list_groups_to_non_admins:global',
8382 'per_application_reports_rate_limit:global',
8383 'per_application_logs_rate_limit:global',
8384 'per_application_metrics_rate_limit:global',
8385 ];
8386
8387 vm.configs = {};
8388
8389 vm.configList = configsResource.query({filter: filters},
8390 function (data) {
8391 vm.loading = {config: false};
8392 _.each(data, function (item) {
8393 if (vm.configs[item.section] === undefined) {
8394 vm.configs[item.section] = {};
8395 }
8396 vm.configs[item.section][item.key] = item;
8397 });
8398 });
8399
8400 vm.save = function () {
8101 8401 vm.loading.config = true;
8102 8402 _.each(vm.configList, function (item) {
8103 8403 item.$save();
@@ -9076,226 +9376,36 b' function EventsController(eventsNoIdResource, eventsResource) {'
9076 9376 eventsResource.update({eventId: event.id}, {status: 0}, function (data) {
9077 9377 event.status = 0;
9078 9378 });
9079 }
9080
9081 }
9082
9083 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
9084 // #
9085 // # This program is free software: you can redistribute it and/or modify
9086 // # it under the terms of the GNU Affero General Public License, version 3
9087 // # (only), as published by the Free Software Foundation.
9088 // #
9089 // # This program is distributed in the hope that it will be useful,
9090 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9091 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9092 // # GNU General Public License for more details.
9093 // #
9094 // # You should have received a copy of the GNU Affero General Public License
9095 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
9096 // #
9097 // # This program is dual-licensed. If you wish to learn more about the
9098 // # AppEnlight Enterprise Edition, including its added features, Support
9099 // # services, and proprietary license terms, please see
9100 // # https://rhodecode.com/licenses/
9101
9102 angular.module('appenlight.controllers').controller('IndexCtrl', IndexCtrl);
9103
9104 IndexCtrl.$inject = [IndexCtrl];
9105
9106 function IndexCtrl() {
9107 var vm = this;
9108 vm.selected_section = 'errors';
9109 }
9110
9111 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
9112 // #
9113 // # This program is free software: you can redistribute it and/or modify
9114 // # it under the terms of the GNU Affero General Public License, version 3
9115 // # (only), as published by the Free Software Foundation.
9116 // #
9117 // # This program is distributed in the hope that it will be useful,
9118 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9119 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9120 // # GNU General Public License for more details.
9121 // #
9122 // # You should have received a copy of the GNU Affero General Public License
9123 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
9124 // #
9125 // # This program is dual-licensed. If you wish to learn more about the
9126 // # AppEnlight Enterprise Edition, including its added features, Support
9127 // # services, and proprietary license terms, please see
9128 // # https://rhodecode.com/licenses/
9129
9130 angular.module('appenlight.controllers')
9131 .controller('BitbucketIntegrationCtrl', BitbucketIntegrationCtrl)
9132
9133 BitbucketIntegrationCtrl.$inject = ['$uibModalInstance', '$state', 'report', 'integrationName', 'integrationResource'];
9134
9135 function BitbucketIntegrationCtrl($uibModalInstance, $state, report, integrationName, integrationResource) {
9136 var vm = this;
9137 vm.loading = true;
9138 vm.assignees = [];
9139 vm.report = report;
9140 vm.integrationName = integrationName;
9141 vm.statuses = [];
9142 vm.priorities = [];
9143 vm.error_messages = [];
9144 vm.form = {
9145 content: '\n' +
9146 'Issue created for report: ' +
9147 $state.href('report.view_detail', {groupId:report.group_id, reportId:report.id}, {absolute:true})
9148 };
9149
9150 vm.fetchInfo = function () {
9151 integrationResource.get({
9152 resourceId: vm.report.resource_id,
9153 action: 'info',
9154 integration: vm.integrationName
9155 }, null,
9156 function (data) {
9157 vm.loading = false;
9158 if (data.error_messages) {
9159 vm.error_messages = data.error_messages;
9160 }
9161 vm.assignees = data.assignees;
9162 vm.priorities = data.priorities;
9163 vm.form.responsible = vm.assignees[0];
9164 vm.form.priority = vm.priorities[0];
9165 }, function (error_data) {
9166 if (error_data.data.error_messages) {
9167 vm.error_messages = error_data.data.error_messages;
9168 }
9169 else {
9170 vm.error_messages = ['There was a problem processing your request'];
9171 }
9172 });
9173 };
9174 vm.ok = function () {
9175 vm.loading = true;
9176 vm.form.group_id = vm.report.group_id;
9177 integrationResource.save({
9178 resourceId: vm.report.resource_id,
9179 action: 'create-issue',
9180 integration: vm.integrationName
9181 }, vm.form,
9182 function (data) {
9183 vm.loading = false;
9184 if (data.error_messages) {
9185 vm.error_messages = data.error_messages;
9186 }
9187 if (data !== false) {
9188 $uibModalInstance.dismiss('success');
9189 }
9190 }, function (error_data) {
9191 if (error_data.data.error_messages) {
9192 vm.error_messages = error_data.data.error_messages;
9193 }
9194 else {
9195 vm.error_messages = ['There was a problem processing your request'];
9196 }
9197 });
9198 };
9199 vm.cancel = function () {
9200 $uibModalInstance.dismiss('cancel');
9201 };
9202 vm.fetchInfo();
9203 }
9204
9205 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
9206 // #
9207 // # This program is free software: you can redistribute it and/or modify
9208 // # it under the terms of the GNU Affero General Public License, version 3
9209 // # (only), as published by the Free Software Foundation.
9210 // #
9211 // # This program is distributed in the hope that it will be useful,
9212 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9213 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9214 // # GNU General Public License for more details.
9215 // #
9216 // # You should have received a copy of the GNU Affero General Public License
9217 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
9218 // #
9219 // # This program is dual-licensed. If you wish to learn more about the
9220 // # AppEnlight Enterprise Edition, including its added features, Support
9221 // # services, and proprietary license terms, please see
9222 // # https://rhodecode.com/licenses/
9223
9224 angular.module('appenlight.controllers')
9225 .controller('GithubIntegrationCtrl', GithubIntegrationCtrl);
9226
9227 GithubIntegrationCtrl.$inject = ['$uibModalInstance', '$state', 'report', 'integrationName', 'integrationResource'];
9228
9229 function GithubIntegrationCtrl($uibModalInstance, $state, report, integrationName, integrationResource) {
9230 var vm = this;
9231 vm.loading = true;
9232 vm.assignees = [];
9233 vm.report = report;
9234 vm.integrationName = integrationName;
9235 vm.statuses = [];
9236 vm.assignees = [];
9237 vm.error_messages = [];
9238 vm.form = {
9239 content: '\n' +
9240 'Issue created for report: ' +
9241 $state.href('report.view_detail', {groupId:report.group_id, reportId:report.id}, {absolute:true})
9242 };
9243
9244 vm.fetchInfo = function () {
9245 integrationResource.get({
9246 resourceId: vm.report.resource_id,
9247 action: 'info',
9248 integration: vm.integrationName
9249 }, null,
9250 function (data) {
9251 vm.loading = false;
9252 if (data.error_messages) {
9253 vm.error_messages = data.error_messages;
9254 }
9255 else {
9256 vm.assignees = data.assignees;
9257 vm.statuses = data.statuses;
9258 vm.form.responsible = vm.assignees[0];
9259 vm.form.status = vm.statuses[0];
9260 }
9261 }, function (error_data) {
9262 if (error_data.data.error_messages) {
9263 vm.error_messages = error_data.data.error_messages;
9264 }
9265 else {
9266 vm.error_messages = ['There was a problem processing your request'];
9267 }
9268 });
9269 };
9270 vm.ok = function () {
9271 vm.loading = true;
9272 vm.form.group_id = vm.report.group_id;
9273 integrationResource.save({
9274 resourceId: vm.report.resource_id,
9275 action: 'create-issue',
9276 integration: vm.integrationName
9277 }, vm.form,
9278 function (data) {
9279 vm.loading = false;
9280 if (data.error_messages) {
9281 vm.error_messages = data.error_messages;
9282 }
9283 else {
9284 $uibModalInstance.dismiss('success');
9285 }
9286 }, function (error_data) {
9287 if (error_data.data.error_messages) {
9288 vm.error_messages = error_data.data.error_messages;
9289 }
9290 else {
9291 vm.error_messages = ['There was a problem processing your request'];
9292 }
9293 });
9294 };
9295 vm.cancel = function () {
9296 $uibModalInstance.dismiss('cancel');
9297 };
9298 vm.fetchInfo();
9379 }
9380
9381 }
9382
9383 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
9384 // #
9385 // # This program is free software: you can redistribute it and/or modify
9386 // # it under the terms of the GNU Affero General Public License, version 3
9387 // # (only), as published by the Free Software Foundation.
9388 // #
9389 // # This program is distributed in the hope that it will be useful,
9390 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9391 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9392 // # GNU General Public License for more details.
9393 // #
9394 // # You should have received a copy of the GNU Affero General Public License
9395 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
9396 // #
9397 // # This program is dual-licensed. If you wish to learn more about the
9398 // # AppEnlight Enterprise Edition, including its added features, Support
9399 // # services, and proprietary license terms, please see
9400 // # https://rhodecode.com/licenses/
9401
9402 angular.module('appenlight.controllers').controller('IndexCtrl', IndexCtrl);
9403
9404 IndexCtrl.$inject = [IndexCtrl];
9405
9406 function IndexCtrl() {
9407 var vm = this;
9408 vm.selected_section = 'errors';
9299 9409 }
9300 9410
9301 9411 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
@@ -9318,11 +9428,11 b' function GithubIntegrationCtrl($uibModalInstance, $state, report, integrationNam'
9318 9428 // # https://rhodecode.com/licenses/
9319 9429
9320 9430 angular.module('appenlight.controllers')
9321 .controller('JiraIntegrationCtrl', JiraIntegrationCtrl)
9431 .controller('BitbucketIntegrationCtrl', BitbucketIntegrationCtrl)
9322 9432
9323 JiraIntegrationCtrl.$inject = ['$uibModalInstance', '$state', 'report', 'integrationName', 'integrationResource'];
9433 BitbucketIntegrationCtrl.$inject = ['$uibModalInstance', '$state', 'report', 'integrationName', 'integrationResource'];
9324 9434
9325 function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName, integrationResource) {
9435 function BitbucketIntegrationCtrl($uibModalInstance, $state, report, integrationName, integrationResource) {
9326 9436 var vm = this;
9327 9437 vm.loading = true;
9328 9438 vm.assignees = [];
@@ -9330,7 +9440,6 b' function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName,'
9330 9440 vm.integrationName = integrationName;
9331 9441 vm.statuses = [];
9332 9442 vm.priorities = [];
9333 vm.issue_types = [];
9334 9443 vm.error_messages = [];
9335 9444 vm.form = {
9336 9445 content: '\n' +
@@ -9351,12 +9460,9 b' function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName,'
9351 9460 }
9352 9461 vm.assignees = data.assignees;
9353 9462 vm.priorities = data.priorities;
9354 vm.issue_types = data.issue_types;
9355 vm.form.issue_type = vm.issue_types[0];
9356 9463 vm.form.responsible = vm.assignees[0];
9357 9464 vm.form.priority = vm.priorities[0];
9358 9465 }, function (error_data) {
9359
9360 9466 if (error_data.data.error_messages) {
9361 9467 vm.error_messages = error_data.data.error_messages;
9362 9468 }
@@ -9375,320 +9481,121 b' function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName,'
9375 9481 }, vm.form,
9376 9482 function (data) {
9377 9483 vm.loading = false;
9378 if (data.error_messages) {
9379 vm.error_messages = data.error_messages;
9380 }
9381 if (data !== false) {
9382 $uibModalInstance.dismiss('success');
9383 }
9384 }, function (error_data) {
9385 if (error_data.data.error_messages) {
9386 vm.error_messages = error_data.data.error_messages;
9387 }
9388 else {
9389 vm.error_messages = ['There was a problem processing your request'];
9390 }
9391 });
9392 };
9393 vm.cancel = function () {
9394 $uibModalInstance.dismiss('cancel');
9395 };
9396 vm.fetchInfo();
9397 }
9398
9399 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
9400 // #
9401 // # This program is free software: you can redistribute it and/or modify
9402 // # it under the terms of the GNU Affero General Public License, version 3
9403 // # (only), as published by the Free Software Foundation.
9404 // #
9405 // # This program is distributed in the hope that it will be useful,
9406 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9407 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9408 // # GNU General Public License for more details.
9409 // #
9410 // # You should have received a copy of the GNU Affero General Public License
9411 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
9412 // #
9413 // # This program is dual-licensed. If you wish to learn more about the
9414 // # AppEnlight Enterprise Edition, including its added features, Support
9415 // # services, and proprietary license terms, please see
9416 // # https://rhodecode.com/licenses/
9417
9418 angular.module('appenlight.controllers').controller('LogsController', LogsController);
9419
9420 LogsController.$inject = ['$location', 'stateHolder', 'typeAheadTagHelper', 'logsNoIdResource', 'sectionViewResource'];
9421
9422 function LogsController($location, stateHolder, typeAheadTagHelper, logsNoIdResource, sectionViewResource) {
9423 var vm = this;
9424 vm.logEventsChartConfig = {
9425 data: {
9426 json: [],
9427 xFormat: '%Y-%m-%dT%H:%M:%S'
9428 },
9429 color: {
9430 pattern: ['#6baed6', '#e6550d', '#74c476', '#fdd0a2', '#8c564b']
9431 },
9432 axis: {
9433 x: {
9434 type: 'timeseries',
9435 tick: {
9436 format: '%Y-%m-%d'
9437 }
9438 },
9439 y: {
9440 tick: {
9441 count: 5,
9442 format: d3.format('.2s')
9443 }
9444 }
9445 },
9446 subchart: {
9447 show: true,
9448 size: {
9449 height: 20
9450 }
9451 },
9452 size: {
9453 height: 250
9454 },
9455 zoom: {
9456 rescale: true
9457 },
9458 grid: {
9459 x: {
9460 show: true
9461 },
9462 y: {
9463 show: true
9464 }
9465 },
9466 tooltip: {
9467 format: {
9468 title: function (d) {
9469 return '' + d;
9470 },
9471 value: function (v) {
9472 return v
9473 }
9474 }
9475 }
9476 };
9477 vm.logEventsChartData = {};
9478 stateHolder.section = 'logs';
9479 vm.today = function () {
9480 vm.pickerDate = new Date();
9481 };
9482 vm.today();
9483
9484 vm.applications = stateHolder.AeUser.applications_map;
9485 vm.logsPage = [];
9486 vm.itemCount = 0;
9487 vm.itemsPerPage = 250;
9488 vm.page = 1;
9489 vm.$location = $location;
9490 vm.isLoading = {
9491 logs: true,
9492 series: true
9493 };
9494 vm.filterTypeAheadOptions = [
9495 {
9496 type: 'message',
9497 text: 'message:',
9498 'description': 'Full-text search in your logs',
9499 tag: 'Message',
9500 example: 'message:text-im-looking-for'
9501 },
9502 {
9503 type: 'namespace',
9504 text: 'namespace:',
9505 'description': 'Query logs from specific namespace',
9506 tag: 'Namespace',
9507 example: "namespace:module.foo"
9508 },
9509 {
9510 type: 'resource',
9511 text: 'resource:',
9512 'description': 'Restrict resultset to application',
9513 tag: 'Application',
9514 example: "resource:ID"
9515 },
9516 {
9517 type: 'request_id',
9518 text: 'request_id:',
9519 'description': 'Show logs with specific request id',
9520 example: "request_id:883143dc572e4c38aceae92af0ea5ae0",
9521 tag: 'Request ID'
9522 },
9523 {
9524 type: 'level',
9525 text: 'level:',
9526 'description': 'Show entries with specific log level',
9527 example: 'level:warning',
9528 tag: 'Level'
9529 },
9530 {
9531 type: 'server_name',
9532 text: 'server_name:',
9533 'description': 'Show entries tagged with this key/value pair',
9534 example: 'server_name:hostname',
9535 tag: 'Tag'
9536 },
9537 {
9538 type: 'start_date',
9539 text: 'start_date:',
9540 'description': 'Show results newer than this date (press TAB for dropdown)',
9541 example: 'start_date:2014-08-15T13:00',
9542 tag: 'Start Date'
9543 },
9544 {
9545 type: 'end_date',
9546 text: 'end_date:',
9547 'description': 'Show results older than this date (press TAB for dropdown)',
9548 example: 'start_date:2014-08-15T23:59',
9549 tag: 'End Date'
9550 },
9551 {type: 'level', value: 'debug', text: 'level:debug'},
9552 {type: 'level', value: 'info', text: 'level:info'},
9553 {type: 'level', value: 'warning', text: 'level:warning'},
9554 {type: 'level', value: 'critical', text: 'level:critical'}
9555 ];
9556 vm.filterTypeAhead = null;
9557 vm.showDatePicker = false;
9558 vm.manualOpen = false;
9559 vm.aheadFilter = typeAheadTagHelper.aheadFilter;
9560 vm.removeSearchTag = function (tag) {
9561 $location.search(tag.type, null);
9562 vm.refresh();
9563 };
9564 vm.addSearchTag = function (tag) {
9565 $location.search(tag.type, tag.value);
9566 vm.refresh();
9567 };
9568
9569 vm.paginationChange = function(){
9570 $location.search('page', vm.page);
9571 vm.refresh();
9572 };
9573
9574
9575 _.each(vm.applications, function (item) {
9576 vm.filterTypeAheadOptions.push({
9577 type: 'resource',
9578 text: 'resource:' + item.resource_id + ':' + item.resource_name,
9579 example: 'resource:' + item.resource_id,
9580 'tag': item.resource_name,
9581 'description': 'Restrict resultset to this application'
9582 });
9583 });
9584
9585 vm.typeAheadTag = function (event) {
9586 var text = vm.filterTypeAhead;
9587 if (_.isObject(vm.filterTypeAhead)) {
9588 text = vm.filterTypeAhead.text;
9589 };
9590 if (!vm.filterTypeAhead) {
9591 return
9484 if (data.error_messages) {
9485 vm.error_messages = data.error_messages;
9592 9486 }
9593 var parsed = text.split(':');
9594 var tag = {'type': null, 'value': null};
9595 // app tags have : twice
9596 if (parsed.length > 2 && parsed[0] == 'resource') {
9597 tag.type = 'resource';
9598 tag.value = parsed[1];
9487 if (data !== false) {
9488 $uibModalInstance.dismiss('success');
9599 9489 }
9600 // normal tag:value
9601 else if (parsed.length > 1) {
9602 tag.type = parsed[0];
9603 tag.value = parsed.slice(1).join(':');
9490 }, function (error_data) {
9491 if (error_data.data.error_messages) {
9492 vm.error_messages = error_data.data.error_messages;
9604 9493 }
9605 9494 else {
9606 tag.type = 'message';
9607 tag.value = parsed.join(':');
9608 }
9609
9610 // set datepicker hour based on type of field
9611 if ('start_date:' == text) {
9612 vm.showDatePicker = true;
9613 vm.filterTypeAhead = 'start_date:' + moment(vm.pickerDate).utc().format();
9495 vm.error_messages = ['There was a problem processing your request'];
9614 9496 }
9615 else if ('end_date:' == text) {
9616 vm.showDatePicker = true;
9617 vm.filterTypeAhead = 'end_date:' + moment(vm.pickerDate).utc().hour(23).minute(59).format();
9497 });
9498 };
9499 vm.cancel = function () {
9500 $uibModalInstance.dismiss('cancel');
9501 };
9502 vm.fetchInfo();
9618 9503 }
9619 9504
9620 if (event.keyCode != 13 || !tag.type || !tag.value) {
9621 return
9622 }
9623 vm.showDatePicker = false;
9624 // aka we selected one of main options
9625 vm.addSearchTag({type: tag.type, value: tag.value});
9626 // clear typeahead
9627 vm.filterTypeAhead = undefined;
9628 };
9505 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
9506 // #
9507 // # This program is free software: you can redistribute it and/or modify
9508 // # it under the terms of the GNU Affero General Public License, version 3
9509 // # (only), as published by the Free Software Foundation.
9510 // #
9511 // # This program is distributed in the hope that it will be useful,
9512 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9513 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9514 // # GNU General Public License for more details.
9515 // #
9516 // # You should have received a copy of the GNU Affero General Public License
9517 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
9518 // #
9519 // # This program is dual-licensed. If you wish to learn more about the
9520 // # AppEnlight Enterprise Edition, including its added features, Support
9521 // # services, and proprietary license terms, please see
9522 // # https://rhodecode.com/licenses/
9629 9523
9524 angular.module('appenlight.controllers')
9525 .controller('GithubIntegrationCtrl', GithubIntegrationCtrl);
9630 9526
9631 vm.pickerDateChanged = function(){
9632 if (vm.filterTypeAhead.indexOf('start_date:') == '0') {
9633 vm.filterTypeAhead = 'start_date:' + moment(vm.pickerDate).utc().format();
9634 }
9635 else if (vm.filterTypeAhead.indexOf('end_date:') == '0') {
9636 vm.filterTypeAhead = 'end_date:' + moment(vm.pickerDate).utc().hour(23).minute(59).format();
9637 }
9638 vm.showDatePicker = false;
9639 };
9527 GithubIntegrationCtrl.$inject = ['$uibModalInstance', '$state', 'report', 'integrationName', 'integrationResource'];
9640 9528
9641 vm.fetchLogs = function (searchParams) {
9642 vm.isLoading.logs = true;
9643 logsNoIdResource.query(searchParams, function (data, getResponseHeaders) {
9644 vm.isLoading.logs = false;
9645 var headers = getResponseHeaders();
9646 vm.logsPage = data;
9647 vm.itemCount = headers['x-total-count'];
9648 vm.itemsPerPage = headers['x-items-per-page'];
9649 }, function () {
9650 vm.isLoading.logs = false;
9651 });
9529 function GithubIntegrationCtrl($uibModalInstance, $state, report, integrationName, integrationResource) {
9530 var vm = this;
9531 vm.loading = true;
9532 vm.assignees = [];
9533 vm.report = report;
9534 vm.integrationName = integrationName;
9535 vm.statuses = [];
9536 vm.assignees = [];
9537 vm.error_messages = [];
9538 vm.form = {
9539 content: '\n' +
9540 'Issue created for report: ' +
9541 $state.href('report.view_detail', {groupId:report.group_id, reportId:report.id}, {absolute:true})
9652 9542 };
9653 9543
9654 vm.fetchSeriesData = function (searchParams) {
9655 searchParams['section'] = 'logs_section';
9656 searchParams['view'] = 'fetch_series';
9657 vm.isLoading.series = true;
9658 sectionViewResource.query(searchParams, function (data) {
9659
9660 vm.logEventsChartData = {
9661 json: data,
9662 xFormat: '%Y-%m-%dT%H:%M:%S',
9663 keys: {
9664 x: 'x',
9665 value: ["logs"]
9666 },
9667 names: {
9668 logs: 'Log events'
9669 },
9670 type: 'bar'
9671 };
9672 vm.isLoading.series = false;
9673 }, function () {
9674 vm.isLoading.series = false;
9544 vm.fetchInfo = function () {
9545 integrationResource.get({
9546 resourceId: vm.report.resource_id,
9547 action: 'info',
9548 integration: vm.integrationName
9549 }, null,
9550 function (data) {
9551 vm.loading = false;
9552 if (data.error_messages) {
9553 vm.error_messages = data.error_messages;
9554 }
9555 else {
9556 vm.assignees = data.assignees;
9557 vm.statuses = data.statuses;
9558 vm.form.responsible = vm.assignees[0];
9559 vm.form.status = vm.statuses[0];
9560 }
9561 }, function (error_data) {
9562 if (error_data.data.error_messages) {
9563 vm.error_messages = error_data.data.error_messages;
9564 }
9565 else {
9566 vm.error_messages = ['There was a problem processing your request'];
9567 }
9675 9568 });
9676 9569 };
9677
9678 vm.filterId = function (log) {
9679 $location.search('request_id', log.request_id);
9680 vm.refresh();
9570 vm.ok = function () {
9571 vm.loading = true;
9572 vm.form.group_id = vm.report.group_id;
9573 integrationResource.save({
9574 resourceId: vm.report.resource_id,
9575 action: 'create-issue',
9576 integration: vm.integrationName
9577 }, vm.form,
9578 function (data) {
9579 vm.loading = false;
9580 if (data.error_messages) {
9581 vm.error_messages = data.error_messages;
9582 }
9583 else {
9584 $uibModalInstance.dismiss('success');
9585 }
9586 }, function (error_data) {
9587 if (error_data.data.error_messages) {
9588 vm.error_messages = error_data.data.error_messages;
9589 }
9590 else {
9591 vm.error_messages = ['There was a problem processing your request'];
9592 }
9593 });
9681 9594 };
9682
9683 vm.refresh = function(){
9684 vm.searchParams = parseSearchToTags($location.search());
9685 vm.page = Number(vm.searchParams.page) || 1;
9686 var params = parseTagsToSearch(vm.searchParams);
9687 vm.fetchLogs(params);
9688 vm.fetchSeriesData(params);
9595 vm.cancel = function () {
9596 $uibModalInstance.dismiss('cancel');
9689 9597 };
9690 console.info('page load');
9691 vm.refresh();
9598 vm.fetchInfo();
9692 9599 }
9693 9600
9694 9601 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
@@ -9711,12 +9618,82 b' function LogsController($location, stateHolder, typeAheadTagHelper, logsNoIdReso'
9711 9618 // # https://rhodecode.com/licenses/
9712 9619
9713 9620 angular.module('appenlight.controllers')
9714 .controller('OverviewCtrl', OverviewCtrl);
9621 .controller('JiraIntegrationCtrl', JiraIntegrationCtrl)
9715 9622
9716 OverviewCtrl.$inject = [];
9623 JiraIntegrationCtrl.$inject = ['$uibModalInstance', '$state', 'report', 'integrationName', 'integrationResource'];
9624
9625 function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName, integrationResource) {
9626 var vm = this;
9627 vm.loading = true;
9628 vm.assignees = [];
9629 vm.report = report;
9630 vm.integrationName = integrationName;
9631 vm.statuses = [];
9632 vm.priorities = [];
9633 vm.issue_types = [];
9634 vm.error_messages = [];
9635 vm.form = {
9636 content: '\n' +
9637 'Issue created for report: ' +
9638 $state.href('report.view_detail', {groupId:report.group_id, reportId:report.id}, {absolute:true})
9639 };
9717 9640
9718 function OverviewCtrl() {
9641 vm.fetchInfo = function () {
9642 integrationResource.get({
9643 resourceId: vm.report.resource_id,
9644 action: 'info',
9645 integration: vm.integrationName
9646 }, null,
9647 function (data) {
9648 vm.loading = false;
9649 if (data.error_messages) {
9650 vm.error_messages = data.error_messages;
9651 }
9652 vm.assignees = data.assignees;
9653 vm.priorities = data.priorities;
9654 vm.issue_types = data.issue_types;
9655 vm.form.issue_type = vm.issue_types[0];
9656 vm.form.responsible = vm.assignees[0];
9657 vm.form.priority = vm.priorities[0];
9658 }, function (error_data) {
9719 9659
9660 if (error_data.data.error_messages) {
9661 vm.error_messages = error_data.data.error_messages;
9662 }
9663 else {
9664 vm.error_messages = ['There was a problem processing your request'];
9665 }
9666 });
9667 };
9668 vm.ok = function () {
9669 vm.loading = true;
9670 vm.form.group_id = vm.report.group_id;
9671 integrationResource.save({
9672 resourceId: vm.report.resource_id,
9673 action: 'create-issue',
9674 integration: vm.integrationName
9675 }, vm.form,
9676 function (data) {
9677 vm.loading = false;
9678 if (data.error_messages) {
9679 vm.error_messages = data.error_messages;
9680 }
9681 if (data !== false) {
9682 $uibModalInstance.dismiss('success');
9683 }
9684 }, function (error_data) {
9685 if (error_data.data.error_messages) {
9686 vm.error_messages = error_data.data.error_messages;
9687 }
9688 else {
9689 vm.error_messages = ['There was a problem processing your request'];
9690 }
9691 });
9692 };
9693 vm.cancel = function () {
9694 $uibModalInstance.dismiss('cancel');
9695 };
9696 vm.fetchInfo();
9720 9697 }
9721 9698
9722 9699 ;// # Copyright (C) 2010-2016 RhodeCode GmbH
@@ -12357,8 +12334,7 b" angular.module('appenlight').config(['$stateProvider', '$urlRouterProvider', fun"
12357 12334
12358 12335 $stateProvider.state('logs', {
12359 12336 url: '/ui/logs?resource',
12360 templateUrl: 'templates/logs.html',
12361 controller: 'LogsController as logs'
12337 component: 'logsBrowserView'
12362 12338 });
12363 12339
12364 12340 $stateProvider.state('front_dashboard', {
@@ -43,7 +43,8 b" angular.module('appenlight.components', ["
43 43 'appenlight.components.channelstream',
44 44 'appenlight.components.appenlightApp',
45 45 'appenlight.components.appenlightHeader',
46 'appenlight.components.indexDashboardView'
46 'appenlight.components.indexDashboardView',
47 'appenlight.components.logsBrowserView',
47 48 ]);
48 49 angular.module('appenlight.directives', [
49 50 'appenlight.directives.c3chart',
@@ -1,14 +1,14 b''
1 <ng-include src="'templates/loader.html'" ng-if="logs.isLoading.logs"></ng-include>
1 <ng-include src="'templates/loader.html'" ng-if="$ctrl.isLoading.logs"></ng-include>
2 2
3 <div ng-if="logs.isLoading.logs === false">
3 <div ng-if="$ctrl.isLoading.logs === false">
4 4
5 5 <p class="search-params">
6 6 <strong>Search params:</strong>
7 <span ng-repeat="tag in logs.searchParams.tags" class="tag">
7 <span ng-repeat="tag in $ctrl.searchParams.tags" class="tag">
8 8 <strong>{{tag.type}}</strong>
9 {{ tag.type == 'resource' ? logs.applications[tag.value].resource_name : tag.value }}
9 {{ tag.type == 'resource' ? $ctrl.applications[tag.value].resource_name : tag.value }}
10 10
11 <a ng-click="logs.removeSearchTag(tag)"><span class="fa fa-times"></span></a>
11 <a ng-click="$ctrl.removeSearchTag(tag)"><span class="fa fa-times"></span></a>
12 12 </span>
13 13 </p>
14 14
@@ -20,15 +20,15 b''
20 20
21 21 <form class="form">
22 22 <div class="typeahead-tags">
23 <input type="text" id="typeAhead" ng-model="logs.filterTypeAhead" placeholder="Start typing to filter logs for events, filter by servers, namespaces, levels."
24 ng-keydown="logs.typeAheadTag($event)"
25 uib-typeahead="tag as tag.text for tag in logs.filterTypeAheadOptions | filter:$viewValue:logs.aheadFilter"
23 <input type="text" id="typeAhead" ng-model="$ctrl.filterTypeAhead" placeholder="Start typing to filter logs for events, filter by servers, namespaces, levels."
24 ng-keydown="$ctrl.typeAheadTag($event)"
25 uib-typeahead="tag as tag.text for tag in $ctrl.filterTypeAheadOptions | filter:$viewValue:$ctrl.aheadFilter"
26 26 typeahead-min-length="1" class="form-control"
27 27 typeahead-template-url="templates/directives/search_type_ahead.html">
28 28 </div>
29 29 </form>
30 30
31 <div class="well animate-show position-absolute increse-zindex" ng-if="logs.showDatePicker" ng-model="logs.pickerDate" ng-change="logs.pickerDateChanged()">
31 <div class="well animate-show position-absolute increse-zindex" ng-if="$ctrl.showDatePicker" ng-model="$ctrl.pickerDate" ng-change="$ctrl.pickerDateChanged()">
32 32 <uib-datepicker></uib-datepicker>
33 33 </div>
34 34
@@ -37,15 +37,15 b''
37 37 <div class="panel">
38 38
39 39 <div class="panel-body">
40 <c3chart data-domid="log_events_chart" data-data="logs.logEventsChartData" data-config="logs.logEventsChartConfig">
40 <c3chart data-domid="log_events_chart" data-data="$ctrl.logEventsChartData" data-config="$ctrl.logEventsChartConfig">
41 41 </c3chart>
42 42 </div>
43 43 </div>
44 44
45 45
46 46 <div class="text-center">
47 <uib-pagination total-items="logs.itemCount" items-per-page="logs.itemsPerPage" ng-model="logs.page" max-size="10"
48 ng-change="logs.paginationChange()"
47 <uib-pagination total-items="$ctrl.itemCount" items-per-page="$ctrl.itemsPerPage" ng-model="$ctrl.page" max-size="10"
48 ng-change="$ctrl.paginationChange()"
49 49 class="pagination pagination-sm" boundary-links="true" direction-links="false"></uib-pagination>
50 50 </div>
51 51
@@ -61,22 +61,22 b''
61 61 </tr>
62 62 </thead>
63 63 <tbody>
64 <tr ng-repeat="log in logs.logsPage track by log.log_id" class="{{$odd ? 'odd' : 'even'}}">
64 <tr ng-repeat="log in $ctrl.logsPage track by log.log_id" class="{{$odd ? 'odd' : 'even'}}">
65 65 <td class="c1">
66 <a class="tag application" ng-click="logs.addSearchTag({type:'resource', value:log.resource_id})">
66 <a class="tag application" ng-click="$ctrl.addSearchTag({type:'resource', value:log.resource_id})">
67 67 <span class="name">{{log.resource_name}}</span></a>
68 68 </td>
69 69 <td class="c2">
70 <a class="tag {{log.log_level|lowercase}}" ng-click="logs.addSearchTag({type:'level', value:log.log_level})">
70 <a class="tag {{log.log_level|lowercase}}" ng-click="$ctrl.addSearchTag({type:'level', value:log.log_level})">
71 71 <span class="name">level:</span> {{log.log_level}}</a>
72 <a class="tag" ng-click="logs.addSearchTag({type:'namespace', value:log.namespace})">
72 <a class="tag" ng-click="$ctrl.addSearchTag({type:'namespace', value:log.namespace})">
73 73 <span class="name">namespace:</span> {{log.namespace}}</a>
74 <a ng-repeat="(tag, value) in log.tags" class="tag" ng-click="logs.addSearchTag({type:tag, value:value})">
74 <a ng-repeat="(tag, value) in log.tags" class="tag" ng-click="$ctrl.addSearchTag({type:tag, value:value})">
75 75 <span class="name">{{tag}}:</span> {{value}}</a>
76 76 <div class="log">{{log.message}}</div>
77 77 </td>
78 78 <td class="c3 when">
79 <a ng-click="logs.filterId(log)" data-uib-tooltip="{{log.timestamp}}">
79 <a ng-click="$ctrl.filterId(log)" data-uib-tooltip="{{log.timestamp}}">
80 80 <iso-to-relative-time time="{{log.timestamp}}"/>
81 81 </a>
82 82 </td>
@@ -88,8 +88,8 b''
88 88 </div>
89 89
90 90 <div class="text-center">
91 <uib-pagination total-items="logs.itemCount" items-per-page="logs.itemsPerPage" ng-model="logs.page" max-size="10"
92 ng-change="logs.paginationChange()"
91 <uib-pagination total-items="$ctrl.itemCount" items-per-page="$ctrl.itemsPerPage" ng-model="$ctrl.page" max-size="10"
92 ng-change="$ctrl.paginationChange()"
93 93 class="pagination pagination-sm" boundary-links="true" direction-links="false"></uib-pagination>
94 94 </div>
95 95
@@ -17,11 +17,15 b''
17 17 // # services, and proprietary license terms, please see
18 18 // # https://rhodecode.com/licenses/
19 19
20 angular.module('appenlight.controllers').controller('LogsController', LogsController);
20 angular.module('appenlight.components.logsBrowserView', [])
21 .component('logsBrowserView', {
22 templateUrl: 'components/views/logs-browser/logs-browser.html',
23 controller: LogsBrowserController
24 });
21 25
22 LogsController.$inject = ['$location', 'stateHolder', 'typeAheadTagHelper', 'logsNoIdResource', 'sectionViewResource'];
26 LogsBrowserController.$inject = ['$location', 'stateHolder', 'typeAheadTagHelper', 'logsNoIdResource', 'sectionViewResource'];
23 27
24 function LogsController($location, stateHolder, typeAheadTagHelper, logsNoIdResource, sectionViewResource) {
28 function LogsBrowserController($location, stateHolder, typeAheadTagHelper, logsNoIdResource, sectionViewResource) {
25 29 var vm = this;
26 30 vm.logEventsChartConfig = {
27 31 data: {
@@ -23,8 +23,7 b" angular.module('appenlight').config(['$stateProvider', '$urlRouterProvider', fun"
23 23
24 24 $stateProvider.state('logs', {
25 25 url: '/ui/logs?resource',
26 templateUrl: 'templates/logs.html',
27 controller: 'LogsController as logs'
26 component: 'logsBrowserView'
28 27 });
29 28
30 29 $stateProvider.state('front_dashboard', {
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now