File tree Expand file tree Collapse file tree 4 files changed +31
-5
lines changed Expand file tree Collapse file tree 4 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -611,6 +611,7 @@ def get_assets(self):
611611 assets = dict (
612612 js = [
613613 "js/helpers/quick_shape_helper.js" ,
614+ "js/helpers/element_helper.js" ,
614615 "js/helpers/debug_rendering_helper.js" ,
615616 "js/helpers/working_area_helper.js" ,
616617 "js/lib/jquery.tinycolorpicker.js" ,
Original file line number Diff line number Diff line change 1+ ( function ( $ ) {
2+ $ . fn . inlineStyle = function ( prop ) {
3+ return this . prop ( "style" ) [ $ . camelCase ( prop ) ] ;
4+ } ;
5+ } ) ( jQuery ) ;
Original file line number Diff line number Diff line change @@ -328,6 +328,31 @@ $(function () {
328328 self . state . _processProgressData = function ( ) { } ;
329329 } ;
330330
331+ // Mutation Observer to show a spinner in working area when file upload is in progress
332+ // since there are no events detecting the start of a the file upload process
333+ const uploadProgressMutationNode = document . getElementById ( "gcode_upload_progress" ) ;
334+ const uploadProgressMutationConfig = {
335+ childList : true ,
336+ attributes : true ,
337+ subtree : true ,
338+ } ;
339+ const uploadProgressMutationCallback = function ( mutationsList , uploadProgressObserver ) {
340+ for ( let mutation of mutationsList ) {
341+ if ( OctoPrint . coreui . selectedTab === "#workingarea" ) {
342+ let width = $ ( mutation . target ) . inlineStyle ( "width" ) ;
343+ if ( width === "0%" ) {
344+ $ ( "body" ) . removeClass ( "activitySpinnerActive" ) ;
345+ } else {
346+ $ ( "body" ) . addClass ( "activitySpinnerActive" ) ;
347+ }
348+ }
349+ }
350+ } ;
351+ const uploadProgressObserver = new MutationObserver ( uploadProgressMutationCallback ) ;
352+ uploadProgressObserver . observe ( uploadProgressMutationNode , uploadProgressMutationConfig ) ;
353+ // End of Mutation Observer
354+
355+
331356 // event fired (once for each file) after onEventFileAdded, but only on upload (not on filecopy)
332357 self . onEventUpload = async function ( payload ) {
333358 // if tab workingarea, place it there (assuming tabs did not change during upload)
Original file line number Diff line number Diff line change @@ -673,11 +673,6 @@ $(function () {
673673 const mutationCallback = function ( mutationsList , observer ) {
674674 for ( let mutation of mutationsList ) {
675675 if ( mutation . type === "childList" ) {
676- ( function ( $ ) {
677- $ . fn . inlineStyle = function ( prop ) {
678- return this . prop ( "style" ) [ $ . camelCase ( prop ) ] ;
679- } ;
680- } ) ( jQuery ) ;
681676 let modalElement = $ ( ".modal-scrollable" ) ;
682677 let backDrop = $ ( ".modal-backdrop" ) ;
683678 if ( modalElement . length !== 0 ) {
You can’t perform that action at this time.
0 commit comments