diff --git a/templates/webpanel/Config.php b/templates/webpanel/Config.php new file mode 100644 index 0000000..2279883 --- /dev/null +++ b/templates/webpanel/Config.php @@ -0,0 +1,7 @@ + '/images/', + 'img_per_page' => 12, + 'lang' => 'es' +); +?> diff --git a/templates/webpanel/Controller/C_predict.php b/templates/webpanel/Controller/C_predict.php new file mode 100644 index 0000000..f5b519e --- /dev/null +++ b/templates/webpanel/Controller/C_predict.php @@ -0,0 +1,6 @@ +getPasses(); + require('Views/V_viewPasses.php'); +?> diff --git a/templates/webpanel/Controller/C_showDetail.php b/templates/webpanel/Controller/C_showDetail.php new file mode 100644 index 0000000..13b378c --- /dev/null +++ b/templates/webpanel/Controller/C_showDetail.php @@ -0,0 +1,8 @@ +getEnhacements($pass_id); + $path = $con->getPath($pass_id); + require('Views/V_viewDetail.php'); +?> diff --git a/templates/webpanel/Controller/C_showLastImage.php b/templates/webpanel/Controller/C_showLastImage.php new file mode 100644 index 0000000..83e6bd6 --- /dev/null +++ b/templates/webpanel/Controller/C_showLastImage.php @@ -0,0 +1,6 @@ +getLastImage(); + require('Views/V_viewLastImage.php'); +?> diff --git a/templates/webpanel/Controller/C_showLastImages.php b/templates/webpanel/Controller/C_showLastImages.php new file mode 100644 index 0000000..80084ce --- /dev/null +++ b/templates/webpanel/Controller/C_showLastImages.php @@ -0,0 +1,11 @@ +img_per_page; + $page_count = $con->totalPages($img_per_page); + if ($page < 1) $page = 1; + if ($page > $page_count) $page = $page_count; + $images = $con->getImages($page, $img_per_page); + require('Views/V_viewLastImages.php'); +?> diff --git a/templates/webpanel/Controller/index.html b/templates/webpanel/Controller/index.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/webpanel/Model/Conn.php b/templates/webpanel/Model/Conn.php new file mode 100644 index 0000000..b60fb51 --- /dev/null +++ b/templates/webpanel/Model/Conn.php @@ -0,0 +1,74 @@ +con = new SQLite3("/home/pi/raspberry-noaa/panel.db"); + } + + public function getPasses() { + $today = strtotime(date('Y-m-d', time())); + $query = $this->con->query("SELECT sat_name, is_active, + pass_start, pass_end, + max_elev FROM predict_passes + WHERE (pass_start > $today) ORDER BY + pass_start ASC;"); + $passes = []; + $i = 0; + while($row = $query->fetchArray()){ + $passes[$i] = $row; + $i++; + } + return $passes; + } + + public function totalPages($img_per_page) { + $total_pages = $this->con->querySingle("SELECT count() from decoded_passes;"); + return ceil($total_pages/$img_per_page); + } + + public function getImages($page, $img_per_page) { + $query = $this->con->prepare("SELECT decoded_passes.id, predict_passes.pass_start, + file_path, is_noaa, predict_passes.sat_name, predict_passes.max_elev + FROM decoded_passes INNER JOIN predict_passes + ON predict_passes.pass_start = decoded_passes.pass_start + ORDER BY decoded_passes.pass_start DESC LIMIT ? OFFSET ?;"); + $query->bindValue(1, $img_per_page); + $query->bindValue(2, $img_per_page * ($page-1)); + $result = $query->execute(); + $images = []; + $i = 0; + while($row = $result->fetchArray()){ + $images[$i] = $row; + $i++; + } + return $images; + } + + public function getEnhacements($id) { + $query = $this->con->prepare('SELECT daylight_pass, is_noaa + FROM decoded_passes WHERE id = ?;'); + $query->bindValue(1, $id); + $result = $query->execute(); + $pass = $result->fetchArray(); + if ($pass['is_noaa'] == 0) { + $enhacements = ['-122-rectified.jpg']; + } else { + if ($pass['daylight_pass'] == 1) { + $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg','-MSA.jpg','-MSA-precip.jpg','-HVC.jpg','-HVC-precip.jpg','-HVCT.jpg','-HVCT-precip.jpg']; + } else { + $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg']; + } + } + return $enhacements; + } + + public function getPath($id) { + $query = $this->con->prepare('SELECT file_path FROM decoded_passes + WHERE id = ?;'); + $query->bindValue(1, $id); + $result = $query->execute(); + $image = $result->fetchArray(); + return $image['file_path']; + } + } +?> diff --git a/templates/webpanel/Model/index.html b/templates/webpanel/Model/index.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/webpanel/Views/V_viewDetail.php b/templates/webpanel/Views/V_viewDetail.php new file mode 100644 index 0000000..2d457c2 --- /dev/null +++ b/templates/webpanel/Views/V_viewDetail.php @@ -0,0 +1,23 @@ +
+ + base_url; + foreach ($enhacements as $enhacement) { + if($row_count%3==0) { + echo ""; + $col_count=1; + } + echo ""; + } + $row_count++; + $col_count++; + } + ?> +
"; + if($col_count==3) { + echo "
+
+ + diff --git a/templates/webpanel/Views/V_viewLastImage.php b/templates/webpanel/Views/V_viewLastImage.php new file mode 100644 index 0000000..57cf7e5 --- /dev/null +++ b/templates/webpanel/Views/V_viewLastImage.php @@ -0,0 +1,24 @@ + + base_url; + foreach ($images as $image) { + if($row_count%3==0) { + echo ""; + $col_count=1; + } + echo ""; + if($col_count==3) { + echo ""; + } + $row_count++; + $col_count++; + } + ?> +
"; + echo "
  • ". $image['sat_name'] ."
  • "; + echo "
  • ". date('d/m/Y H:i:s', $image['pass_start']) ."
