@@ -435,6 +435,8 @@ function generate_edit_app_section(app) {
435
435
if ( app . result )
436
436
app = app . result ;
437
437
438
+ let maximize_on_start = app . maximize_on_start ? 'checked' : '' ;
439
+
438
440
let h = `` ;
439
441
h += `
440
442
<div class="edit-app-navbar">
@@ -485,11 +487,6 @@ function generate_edit_app_section(app) {
485
487
<label for="edit-app-app-id">App ID</label>
486
488
<input type="text" style="width: 362px;" class="app-uid" value="${ html_encode ( app . uid ) } " readonly>
487
489
488
- <div>
489
- <input type="checkbox" id="edit-app-maximize-on-start" name="edit-app-maximize-on-start" value="true" style="margin-top:30px;" ${ app . maximize_on_start ? 'checked' : '' } >
490
- <label for="edit-app-maximize-on-start" style="display: inline;">Maximize window on start</label>
491
- </div>
492
-
493
490
<div>
494
491
<input type="checkbox" id="edit-app-background" name="edit-app-background" value="true" style="margin-top:30px;" ${ app . background ? 'checked' : '' } >
495
492
<label for="edit-app-background" style="display: inline;">Run as a background process.</label>
@@ -500,6 +497,35 @@ function generate_edit_app_section(app) {
500
497
<label for="edit-app-fullpage-on-landing" style="display: inline;">Load in full-page mode when a user lands directly on this app.</label>
501
498
</div>
502
499
500
+ <div>
501
+ <input type="checkbox" id="edit-app-maximize-on-start" name="edit-app-maximize-on-start" value="true" style="margin-top:30px;" ${ maximize_on_start ? 'checked' : '' } >
502
+ <label for="edit-app-maximize-on-start" style="display: inline;">Maximize window on start</label>
503
+ </div>
504
+
505
+ <div>
506
+ <label for="edit-app-window-width">Window Width</label>
507
+ <input type="number" id="edit-app-window-width" placeholder="800" value="${ html_encode ( app . metadata ?. window_size ?. width ?? 800 ) } " style="width:200px;" ${ maximize_on_start ? 'disabled' : '' } >
508
+ <label for="edit-app-window-height">Window Height</label>
509
+ <input type="number" id="edit-app-window-height" placeholder="600" value="${ html_encode ( app . metadata ?. window_size ?. height ?? 600 ) } " style="width:200px;" ${ maximize_on_start ? 'disabled' : '' } >
510
+ </div>
511
+
512
+ <div style="margin-top:30px;">
513
+ <label for="edit-app-window-top">Window Top</label>
514
+ <input type="number" id="edit-app-window-top" placeholder="100" value="${ app . metadata ?. window_position ?. top ? html_encode ( app . metadata . window_position . top ) : '' } " style="width:200px;" ${ maximize_on_start ? 'disabled' : '' } >
515
+ <label for="edit-app-window-left">Window Left</label>
516
+ <input type="number" id="edit-app-window-left" placeholder="100" value="${ app . metadata ?. window_position ?. left ? html_encode ( app . metadata . window_position . left ) : '' } " style="width:200px;" ${ maximize_on_start ? 'disabled' : '' } >
517
+ </div>
518
+
519
+ <div style="margin-top:30px;">
520
+ <input type="checkbox" id="edit-app-window-resizable" name="edit-app-window-resizable" value="true" ${ app . metadata ?. window_resizable ? 'checked' : '' } >
521
+ <label for="edit-app-window-resizable" style="display: inline;">Window Resizable</label>
522
+ </div>
523
+
524
+ <div style="margin-top:30px;">
525
+ <input type="checkbox" id="edit-app-hide-titlebar" name="edit-app-hide-titlebar" value="true" ${ app . metadata ?. hide_titlebar ? 'checked' : '' } >
526
+ <label for="edit-app-hide-titlebar" style="display: inline;">Hide Titlebar</label>
527
+ </div>
528
+
503
529
<label for="edit-app-icon">Icon</label>
504
530
<div id="edit-app-icon" style="background-image:url(${ ! app . icon ? './img/app.svg' : html_encode ( app . icon ) } );" ${ app . icon ? 'data-url="' + html_encode ( app . icon ) + '"' : '' } >
505
531
<div id="change-app-icon">Change App Icon</div>
@@ -804,6 +830,11 @@ $(document).on('click', '.edit-app-save-btn', async function (e) {
804
830
const index_url = $ ( '#edit-app-index-url' ) . val ( ) ;
805
831
const description = $ ( '#edit-app-description' ) . val ( ) ;
806
832
const uid = $ ( '#edit-app-uid' ) . val ( ) ;
833
+ const height = $ ( '#edit-app-window-height' ) . val ( ) ;
834
+ const width = $ ( '#edit-app-window-width' ) . val ( ) ;
835
+ const top = $ ( '#edit-app-window-top' ) . val ( ) ;
836
+ const left = $ ( '#edit-app-window-left' ) . val ( ) ;
837
+
807
838
let filetype_associations = $ ( '#edit-app-filetype-associations' ) . val ( ) ;
808
839
809
840
let icon ;
@@ -827,6 +858,24 @@ $(document).on('click', '.edit-app-save-btn', async function (e) {
827
858
error = `<strong>Index URL</strong> must be a valid url.` ;
828
859
else if ( ! index_url . toLowerCase ( ) . startsWith ( 'https://' ) && ! index_url . toLowerCase ( ) . startsWith ( 'http://' ) )
829
860
error = `<strong>Index URL</strong> must start with 'https://' or 'http://'.` ;
861
+ // height must be a number
862
+ else if ( isNaN ( height ) )
863
+ error = `<strong>Window Height</strong> must be a number.` ;
864
+ // height must be greater than 0
865
+ else if ( height <= 0 )
866
+ error = `<strong>Window Height</strong> must be greater than 0.` ;
867
+ // width must be a number
868
+ else if ( isNaN ( width ) )
869
+ error = `<strong>Window Width</strong> must be a number.` ;
870
+ // width must be greater than 0
871
+ else if ( width <= 0 )
872
+ error = `<strong>Window Width</strong> must be greater than 0.` ;
873
+ // top must be a number
874
+ else if ( top && isNaN ( top ) )
875
+ error = `<strong>Window Top</strong> must be a number.` ;
876
+ // left must be a number
877
+ else if ( left && isNaN ( left ) )
878
+ error = `<strong>Window Left</strong> must be a number.` ;
830
879
831
880
// download icon from URL
832
881
else {
@@ -871,6 +920,16 @@ $(document).on('click', '.edit-app-save-btn', async function (e) {
871
920
background : $ ( '#edit-app-background' ) . is ( ":checked" ) ,
872
921
metadata : {
873
922
fullpage_on_landing : $ ( '#edit-app-fullpage-on-landing' ) . is ( ":checked" ) ,
923
+ window_size : {
924
+ width : width ?? 800 ,
925
+ height : height ?? 600 ,
926
+ } ,
927
+ window_position : {
928
+ top : top ,
929
+ left : left ,
930
+ } ,
931
+ window_resizable : $ ( '#edit-app-window-resizable' ) . is ( ":checked" ) ,
932
+ hide_titlebar : $ ( '#edit-app-hide-titlebar' ) . is ( ":checked" ) ,
874
933
} ,
875
934
filetypeAssociations : filetype_associations ,
876
935
} ) . then ( async ( app ) => {
@@ -2013,4 +2072,15 @@ function getMimeType(extension) {
2013
2072
2014
2073
// Return the MIME type if found, otherwise return 'application/octet-stream'
2015
2074
return mimeTypes [ cleanExtension ] || 'application/octet-stream' ;
2016
- }
2075
+ }
2076
+
2077
+ // if edit-app-maximize-on-start is checked, disable window size and position fields
2078
+ $ ( document ) . on ( 'change' , '#edit-app-maximize-on-start' , function ( e ) {
2079
+ if ( $ ( this ) . is ( ':checked' ) ) {
2080
+ $ ( '#edit-app-window-width, #edit-app-window-height' ) . prop ( 'disabled' , true ) ;
2081
+ $ ( '#edit-app-window-top, #edit-app-window-left' ) . prop ( 'disabled' , true ) ;
2082
+ } else {
2083
+ $ ( '#edit-app-window-width, #edit-app-window-height' ) . prop ( 'disabled' , false ) ;
2084
+ $ ( '#edit-app-window-top, #edit-app-window-left' ) . prop ( 'disabled' , false ) ;
2085
+ }
2086
+ } )
0 commit comments