@@ -640,8 +640,8 @@ var exchange_types;
640640// Used for access control
641641var user_tags ;
642642var user ;
643- var ac ;
644- var display ;
643+ var ac = new AccessControl ( ) ;
644+ var display = new DisplayControl ( ) ;
645645
646646var ui_data_model = {
647647 vhosts : [ ] ,
@@ -651,42 +651,60 @@ var ui_data_model = {
651651
652652// Access control
653653
654- function AccessControl ( user , ui_data_model ) {
655- this . user = user ;
656- this . user_tags = expand_user_tags ( user . tags ) ;
657- this . ui_data_model = ui_data_model ;
654+ function AccessControl ( ) {
658655
656+ this . update = function ( user , ui_data_model ) {
657+ this . user = user ;
658+ this . user_tags = expand_user_tags ( user . tags ) ;
659+ this . ui_data_model = ui_data_model ;
660+ } ;
659661 this . isMonitoringUser = function ( ) {
660- return this . user_tags . includes ( "monitoring" ) ;
662+ if ( this . user_tags )
663+ return this . user_tags . includes ( "monitoring" ) ;
664+ else return false ;
661665 } ;
662666 this . isAdministratorUser = function ( ) {
663- return this . user_tags . includes ( "administrator" ) ;
667+ if ( this . user_tags )
668+ return this . user_tags . includes ( "administrator" ) ;
669+ else return false ;
664670 } ;
665671 this . isPolicyMakerUser = function ( ) {
666- return this . user_tags . includes ( "policymaker" ) ;
672+ if ( this . user_tags )
673+ return this . user_tags . includes ( "policymaker" ) ;
674+ else return false ;
667675 } ;
668676 this . canAccessVhosts = function ( ) {
669- return this . ui_data_model . vhosts . length > 0 ;
677+ if ( this . ui_data_model )
678+ return this . ui_data_model . vhosts . length > 0 ;
679+ else return false ;
670680 } ;
671681 this . canListNodes = function ( ) {
672- return this . isMonitoringUser ( ) && this . ui_data_model . nodes . length > 1 ;
682+ if ( this . ui_data_model )
683+ return this . isMonitoringUser ( ) && this . ui_data_model . nodes . length > 1 ;
684+ else return false ;
673685 } ;
674686
675687} ;
676688
677- function DisplayControl ( overview , ui_data_model ) {
678- this . nodes = ac . canListNodes ( ) && ui_data_model . nodes . length > 1 ;
679- this . vhosts = ac . canAccessVhosts ( ) ;
680- this . rabbitmqVersions = false ;
681- var v = '' ;
682- for ( var i = 0 ; i < ui_data_model . nodes . length ; i ++ ) {
683- var v1 = fmt_rabbit_version ( ui_data_model . nodes [ i ] . applications ) ;
684- if ( v1 != 'unknown' ) {
685- if ( v != '' && v != v1 ) this . rabbitmqVersions = true ;
686- v = v1 ;
687- }
689+ function DisplayControl ( ) {
690+ this . nodes = false
691+ this . vhosts = false
692+ this . rabbitmqVersions = false
693+
694+ this . update = function ( overview , ui_data_model ) {
695+ this . nodes = ac . canListNodes ( ) && ui_data_model . nodes . length > 1
696+ this . vhosts = ac . canAccessVhosts ( )
697+ this . rabbitmqVersions = false
698+ var v = '' ;
699+ for ( var i = 0 ; i < ui_data_model . nodes . length ; i ++ ) {
700+ var v1 = fmt_rabbit_version ( ui_data_model . nodes [ i ] . applications ) ;
701+ if ( v1 != 'unknown' ) {
702+ if ( v != '' && v != v1 ) this . rabbitmqVersions = true ;
703+ v = v1 ;
704+ }
705+ }
706+ this . data = ui_data_model ;
688707 }
689- this . data = ui_data_model ;
690708
691709}
692710
0 commit comments