@@ -320,7 +320,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
320320
321321 trashedAt : {
322322 check : "Date" ,
323- apply : "_applyTrasehdAt " ,
323+ apply : "_applyTrashedAt " ,
324324 nullable : true
325325 } ,
326326
@@ -385,15 +385,15 @@ qx.Class.define("osparc.dashboard.CardBase", {
385385 apply : "__applyState"
386386 } ,
387387
388- projectState : {
389- check : [ "NOT_STARTED" , "STARTED" , "SUCCESS" , "FAILED" , "UNKNOWN" ] ,
390- nullable : false ,
391- init : "UNKNOWN" ,
392- apply : "_applyProjectState "
388+ debt : {
389+ check : "Number" ,
390+ nullable : true ,
391+ init : 0 ,
392+ apply : "__applyDebt "
393393 } ,
394394
395395 blocked : {
396- check : [ true , "UNKNOWN_SERVICES" , "IN_USE" , false ] ,
396+ check : [ true , "UNKNOWN_SERVICES" , "IN_USE" , "IN_DEBT" , false ] ,
397397 init : false ,
398398 nullable : false ,
399399 apply : "__applyBlocked"
@@ -547,7 +547,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
547547 throw new Error ( "Abstract method called!" ) ;
548548 } ,
549549
550- _applyTrasehdAt : function ( value , old ) {
550+ _applyTrashedAt : function ( value , old ) {
551551 throw new Error ( "Abstract method called!" ) ;
552552 } ,
553553
@@ -633,7 +633,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
633633 const unaccessibleServices = osparc . study . Utils . getInaccessibleServices ( workbench )
634634 if ( unaccessibleServices . length ) {
635635 this . setBlocked ( "UNKNOWN_SERVICES" ) ;
636- const image = "@FontAwesome5Solid/ban/" ;
636+ let image = "@FontAwesome5Solid/ban/" ;
637637 let toolTipText = this . tr ( "Service info missing" ) ;
638638 unaccessibleServices . forEach ( unSrv => {
639639 toolTipText += "<br>" + unSrv . key + ":" + unSrv . version ;
@@ -681,65 +681,75 @@ qx.Class.define("osparc.dashboard.CardBase", {
681681 } ,
682682
683683 __applyState : function ( state ) {
684- const locked = ( "locked" in state ) ? state [ "locked" ] [ "value" ] : false ;
685- this . setBlocked ( locked ? "IN_USE" : false ) ;
686- if ( locked ) {
687- this . __showBlockedCardFromStatus ( state [ "locked" ] ) ;
684+ let lockInUse = false ;
685+ if ( "locked" in state && "value" in state [ "locked" ] ) {
686+ lockInUse = state [ "locked" ] [ "value" ] ;
687+ }
688+ this . setBlocked ( lockInUse ? "IN_USE" : false ) ;
689+ if ( lockInUse ) {
690+ this . __showBlockedCardFromStatus ( "IN_USE" , state [ "locked" ] ) ;
688691 }
689692
690- const projectState = ( "state" in state ) ? state [ "state" ] [ "value" ] : undefined ;
691- if ( projectState ) {
692- this . _applyProjectState ( state [ "state" ] ) ;
693+ const pipelineState = ( "state" in state ) ? state [ "state" ] [ "value" ] : undefined ;
694+ if ( pipelineState ) {
695+ this . __applyPipelineState ( state [ "state" ] [ "value "] ) ;
693696 }
694697 } ,
695698
696- _applyProjectState : function ( projectStatus ) {
697- const status = projectStatus [ "value" ] ;
698- let icon ;
699- let toolTip ;
700- let border ;
701- switch ( status ) {
699+ __applyDebt : function ( debt ) {
700+ this . setBlocked ( debt ? "IN_DEBT" : false ) ;
701+ if ( debt ) {
702+ this . __showBlockedCardFromStatus ( "IN_DEBT" , debt ) ;
703+ }
704+ } ,
705+
706+ // pipelineState: ["NOT_STARTED", "STARTED", "SUCCESS", "ABORTED", "FAILED", "UNKNOWN"]
707+ __applyPipelineState : function ( pipelineState ) {
708+ let iconSource ;
709+ let toolTipText ;
710+ let borderColor ;
711+ switch ( pipelineState ) {
702712 case "STARTED" :
703- icon = "@FontAwesome5Solid/spinner/10" ;
704- toolTip = this . tr ( "Running" ) ;
705- border = "info" ;
713+ iconSource = "@FontAwesome5Solid/spinner/10" ;
714+ toolTipText = this . tr ( "Running" ) ;
715+ borderColor = "info" ;
706716 break ;
707717 case "SUCCESS" :
708- icon = "@FontAwesome5Solid/check/10" ;
709- toolTip = this . tr ( "Ran successfully" ) ;
710- border = "success" ;
718+ iconSource = "@FontAwesome5Solid/check/10" ;
719+ toolTipText = this . tr ( "Ran successfully" ) ;
720+ borderColor = "success" ;
711721 break ;
712722 case "ABORTED" :
713- icon = "@FontAwesome5Solid/exclamation/10" ;
714- toolTip = this . tr ( "Run aborted" ) ;
715- border = "warning" ;
723+ iconSource = "@FontAwesome5Solid/exclamation/10" ;
724+ toolTipText = this . tr ( "Run aborted" ) ;
725+ borderColor = "warning" ;
716726 break ;
717727 case "FAILED" :
718- icon = "@FontAwesome5Solid/exclamation/10" ;
719- toolTip = this . tr ( "Ran with error" ) ;
720- border = "error" ;
728+ iconSource = "@FontAwesome5Solid/exclamation/10" ;
729+ toolTipText = this . tr ( "Ran with error" ) ;
730+ borderColor = "error" ;
721731 break ;
732+ case "UNKNOWN" :
733+ case "NOT_STARTED" :
722734 default :
723- icon = null ;
724- toolTip = null ;
725- border = null ;
735+ iconSource = null ;
736+ toolTipText = null ;
737+ borderColor = null ;
726738 break ;
727739 }
728- this . __applyProjectLabel ( icon , toolTip , border ) ;
729- } ,
730740
731- __applyProjectLabel : function ( icn , toolTipText , bdr ) {
732741 const border = new qx . ui . decoration . Decorator ( ) . set ( {
733742 radius : 10 ,
734743 width : 1 ,
735744 style : "solid" ,
736- color : bdr ,
737- backgroundColor : bdr ? bdr + "-bg" : null
745+ color : borderColor ,
746+ backgroundColor : borderColor ? borderColor + "-bg" : null
738747 } ) ;
748+
739749 const projectStatusLabel = this . getChildControl ( "project-status" ) ;
740750 projectStatusLabel . set ( {
741751 decorator : border ,
742- textColor : bdr ,
752+ textColor : borderColor ,
743753 alignX : "center" ,
744754 alignY : "middle" ,
745755 height : 17 ,
@@ -748,14 +758,25 @@ qx.Class.define("osparc.dashboard.CardBase", {
748758 } ) ;
749759
750760 projectStatusLabel . set ( {
751- visibility : icn && toolTipText && bdr ? "visible" : "excluded" ,
752- source : icn ,
753- toolTipIcon : icn ,
761+ visibility : iconSource && toolTipText && borderColor ? "visible" : "excluded" ,
762+ source : iconSource ,
763+ toolTipIcon : iconSource ,
754764 toolTipText
755765 } ) ;
756766 } ,
757767
758- __showBlockedCardFromStatus : function ( lockedStatus ) {
768+ __showBlockedCardFromStatus : function ( reason , moreInfo ) {
769+ switch ( reason ) {
770+ case "IN_USE" :
771+ this . __blockedInUse ( moreInfo ) ;
772+ break ;
773+ case "IN_DEBT" :
774+ this . __blockedInDebt ( moreInfo ) ;
775+ break ;
776+ }
777+ } ,
778+
779+ __blockedInUse : function ( lockedStatus ) {
759780 const status = lockedStatus [ "status" ] ;
760781 const owner = lockedStatus [ "owner" ] ;
761782 let toolTip = osparc . utils . Utils . firstsUp ( owner [ "first_name" ] || this . tr ( "A user" ) , owner [ "last_name" ] || "" ) ; // it will be replaced by "userName"
@@ -788,14 +809,23 @@ qx.Class.define("osparc.dashboard.CardBase", {
788809 this . __showBlockedCard ( image , toolTip ) ;
789810 } ,
790811
812+ __blockedInDebt : function ( ) {
813+ const studyAlias = osparc . product . Utils . getStudyAlias ( { firstUpperCase : true } ) ;
814+ const toolTip = studyAlias + " " + this . tr ( "Embargoed<br>Credits Required" ) ;
815+ const image = "@FontAwesome5Solid/lock/" ;
816+ this . __showBlockedCard ( image , toolTip ) ;
817+ } ,
818+
791819 __showBlockedCard : function ( lockImageSrc , toolTipText ) {
792820 this . getChildControl ( "lock-status" ) . set ( {
793821 opacity : 1.0 ,
794822 visibility : "visible"
795823 } ) ;
824+
796825 const lockImage = this . getChildControl ( "lock-status" ) . getChildControl ( "image" ) ;
797826 lockImageSrc += this . classname . includes ( "Grid" ) ? "32" : "22" ;
798827 lockImage . setSource ( lockImageSrc ) ;
828+
799829 if ( toolTipText ) {
800830 this . set ( {
801831 toolTipText
0 commit comments