|
11 | 11 | * See the License for the specific language governing permissions and |
12 | 12 | * limitations under the License. |
13 | 13 | */ |
14 | | - |
15 | 14 | 'use strict'; |
| 15 | +(function() { |
| 16 | + |
| 17 | + angular.module('zeppelinWebApp').controller('NavCtrl', NavCtrl); |
| 18 | + |
| 19 | + NavCtrl.$inject = [ |
| 20 | + '$scope', |
| 21 | + '$rootScope', |
| 22 | + '$http', |
| 23 | + '$routeParams', |
| 24 | + '$location', |
| 25 | + 'notebookListDataFactory', |
| 26 | + 'baseUrlSrv', |
| 27 | + 'websocketMsgSrv', |
| 28 | + 'arrayOrderingSrv', |
| 29 | + 'searchService' |
| 30 | + ]; |
| 31 | + |
| 32 | + function NavCtrl($scope, $rootScope, $http, $routeParams, $location, |
| 33 | + notebookListDataFactory, baseUrlSrv, websocketMsgSrv, |
| 34 | + arrayOrderingSrv, searchService) { |
| 35 | + var vm = this; |
| 36 | + vm.arrayOrderingSrv = arrayOrderingSrv; |
| 37 | + vm.connected = websocketMsgSrv.isConnected(); |
| 38 | + vm.isActive = isActive; |
| 39 | + vm.logout = logout; |
| 40 | + vm.notes = notebookListDataFactory; |
| 41 | + vm.search = search; |
| 42 | + vm.searchForm = searchService; |
| 43 | + vm.showLoginWindow = showLoginWindow; |
| 44 | + |
| 45 | + $scope.query = {q: ''}; |
| 46 | + |
| 47 | + initController(); |
| 48 | + |
| 49 | + function getZeppelinVersion() { |
| 50 | + $http.get(baseUrlSrv.getRestApiBase() + '/version').success( |
| 51 | + function(data, status, headers, config) { |
| 52 | + $rootScope.zeppelinVersion = data.body; |
| 53 | + }).error( |
| 54 | + function(data, status, headers, config) { |
| 55 | + console.log('Error %o %o', status, data.message); |
| 56 | + }); |
| 57 | + } |
16 | 58 |
|
17 | | -angular.module('zeppelinWebApp') |
18 | | -.controller('NavCtrl', function($scope, $rootScope, $http, $routeParams, |
19 | | - $location, notebookListDataFactory, baseUrlSrv, websocketMsgSrv, arrayOrderingSrv, searchService) { |
20 | | - |
21 | | - var vm = this; |
22 | | - vm.arrayOrderingSrv = arrayOrderingSrv; |
23 | | - vm.connected = websocketMsgSrv.isConnected(); |
24 | | - vm.isActive = isActive; |
25 | | - vm.logout = logout; |
26 | | - vm.notes = notebookListDataFactory; |
27 | | - vm.search = search; |
28 | | - vm.searchForm = searchService; |
29 | | - vm.showLoginWindow = showLoginWindow; |
30 | | - |
31 | | - $scope.query = {q: ''}; |
32 | | - |
33 | | - initController(); |
34 | | - |
35 | | - function getZeppelinVersion() { |
36 | | - $http.get(baseUrlSrv.getRestApiBase() + '/version').success( |
37 | | - function(data, status, headers, config) { |
38 | | - $rootScope.zeppelinVersion = data.body; |
39 | | - }).error( |
40 | | - function(data, status, headers, config) { |
41 | | - console.log('Error %o %o', status, data.message); |
42 | | - }); |
43 | | - } |
44 | | - |
45 | | - function initController() { |
46 | | - angular.element('#notebook-list').perfectScrollbar({suppressScrollX: true}); |
| 59 | + function initController() { |
| 60 | + angular.element('#notebook-list').perfectScrollbar({suppressScrollX: true}); |
47 | 61 |
|
48 | | - angular.element(document).click(function() { |
49 | | - $scope.query.q = ''; |
50 | | - }); |
| 62 | + angular.element(document).click(function() { |
| 63 | + $scope.query.q = ''; |
| 64 | + }); |
51 | 65 |
|
52 | | - getZeppelinVersion(); |
53 | | - loadNotes(); |
54 | | - } |
| 66 | + getZeppelinVersion(); |
| 67 | + loadNotes(); |
| 68 | + } |
55 | 69 |
|
56 | | - function isActive(noteId) { |
57 | | - return ($routeParams.noteId === noteId); |
58 | | - } |
| 70 | + function isActive(noteId) { |
| 71 | + return ($routeParams.noteId === noteId); |
| 72 | + } |
59 | 73 |
|
60 | | - function loadNotes() { |
61 | | - websocketMsgSrv.getNotebookList(); |
62 | | - } |
| 74 | + function loadNotes() { |
| 75 | + websocketMsgSrv.getNotebookList(); |
| 76 | + } |
63 | 77 |
|
64 | | - function logout() { |
65 | | - var logoutURL = baseUrlSrv.getRestApiBase() + '/login/logout'; |
| 78 | + function logout() { |
| 79 | + var logoutURL = baseUrlSrv.getRestApiBase() + '/login/logout'; |
66 | 80 |
|
67 | | - //for firefox and safari |
68 | | - logoutURL = logoutURL.replace('//', '//false:false@'); |
69 | | - $http.post(logoutURL).error(function() { |
70 | | - //force authcBasic (if configured) to logout |
| 81 | + //for firefox and safari |
| 82 | + logoutURL = logoutURL.replace('//', '//false:false@'); |
71 | 83 | $http.post(logoutURL).error(function() { |
72 | | - $rootScope.userName = ''; |
73 | | - $rootScope.ticket.principal = ''; |
74 | | - $rootScope.ticket.ticket = ''; |
75 | | - $rootScope.ticket.roles = ''; |
76 | | - BootstrapDialog.show({ |
77 | | - message: 'Logout Success' |
| 84 | + //force authcBasic (if configured) to logout |
| 85 | + $http.post(logoutURL).error(function() { |
| 86 | + $rootScope.userName = ''; |
| 87 | + $rootScope.ticket.principal = ''; |
| 88 | + $rootScope.ticket.ticket = ''; |
| 89 | + $rootScope.ticket.roles = ''; |
| 90 | + BootstrapDialog.show({ |
| 91 | + message: 'Logout Success' |
| 92 | + }); |
| 93 | + setTimeout(function() { |
| 94 | + window.location.replace('/'); |
| 95 | + }, 1000); |
78 | 96 | }); |
79 | | - setTimeout(function() { |
80 | | - window.location.replace('/'); |
81 | | - }, 1000); |
82 | 97 | }); |
83 | | - }); |
84 | | - } |
| 98 | + } |
85 | 99 |
|
86 | | - function search(searchTerm) { |
87 | | - $location.path('/search/' + searchTerm); |
88 | | - } |
| 100 | + function search(searchTerm) { |
| 101 | + $location.path('/search/' + searchTerm); |
| 102 | + } |
89 | 103 |
|
90 | | - function showLoginWindow() { |
91 | | - setTimeout(function() { |
92 | | - angular.element('#userName').focus(); |
93 | | - }, 500); |
94 | | - } |
| 104 | + function showLoginWindow() { |
| 105 | + setTimeout(function() { |
| 106 | + angular.element('#userName').focus(); |
| 107 | + }, 500); |
| 108 | + } |
95 | 109 |
|
96 | | - /* |
97 | | - ** $scope.$on functions below |
98 | | - */ |
| 110 | + /* |
| 111 | + ** $scope.$on functions below |
| 112 | + */ |
99 | 113 |
|
100 | | - $scope.$on('setNoteMenu', function(event, notes) { |
101 | | - notebookListDataFactory.setNotes(notes); |
102 | | - }); |
| 114 | + $scope.$on('setNoteMenu', function(event, notes) { |
| 115 | + notebookListDataFactory.setNotes(notes); |
| 116 | + }); |
103 | 117 |
|
104 | | - $scope.$on('setConnectedStatus', function(event, param) { |
105 | | - vm.connected = param; |
106 | | - }); |
| 118 | + $scope.$on('setConnectedStatus', function(event, param) { |
| 119 | + vm.connected = param; |
| 120 | + }); |
107 | 121 |
|
108 | | - $scope.$on('loginSuccess', function(event, param) { |
109 | | - loadNotes(); |
110 | | - }); |
| 122 | + $scope.$on('loginSuccess', function(event, param) { |
| 123 | + loadNotes(); |
| 124 | + }); |
| 125 | + } |
111 | 126 |
|
112 | | -}); |
| 127 | +})(); |
0 commit comments