Skip to content

Commit

Permalink
feat: generate raports
Browse files Browse the repository at this point in the history
  • Loading branch information
Norbiros committed Oct 7, 2024
1 parent 9977c88 commit da44228
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backend/routers/report_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
report_router = APIRouter()


@report_router.get("/generate_report")
@report_router.post("/generate_report")
async def generate_report(scene_id: str, background_tasks: BackgroundTasks, db: Session = Depends(get_db)):
query = db.query(models.Report).filter_by(scene_id=scene_id)
report = query.first()
Expand Down
16 changes: 15 additions & 1 deletion frontend/components/GenerateRaportDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="console.log('Generate raporot')">
<AlertDialogAction @click="generateReport">
Continue
</AlertDialogAction>
</AlertDialogFooter>
Expand All @@ -35,4 +35,18 @@ import {
AlertDialogTrigger
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
const props = defineProps<{
sceneId: string
}>();
async function generateReport() {
await useApi("/report/generate_report", {
method: "POST",
query: {
scene_id: props.sceneId
}
});
navigateTo("/panel/reports");
}
</script>
3 changes: 1 addition & 2 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export default defineNuxtConfig({
"nuxt-aos"
],
css: [
"@unocss/reset/tailwind.css",
"~/assets/css/uno.css"
"@unocss/reset/tailwind.css"
],
devtools: { enabled: true },
compatibilityDate: "2024-04-03",
Expand Down
2 changes: 1 addition & 1 deletion frontend/openapi/api/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/pages/panel/report/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</TableRow>
</TableHeader>
<TableBody>
<TableRow v-for="(value, key) in metadata">
<TableRow v-for="(value, key) in metadata" :key="key">
<TableCell class="font-medium">
{{ key }}
</TableCell>
Expand Down
13 changes: 5 additions & 8 deletions frontend/pages/panel/select_scene.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<DatePicker v-model="dateTo" placeholder="End" />
<Input v-model="maxCloudCover" type="number" placeholder="Max cloud cover" max="100" min="0" step="1" />
<div overflow-auto h="5/7" p-5>
<div v-for="(polygon, index) in polygons" :key="index" @mouseover="logPolygon(polygon)" @click="showPolygon(polygon)">
<div v-for="(polygon, index) in polygons" :key="index" @mouseover="logPolygon(polygon)" @mouseleave="selectedPolygon = undefined" @click="showPolygon(polygon)">
<button>
<img h-20 :src="polygon.rendered_preview">
<img h-20 :src="polygon.rendered_preview" :class="{ 'bg-gray-600': polygon === selectedPolygonData }">
<span>{{ polygon.id }}</span><br>
<span>{{ polygon.datetime }}</span><br>
<span>{{ polygon.eo_cloud_cover }}</span>
Expand All @@ -20,7 +20,7 @@
</div>
</div>
<!-- todo: get which raport is selected -->
<GenerateRaportDialog v-if="polygons.length !== 0" mb-5 />
<GenerateRaportDialog v-if="selectedPolygonData" :scene-id="selectedPolygonData.id" mb-5 />
</div>
<div class="w-3/4">
<Map :marker="marker" :selected-polygon="selectedPolygon" :tile-layer-overlay="tileLayer" @map-click="updateMarkerPosition" @search-location="search" />
Expand All @@ -41,6 +41,7 @@ const tileLayer = ref<{
const polygons = ref<Polygon[]>([]);
const selectedPolygon = ref<LatLng[] | undefined>(undefined);
const selectedPolygonData = ref<Polygon | undefined>(undefined);
const dateFrom = ref<DateValue | null>(null); // Parent holds the selected date
const dateTo = ref<DateValue | null>(null); // Parent holds the selected date
Expand Down Expand Up @@ -106,11 +107,7 @@ function logPolygon(polygon: Polygon) {
async function showPolygon(polygon: Polygon) {
const sceneId = polygon.id;
// L.map("map").setView([polygon.polygon.coordinates[0].lat, polygon.polygon.coordinates[0].lon], 6);
// map.value.curentPosition = [polygon.polygon.coordinates[0].lat, polygon.polygon.coordinates[0].lon];
// marker.value
selectedPolygonData.value = polygon;
// todo: swithcc to useApi
const { data } = await useApi("/landsat/mosaic", {
Expand Down

0 comments on commit da44228

Please sign in to comment.