File tree Expand file tree Collapse file tree 9 files changed +51
-22
lines changed
Expand file tree Collapse file tree 9 files changed +51
-22
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ Retrieve information about crontab.
4545http://your-host/api/info
4646```
4747
48+ - ` GET ` Time<br />
49+ Get current server date and time information.
50+ ```
51+ http://your-host/api/time
52+ ```
53+
4854- ` GET ` Jobs<br />
4955Retrieve a list of existing jobs.
5056```
@@ -106,7 +112,7 @@ http://your-host/api/jobs/{id}
106112| active | Boolean | If the job is enabled or not. |
107113
108114## To Do
109- - Add current container time to web interface
115+ - Have more ideas...
110116
111117## License
112118
Original file line number Diff line number Diff line change 3434 <!-- Topbar -->
3535 < nav class ="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow ">
3636 < span class ="navbar-brand "> Docker Cronjob Manager</ span >
37+ < small > Server Time: {{ currentTime }}</ small >
3738 </ nav >
3839 <!-- End of Topbar -->
3940
@@ -250,7 +251,7 @@ <h5 class="modal-title" id="exampleModalLabel">Job Management</h5>
250251 < input beth-bind ="formObject.cron " type ="text " class ="form-control " id ="txtJobSchedule " name ="cron " aria-describedby ="jobScheduleHelp " placeholder ="* * * * * ">
251252 < small id ="jobScheduleHelp " class ="form-text text-muted "> The crontab schedule for this job. Click < a href ="https://crontab.guru/ " target ="_blank "> here</ a > to create a crontab.</ small >
252253 </ div >
253-
254+
254255 < div class ="form-check ">
255256 < input beth-bind ="formObject.active " type ="checkbox " class ="form-check-input " id ="ckbJobActive " name ="active ">
256257 < label class ="form-check-label " for ="ckbJobActive "> Enable Job</ label >
@@ -290,12 +291,14 @@ <h5 class="modal-title" id="exampleModalLabel">Job Management</h5>
290291 < script src ="js/sb-admin-2.js "> </ script >
291292
292293 <!-- Dashboard -->
294+ < script src ="modules/commons.js "> </ script >
293295 < script src ="modules/dashboard/info.js "> </ script >
294296 < script src ="modules/dashboard/find.js "> </ script >
295297 < script src ="modules/dashboard/list.js "> </ script >
296298 < script src ="modules/dashboard/form.js "> </ script >
297299 < script src ="modules/dashboard/logs.js "> </ script >
298300 < script src ="modules/dashboard/delete.js "> </ script >
301+ < script src ="modules/dashboard/time.js "> </ script >
299302</ body >
300303
301304</ html >
Original file line number Diff line number Diff line change 4747 } ) ;
4848
4949} ) ( jQuery ) ; // End of use strict
50-
51- const makeToast = ( type , message ) => {
52- $ . toast ( {
53- text : message ,
54- icon : type ,
55- showHideTransition : 'fade' ,
56- allowToastClose : false ,
57- hideAfter : 3000 ,
58- stack : 50 ,
59- position : 'top-right' ,
60- textAlign : 'left' ,
61- loader : true ,
62- loaderBg : '#FFFFFF' ,
63- } ) ;
64- }
Original file line number Diff line number Diff line change 1+ const makeToast = ( type , message ) => {
2+ $ . toast ( {
3+ text : message ,
4+ icon : type ,
5+ showHideTransition : 'fade' ,
6+ allowToastClose : false ,
7+ hideAfter : 3000 ,
8+ stack : 50 ,
9+ position : 'top-right' ,
10+ textAlign : 'left' ,
11+ loader : true ,
12+ loaderBg : '#FFFFFF' ,
13+ } ) ;
14+ }
15+
16+ const formatDateTimeString = ( date ) => {
17+ return new Date ( Date . parse ( date ) ) . toLocaleString ( ) ;
18+ }
19+
20+ const formatServerTime = ( date ) => {
21+ return new Date ( Date . parse ( date ) ) . toLocaleString ( [ ] , { hour : '2-digit' , minute :'2-digit' } ) ;
22+ }
Original file line number Diff line number Diff line change 11const deleteJob = ( job_id ) => {
22 findJobById ( job_id , ( job ) => {
3- console . log ( job ) ;
43 Swal . fire ( {
54 title : `Deleting job: ${ job . name } (id: ${ job . id } )` ,
65 text : "You are about to delete this job." ,
Original file line number Diff line number Diff line change @@ -15,8 +15,4 @@ const getJobsList = () => {
1515 } ) ;
1616}
1717
18- const formatDateTimeString = ( date ) => {
19- return new Date ( Date . parse ( date ) ) . toLocaleString ( ) ;
20- }
21-
2218getJobsList ( ) ;
Original file line number Diff line number Diff line change 1+ var currentTime = "" ;
2+
3+ const getCurrentTime = ( ) => {
4+ $ . get ( `api/time` , ( response ) => {
5+ currentTime = formatServerTime ( response . data ) ;
6+ } ) . fail ( ( xhr ) => {
7+ makeToast ( 'error' , xhr . responseJSON . message ) ;
8+ } ) ;
9+
10+ setTimeout ( getCurrentTime , 60000 ) ;
11+ }
12+
13+ getCurrentTime ( ) ;
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ const register = (app) => {
1818 res . json ( { message : err . message } ) ;
1919 } ) ;
2020
21+ app . get ( "/api/time" , async ( req , res ) => {
22+ res . status ( 200 ) ;
23+ res . json ( { "data" : new Date ( ) , "message" : "" } ) ;
24+ } ) ;
25+
2126 app . get ( "/api/jobs" , async ( req , res ) => {
2227 let jobs = await jobDao . list ( ) ;
2328
You can’t perform that action at this time.
0 commit comments