@@ -68,6 +68,63 @@ function cpu_pinning() {
6868## CREATE CONTAINER ##
6969##########################
7070
71+ // Simple UI blocker used by create/update operations so the user can't keep clicking around mid-install.
72+ function dockerUIBlockerScript ($ enable ) {
73+ if ($ enable ) {
74+ echo <<<HTML
75+ <script>
76+ (function () {
77+ try {
78+ var d = (window.parent && window.parent.document) ? window.parent.document : document;
79+ if (!d || !d.body) return;
80+
81+ // Define helpers once.
82+ if (!window.parent) window.parent = window;
83+ if (!window.parent.dockerUIBlock) {
84+ window.parent.dockerUIBlock = function (on) {
85+ try {
86+ var doc = (window.parent && window.parent.document) ? window.parent.document : document;
87+ if (!doc || !doc.body) return;
88+
89+ var blockerId = 'dockerInstallBlocker';
90+ var blockerClass = 'docker-install-blocker';
91+
92+ if (!on) {
93+ var o = doc.getElementById(blockerId);
94+ if (o) o.remove();
95+ return;
96+ }
97+
98+ var o2 = doc.getElementById(blockerId);
99+ if (!o2) {
100+ o2 = doc.createElement('div');
101+ o2.id = blockerId;
102+ o2.className = blockerClass;
103+ doc.body.appendChild(o2);
104+ }
105+ } catch (e) {}
106+ };
107+ }
108+
109+ window.parent.dockerUIBlock(true);
110+ } catch (e) {}
111+ })();
112+ </script>
113+ HTML ;
114+ } else {
115+ echo <<<HTML
116+ <script>
117+ (function () {
118+ try {
119+ var w = window.parent || window;
120+ if (w && w.dockerUIBlock) w.dockerUIBlock(false);
121+ } catch (e) {}
122+ })();
123+ </script>
124+ HTML ;
125+ }
126+ }
127+
71128if (isset ($ _POST ['contName ' ])) {
72129 $ postXML = postToXML ($ _POST , true );
73130 $ dry_run = isset ($ _POST ['dryRun ' ]) && $ _POST ['dryRun ' ]=='true ' ;
@@ -76,6 +133,8 @@ function cpu_pinning() {
76133 // Get the command line
77134 [$ cmd , $ Name , $ Repository ] = xmlToCommand ($ postXML , $ create_paths );
78135 readfile ("$ docroot/plugins/dynamix.docker.manager/log.htm " );
136+ echo '<link type="text/css" rel="stylesheet" href=" ' .autov ("/plugins/dynamix.docker.manager/sheets/AddContainer.css " ,true ).'"> ' ;
137+ if (!$ dry_run ) dockerUIBlockerScript (true );
79138 @flush ();
80139 // Saving the generated configuration file.
81140 $ userTmplDir = $ dockerManPaths ['templates-user ' ];
@@ -114,6 +173,7 @@ function cpu_pinning() {
114173 if (!$ DockerClient ->doesImageExist ($ Repository )) {
115174 // Pull image
116175 if (!pullImage ($ Name , $ Repository )) {
176+ dockerUIBlockerScript (false );
117177 echo '<div style="text-align:center"><button type="button" onclick="done()"> ' ._ ('Done ' ).'</button></div><br> ' ;
118178 goto END ;
119179 }
@@ -166,6 +226,7 @@ function cpu_pinning() {
166226 execCommand ($ cmd );
167227 if ($ startContainer ) addRoute ($ Name ); // add route for remote WireGuard access
168228
229+ dockerUIBlockerScript (false );
169230 echo '<div style="text-align:center"><button type="button" onclick="openTerminal( \'docker \', \'' .addslashes ($ Name ).'\', \'.log \')"> ' ._ ('View Container Log ' ).'</button> <button type="button" onclick="done()"> ' ._ ('Done ' ).'</button></div><br> ' ;
170231 goto END ;
171232}
@@ -178,6 +239,8 @@ function cpu_pinning() {
178239 $ echo = empty ($ _GET ['mute ' ]);
179240 if ($ echo ) {
180241 readfile ("$ docroot/plugins/dynamix.docker.manager/log.htm " );
242+ echo '<link type="text/css" rel="stylesheet" href=" ' .autov ("/plugins/dynamix.docker.manager/sheets/AddContainer.css " ,true ).'"> ' ;
243+ dockerUIBlockerScript (true );
181244 @flush ();
182245 }
183246 foreach ($ _GET ['ct ' ] as $ value ) {
@@ -245,6 +308,9 @@ function cpu_pinning() {
245308 // remove old orphan image since it's no longer used by this container
246309 if ($ oldImageID && $ oldImageID != $ newImageID ) removeImage ($ oldImageID , $ echo );
247310 }
311+ if ($ echo ) {
312+ dockerUIBlockerScript (false );
313+ }
248314 echo '<div style="text-align:center"><button type="button" onclick="window.parent.jQuery( \'#iframe-popup \').dialog( \'close \')"> ' ._ ('Done ' ).'</button></div><br> ' ;
249315 goto END ;
250316}
0 commit comments