Skip to content

Commit 54ae69b

Browse files
committed
feat: add an 'Upload' button at the bottom of OpenFilePicker
1 parent cd8a080 commit 54ae69b

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/gui/src/UI/UIWindow.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ async function UIWindow(options) {
374374
// is_saveFileDialog
375375
if(options.is_saveFileDialog){
376376
h += `<div class="window-filedialog-prompt">`;
377-
h += `<div style="display:flex;">`;
378-
h += `<input type="text" class="savefiledialog-filename" autocorrect="off" spellcheck="false" value="${html_encode(options.saveFileDialog_default_filename) ?? ''}">`;
377+
h += `<div style="display:flex; flex-grow: 1;">`;
378+
h += `<input type="text" style="flex-grow:1;" class="savefiledialog-filename" autocorrect="off" spellcheck="false" value="${html_encode(options.saveFileDialog_default_filename) ?? ''}">`;
379379
h += `<button class="button button-small filedialog-cancel-btn">${i18n('cancel')}</button>`;
380380
h += `<button class="button `;
381381
if(options.saveFileDialog_default_filename === undefined || options.saveFileDialog_default_filename === '')
@@ -388,7 +388,13 @@ async function UIWindow(options) {
388388
// is_openFileDialog
389389
else if(options.is_openFileDialog){
390390
h += `<div class="window-filedialog-prompt">`;
391-
h += `<div style="text-align:right;">`;
391+
// 'upload here'
392+
h += `<div class="window-filedialog-upload-here"><svg xmlns="http://www.w3.org/2000/svg" style="width: 18px; height: 18px; margin-bottom: -5px;" width="16" height="16" fill="currentColor" class="bi bi-cloud-arrow-up" viewBox="0 0 16 16">
393+
<path fill-rule="evenodd" d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708z"/>
394+
<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"/>
395+
</svg> ${i18n('upload')}</div>`;
396+
397+
h += `<div style="text-align:right; flex-grow:1;">`;
392398
h += `<button class="button button-small filedialog-cancel-btn">${i18n('cancel')}</button>`;
393399
h += `<button class="button disabled button-small button-primary openfiledialog-open-btn">${i18n('open')}</button>`;
394400
h += `</div>`;
@@ -398,7 +404,7 @@ async function UIWindow(options) {
398404
// is_directoryPicker
399405
else if(options.is_directoryPicker){
400406
h += `<div class="window-filedialog-prompt">`;
401-
h += `<div style="text-align:right;">`;
407+
h += `<div style="text-align:right; flex-grow: 1;">`;
402408
h += `<button class="button button-small filedialog-cancel-btn">${i18n('cancel')}</button>`;
403409
h += `<button class="button button-small button-primary directorypicker-select-btn" style="margin-left:10px;">${i18n('select')}</button>`;
404410
h += `</div>`;
@@ -492,7 +498,13 @@ async function UIWindow(options) {
492498
const el_filedialog_cancel_btn = document.querySelector(`#window-${win_id} .filedialog-cancel-btn`);
493499
const el_openfiledialog_open_btn = document.querySelector(`#window-${win_id} .openfiledialog-open-btn`);
494500
const el_directorypicker_select_btn = document.querySelector(`#window-${win_id} .directorypicker-select-btn`);
501+
const el_window_filedialog_upload_here = document.querySelector(`#window-${win_id} .window-filedialog-upload-here`);
495502

503+
if(el_window_filedialog_upload_here){
504+
el_window_filedialog_upload_here.addEventListener('click', function(){
505+
window.init_upload_using_dialog(el_window_body, $(el_window).attr('data-path') + '/');
506+
});
507+
}
496508
// attach optional event listeners
497509
el_window.on_before_exit = options.on_before_exit;
498510

src/gui/src/css/style.css

+12-1
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,9 @@ span.header-sort-icon img {
13241324
background-color: #f3f5f9;
13251325
padding: 0 15px;
13261326
display: flex;
1327-
flex-direction: column;
1327+
flex-direction: row;
13281328
justify-content: center;
1329+
align-items: center;
13291330
}
13301331

13311332
.savefiledialog-filename {
@@ -1337,6 +1338,16 @@ span.header-sort-icon img {
13371338
flex-grow: 1;
13381339
}
13391340

1341+
.window-filedialog-upload-here{
1342+
-webkit-font-smoothing: antialiased;
1343+
opacity: 0.7;
1344+
font-size: 14px;
1345+
}
1346+
1347+
.window-filedialog-upload-here:hover{
1348+
cursor: pointer;
1349+
opacity: 1;
1350+
}
13401351
.savefiledialog-save-btn, .openfiledialog-open-btn {
13411352
margin-left: 10px;
13421353
}

src/gui/src/helpers/launch_app.js

-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ const launch_app = async (options)=>{
306306
if(app_info.metadata?.credentialless !== undefined && typeof app_info.metadata.credentialless === 'boolean')
307307
credentialless = app_info.metadata.credentialless;
308308

309-
console.log('credentialless', credentialless);
310309
// open window
311310
el_win = UIWindow({
312311
element_uuid: uuid,

0 commit comments

Comments
 (0)