File tree Expand file tree Collapse file tree 3 files changed +28
-19
lines changed
services/static-webserver/client/source/class/osparc Expand file tree Collapse file tree 3 files changed +28
-19
lines changed Original file line number Diff line number Diff line change @@ -59,16 +59,10 @@ qx.Class.define("osparc.node.TierSelectionView", {
5959 } ) ;
6060 const studyId = node . getStudy ( ) . getUuid ( ) ;
6161 const nodeId = node . getNodeId ( ) ;
62- const unitParams = {
63- url : {
64- studyId,
65- nodeId
66- }
67- } ;
68- osparc . data . Resources . fetch ( "studies" , "getPricingUnit" , unitParams )
69- . then ( preselectedPricingUnit => {
70- if ( preselectedPricingUnit && preselectedPricingUnit [ "pricingUnitId" ] ) {
71- const tierFound = tierBox . getSelectables ( ) . find ( t => t . getModel ( ) === preselectedPricingUnit [ "pricingUnitId" ] ) ;
62+ osparc . store . Study . getSelectedPricingUnit ( studyId , nodeId )
63+ . then ( selectedPricingUnit => {
64+ if ( selectedPricingUnit && selectedPricingUnit [ "pricingUnitId" ] ) {
65+ const tierFound = tierBox . getSelectables ( ) . find ( t => t . getModel ( ) === selectedPricingUnit [ "pricingUnitId" ] ) ;
7266 if ( tierFound ) {
7367 tierBox . setSelection ( [ tierFound ] ) ;
7468 } else {
Original file line number Diff line number Diff line change @@ -198,5 +198,26 @@ qx.Class.define("osparc.store.Study", {
198198 this . __nodeResources [ studyId ] [ nodeId ] = updatedResources ;
199199 } ) ;
200200 } ,
201+
202+ getSelectedPricingUnit : function ( studyId , nodeId ) {
203+ const params = {
204+ url : {
205+ studyId,
206+ nodeId
207+ }
208+ } ;
209+ return osparc . data . Resources . fetch ( "studies" , "getPricingUnits" , params )
210+ . then ( pricingUnits => {
211+ if ( pricingUnits && pricingUnits [ "pricingUnits" ] ) {
212+ return pricingUnits [ "pricingUnits" ] ;
213+ } else {
214+ throw new Error ( "No pricing units found" ) ;
215+ }
216+ } )
217+ . catch ( err => {
218+ console . error ( "Failed to fetch pricing units:" , err ) ;
219+ throw err ;
220+ } ) ;
221+ }
201222 }
202223} ) ;
Original file line number Diff line number Diff line change @@ -103,20 +103,14 @@ qx.Class.define("osparc.study.NodePricingUnits", {
103103 osparc . store . Services . getPricingPlan ( nodeKey , nodeVersion )
104104 . then ( pricingPlanData => {
105105 if ( pricingPlanData ) {
106- const unitParams = {
107- url : {
108- studyId,
109- nodeId
110- }
111- } ;
112106 this . set ( {
113107 pricingPlanId : pricingPlanData [ "pricingPlanId" ]
114108 } ) ;
115- osparc . data . Resources . fetch ( "studies" , "getPricingUnit" , unitParams )
116- . then ( preselectedPricingUnit => {
109+ osparc . store . Study . getSelectedPricingUnit ( studyId , nodeId )
110+ . then ( selectedPricingUnit => {
117111 if ( pricingPlanData && "pricingUnits" in pricingPlanData && pricingPlanData [ "pricingUnits" ] . length ) {
118112 const pricingUnitsData = pricingPlanData [ "pricingUnits" ] ;
119- const pricingUnitTiers = this . __pricingUnits = new osparc . study . PricingUnitTiers ( pricingUnitsData , preselectedPricingUnit ) ;
113+ const pricingUnitTiers = this . __pricingUnits = new osparc . study . PricingUnitTiers ( pricingUnitsData , selectedPricingUnit ) ;
120114 if ( inGroupBox ) {
121115 const pricingUnitsLayout = osparc . study . StudyOptions . createGroupBox ( nodeLabel ) ;
122116 pricingUnitsLayout . add ( pricingUnitTiers ) ;
You can’t perform that action at this time.
0 commit comments