+ + + diff --git a/templates/webpanel/Views/V_viewLastImages.php b/templates/webpanel/Views/V_viewLastImages.php new file mode 100644 index 0000000..81f187d --- /dev/null +++ b/templates/webpanel/Views/V_viewLastImages.php @@ -0,0 +1,42 @@ +
+ + 1) { + echo ""; + } else { + echo ""; + } + echo ""; + if ($page < $page_count) { + echo ""; + } else { + echo ""; + } + $row_count=0; + $col_count=0; + $baseurl = $configs->base_url; + foreach ($images as $image) { + if($row_count%3==0) { + echo ""; + $col_count=1; + } + if ($image['is_noaa'] == true) { + $ending = "-MCIR.jpg"; + } else { + $ending = "-122-rectified.jpg"; + } + echo ""; + if($col_count==3) { + echo ""; + } + $row_count++; + $col_count++; + } + ?> +
" . $lang['prev'] . "
" . $lang['page'] . " $page " . $lang['of'] . " $page_count" . $lang['next'] . "
"; + echo "
  • ". $image['sat_name'] ."
  • "; + echo "
  • " . $lang['elev'] . ": ". $image['max_elev'] ."°
  • "; + echo "
  • ". date('d/m/Y H:i:s', $image['pass_start']) ."
