1010 Local Operators
1111 </ title >
1212 < link rel ="stylesheet " type ="text/css " href ="../../../../../root/webapp/main.css "/>
13+ < script >
14+ function prepareExport ( ) {
15+ if ( exportButton . getAttribute ( "href" ) . length === 1 ) {
16+ const ops = [ ] ;
17+ for ( const r of data ) {
18+ ops . push ( {
19+ "username" :r [ 0 ] ,
20+ "display_name" :r [ 1 ] ,
21+ "password" :r [ 2 ] ,
22+ "session_timeout" :Number ( r [ 3 ] ) ,
23+ "auto_collapse" :Boolean ( r [ 4 ] )
24+ } ) ;
25+ }
26+ exportButton . setAttribute ( "href" , "data:text/plain;charset=utf-8," + encodeURIComponent ( JSON . stringify ( ops , undefined , 2 ) ) ) ;
27+ }
28+ }
29+ function uploadOperators ( ) {
30+ if ( ! submittingFile && fileField . value . length > 0 ) {
31+ if ( fileField . files [ 0 ] . size > 1048576 ) {
32+ fileField . value = null ;
33+ alert ( "Selected file size has exceeded the 1MB limit." ) ;
34+ return ;
35+ }
36+ submittingFile = true ;
37+ const formData = new FormData ( ) ;
38+ formData . append ( "file" , fileField . files [ 0 ] ) ;
39+ fileField . value = null ;
40+ const req = new XMLHttpRequest ( ) ;
41+ req . open ( "POST" , "__PREFIX__/LocalOperators?cmd=import" ) ;
42+ req . onreadystatechange = function ( ) {
43+ if ( this . readyState === 4 ) {
44+ if ( this . status === 200 ) {
45+ location . reload ( ) ;
46+ } else if ( this . status == 0 ) {
47+ alert ( "Request timed out." ) ;
48+ } else {
49+ alert ( "An error has occurred: " + this . status ) ;
50+ }
51+ submittingFile = false ;
52+ }
53+ } ;
54+ req . send ( formData ) ;
55+ }
56+ }
57+ </ script >
1358 </ head >
1459 < body >
1560 < div style ="text-align:center ">
1661 < h1 id ="mainTitle "> Local Operators</ h1 >
1762 < br >
18- < table >
19- < thead > < tr >
20- < th > Username</ th >
21- < th > Display Name</ th >
22- < th > Password</ th >
23- < th > Session Timeout (seconds)</ th >
24- < th > Auto-Collapse Trees</ th >
25- </ tr > </ thead >
26- < tbody id ="tableBody "> </ tbody >
27- </ table >
63+ < table >
64+ < thead > < tr >
65+ < th > Username</ th >
66+ < th > Display Name</ th >
67+ < th > Password</ th >
68+ < th > Session Timeout (seconds)</ th >
69+ < th > Auto-Collapse Trees</ th >
70+ </ tr > </ thead >
71+ < tbody id ="tableBody "> </ tbody >
72+ </ table >
73+ < br >
74+ < a class ="e " id ="exportButton " href ="# " download ="operators.json " onclick ="prepareExport() "> Export</ a >
75+ < button id ="importButton " class ="e " onclick ="fileField.click() "> Import</ button >
76+ < input type ="file " id ="fileField " accept =".json " style ="display:none " oninput ="uploadOperators(); ">
2877 < br > < br >
2978 < a class ="e nav " href ="__PREFIX__/TableEditor?table=servers "> Server List</ a >
3079 < a class ="e nav " href ="__PREFIX__/TableEditor?table=operator_whitelist "> Operator Whitelist</ a >
@@ -41,6 +90,7 @@ <h1 id="mainTitle">Local Operators</h1>
4190 < a class ="e nav " href ="__DOCUMENTATION__ " target ="_blank "> Documentation</ a >
4291 </ div >
4392 < script >
93+ var submittingFile = false ;
4494 const data = __OPERATORS__ ;
4595 const body = document . getElementById ( "tableBody" ) ;
4696 for ( const r of data ) {
0 commit comments