@@ -42,7 +42,24 @@ qx.Class.define("osparc.MaintenanceTracker", {
4242 statics : {
4343 CHECK_INTERVAL : 15 * 60 * 1000 , // Check every 15'
4444 CLOSABLE_WARN_IN_ADVANCE : 4 * 24 * 60 * 60 * 1000 , // Show Closable Ribbon Message 4 days in advance
45- PERMANENT_WARN_IN_ADVANCE : 60 * 60 * 1000 // Show Permanent Ribbon Message 60' in advance
45+ PERMANENT_WARN_IN_ADVANCE : 60 * 60 * 1000 , // Show Permanent Ribbon Message 60' in advance
46+
47+ dataToText : function ( start , end , reason ) {
48+ let text = osparc . utils . Utils . formatDateAndTime ( start ) ;
49+ if ( end ) {
50+ if ( start . getDate ( ) === end . getDate ( ) ) {
51+ // do not print the same day twice
52+ text += " - " + osparc . utils . Utils . formatTime ( end ) ;
53+ } else {
54+ text += " - " + osparc . utils . Utils . formatDateAndTime ( end ) ;
55+ }
56+ }
57+ text += " (local time)" ;
58+ if ( reason ) {
59+ text += ": " + reason ;
60+ }
61+ return text ;
62+ } ,
4663 } ,
4764
4865 members : {
@@ -78,20 +95,7 @@ qx.Class.define("osparc.MaintenanceTracker", {
7895 return null ;
7996 }
8097
81- let text = osparc . utils . Utils . formatDateAndTime ( this . getStart ( ) ) ;
82- if ( this . getEnd ( ) ) {
83- if ( this . getStart ( ) . getDate ( ) === this . getEnd ( ) . getDate ( ) ) {
84- // do not print the same day twice
85- text += " - " + osparc . utils . Utils . formatTime ( this . getEnd ( ) ) ;
86- } else {
87- text += " - " + osparc . utils . Utils . formatDateAndTime ( this . getEnd ( ) ) ;
88- }
89- }
90- text += " (local time)" ;
91- if ( this . getReason ( ) ) {
92- text += ": " + this . getReason ( ) ;
93- }
94- return text ;
98+ return this . self ( ) . dataToText ( this . getStart ( ) , this . getEnd ( ) , this . getReason ( ) ) ;
9599 } ,
96100
97101 __setMaintenance : function ( maintenanceData ) {
@@ -129,9 +133,9 @@ qx.Class.define("osparc.MaintenanceTracker", {
129133 }
130134 } ,
131135
132- __messageToRibbon : function ( closable ) {
136+ messageToRibbon : function ( closable , message = null ) {
133137 this . __removeRibbonMessage ( ) ;
134- const text = this . __getText ( ) ;
138+ const text = message || this . __getText ( ) ;
135139 const notification = new osparc . notification . RibbonNotification ( text , "maintenance" , closable ) ;
136140 osparc . notification . RibbonNotifications . getInstance ( ) . addNotification ( notification ) ;
137141 this . __lastRibbonMessage = notification ;
@@ -143,14 +147,14 @@ qx.Class.define("osparc.MaintenanceTracker", {
143147 const diffPermanent = this . getStart ( ) . getTime ( ) - now . getTime ( ) - this . self ( ) . PERMANENT_WARN_IN_ADVANCE ;
144148
145149 if ( diffClosable < 0 ) {
146- this . __messageToRibbon ( true ) ;
150+ this . messageToRibbon ( true ) ;
147151 } else {
148- setTimeout ( ( ) => this . __messageToRibbon ( true ) , diffClosable ) ;
152+ setTimeout ( ( ) => this . messageToRibbon ( true ) , diffClosable ) ;
149153 }
150154 if ( diffPermanent < 0 ) {
151- this . __messageToRibbon ( false ) ;
155+ this . messageToRibbon ( false ) ;
152156 } else {
153- setTimeout ( ( ) => this . __messageToRibbon ( false ) , diffPermanent ) ;
157+ setTimeout ( ( ) => this . messageToRibbon ( false ) , diffPermanent ) ;
154158 }
155159 } ,
156160
0 commit comments