+
+ + diff --git a/templates/webpanel/Views/V_viewPasses.php b/templates/webpanel/Views/V_viewPasses.php new file mode 100644 index 0000000..cf8cd2b --- /dev/null +++ b/templates/webpanel/Views/V_viewPasses.php @@ -0,0 +1,24 @@ +
+ + + + + + + + "; + } else { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> +
". $pass['sat_name'] ."". date('H:i:s', $pass['pass_start']) ."". date('H:i:s', $pass['pass_end']) ."". $pass['max_elev'] ."
+
diff --git a/templates/webpanel/Views/index.html b/templates/webpanel/Views/index.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/webpanel/detail.php b/templates/webpanel/detail.php new file mode 100644 index 0000000..a11d8d6 --- /dev/null +++ b/templates/webpanel/detail.php @@ -0,0 +1,7 @@ + diff --git a/templates/webpanel/footer.php b/templates/webpanel/footer.php new file mode 100644 index 0000000..02bc661 --- /dev/null +++ b/templates/webpanel/footer.php @@ -0,0 +1,6 @@ + + + + diff --git a/templates/webpanel/header.php b/templates/webpanel/header.php new file mode 100644 index 0000000..5efac7e --- /dev/null +++ b/templates/webpanel/header.php @@ -0,0 +1,27 @@ +lang; + include_once('language/' . $lang . '.php'); +?> + + + + + + + + <?= isset($PageTitle) ? $PageTitle : "Raspberry NOAA"?> + + +
+ " href="passes.php"> + " href="index.php"> +
+
+ + diff --git a/templates/webpanel/index.php b/templates/webpanel/index.php new file mode 100644 index 0000000..ddaa13c --- /dev/null +++ b/templates/webpanel/index.php @@ -0,0 +1,7 @@ + diff --git a/templates/webpanel/language/en.php b/templates/webpanel/language/en.php new file mode 100644 index 0000000..5373e27 --- /dev/null +++ b/templates/webpanel/language/en.php @@ -0,0 +1,15 @@ + "Passes", + "satellite" => "Satellite", + "images" => "Images", + "pass_start" => "Pass start", + "pass_end" => "Pass end", + "max_elev" => "Max elevation", + "elev" => "Elevation", + "page" => "Page", + "of" => "of", + "prev" => "Prev", + "next" => "Next", +); +?> diff --git a/templates/webpanel/language/es.php b/templates/webpanel/language/es.php new file mode 100644 index 0000000..0b4e507 --- /dev/null +++ b/templates/webpanel/language/es.php @@ -0,0 +1,15 @@ + "Pasadas", + "satellite" => "Satélite", + "images" => "Imagenes", + "pass_start" => "Inicio", + "pass_end" => "Fin", + "max_elev" => "Elevación", + "elev" => "Elevación", + "page" => "Página", + "of" => "de", + "prev" => "Anterior", + "next" => "Siguiente", +); +?> diff --git a/templates/webpanel/logo-small.png b/templates/webpanel/logo-small.png new file mode 100755 index 0000000..5ec241b Binary files /dev/null and b/templates/webpanel/logo-small.png differ diff --git a/templates/webpanel/passes.php b/templates/webpanel/passes.php new file mode 100644 index 0000000..d578e3b --- /dev/null +++ b/templates/webpanel/passes.php @@ -0,0 +1,5 @@ + diff --git a/templates/webpanel/style.css b/templates/webpanel/style.css new file mode 100644 index 0000000..e17a0bb --- /dev/null +++ b/templates/webpanel/style.css @@ -0,0 +1,99 @@ +body { + margin: 0; + font-family: Arial, Helvetica, sans-serif; +} + +.container { + margin: 20px auto; + max-width: 800px; +} + +.topnav { + overflow: hidden; + background-color: #333; +} + +.topnav a { + float: left; + color: #f2f2f2; + text-align: center; + padding: 14px 16px; + text-decoration: none; + font-size: 17px; +} + +.topnav a:hover { + background-color: #ddd; + color: black; +} + +.topnav a.active { + background-color: #4CAF50; + color: white; +} + +#passes { + font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; + border-collapse: collapse; + max-width: 500px; + width: 100%; + margin: auto; +} + +#passes.img-grid { + max-width: 700px; +} + +#passes td, +#passes th { + border: 1px solid #ddd; + padding: 8px; +} + +#passes tr:nth-child(even) { + background-color: #f2f2f2; +} + + +/* #passes tr:hover {background-color: #ddd;} */ + +#passes th { + padding-top: 12px; + padding-bottom: 12px; + background-color: #4CAF50; + text-align: center; + color: white; +} + +#passes tr.inactive { + color: lightgray; +} + +#satimg { + max-width: 200px; + max-height: 200px; + width: 100%; +} + +#satimgdiv { + width: 100%; + height: 100%; + max-width: 200px; + background-color: antiquewhite; + /* margin: 10px; */ + display: inline-block; + vertical-align: middle; + text-align: center; +} + +footer { + /* position: absolute; */ + margin: 20px; + bottom: 0; + max-width: 100%; + text-align: center; +} + +img.img-footer { + max-width: 100%; +} \ No newline at end of file