@@ -24,7 +24,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
2424 construct : function ( ) {
2525 this . base ( arguments ) ;
2626
27- if ( osparc . utils . DisabledPlugins . isSimultaneousAccessEnabled ( ) ) {
27+ if ( osparc . utils . DisabledPlugins . isRTCEnabled ( ) ) {
2828 // "IN_USE" is not a blocker anymore
2929 const inUseIdx = qx . util . PropertyUtil . getProperties ( osparc . dashboard . CardBase ) . blocked . check . indexOf ( "IN_USE" ) ;
3030 if ( inUseIdx > - 1 ) {
@@ -804,34 +804,26 @@ qx.Class.define("osparc.dashboard.CardBase", {
804804 } ,
805805
806806 __applyState : function ( state ) {
807- let projectInUse = false ;
808- if ( "shareState" in state && "locked" in state [ "shareState" ] ) {
809- projectInUse = state [ "shareState" ] [ "locked" ] ;
810- }
807+ const projectLocked = osparc . study . Utils . state . isProjectLocked ( state ) ;
808+ const currentUserGroupIds = osparc . study . Utils . state . getCurrentGroupIds ( state ) ;
809+ const pipelineState = osparc . study . Utils . state . getPipelineState ( state ) ;
811810
812- if ( osparc . utils . DisabledPlugins . isSimultaneousAccessEnabled ( ) ) {
813- if ( projectInUse && state [ "shareState" ] [ "status" ] === "OPENED" ) {
814- this . __showWhoIsIn ( state [ "shareState" ] [ "currentUserGroupids" ] ) ;
815- } else {
816- this . __showWhoIsIn ( null ) ;
817- }
818- } else {
819- this . setBlocked ( projectInUse ? "IN_USE" : false ) ;
820- if ( projectInUse ) {
821- this . __showBlockedCardFromStatus ( "IN_USE" , state [ "shareState" ] ) ;
822- }
811+ this . __showCurrentUserGroupIds ( currentUserGroupIds ) ;
812+
813+ this . setBlocked ( projectLocked ? "IN_USE" : false ) ;
814+ if ( projectLocked ) {
815+ this . __showBlockedCardFromStatus ( "IN_USE" , state [ "shareState" ] ) ;
823816 }
824817
825- const pipelineState = ( "state" in state ) ? state [ "state" ] [ "value" ] : undefined ;
826818 if ( pipelineState ) {
827- this . __applyPipelineState ( state [ "state" ] [ "value" ] ) ;
819+ this . __applyPipelineState ( pipelineState ) ;
828820 }
829821 } ,
830822
831823 __applyDebt : function ( debt ) {
832824 this . setBlocked ( debt ? "IN_DEBT" : false ) ;
833825 if ( debt ) {
834- this . __showBlockedCardFromStatus ( "IN_DEBT" , debt ) ;
826+ this . __showBlockedCardFromStatus ( "IN_DEBT" ) ;
835827 }
836828 } ,
837829
@@ -899,73 +891,70 @@ qx.Class.define("osparc.dashboard.CardBase", {
899891 } ) ;
900892 } ,
901893
902- __showWhoIsIn : function ( whoIsIn ) {
903- let users = [ ] ;
904- if ( whoIsIn ) {
905- // replace this once the backend returns a list of group__ids
906- const allUsers = [
907- { name : "Alice" , avatar : "https://i.pravatar.cc/150?img=1" } ,
908- { name : "Bob" , avatar : "https://i.pravatar.cc/150?img=2" } ,
909- { name : "Charlie" , avatar : "https://i.pravatar.cc/150?img=3" } ,
910- { name : "Dana" , avatar : "https://i.pravatar.cc/150?img=4" } ,
911- { name : "Eve" , avatar : "https://i.pravatar.cc/150?img=5" } ,
912- { name : "Frank" , avatar : "https://i.pravatar.cc/150?img=6" } ,
913- ] ;
914- // Random number of users between 1 and 6
915- const randomCount = Math . floor ( Math . random ( ) * 6 ) + 1 ;
916- // Shuffle the array and take the first randomCount users
917- const shuffled = allUsers . sort ( ( ) => 0.5 - Math . random ( ) ) ;
918- users = shuffled . slice ( 0 , randomCount ) ;
919- }
920- if ( osparc . utils . DisabledPlugins . isSimultaneousAccessEnabled ( ) && this . getResourceType ( ) === "study" ) {
921- const avatarGroup = this . getChildControl ( "avatar-group" ) ;
922- avatarGroup . setUsers ( users ) ;
923- }
894+ __showCurrentUserGroupIds : function ( currentUserGroupIds ) {
895+ const avatarGroup = this . getChildControl ( "avatar-group" ) ;
896+ avatarGroup . setUserGroupIds ( currentUserGroupIds ) ;
924897 } ,
925898
926- __showBlockedCardFromStatus : function ( reason , moreInfo ) {
899+ __showBlockedCardFromStatus : function ( reason , shareState ) {
927900 switch ( reason ) {
928901 case "IN_USE" :
929- this . __blockedInUse ( moreInfo ) ;
902+ this . __blockedInUse ( shareState ) ;
930903 break ;
931904 case "IN_DEBT" :
932- this . __blockedInDebt ( moreInfo ) ;
905+ this . __blockedInDebt ( ) ;
933906 break ;
934907 }
935908 } ,
936909
937- __blockedInUse : function ( lockedStatus ) {
938- const status = lockedStatus [ "status" ] ;
939- const userGroupIDs = lockedStatus [ "currentUserGroupids" ] ;
940- let toolTip = userGroupIDs [ 0 ]
941- // osparc.utils.Utils.firstsUp(userGroupIDs[0]["first_name"] || this.tr("A user"), userGroupIDs[0]["last_name"] || ""); // it will be replaced by "userName"
910+ __blockedInUse : function ( shareState ) {
911+ const status = shareState [ "status" ] ;
912+ const currentUserGroupIds = shareState [ "currentUserGroupids" ] ;
913+ const usersStore = osparc . store . Users . getInstance ( ) ;
914+ const userPromises = currentUserGroupIds . map ( userGroupId => usersStore . getUser ( userGroupId ) ) ;
915+ const usernames = [ ] ;
916+ let toolTip = "" ;
942917 let image = null ;
943- switch ( status ) {
944- case "CLOSING" :
945- image = "@FontAwesome5Solid/key/" ;
946- toolTip += this . tr ( " is closing it..." ) ;
947- break ;
948- case "CLONING" :
949- image = "@FontAwesome5Solid/clone/" ;
950- toolTip += this . tr ( " is cloning it..." ) ;
951- break ;
952- case "EXPORTING" :
953- image = osparc . task . Export . ICON + "/" ;
954- toolTip += this . tr ( " is exporting it..." ) ;
955- break ;
956- case "OPENING" :
957- image = "@FontAwesome5Solid/key/" ;
958- toolTip += this . tr ( " is opening it..." ) ;
959- break ;
960- case "OPENED" :
961- image = "@FontAwesome5Solid/lock/" ;
962- toolTip += this . tr ( " is using it." ) ;
963- break ;
964- default :
965- image = "@FontAwesome5Solid/lock/" ;
966- break ;
967- }
968- this . __showBlockedCard ( image , toolTip ) ;
918+ Promise . all ( userPromises )
919+ . then ( usersResult => {
920+ usersResult . forEach ( user => {
921+ usernames . push ( user . getUsername ( ) ) ;
922+ } ) ;
923+ } )
924+ . catch ( error => {
925+ console . error ( "Failed to fetch user data for avatars:" , error ) ;
926+ } )
927+ . finally ( ( ) => {
928+ switch ( status ) {
929+ case "CLOSING" :
930+ image = "@FontAwesome5Solid/key/" ;
931+ toolTip += this . tr ( "Closing..." ) ;
932+ break ;
933+ case "CLONING" :
934+ image = "@FontAwesome5Solid/clone/" ;
935+ toolTip += this . tr ( "Cloning..." ) ;
936+ break ;
937+ case "EXPORTING" :
938+ image = osparc . task . Export . ICON + "/" ;
939+ toolTip += this . tr ( "Exporting..." ) ;
940+ break ;
941+ case "OPENING" :
942+ image = "@FontAwesome5Solid/key/" ;
943+ toolTip += this . tr ( "Opening..." ) ;
944+ break ;
945+ case "OPENED" :
946+ image = "@FontAwesome5Solid/lock/" ;
947+ toolTip += this . tr ( "In use..." ) ;
948+ break ;
949+ default :
950+ image = "@FontAwesome5Solid/lock/" ;
951+ break ;
952+ }
953+ usernames . forEach ( username => {
954+ toolTip += "<br>" + username ;
955+ } ) ;
956+ this . __showBlockedCard ( image , toolTip ) ;
957+ } ) ;
969958 } ,
970959
971960 __blockedInDebt : function ( ) {
0 commit comments