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 @@ +
+