luci-base: ui.js: show filename after selecting upload file
authorJo-Philipp Wich <jo@mein.io>
Sun, 10 Nov 2019 18:45:58 +0000 (19:45 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sun, 10 Nov 2019 18:45:58 +0000 (19:45 +0100)
Fixes: #3286
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/ui.js

index ffa36402a6aa5c27992a85d8caf493be0d4fd07a..2e360410dfb6720fc43f4a322b7573d75ac9aee5 100644 (file)
@@ -2277,7 +2277,23 @@ return L.Class.extend({
                                                        type: 'file',
                                                        style: 'display:none',
                                                        change: function(ev) {
-                                                               L.dom.parent(ev.target, '.modal').querySelector('.cbi-button-action.important').disabled = false;
+                                                               var modal = L.dom.parent(ev.target, '.modal'),
+                                                                   body = modal.querySelector('p'),
+                                                                   upload = modal.querySelector('.cbi-button-action.important'),
+                                                                   file = ev.currentTarget.files[0];
+
+                                                               if (file == null)
+                                                                       return;
+
+                                                               L.dom.content(body, [
+                                                                       E('ul', {}, [
+                                                                               E('li', {}, [ '%s: %s'.format(_('Name'), file.name.replace(/^.*[\\\/]/, '')) ]),
+                                                                               E('li', {}, [ '%s: %1024mB'.format(_('Size'), file.size) ])
+                                                                       ])
+                                                               ]);
+
+                                                               upload.disabled = false;
+                                                               upload.focus();
                                                        }
                                                }),
                                                E('button', {