##// END OF EJS Templates
frontend: move link definitions to javascript layer
ergo -
Show More
@@ -71,7 +71,6 b' def register_appenlight_plugin(config, plugin_name, plugin_config):'
71 71 'javascript': None,
72 72 'static': None,
73 73 'css': None,
74 'top_nav': None,
75 74 'celery_tasks': None,
76 75 'celery_beats': None,
77 76 'fulltext_indexer': None,
@@ -2744,6 +2744,7 b' var pluginsToLoad = _.map(decodeEncodedJSON(window.AE.plugins),'
2744 2744 function(item){
2745 2745 return item.config.angular_module
2746 2746 });
2747 console.info(pluginsToLoad);
2747 2748
2748 2749 angular.module('appenlight.plugins', pluginsToLoad);
2749 2750
@@ -2815,6 +2816,14 b' function kickstartAE(initialUserData) {'
2815 2816 function ($rootScope, $timeout, stateHolder, $state, $location, $transitions, $window, AeConfig) {
2816 2817 if (initialUserData){
2817 2818 stateHolder.AeUser.update(initialUserData);
2819
2820 if (stateHolder.AeUser.hasAppPermission('root_administration'
2821 )){
2822 AeConfig.topNav.menuAdminItems.push(
2823 {'sref': 'admin', 'label': 'Admin Settings'}
2824 )
2825 }
2826
2818 2827 }
2819 2828 $rootScope.$state = $state;
2820 2829 $rootScope.stateHolder = stateHolder;
@@ -2948,7 +2957,7 b' function kickstartAE(initialUserData) {'
2948 2957 " <span class=\"fa fa-bar-chart-o \"></span></a>\n" +
2949 2958 " <ul class=\"dropdown-menu\">\n" +
2950 2959 " <li role=\"presentation\"><a data-ui-sref=\"front_dashboard\">Main dashboard</a></li>\n" +
2951 " <li role=\"presentation\" ng-repeat=\"item in $ctrl.AeConfig.topNav.menu_dashboards_items\">\n" +
2960 " <li role=\"presentation\" ng-repeat=\"item in $ctrl.AeConfig.topNav.menuDashboardsItems\">\n" +
2952 2961 " <a data-ui-sref=\"{{ item.sref }}\">{{ item.label }}</a>\n" +
2953 2962 " </li>\n" +
2954 2963 " </ul>\n" +
@@ -2973,11 +2982,11 b' function kickstartAE(initialUserData) {'
2973 2982 " <li>\n" +
2974 2983 " <a data-ui-sref=\"user\" data-uib-tooltip=\"Settings\" tooltip-placement=\"bottom\"><span class=\"fa fa-cog \"></span></a>\n" +
2975 2984 " </li>\n" +
2976 " <li class=\"dropdown\" data-uib-dropdown data-ng-if=\"$ctrl.AeConfig.topNav.menu_admin_items.length\">\n" +
2985 " <li class=\"dropdown\" data-uib-dropdown data-ng-if=\"$ctrl.AeConfig.topNav.menuAdminItems.length\">\n" +
2977 2986 " <a class=\"dropdown-toggle\" data-uib-dropdown-toggle tooltip-placement=\"bottom\" data-uib-tooltip=\"Admin Settings\">\n" +
2978 2987 " <span class=\"fa fa-wrench\"></span></a>\n" +
2979 2988 " <ul class=\"dropdown-menu\">\n" +
2980 " <li role=\"presentation\" ng-repeat=\"item in $ctrl.AeConfig.topNav.menu_admin_items\">\n" +
2989 " <li role=\"presentation\" ng-repeat=\"item in $ctrl.AeConfig.topNav.menuAdminItems\">\n" +
2981 2990 " <a data-ui-sref=\"{{ item.sref }}\">{{ item.label }}</a>\n" +
2982 2991 " </li>\n" +
2983 2992 " </ul>\n" +
@@ -6157,6 +6166,13 b' function kickstartAE(initialUserData) {'
6157 6166 " <li class=\"list-group-item\" ui-sref-active-eq=\"active\"><a data-ui-sref=\"applications.update({resourceId:'new'})\"><span class=\"fa fa-plus-circle\"></span> Create application</a></li>\n" +
6158 6167 " <li class=\"list-group-item\" ui-sref-active-eq=\"active\"><a data-ui-sref=\"applications.purge_logs\"><span class=\"fa fa-trash-o\"></span> Purge logs</a></li>\n" +
6159 6168 " </ul>\n" +
6169 "\n" +
6170 " <ul class=\"list-group\" data-ng-if=\"$ctrl.AeConfig.settingsNav.menuApplicationsItems.length\">\n" +
6171 " <li class=\"list-group-item\" ng-repeat=\"item in $ctrl.AeConfig.settingsNav.menuApplicationsItems\">\n" +
6172 " <a data-ui-sref=\"{{ item.sref }}\">{{ item.label }}</a>\n" +
6173 " </li>\n" +
6174 " </ul>\n" +
6175 "\n" +
6160 6176 " </div>\n" +
6161 6177 "\n" +
6162 6178 "\n" +
@@ -6168,6 +6184,13 b' function kickstartAE(initialUserData) {'
6168 6184 " <li class=\"list-group-item\" ui-sref-active-eq=\"active\"><a data-ui-sref=\"user.profile.identities\"><span class=\"fa fa-link\"></span> External Identities</a></li>\n" +
6169 6185 " <li class=\"list-group-item\" ui-sref-active-eq=\"active\"><a data-ui-sref=\"user.profile.auth_tokens\"><span class=\"fa fa-unlock\"></span> Auth Tokens</a></li>\n" +
6170 6186 " </ul>\n" +
6187 "\n" +
6188 " <ul class=\"list-group\" data-ng-if=\"$ctrl.AeConfig.settingsNav.menuUserSettingsItems.length\">\n" +
6189 " <li class=\"list-group-item\" ng-repeat=\"item in $ctrl.AeConfig.settingsNav.menuUserSettingsItems\">\n" +
6190 " <a data-ui-sref=\"{{ item.sref }}\">{{ item.label }}</a>\n" +
6191 " </li>\n" +
6192 " </ul>\n" +
6193 "\n" +
6171 6194 " </div>\n" +
6172 6195 "\n" +
6173 6196 " <div class=\"panel panel-default\">\n" +
@@ -6176,7 +6199,15 b' function kickstartAE(initialUserData) {'
6176 6199 " <li class=\"list-group-item\" ui-sref-active-eq=\"active\"><a data-ui-sref=\"user.alert_channels.list\"><span class=\"fa fa-bullhorn\"></span> Alert channels</a></li>\n" +
6177 6200 " <li class=\"list-group-item\" ui-sref-active-eq=\"active\"><a data-ui-sref=\"user.alert_channels.email\"><span class=\"fa fa-envelope\"></span> Add email channel</a></li>\n" +
6178 6201 " </ul>\n" +
6202 "\n" +
6203 " <ul class=\"list-group\" data-ng-if=\"$ctrl.AeConfig.settingsNav.menuNotificationsItems.length\">\n" +
6204 " <li class=\"list-group-item\" ng-repeat=\"item in $ctrl.AeConfig.settingsNav.menuNotificationsItems\">\n" +
6205 " <a data-ui-sref=\"{{ item.sref }}\">{{ item.label }}</a>\n" +
6206 " </li>\n" +
6207 " </ul>\n" +
6208 "\n" +
6179 6209 " </div>\n" +
6210 "\n" +
6180 6211 " </div>\n" +
6181 6212 "\n" +
6182 6213 " <div class=\"col-sm-9\" ui-view></div>\n" +
@@ -10465,10 +10496,11 b" angular.module('appenlight.components.settingsView', [])"
10465 10496 controller: SettingsViewController
10466 10497 });
10467 10498
10468 SettingsViewController.$inject = ['$state'];
10499 SettingsViewController.$inject = ['$state', 'AeConfig'];
10469 10500
10470 function SettingsViewController($state) {
10501 function SettingsViewController($state, AeConfig) {
10471 10502 this.$state = $state;
10503 this.AeConfig = AeConfig;
10472 10504 console.info('SettingsViewController');
10473 10505 }
10474 10506
@@ -10921,7 +10953,19 b" aeconfig.factory('AeConfig', function () {"
10921 10953 obj.flashMessages = decodeEncodedJSON(window.AE.flash_messages);
10922 10954 obj.timeOptions = decodeEncodedJSON(window.AE.timeOptions);
10923 10955 obj.plugins = decodeEncodedJSON(window.AE.plugins);
10924 obj.topNav = decodeEncodedJSON(window.AE.topNav);
10956 obj.topNav = {
10957 menuDashboardsItems: [],
10958 menuReportsItems: [],
10959 menuLogsItems: [],
10960 menuSettingsItems: [],
10961 menuAdminItems: []
10962 };
10963 obj.settingsNav = {
10964 menuApplicationsItems: [],
10965 menuUserSettingsItems: [],
10966 menuNotificationsItems: []
10967 };
10968 obj.adminNav = {};
10925 10969 obj.ws_url = window.AE.ws_url;
10926 10970 obj.urls = window.AE.urls;
10927 10971 // set keys on values because we wont be able to retrieve them everywhere
@@ -13096,7 +13140,14 b" angular.module('appenlight.services.stateHolder', []).factory('stateHolder',"
13096 13140 self.inclusions[name] = [];
13097 13141 }
13098 13142 self.inclusions[name].push(inclusion);
13099 }
13143 },
13144 addnavigation: function (name, inclusion) {
13145 var self = this;
13146 if (self.inclusions.hasOwnProperty(name) === false) {
13147 self.inclusions[name] = [];
13148 }
13149 self.inclusions[name].push(inclusion);
13150 },
13100 13151 };
13101 13152
13102 13153 var stateHolder = {
@@ -38,8 +38,8 b' def gen_urls(request):'
38 38 'applicationsNoId': request.route_url('applications_no_id'),
39 39 'applications': request.route_url('applications', resource_id='REPLACE_ID').replace('REPLACE_ID',':resourceId'),
40 40 'applicationsProperty': request.route_url('applications_property',key='REPLACE_KEY', resource_id='REPLACE_ID').replace('REPLACE_ID',':resourceId').replace('REPLACE_KEY',':key'),
41 'configsNoId': request.route_url('admin_configs'),
42 'configs': request.route_url('admin_config', key='REPLACE_KEY', section='REPLACE_SECTION').replace('REPLACE_SECTION',':section').replace('REPLACE_KEY',':key'),
41 'configsNoId': request.route_url('admin_configs'),
42 'configs': request.route_url('admin_config', key='REPLACE_KEY', section='REPLACE_SECTION').replace('REPLACE_SECTION',':section').replace('REPLACE_KEY',':key'),
43 43 'docs': 'http://getappenlight.com/page/api/main.html',
44 44 'eventsNoId': request.route_url('events_no_id'),
45 45 'events': request.route_url('events', event_id='REPLACE_ID').replace('REPLACE_ID',':eventId'),
@@ -47,34 +47,34 b' def gen_urls(request):'
47 47 'groupsNoId': request.route_url('groups_no_id'),
48 48 'groups': request.route_url('groups', group_id='REPLACE_ID').replace('REPLACE_ID',':groupId'),
49 49 'groupsProperty': request.route_url('groups_property',key='REPLACE_KEY', group_id='REPLACE_ID').replace('REPLACE_ID',':groupId').replace('REPLACE_KEY',':key'),
50 'logsNoId': request.route_url('logs_no_id'),
50 'logsNoId': request.route_url('logs_no_id'),
51 51 'integrationAction': request.route_url('integrations_id',action='REPLACE_ACT', resource_id='REPLACE_RID', integration='REPLACE_IID').replace('REPLACE_RID',':resourceId').replace('REPLACE_ACT',':action').replace('REPLACE_IID',':integration'),
52 52 'usersNoId': request.route_url('users_no_id'),
53 53 'users': request.route_url('users', user_id='REPLACE_ID').replace('REPLACE_ID',':userId'),
54 54 'usersProperty': request.route_url('users_property',key='REPLACE_KEY', user_id='REPLACE_ID').replace('REPLACE_ID',':userId').replace('REPLACE_KEY',':key'),
55 55 'userSelf': request.route_url('users_self'),
56 56 'userSelfProperty': request.route_url('users_self_property',key='REPLACE_KEY').replace('REPLACE_KEY',':key'),
57 'reports': request.route_url('reports'),
58 'reportGroup': request.route_url('report_groups', group_id='REPLACE_RID').replace('REPLACE_RID',':groupId'),
59 'reportGroupProperty': request.route_url('report_groups_property', key='REPLACE_KEY', group_id='REPLACE_GID').replace('REPLACE_KEY',':key').replace('REPLACE_GID',':groupId'),
60 'pluginConfigsNoId': request.route_url('plugin_configs', plugin_name='REPLACE_TYPE').replace('REPLACE_TYPE',':plugin_name'),
61 'pluginConfigs': request.route_url('plugin_config', id='REPLACE_ID', plugin_name='REPLACE_TYPE').replace('REPLACE_ID',':id').replace('REPLACE_TYPE',':plugin_name'),
57 'reports': request.route_url('reports'),
58 'reportGroup': request.route_url('report_groups', group_id='REPLACE_RID').replace('REPLACE_RID',':groupId'),
59 'reportGroupProperty': request.route_url('report_groups_property', key='REPLACE_KEY', group_id='REPLACE_GID').replace('REPLACE_KEY',':key').replace('REPLACE_GID',':groupId'),
60 'pluginConfigsNoId': request.route_url('plugin_configs', plugin_name='REPLACE_TYPE').replace('REPLACE_TYPE',':plugin_name'),
61 'pluginConfigs': request.route_url('plugin_config', id='REPLACE_ID', plugin_name='REPLACE_TYPE').replace('REPLACE_ID',':id').replace('REPLACE_TYPE',':plugin_name'),
62 62 'resourceProperty': request.route_url('resources_property',key='REPLACE_KEY', resource_id='REPLACE_ID').replace('REPLACE_ID',':resourceId').replace('REPLACE_KEY',':key'),
63 'slowReports': request.route_url('slow_reports'),
64 'sectionView': request.route_url('section_view', section='REPLACE_S', view='REPLACE_V').replace('REPLACE_S',':section').replace('REPLACE_V',':view'),
63 'slowReports': request.route_url('slow_reports'),
64 'sectionView': request.route_url('section_view', section='REPLACE_S', view='REPLACE_V').replace('REPLACE_S',':section').replace('REPLACE_V',':view'),
65 65 'otherRoutes': {
66 'register': request.route_url('register') ,
67 'lostPassword': request.route_url('lost_password') ,
68 'lostPasswordGenerate': request.route_url('lost_password_generate'),
66 'register': request.route_url('register'),
67 'lostPassword': request.route_url('lost_password'),
68 'lostPasswordGenerate': request.route_url('lost_password_generate'),
69 69 'signOut': request.route_url('ziggurat.routes.sign_out')
70 70 },
71 71 'social_auth': {
72 'google':request.route_url('social_auth', provider='google'),
73 'twitter':request.route_url('social_auth', provider='twitter'),
74 'bitbucket':request.route_url('social_auth', provider='bitbucket'),
75 'github':request.route_url('social_auth', provider='github'),
72 'google': request.route_url('social_auth', provider='google'),
73 'twitter': request.route_url('social_auth', provider='twitter'),
74 'bitbucket': request.route_url('social_auth', provider='bitbucket'),
75 'github': request.route_url('social_auth', provider='github'),
76 76 },
77 "plugins":{},
77 "plugins": {},
78 78 "adminAction": request.route_url('admin', action="REPLACE_ACT").replace('REPLACE_ACT',':action')
79 79 }
80 80 return urls
@@ -111,13 +111,6 b' def add_renderer_globals(event):'
111 111 renderer_globals['security'] = security
112 112 renderer_globals['flash_msgs'] = []
113 113 renderer_globals['js_plugins'] = []
114 renderer_globals['top_nav'] = {
115 'menu_dashboards_items': [],
116 'menu_reports_items': [],
117 'menu_logs_items': [],
118 'menu_settings_items': [],
119 'menu_admin_items': [],
120 }
121 114
122 115 if 'jinja' in event['renderer_info'].type:
123 116 renderer_globals['url_list'] = gen_urls(request)
@@ -129,17 +122,7 b' def add_renderer_globals(event):'
129 122
130 123 if config['javascript']:
131 124 renderer_globals['js_plugins'].append(
132 ({'name':module, 'config':config['javascript']}))
133 for nav_key in renderer_globals['top_nav'].keys():
134 if nav_key in config['top_nav'] and config['top_nav'][nav_key]:
135 renderer_globals['top_nav'][nav_key].append(
136 config['top_nav'][nav_key])
137
138 if request.has_permission('root_administration',
139 security.RootFactory(request)):
140 renderer_globals['top_nav']['menu_admin_items'].append(
141 {'sref': 'admin', 'label': 'Admin Settings'}
142 )
125 ({'name': module, 'config': config['javascript']}))
143 126
144 127 footer_config = ConfigService.by_key_and_section(
145 128 'template_footer_html', 'global', default_value='')
@@ -27,7 +27,6 b''
27 27 AE.flash_messages = {{ flash_msgs|toJSONUnsafe }};
28 28 AE.timeOptions = {{ h.time_options|toJSONUnsafe }};
29 29 AE.plugins = {{ js_plugins|toJSONUnsafe }};
30 AE.topNav = {{ top_nav|toJSONUnsafe }};
31 30 </script>
32 31 {% if request.registry.settings.get('appenlight.public_api_key') %}
33 32 <script type="application/javascript">
@@ -108,7 +108,8 b' var pluginsToLoad = _.map(decodeEncodedJSON(window.AE.plugins),'
108 108 function(item){
109 109 return item.config.angular_module
110 110 });
111 console.log(pluginsToLoad);
111 console.info(pluginsToLoad);
112
112 113 angular.module('appenlight.plugins', pluginsToLoad);
113 114
114 115 var app = angular.module('appenlight', [
@@ -179,6 +180,14 b' function kickstartAE(initialUserData) {'
179 180 function ($rootScope, $timeout, stateHolder, $state, $location, $transitions, $window, AeConfig) {
180 181 if (initialUserData){
181 182 stateHolder.AeUser.update(initialUserData);
183
184 if (stateHolder.AeUser.hasAppPermission('root_administration'
185 )){
186 AeConfig.topNav.menuAdminItems.push(
187 {'sref': 'admin', 'label': 'Admin Settings'}
188 )
189 }
190
182 191 }
183 192 $rootScope.$state = $state;
184 193 $rootScope.stateHolder = stateHolder;
@@ -53,7 +53,7 b''
53 53 <span class="fa fa-bar-chart-o "></span></a>
54 54 <ul class="dropdown-menu">
55 55 <li role="presentation"><a data-ui-sref="front_dashboard">Main dashboard</a></li>
56 <li role="presentation" ng-repeat="item in $ctrl.AeConfig.topNav.menu_dashboards_items">
56 <li role="presentation" ng-repeat="item in $ctrl.AeConfig.topNav.menuDashboardsItems">
57 57 <a data-ui-sref="{{ item.sref }}">{{ item.label }}</a>
58 58 </li>
59 59 </ul>
@@ -78,11 +78,11 b''
78 78 <li>
79 79 <a data-ui-sref="user" data-uib-tooltip="Settings" tooltip-placement="bottom"><span class="fa fa-cog "></span></a>
80 80 </li>
81 <li class="dropdown" data-uib-dropdown data-ng-if="$ctrl.AeConfig.topNav.menu_admin_items.length">
81 <li class="dropdown" data-uib-dropdown data-ng-if="$ctrl.AeConfig.topNav.menuAdminItems.length">
82 82 <a class="dropdown-toggle" data-uib-dropdown-toggle tooltip-placement="bottom" data-uib-tooltip="Admin Settings">
83 83 <span class="fa fa-wrench"></span></a>
84 84 <ul class="dropdown-menu">
85 <li role="presentation" ng-repeat="item in $ctrl.AeConfig.topNav.menu_admin_items">
85 <li role="presentation" ng-repeat="item in $ctrl.AeConfig.topNav.menuAdminItems">
86 86 <a data-ui-sref="{{ item.sref }}">{{ item.label }}</a>
87 87 </li>
88 88 </ul>
@@ -7,6 +7,13 b''
7 7 <li class="list-group-item" ui-sref-active-eq="active"><a data-ui-sref="applications.update({resourceId:'new'})"><span class="fa fa-plus-circle"></span> Create application</a></li>
8 8 <li class="list-group-item" ui-sref-active-eq="active"><a data-ui-sref="applications.purge_logs"><span class="fa fa-trash-o"></span> Purge logs</a></li>
9 9 </ul>
10
11 <ul class="list-group" data-ng-if="$ctrl.AeConfig.settingsNav.menuApplicationsItems.length">
12 <li class="list-group-item" ng-repeat="item in $ctrl.AeConfig.settingsNav.menuApplicationsItems">
13 <a data-ui-sref="{{ item.sref }}">{{ item.label }}</a>
14 </li>
15 </ul>
16
10 17 </div>
11 18
12 19
@@ -18,6 +25,13 b''
18 25 <li class="list-group-item" ui-sref-active-eq="active"><a data-ui-sref="user.profile.identities"><span class="fa fa-link"></span> External Identities</a></li>
19 26 <li class="list-group-item" ui-sref-active-eq="active"><a data-ui-sref="user.profile.auth_tokens"><span class="fa fa-unlock"></span> Auth Tokens</a></li>
20 27 </ul>
28
29 <ul class="list-group" data-ng-if="$ctrl.AeConfig.settingsNav.menuUserSettingsItems.length">
30 <li class="list-group-item" ng-repeat="item in $ctrl.AeConfig.settingsNav.menuUserSettingsItems">
31 <a data-ui-sref="{{ item.sref }}">{{ item.label }}</a>
32 </li>
33 </ul>
34
21 35 </div>
22 36
23 37 <div class="panel panel-default">
@@ -26,7 +40,15 b''
26 40 <li class="list-group-item" ui-sref-active-eq="active"><a data-ui-sref="user.alert_channels.list"><span class="fa fa-bullhorn"></span> Alert channels</a></li>
27 41 <li class="list-group-item" ui-sref-active-eq="active"><a data-ui-sref="user.alert_channels.email"><span class="fa fa-envelope"></span> Add email channel</a></li>
28 42 </ul>
43
44 <ul class="list-group" data-ng-if="$ctrl.AeConfig.settingsNav.menuNotificationsItems.length">
45 <li class="list-group-item" ng-repeat="item in $ctrl.AeConfig.settingsNav.menuNotificationsItems">
46 <a data-ui-sref="{{ item.sref }}">{{ item.label }}</a>
47 </li>
48 </ul>
49
29 50 </div>
51
30 52 </div>
31 53
32 54 <div class="col-sm-9" ui-view></div>
@@ -23,9 +23,10 b" angular.module('appenlight.components.settingsView', [])"
23 23 controller: SettingsViewController
24 24 });
25 25
26 SettingsViewController.$inject = ['$state'];
26 SettingsViewController.$inject = ['$state', 'AeConfig'];
27 27
28 function SettingsViewController($state) {
28 function SettingsViewController($state, AeConfig) {
29 29 this.$state = $state;
30 this.AeConfig = AeConfig;
30 31 console.info('SettingsViewController');
31 32 }
@@ -23,7 +23,19 b" aeconfig.factory('AeConfig', function () {"
23 23 obj.flashMessages = decodeEncodedJSON(window.AE.flash_messages);
24 24 obj.timeOptions = decodeEncodedJSON(window.AE.timeOptions);
25 25 obj.plugins = decodeEncodedJSON(window.AE.plugins);
26 obj.topNav = decodeEncodedJSON(window.AE.topNav);
26 obj.topNav = {
27 menuDashboardsItems: [],
28 menuReportsItems: [],
29 menuLogsItems: [],
30 menuSettingsItems: [],
31 menuAdminItems: []
32 };
33 obj.settingsNav = {
34 menuApplicationsItems: [],
35 menuUserSettingsItems: [],
36 menuNotificationsItems: []
37 };
38 obj.adminNav = {};
27 39 obj.ws_url = window.AE.ws_url;
28 40 obj.urls = window.AE.urls;
29 41 // set keys on values because we wont be able to retrieve them everywhere
General Comments 0
You need to be logged in to leave comments. Login now