@@ -2021,6 +2021,7 @@ window.DurationView = countlyView.extend({
2021
2021
} ) ;
2022
2022
2023
2023
window . ManageAppsView = countlyView . extend ( {
2024
+ featureName : 'global_applications' ,
2024
2025
initialize : function ( ) {
2025
2026
this . template = Handlebars . compile ( $ ( "#template-management-applications" ) . html ( ) ) ;
2026
2027
this . templatePlugins = Handlebars . compile ( $ ( "#template-management-plugins" ) . html ( ) ) ;
@@ -2047,9 +2048,10 @@ window.ManageAppsView = countlyView.extend({
2047
2048
renderCommon : function ( ) {
2048
2049
var appTypes = { } , self = this ;
2049
2050
var adminApps = countlyAuth . getAdminApps ( ) ;
2051
+ var userApps = countlyAuth . getUserApps ( ) ;
2050
2052
var oAdminApps = [ ] ;
2051
- for ( var i = 0 ; i < adminApps . length ; i ++ ) {
2052
- oAdminApps . push ( countlyGlobal . apps [ adminApps [ i ] ] ) ;
2053
+ for ( var j = 0 ; j < userApps . length ; j ++ ) {
2054
+ oAdminApps . push ( countlyGlobal . apps [ userApps [ j ] ] ) ;
2053
2055
}
2054
2056
var j = 0 ;
2055
2057
for ( j in app . appTypes ) {
@@ -2201,22 +2203,14 @@ window.ManageAppsView = countlyView.extend({
2201
2203
function initAppManagement ( app_id ) {
2202
2204
var adminApps = countlyAuth . getAdminApps ( ) ;
2203
2205
var userApps = countlyAuth . getUserApps ( ) ;
2206
+
2204
2207
if ( userApps . length === 0 ) {
2205
- showAdd ( ) ;
2206
2208
firstApp ( ) ;
2207
2209
$ ( "body" ) . off ( "click" , "#save-first-app-add" ) . on ( "click" , "#save-first-app-add" , function ( ) {
2208
2210
saveApp ( ) ;
2209
2211
} ) ;
2210
2212
return false ;
2211
2213
}
2212
- else if ( countlyAuth . validateCreate ( 'global_applications' ) ) {
2213
- showAdd ( ) ;
2214
- $ ( "body" ) . off ( "click" , "#save-app-add" ) . on ( "click" , "#save-app-add" , function ( ) {
2215
- saveApp ( ) ;
2216
- } ) ;
2217
- store . set ( 'first_app' , false ) ;
2218
- return false ;
2219
- }
2220
2214
else {
2221
2215
$ ( '#content' ) . css ( { "width" : "" , "height" : "" , "margin-left" : "" , "margin-top" : "" } ) ;
2222
2216
store . set ( 'first_app' , false ) ;
@@ -2231,13 +2225,6 @@ window.ManageAppsView = countlyView.extend({
2231
2225
} ) ;
2232
2226
}
2233
2227
2234
- if ( adminApps . indexOf ( app_id ) !== - 1 ) {
2235
- $ ( "#app-delete-button" ) . addClass ( "inactive" ) ;
2236
- }
2237
- else {
2238
- $ ( "#app-delete-button" ) . removeClass ( "inactive" ) ;
2239
- }
2240
-
2241
2228
$ ( "body" ) . off ( "click" , "#save-app-add" ) . on ( "click" , "#save-app-add" , function ( ) {
2242
2229
saveApp ( ) ;
2243
2230
} ) ;
@@ -2480,6 +2467,34 @@ window.ManageAppsView = countlyView.extend({
2480
2467
} ) ;
2481
2468
} ) ;
2482
2469
app . localize ( $ ( "#content" ) ) ;
2470
+
2471
+ var hasDeleteRight = countlyAuth . validateDelete ( self . featureName , countlyGlobal . member , app_id ) ;
2472
+ var hasUpdateRight = countlyAuth . validateUpdate ( self . featureName , countlyGlobal . member , app_id ) ;
2473
+
2474
+ if ( hasDeleteRight ) {
2475
+ $ ( "#app-delete-button" ) . show ( ) ;
2476
+ $ ( '#app-clear-button' ) . show ( ) ;
2477
+ $ ( '#app-reset-button' ) . show ( ) ;
2478
+ }
2479
+ else {
2480
+ $ ( "#app-delete-button" ) . hide ( ) ;
2481
+ $ ( '#app-clear-button' ) . hide ( ) ;
2482
+ $ ( '#app-reset-button' ) . hide ( ) ;
2483
+ }
2484
+
2485
+ if ( hasUpdateRight ) {
2486
+ $ ( "#app-edit-button" ) . show ( ) ;
2487
+ $ ( '#app-lock-button' ) . show ( ) ;
2488
+ }
2489
+ else {
2490
+ $ ( "#app-edit-button" ) . show ( ) ;
2491
+ $ ( '#app-lock-button' ) . show ( ) ;
2492
+ }
2493
+
2494
+ if ( ! hasDeleteRight && ! hasUpdateRight ) {
2495
+ $ ( '#view-app .cly-button-menu-trigger' ) . hide ( ) ;
2496
+ }
2497
+
2483
2498
}
2484
2499
/** initializes country select
2485
2500
* @param {object } parent - select parent element
@@ -2861,6 +2876,7 @@ window.ManageAppsView = countlyView.extend({
2861
2876
}
2862
2877
2863
2878
if ( ! countlyGlobal . member . global_admin && $ . isEmptyObject ( countlyGlobal . apps ) && $ . isEmptyObject ( countlyGlobal . admin_apps ) && ! countlyGlobal . config . autonomous ) {
2879
+ console . log ( 'no auth for app manage screen' ) ;
2864
2880
prepareUnauthorizeScreen ( ) ;
2865
2881
}
2866
2882
else {
@@ -3808,6 +3824,7 @@ window.ManageUsersView = countlyView.extend({
3808
3824
// Events handlers
3809
3825
$ ( 'body' ) . off ( 'click' , '.manage-users-options-item .show-edit-menu' ) . on ( 'click' , '.manage-users-options-item .show-edit-menu' , function ( ) {
3810
3826
var that = this ;
3827
+ $ ( '.edit-menu' ) . hide ( ) ;
3811
3828
$ ( '.manage-users-menu-' + $ ( this ) . data ( 'id' ) ) . show ( ) ;
3812
3829
setTimeout ( function ( ) {
3813
3830
$ ( '.manage-users-menu-' + $ ( that ) . data ( 'id' ) ) . fadeOut ( ) ;
@@ -4032,7 +4049,6 @@ window.ManageUsersView = countlyView.extend({
4032
4049
for ( var i = 0 ; i < self . features . length ; i ++ ) {
4033
4050
if ( self . features [ i ] === 'core' ) continue ;
4034
4051
$ ( '.create-user-drawer #' + type . substr ( 0 , 1 ) + '-' + self . features [ i ] + '-' + index ) . countlyCheckbox ( ) . set ( true ) ;
4035
- //$('.create-user-drawer #' + type.substr(0, 1) + '-' + self.features[i] + '-' + index).countlyCheckbox().setDisabled();
4036
4052
}
4037
4053
4038
4054
self . permissionSets [ index ] = countlyAuth . updatePermissionByType ( type . substr ( 0 , 1 ) , self . permissionSets [ index ] , true ) ;
@@ -4041,7 +4057,6 @@ window.ManageUsersView = countlyView.extend({
4041
4057
for ( var j = 0 ; j < self . features . length ; j ++ ) {
4042
4058
if ( self . features [ j ] === 'core' ) continue ;
4043
4059
$ ( '.create-user-drawer #' + type . substr ( 0 , 1 ) + '-' + self . features [ j ] + '-' + index ) . countlyCheckbox ( ) . set ( false ) ;
4044
- //$('.create-user-drawer #' + type.substr(0, 1) + '-' + self.features[j] + '-' + index).countlyCheckbox().unsetDisabled();
4045
4060
}
4046
4061
4047
4062
self . permissionSets [ index ] = countlyAuth . updatePermissionByType ( type . substr ( 0 , 1 ) , self . permissionSets [ index ] , false ) ;
@@ -4144,6 +4159,16 @@ window.ManageUsersView = countlyView.extend({
4144
4159
return ;
4145
4160
}
4146
4161
4162
+ if ( self . memberModel . permission . _ . u [ 0 ] . length === 0 && self . memberModel . permission . _ . a . length === 0 ) {
4163
+ CountlyHelpers . notify ( {
4164
+ type : 'warning' ,
4165
+ delay : 3000 ,
4166
+ title : 'Validation error' ,
4167
+ message : $ . i18n . map [ 'management-users.at-least-one-app-required' ]
4168
+ } ) ;
4169
+ return ;
4170
+ }
4171
+
4147
4172
if ( ! self . memberModel . global_admin ) {
4148
4173
//self.memberModel.admin_of = currUserDetails.find(".admin-apps .app-list").val().split(",");
4149
4174
//self.memberModel.user_of = currUserDetails.find(".user-apps .app-list").val().split(",");
0 commit comments