@@ -21,57 +21,55 @@ class TrainingDashboard {
2121
2222 async init ( ) {
2323 this . showLoading ( ) ;
24- let outputs = null ;
2524 let trainMD = null ;
2625 let testMD = null ;
27- let dataLoaded = false ;
26+ let lastUpdated = 'Loading...' ;
2827 try {
29- // Try outputs.txt first
30- try {
31- const text = await this . fetchText ( 'outputs.txt' ) ;
32- outputs = this . parseKV ( text ) ;
33- } catch ( err ) {
34- // Ignore missing outputs.txt
28+ // Always load markdowns for metrics and images
29+ [ trainMD , testMD ] = await Promise . all ( [
30+ this . fetchText ( 'train_output.md' ) ,
31+ this . fetchText ( 'test_output.md' ) ,
32+ ] ) ;
33+ // Get last modified time from markdown files
34+ const trainRes = await fetch ( 'train_output.md' , { method : 'HEAD' } ) ;
35+ const testRes = await fetch ( 'test_output.md' , { method : 'HEAD' } ) ;
36+ let trainDate = trainRes . headers . get ( 'last-modified' ) ;
37+ let testDate = testRes . headers . get ( 'last-modified' ) ;
38+ if ( trainDate || testDate ) {
39+ // Use the most recent
40+ const d1 = trainDate ? new Date ( trainDate ) : null ;
41+ const d2 = testDate ? new Date ( testDate ) : null ;
42+ let latest = d1 && d2 ? ( d1 > d2 ? d1 : d2 ) : ( d1 || d2 ) ;
43+ if ( latest ) {
44+ lastUpdated = latest . toLocaleString ( ) ;
45+ }
3546 }
3647
37- // Always try to load markdowns
38- try {
39- [ trainMD , testMD ] = await Promise . all ( [
40- this . fetchText ( 'train_output.md' ) ,
41- this . fetchText ( 'test_output.md' ) ,
42- ] ) ;
43- } catch ( err ) {
44- // If markdowns missing, fail
45- throw new Error ( 'Missing training or test markdown' ) ;
46- }
47-
48- // If outputs.txt present, use it for metrics and predictions
49- if ( outputs ) {
50- this . applyOutputs ( outputs ) ;
51- dataLoaded = true ;
52- }
53- // Always parse markdowns for images and fallback metrics
54- if ( trainMD && testMD ) {
55- this . parseTraining ( trainMD ) ;
56- this . parseTest ( testMD ) ;
57- this . renderImagesFromMarkdown ( testMD ) ;
58- dataLoaded = true ;
59- }
48+ // Parse markdowns for metrics and images
49+ this . parseTraining ( trainMD ) ;
50+ this . parseTest ( testMD ) ;
51+ this . renderImagesFromMarkdown ( testMD ) ;
6052
6153 this . renderMetrics ( ) ;
62- this . renderCharts ( outputs ) ;
54+ // Render charts from static image paths
55+ this . renderCharts ( ) ;
6356 if ( this . statusBadge ) {
64- this . statusBadge . textContent = dataLoaded ? 'Data Loaded' : 'No Data' ;
65- this . statusBadge . classList . toggle ( 'error' , ! dataLoaded ) ;
57+ this . statusBadge . textContent = 'Data Loaded' ;
58+ this . statusBadge . classList . remove ( 'error' ) ;
59+ }
60+ // Update last updated in footer
61+ const footerText = document . querySelector ( '.footer-text' ) ;
62+ if ( footerText ) {
63+ footerText . textContent = `Last updated: ${ lastUpdated } ` ;
6664 }
6765 } catch ( err ) {
6866 console . error ( 'Init error:' , err ) ;
6967 this . failBadge ( 'Data Load Error' ) ;
7068 }
71- // Always hide preloader after 3 seconds, regardless of data loading
72- setTimeout ( ( ) => {
73- this . hideLoading ( ) ;
74- } , 3000 ) ;
69+ // Always hide preloader after 1.2 seconds, regardless of data loading
70+ setTimeout ( ( ) => {
71+ this . hideLoading ( ) ;
72+ } , 1200 ) ;
7573 this . startAutoRefresh ( ) ;
7674 }
7775
@@ -152,13 +150,12 @@ class TrainingDashboard {
152150 img . onerror = ( ) => { container . innerHTML = '<div class="chart-error">Chart not available</div>' ; } ;
153151 container . appendChild ( img ) ;
154152 } ;
155- const lossSrc = outputs ?. train_loss_image || 'images/train_loss.png' ;
156- const accSrc = outputs ?. train_accuracy_image || 'images/train_accuracy.png' ;
157- ensureImg ( this . lossChart , lossSrc , 'Training Loss' ) ;
158- ensureImg ( this . accChart , accSrc , 'Training Accuracy' ) ;
153+ // Always use static image paths
154+ ensureImg ( this . lossChart , 'images/train_loss.png' , 'Training Loss' ) ;
155+ ensureImg ( this . accChart , 'images/train_accuracy.png' , 'Training Accuracy' ) ;
159156 // Optional: render test accuracy image above images grid
160157 const testAccImg = document . createElement ( 'img' ) ;
161- testAccImg . src = outputs ?. test_accuracy_image || 'images/test_accuracy.png' ;
158+ testAccImg . src = 'images/test_accuracy.png' ;
162159 testAccImg . alt = 'Test Accuracy' ;
163160 testAccImg . className = 'chart-image' ;
164161 testAccImg . style . maxWidth = '320px' ;
0 commit comments