22
33var adminCtrl = angular . module ( "surveyApp" ) ;
44
5- adminCtrl . controller ( "adminController" , function ( $scope , $rootScope , $http ) {
5+ adminCtrl . controller ( "adminController" , function ( $scope , $rootScope , $http , $location ) {
66
77 $rootScope . isSuperAdmin = true ;
88 $rootScope . username = "" ;
99 $scope . authMsg = "" ;
1010
11- $scope . loadAdminUsers = function ( ) {
12-
13- $ ( '#loading_Overlay' ) . show ( ) ;
14- $ ( '#loading_img' ) . show ( ) ;
15-
16- var dataObj = {
17- "page" : $scope . pagingOptions1 . currentPage ,
18- "pageSize" : $scope . pagingOptions1 . pageSize ,
19- "userName" : $scope . userText ,
20- "roleId" :1
21- } ;
22-
23- $http ( {
24- method : "POST" ,
25- url : baseUrl + "loadAdminUsers" ,
26- data : JSON . stringify ( dataObj ) ,
27- headers : { 'Content-Type' : 'application/json' }
28- } ) . then ( function ( response ) {
29- $scope . myUserData = response . data . userPojoList ;
30- $scope . totalServerItems1 = response . data . count ;
31- $ ( '#loading_Overlay' ) . hide ( ) ;
32- $ ( '#loading_img' ) . hide ( ) ;
33- } ) . catch ( function ( data ) {
34- $ ( '#loading_Overlay' ) . hide ( ) ;
35- $ ( '#loading_img' ) . hide ( ) ;
36- } ) ;
37-
38- }
39-
4011 $scope . totalServerItems = 0 ;
4112 $scope . pagingOptions = {
4213 pageSizes : [ 10 , 50 , 100 ] ,
4314 pageSize : "10" ,
4415 currentPage : 1
4516 } ;
46-
47- $scope . totalServerItems1 = 0 ;
48- $scope . pagingOptions1 = {
49- pageSizes : [ 10 , 50 , 100 ] ,
50- pageSize : "10" ,
51- currentPage : 1
52- } ;
53-
17+
5418 $http ( {
5519 method : "POST" ,
5620 url : baseUrl + "validateSuperAdmin" ,
@@ -81,10 +45,6 @@ adminCtrl.controller("adminController", function($scope, $rootScope, $http) {
8145
8246 } ) ;
8347
84- if ( $rootScope . isSuperAdmin ) {
85- $scope . loadAdminUsers ( ) ;
86- }
87-
8848 $scope . pieDataSR ;
8949 $scope . pieDataSTR ;
9050 $scope . myChartObjectSR = { } ;
@@ -141,69 +101,16 @@ adminCtrl.controller("adminController", function($scope, $rootScope, $http) {
141101 $scope . fromDate = new Date ( ) ;
142102 $scope . toDate = new Date ( ) ;
143103
104+ $scope . isActive = function ( viewLocation ) {
105+ return viewLocation === $location . path ( ) ;
106+ } ;
107+
144108 $scope . dpOpenStatus = { } ;
145109
146110 $scope . setDpOpenStatus = function ( id ) {
147111 $scope . dpOpenStatus [ id ] = true
148112 } ;
149-
150- // super admin
151- $scope . addAdmin = function ( ) {
152-
153- $ ( '#loading_Overlay' ) . show ( ) ;
154- $ ( '#loading_img' ) . show ( ) ;
155-
156- var dataObj = {
157- "userName" : $scope . superAdmin ,
158- "roleId" :1
159- } ;
160-
161- $http ( {
162- method : "POST" ,
163- url : baseUrl + "saveUser" ,
164- data : JSON . stringify ( dataObj ) ,
165- headers : { 'Content-Type' : 'application/json' }
166- } ) . then ( function ( response ) {
167-
168- $ ( '#loading_Overlay' ) . hide ( ) ;
169- $ ( '#loading_img' ) . hide ( ) ;
170-
171- var JSONObject = response . data ;
172-
173- var messageVal = JSONObject [ "value" ] ;
174-
175- if ( messageVal == "Success" ) {
176- $scope . message = "User " + $scope . superAdmin + " Added Successfully" ;
177- $scope . loadAdminUsers ( ) ;
178-
179- } else if ( messageVal == "alreadyPresent" ) {
180- $scope . message = "User " + $scope . superAdmin + " is already there" ;
181-
182- } else {
183- $scope . message = "Error adding in User " + $scope . superAdmin ;
184- }
185-
186- } ) ;
187- } ;
188-
189- $scope . deactivateUsers = function ( ) {
190-
191- $ ( '#loading_Overlay' ) . show ( ) ;
192- $ ( '#loading_img' ) . show ( ) ;
193-
194- $http ( {
195- method : "POST" ,
196- url : baseUrl + "deleteAdminUser" ,
197- data : $scope . selectedRows ,
198- headers : { 'Content-Type' : 'application/json' }
199- } ) . then ( function ( response ) {
200- $scope . loadAdminUsers ( ) ;
201- $scope . gridOptions1 . selectedItems . length = 0 ;
202- $ ( '#loading_Overlay' ) . hide ( ) ;
203- $ ( '#loading_img' ) . hide ( ) ;
204- } ) ;
205- } ;
206-
113+
207114 $scope . $watch ( 'pagingOptions' , function ( newVal , oldVal ) {
208115 if ( ( newVal !== oldVal ) && ( newVal . currentPage !== oldVal . currentPage ) || ( newVal . pageSize !== oldVal . pageSize ) ) {
209116 $ ( '#loading_Overlay' ) . show ( ) ;
@@ -234,15 +141,7 @@ adminCtrl.controller("adminController", function($scope, $rootScope, $http) {
234141 } ) ;
235142 }
236143 } , true ) ;
237-
238-
239- $scope . $watch ( 'pagingOptions1' , function ( newVal , oldVal ) {
240- if ( ( newVal !== oldVal ) && ( newVal . currentPage !== oldVal . currentPage ) || ( newVal . pageSize !== oldVal . pageSize ) ) {
241- $scope . loadAdminUsers ( ) ;
242- }
243- } , true ) ;
244-
245-
144+
246145 // search
247146
248147 $scope . searchSurvey = function ( ) {
@@ -455,27 +354,5 @@ adminCtrl.controller("adminController", function($scope, $rootScope, $http) {
455354 { field :'feedback' , displayName :'Feedback' , width : '100px' } ,
456355 { field :'createdDate' , displayName :'Date' , width : '200px' }
457356 ]
458- } ;
459-
460- $scope . selectedRows = [ ] ;
461-
462- $scope . gridOptions1 = {
463- data : 'myUserData' ,
464- enablePaging : true ,
465- totalServerItems :'totalServerItems1' ,
466- pagingOptions : $scope . pagingOptions1 ,
467- showFooter : true ,
468- multiSelect : true ,
469- enableHighlighting : true ,
470- enableRowSelection : true ,
471- selectedItems :$scope . selectedRows ,
472- showFilter : true ,
473- enableColumnResize : true ,
474- showSelectionCheckbox : true ,
475- columnDefs : [
476- { field : 'userName' , displayName : 'User Name' , width : '305px' } ,
477- { field :'roleName' , displayName :'Role' , width : '160px' }
478- ]
479- } ;
480-
357+ } ;
481358} ) ;
0 commit comments