##// END OF EJS Templates
flash: re-add flash messages to top application component
ergo -
Show More
@@ -1,18 +1,11 b''
1 1 {% extends "/layout_base.jinja2" %}
2 2
3 3 {% block outer_content %}
4 4 <!-- Begin page content -->
5 5 <div class="container">
6 <div class="row ng-cloak" data-ng-if="flash.length" style="margin-bottom: 10px">
7 <div class="col-xs-12">
8 {% raw %}
9 <uib-alert data-ng-repeat="message in flash" type="{{ message.type}}" close="closeAlert($index)" class="animate-repeat">{{message.msg}}</uib-alert>
10 {% endraw %}
11 </div>
12 </div>
13 6 <div class="row">
14 7 {% block content %}{% endblock %}
15 8 </div>
16 9 </div>
17 10
18 11 {% endblock %}
@@ -1,203 +1,206 b''
1 1 // # Copyright (C) 2010-2016 RhodeCode GmbH
2 2 // #
3 3 // # This program is free software: you can redistribute it and/or modify
4 4 // # it under the terms of the GNU Affero General Public License, version 3
5 5 // # (only), as published by the Free Software Foundation.
6 6 // #
7 7 // # This program is distributed in the hope that it will be useful,
8 8 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 9 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 10 // # GNU General Public License for more details.
11 11 // #
12 12 // # You should have received a copy of the GNU Affero General Public License
13 13 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 14 // #
15 15 // # This program is dual-licensed. If you wish to learn more about the
16 16 // # AppEnlight Enterprise Edition, including its added features, Support
17 17 // # services, and proprietary license terms, please see
18 18 // # https://rhodecode.com/licenses/
19 19
20 20 'use strict';
21 21
22 22 // Declare app level module which depends on filters, and services
23 23 angular.module('appenlight.base', [
24 24 'ngRoute',
25 25 'ui.router',
26 26 'ui.router.router',
27 27 'underscore',
28 28 'ui.bootstrap',
29 29 'ngResource',
30 30 'ngAnimate',
31 31 'ngCookies',
32 32 'smart-table',
33 33 'angular-toArrayFilter',
34 34 'mentio'
35 35 ]);
36 36
37 37 angular.module('appenlight.filters', []);
38 38 angular.module('appenlight.templates', []);
39 39 angular.module('appenlight.controllers', [
40 40 'appenlight.base'
41 41 ]);
42 42 angular.module('appenlight.components', [
43 43 'appenlight.components.channelstream',
44 44 'appenlight.components.appenlightApp',
45 45 'appenlight.components.appenlightHeader',
46 46 'appenlight.components.indexDashboardView',
47 47 'appenlight.components.logsBrowserView',
48 'appenlight.components.eventBrowserView'
48 'appenlight.components.eventBrowserView',
49 'appenlight.components.userProfileView',
50 'appenlight.components.userIdentitiesView',
51 'appenlight.components.settingsView'
49 52 ]);
50 53 angular.module('appenlight.directives', [
51 54 'appenlight.directives.c3chart',
52 55 'appenlight.directives.confirmValidate',
53 56 'appenlight.directives.focus',
54 57 'appenlight.directives.formErrors',
55 58 'appenlight.directives.humanFormat',
56 59 'appenlight.directives.isoToRelativeTime',
57 60 'appenlight.directives.permissionsForm',
58 61 'appenlight.directives.smallReportGroupList',
59 62 'appenlight.directives.smallReportList',
60 63 'appenlight.directives.pluginConfig',
61 64 'appenlight.directives.recursive',
62 65 'appenlight.directives.reportAlertAction',
63 66 'appenlight.directives.postProcessAction',
64 67 'appenlight.directives.rule',
65 68 'appenlight.directives.ruleReadOnly'
66 69 ]);
67 70 angular.module('appenlight.services', [
68 71 'appenlight.services.chartResultParser',
69 72 'appenlight.services.resources',
70 73 'appenlight.services.stateHolder',
71 74 'appenlight.services.typeAheadTagHelper',
72 75 'appenlight.services.UUIDProvider'
73 76 ]).value('version', '0.1');
74 77
75 78
76 79 var pluginsToLoad = _.map(decodeEncodedJSON(window.AE.plugins),
77 80 function(item){
78 81 return item.config.angular_module
79 82 });
80 83 console.log(pluginsToLoad);
81 84 angular.module('appenlight.plugins', pluginsToLoad);
82 85
83 86 var app = angular.module('appenlight', [
84 87 'appenlight.base',
85 88 'appenlight.config',
86 89 'appenlight.templates',
87 90 'appenlight.filters',
88 91 'appenlight.services',
89 92 'appenlight.directives',
90 93 'appenlight.controllers',
91 94 'appenlight.components',
92 95 'appenlight.plugins'
93 96 ]);
94 97
95 98 // needs manual execution because of plugin files
96 99 function kickstartAE(initialUserData) {
97 100 app.config(['$httpProvider', '$uibTooltipProvider', '$locationProvider', function ($httpProvider, $uibTooltipProvider, $locationProvider) {
98 101 $locationProvider.html5Mode(true);
99 102 $httpProvider.interceptors.push(['$q', '$rootScope', '$timeout', 'stateHolder', function ($q, $rootScope, $timeout, stateHolder) {
100 103 return {
101 104 'response': function (response) {
102 105 var flashMessages = angular.fromJson(response.headers('x-flash-messages'));
103 106 if (flashMessages && flashMessages.length > 0) {
104 107 stateHolder.flashMessages.extend(flashMessages);
105 108 }
106 109 return response;
107 110 },
108 111 'responseError': function (rejection) {
109 112 if (rejection.status > 299 && rejection.status !== 422) {
110 113 stateHolder.flashMessages.extend([{
111 114 msg: 'Response status code: ' + rejection.status + ', "' + rejection.statusText + '", url: ' + rejection.config.url,
112 115 type: 'error'
113 116 }]);
114 117 }
115 118 if (rejection.status == 0) {
116 119 stateHolder.flashMessages.extend([{
117 120 msg: 'Response timeout',
118 121 type: 'error'
119 122 }]);
120 123 }
121 124 var flashMessages = angular.fromJson(rejection.headers('x-flash-messages'));
122 125 if (flashMessages && flashMessages.length > 0) {
123 126 stateHolder.flashMessages.extend(flashMessages);
124 127 }
125 128
126 129 return $q.reject(rejection);
127 130 }
128 131 }
129 132 }]);
130 133
131 134 $uibTooltipProvider.options({appendToBody: true});
132 135
133 136 }]);
134 137
135 138
136 139 app.config(function ($provide) {
137 140 $provide.decorator("$exceptionHandler", function ($delegate) {
138 141 return function (exception, cause) {
139 142 $delegate(exception, cause);
140 143 if (typeof AppEnlight !== 'undefined') {
141 144 AppEnlight.grabError(exception);
142 145 }
143 146 };
144 147 });
145 148 });
146 149
147 150 app.run(['$rootScope', '$timeout', 'stateHolder', '$state', '$location', '$transitions', '$window', 'AeConfig',
148 151 function ($rootScope, $timeout, stateHolder, $state, $location, $transitions, $window, AeConfig) {
149 152 if (initialUserData){
150 153 stateHolder.AeUser.update(initialUserData);
151 154 }
152 155 $rootScope.$state = $state;
153 156 $rootScope.stateHolder = stateHolder;
154 157 $rootScope.flash = stateHolder.flashMessages.list;
155 158 $rootScope.closeAlert = stateHolder.flashMessages.closeAlert;
156 159 $rootScope.AeConfig = AeConfig;
157 160
158 161 var transitionApp = function($transition$, $state) {
159 162 // redirect user to /register unless its one of open views
160 163 var isGuestState = [
161 164 'report.view_detail',
162 165 'report.view_group',
163 166 'dashboard.view'
164 167 ].indexOf($transition$.to().name) !== -1;
165 168
166 169 var path = $window.location.pathname;
167 170 // strip trailing slash
168 171 if (path.substr(path.length - 1) === '/') {
169 172 path = path.substr(0, path.length - 1);
170 173 }
171 174 var isOpenView = false;
172 175 var openViews = [
173 176 AeConfig.urls.otherRoutes.lostPassword,
174 177 AeConfig.urls.otherRoutes.lostPasswordGenerate
175 178 ];
176 179 console.log('$transitions.onBefore', path, $transition$.to().name, $state);
177 180 _.each(openViews, function (url) {
178 181 var url = '/' + url.split('/').slice(3).join('/');
179 182 if (url === path) {
180 183 isOpenView = true;
181 184 }
182 185 });
183 186 if (stateHolder.AeUser.id === null && !isGuestState && !isOpenView) {
184 187 if (window.location.toString().indexOf(AeConfig.urls.otherRoutes.register) === -1) {
185 188 console.log('redirect to register');
186 189 var newLocation = AeConfig.urls.otherRoutes.register + '?came_from=' + encodeURIComponent(window.location);
187 190 // fix infinite digest here
188 191 $rootScope.$on('$locationChangeStart',
189 192 function(event, toState, toParams, fromState, fromParams, options){
190 193 event.preventDefault();
191 194 $window.location = newLocation;
192 195 });
193 196 $window.location = newLocation;
194 197 return false;
195 198 }
196 199 return false;
197 200 }
198 201 return true;
199 202 };
200 203 $transitions.onBefore({}, transitionApp);
201 204
202 205 }]);
203 206 }
@@ -1,5 +1,16 b''
1 1 <channelstream config="AeConfig"></channelstream>
2 2 <appenlight-header></appenlight-header>
3 <div class="container" data-ng-if="flash.length">
4 <div class="row" style="margin-bottom: 10px">
5 <div class="col-xs-12">
6 <uib-alert data-ng-repeat="message in flash"
7 type="{{ message.type }}"
8 close="closeAlert($index)" class="animate-repeat">
9 {{ message.msg }}</uib-alert>
10 </div>
11 </div>
12 </div>
13
3 14 <div id="outer-content">
4 15 <div ui-view class="container"></div>
5 16 </div>
@@ -1,247 +1,244 b''
1 1 // # Copyright (C) 2010-2016 RhodeCode GmbH
2 2 // #
3 3 // # This program is free software: you can redistribute it and/or modify
4 4 // # it under the terms of the GNU Affero General Public License, version 3
5 5 // # (only), as published by the Free Software Foundation.
6 6 // #
7 7 // # This program is distributed in the hope that it will be useful,
8 8 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 9 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 10 // # GNU General Public License for more details.
11 11 // #
12 12 // # You should have received a copy of the GNU Affero General Public License
13 13 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 14 // #
15 15 // # This program is dual-licensed. If you wish to learn more about the
16 16 // # AppEnlight Enterprise Edition, including its added features, Support
17 17 // # services, and proprietary license terms, please see
18 18 // # https://rhodecode.com/licenses/
19 19
20 20 angular.module('appenlight').config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
21 21
22 22 $urlRouterProvider.otherwise('/ui');
23 23
24 24 $stateProvider.state('logs', {
25 25 url: '/ui/logs?resource',
26 26 component: 'logsBrowserView'
27 27 });
28 28
29 29 $stateProvider.state('front_dashboard', {
30 30 url: '/ui',
31 31 component: 'indexDashboardView'
32 32 });
33 33
34 34 $stateProvider.state('report', {
35 35 abstract: true,
36 36 url: '/ui/report',
37 37 templateUrl: 'templates/reports/parent_view.html'
38 38 });
39 39
40 40 $stateProvider.state('report.list', {
41 41 url: '?start_date&min_duration&max_duration&{view_name:any}&{server_name:any}&resource',
42 42 templateUrl: 'templates/reports/list.html',
43 43 controller: 'ReportsListController as reports_list'
44 44 });
45 45
46 46 $stateProvider.state('report.list_slow', {
47 47 url: '/list_slow?start_date&min_duration&max_duration&{view_name:any}&{server_name:any}&resource',
48 48 templateUrl: 'templates/reports/list_slow.html',
49 49 controller: 'ReportsListSlowController as reports_list'
50 50 });
51 51
52 52 $stateProvider.state('report.view_detail', {
53 53 url: '/:groupId/:reportId',
54 54 templateUrl: 'templates/reports/view.html',
55 55 controller: 'ReportsViewController as report'
56 56 });
57 57 $stateProvider.state('report.view_group', {
58 58 url: '/:groupId',
59 59 templateUrl: 'templates/reports/view.html',
60 60 controller: 'ReportsViewController as report'
61 61 });
62 62 $stateProvider.state('events', {
63 63 url: '/ui/events',
64 64 component: 'eventBrowserView'
65 65 });
66 66 $stateProvider.state('admin', {
67 67 url: '/ui/admin',
68 68 templateUrl: 'templates/admin/parent_view.html'
69 69 });
70 70 $stateProvider.state('admin.user', {
71 71 abstract: true,
72 72 url: '/user',
73 73 templateUrl: 'templates/admin/users/parent_view.html'
74 74 });
75 75 $stateProvider.state('admin.user.list', {
76 76 url: '/list',
77 77 templateUrl: 'templates/admin/users/users_list.html',
78 78 controller: 'AdminUsersController as users'
79 79 });
80 80 $stateProvider.state('admin.user.create', {
81 81 url: '/create',
82 82 templateUrl: 'templates/admin/users/users_create.html',
83 83 controller: 'AdminUsersCreateController as user'
84 84 });
85 85 $stateProvider.state('admin.user.update', {
86 86 url: '/{userId}/update',
87 87 templateUrl: 'templates/admin/users/users_create.html',
88 88 controller: 'AdminUsersCreateController as user'
89 89 });
90 90
91 91
92 92 $stateProvider.state('admin.group', {
93 93 abstract: true,
94 94 url: '/group',
95 95 templateUrl: 'templates/admin/groups/parent_view.html'
96 96 });
97 97 $stateProvider.state('admin.group.list', {
98 98 url: '/list',
99 99 templateUrl: 'templates/admin/groups/groups_list.html',
100 100 controller: 'AdminGroupsController as groups'
101 101 });
102 102 $stateProvider.state('admin.group.create', {
103 103 url: '/create',
104 104 templateUrl: 'templates/admin/groups/groups_create.html',
105 105 controller: 'AdminGroupsCreateController as group'
106 106 });
107 107 $stateProvider.state('admin.group.update', {
108 108 url: '/{groupId}/update',
109 109 templateUrl: 'templates/admin/groups/groups_create.html',
110 110 controller: 'AdminGroupsCreateController as group'
111 111 });
112 112
113 113 $stateProvider.state('admin.application', {
114 114 abstract: true,
115 115 url: '/application',
116 116 templateUrl: 'templates/admin/users/parent_view.html'
117 117 });
118 118
119 119 $stateProvider.state('admin.application.list', {
120 120 url: '/list',
121 121 templateUrl: 'templates/admin/applications/applications_list.html',
122 122 controller: 'AdminApplicationsListController as applications'
123 123 });
124 124
125 125 $stateProvider.state('admin.partitions', {
126 126 url: '/partitions',
127 127 templateUrl: 'templates/admin/partitions.html',
128 128 controller: 'AdminPartitionsController as partitions'
129 129 });
130 130 $stateProvider.state('admin.system', {
131 131 url: '/system',
132 132 templateUrl: 'templates/admin/system.html',
133 133 controller: 'AdminSystemController as system'
134 134 });
135 135
136 136 $stateProvider.state('admin.configs', {
137 137 abstract: true,
138 138 url: '/configs',
139 139 templateUrl: 'templates/admin/configs/parent_view.html'
140 140 });
141 141
142 142 $stateProvider.state('admin.configs.list', {
143 url: '',
143 url: '/list',
144 144 templateUrl: 'templates/admin/configs/edit.html',
145 145 controller: 'ConfigsListController as configs'
146 146 });
147 147
148 148 $stateProvider.state('user', {
149 149 url: '/ui/user',
150 templateUrl: 'templates/user/parent_view.html'
150 component: 'settingsView'
151 151 });
152 152
153 153 $stateProvider.state('user.profile', {
154 154 abstract: true,
155 url: '/profile',
156 templateUrl: 'templates/user/profile.html'
155 template: '<ui-view></ui-view>'
157 156 });
158 157 $stateProvider.state('user.profile.edit', {
159 url: '',
160 templateUrl: 'templates/user/profile_edit.html',
161 controller: 'UserProfileController as profile'
158 url: '/profile',
159 component: 'userProfileView'
162 160 });
163 161
164 162
165 163 $stateProvider.state('user.profile.password', {
166 164 url: '/password',
167 165 templateUrl: 'templates/user/profile_password.html',
168 166 controller: 'UserPasswordController as password'
169 167 });
170 168
171 169 $stateProvider.state('user.profile.identities', {
172 170 url: '/identities',
173 templateUrl: 'templates/user/profile_identities.html',
174 controller: 'UserIdentitiesController as identities'
171 component: 'userIdentitiesView'
175 172 });
176 173
177 174 $stateProvider.state('user.profile.auth_tokens', {
178 175 url: '/auth_tokens',
179 176 templateUrl: 'templates/user/auth_tokens.html',
180 177 controller: 'UserAuthTokensController as auth_tokens'
181 178 });
182 179
183 180 $stateProvider.state('user.alert_channels', {
184 181 abstract: true,
185 182 url: '/alert_channels',
186 183 templateUrl: 'templates/user/alert_channels.html'
187 184 });
188 185
189 186 $stateProvider.state('user.alert_channels.list', {
190 url: '',
187 url: '/list',
191 188 templateUrl: 'templates/user/alert_channels_list.html',
192 189 controller: 'AlertChannelsController as channels'
193 190 });
194 191
195 192 $stateProvider.state('user.alert_channels.email', {
196 193 url: '/email',
197 194 templateUrl: 'templates/user/alert_channels_email.html',
198 195 controller: 'AlertChannelsEmailController as email'
199 196 });
200 197
201 198 $stateProvider.state('applications', {
202 199 abstract: true,
203 200 url: '/ui/applications',
204 201 templateUrl: 'templates/applications/parent_view.html'
205 202 });
206 203
207 204 $stateProvider.state('applications.list', {
208 url: '',
205 url: '/list',
209 206 templateUrl: 'templates/applications/list.html',
210 207 controller: 'ApplicationsListController as applications'
211 208 });
212 209 $stateProvider.state('applications.update', {
213 210 url: '/{resourceId}/update',
214 211 templateUrl: 'templates/applications/applications_update.html',
215 212 controller: 'ApplicationsUpdateController as application'
216 213 });
217 214
218 215 $stateProvider.state('applications.integrations', {
219 216 url: '/{resourceId}/integrations',
220 217 templateUrl: 'templates/applications/integrations.html',
221 218 controller: 'IntegrationsListController as integrations',
222 219 data: {
223 220 resource: null
224 221 }
225 222 });
226 223
227 224 $stateProvider.state('applications.purge_logs', {
228 225 url: '/purge_logs',
229 226 templateUrl: 'templates/applications/applications_purge_logs.html',
230 227 controller: 'ApplicationsPurgeLogsController as applications_purge'
231 228 });
232 229
233 230 $stateProvider.state('applications.integrations.edit', {
234 231 url: '/{integration}',
235 232 templateUrl: function ($stateParams) {
236 233 return 'templates/applications/integrations/' + $stateParams.integration + '.html'
237 234 },
238 235 controller: 'IntegrationController as integration'
239 236 });
240 237
241 238 $stateProvider.state('tests', {
242 239 url: '/ui/tests',
243 240 templateUrl: 'templates/user/alert_channels_test.html',
244 241 controller: 'AlertChannelsTestController as test_action'
245 242 });
246 243
247 244 }]);
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now