@@ -24,6 +24,14 @@ qx.Class.define("osparc.dashboard.CardBase", {
2424 construct : function ( ) {
2525 this . base ( arguments ) ;
2626
27+ if ( osparc . utils . DisabledPlugins . isSimultaneousAccessEnabled ( ) ) {
28+ // "IN_USE" is not a blocker anymore
29+ const inUseIdx = qx . util . PropertyUtil . getProperties ( osparc . dashboard . CardBase ) . blocked . check . indexOf ( "IN_USE" ) ;
30+ if ( inUseIdx > - 1 ) {
31+ qx . util . PropertyUtil . getProperties ( osparc . dashboard . CardBase ) . blocked . check . splice ( inUseIdx , 1 ) ;
32+ }
33+ }
34+
2735 [
2836 "pointerover" ,
2937 "focus"
@@ -768,13 +776,22 @@ qx.Class.define("osparc.dashboard.CardBase", {
768776 } ,
769777
770778 __applyState : function ( state ) {
771- let lockInUse = false ;
779+ let projectInUse = false ;
772780 if ( "locked" in state && "value" in state [ "locked" ] ) {
773- lockInUse = state [ "locked" ] [ "value" ] ;
781+ projectInUse = state [ "locked" ] [ "value" ] ;
774782 }
775- this . setBlocked ( lockInUse ? "IN_USE" : false ) ;
776- if ( lockInUse ) {
777- this . __showBlockedCardFromStatus ( "IN_USE" , state [ "locked" ] ) ;
783+
784+ if ( osparc . utils . DisabledPlugins . isSimultaneousAccessEnabled ( ) ) {
785+ if ( projectInUse && state [ "locked" ] [ "status" ] === "OPENED" ) {
786+ this . __showWhoIsIn ( state [ "locked" ] [ "owner" ] ) ;
787+ } else {
788+ this . __showWhoIsIn ( null ) ;
789+ }
790+ } else {
791+ this . setBlocked ( projectInUse ? "IN_USE" : false ) ;
792+ if ( projectInUse ) {
793+ this . __showBlockedCardFromStatus ( "IN_USE" , state [ "locked" ] ) ;
794+ }
778795 }
779796
780797 const pipelineState = ( "state" in state ) ? state [ "state" ] [ "value" ] : undefined ;
@@ -854,6 +871,30 @@ qx.Class.define("osparc.dashboard.CardBase", {
854871 } ) ;
855872 } ,
856873
874+ __showWhoIsIn : function ( whoIsIn ) {
875+ let users = [ ] ;
876+ if ( whoIsIn ) {
877+ // replace this once the backend returns a list of group__ids
878+ const allUsers = [
879+ { name : "Alice" , avatar : "https://i.pravatar.cc/150?img=1" } ,
880+ { name : "Bob" , avatar : "https://i.pravatar.cc/150?img=2" } ,
881+ { name : "Charlie" , avatar : "https://i.pravatar.cc/150?img=3" } ,
882+ { name : "Dana" , avatar : "https://i.pravatar.cc/150?img=4" } ,
883+ { name : "Eve" , avatar : "https://i.pravatar.cc/150?img=5" } ,
884+ { name : "Frank" , avatar : "https://i.pravatar.cc/150?img=6" } ,
885+ ] ;
886+ // Random number of users between 1 and 6
887+ const randomCount = Math . floor ( Math . random ( ) * 6 ) + 1 ;
888+ // Shuffle the array and take the first randomCount users
889+ const shuffled = allUsers . sort ( ( ) => 0.5 - Math . random ( ) ) ;
890+ users = shuffled . slice ( 0 , randomCount ) ;
891+ }
892+ if ( osparc . utils . DisabledPlugins . isSimultaneousAccessEnabled ( ) && this . getResourceType ( ) === "study" ) {
893+ const avatarGroup = this . getChildControl ( "avatar-group" ) ;
894+ avatarGroup . setUsers ( users ) ;
895+ }
896+ } ,
897+
857898 __showBlockedCardFromStatus : function ( reason , moreInfo ) {
858899 switch ( reason ) {
859900 case "IN_USE" :
0 commit comments