Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] #1699

Merged
merged 9 commits into from
Nov 10, 2022
Merged

[FIX] #1699

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ Pajares, E.; Muñoz Nieto, R.; Meng, L.; Wulfhorst, G. Population Disaggregation

Pajares, E., Jehle, U., 2021. GOAT: Ein interaktives Erreichbarkeitsinstrument zur Planung der 15-Minuten-Stadt, in: Flächennutzungsmonitoring XIII: Flächenpolitik - Konzepte - Analysen - Tools, IÖR Schriften. Rhombos-Verlag, Berlin, pp. 265–273. https://doi.org/10.26084/13dfns-p024

Pajares, E., Jehle, U., Hall, J., Miramontes, M., Wulfhorst, G., 2022. Assessment of the usefulness of the accessibility instrument GOAT for the planning practice. Journal of Urban Mobility 2, 100033. https://doi.org/10.1016/j.urbmob.2022.100033

Jehle, U., Pajares, E., Analyse der Fußwegequalitäten zu Schulen – Entwicklung von Indikatoren auf Basis von OpenData. In: Meinel, G.; Krüger, T.; Behnisch, M.; Ehrhardt, D. (Hrsg.): Flächennutzungsmonitoring XIII: Flächenpolitik - Konzepte - Analysen - Tools. Berlin: Rhombos-Verlag, 2021, (IÖR-Schriften Band 79), S.221-232, https://doi.org/10.26084/13dfns-p020
2 changes: 2 additions & 0 deletions app/api/src/endpoints/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
static_layers,
static_layers_extra,
study_area,
system,
upload,
users,
utils,
)

api_router = APIRouter()
api_router.include_router(login.router, tags=["Login"])
api_router.include_router(system.router, prefix="", tags=["Health Check"])

api_router.include_router(organizations.router, prefix="/organizations", tags=["Organizations"])
api_router.include_router(roles.router, prefix="/roles", tags=["Roles"])
Expand Down
25 changes: 25 additions & 0 deletions app/api/src/endpoints/v1/system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Any, List

from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.ext.asyncio import AsyncSession

from src import crud
from src.db import models
from src.endpoints import deps
from src.schemas.system import SystemStatusModel

router = APIRouter()


@router.put("/status", response_model=SystemStatusModel)
async def status_check(
status_in: SystemStatusModel,
db: AsyncSession = Depends(deps.get_db),
current_user: models.User = Depends(deps.get_current_active_superuser),
):
results = await crud.system.get_by_key(db, key="type", value="status")
system = results[0]
system.setting = status_in.dict()
system = await crud.system.update(db, db_obj=system, obj_in=system)

return system.setting
4 changes: 2 additions & 2 deletions app/api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def startup_event():
async with async_session() as db:
table_index = await crud.layer.table_index(db)
app.state.table_catalog = table_index

if not os.environ.get("DISABLE_NUMBA_STARTUP_CALL") == "True":
await run_time_method_calls.call_isochrones_startup(app=app)

Expand Down Expand Up @@ -99,7 +99,7 @@ async def status_check(db: AsyncSession = Depends(deps.get_db)):
except Exception as e:
return JSONResponse(status_code=503, content={"message": "Service Unavailable"})

if results.setting["status"] == "maintenance":
if results.setting.get("status") == "maintenance":
return JSONResponse(status_code=503, content={"message": "Service Unavailable"})
else:
return {"status": "ok"}
Expand Down
5 changes: 5 additions & 0 deletions app/api/src/resources/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,8 @@ class LayerGroupsEnum(str, Enum):
class GeostoreType(str, Enum):
geoadmin = "geoadmin"
other = "other"


class SystemStatus(str, Enum):
maintenance = "maintenance"
running = "running"
7 changes: 7 additions & 0 deletions app/api/src/schemas/system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from lib2to3.pytree import Base
from pydantic import BaseModel
from src.resources.enums import SystemStatus


class SystemStatusModel(BaseModel):
status: SystemStatus
21 changes: 19 additions & 2 deletions app/client/src/components/isochrones/IsochroneThematicData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@
};`
"
></div>
<span>Isochrone {{ selectedCalculations[0].id }}</span>
<span
>Isochrone
{{
getCurrentIsochroneNumber(selectedCalculations[0])
}}</span
>
<div
class="ml-6 mr-2 colorPalettePicker"
:style="
Expand All @@ -78,7 +83,12 @@
};`
"
></div>
<span>Isochrone {{ selectedCalculations[1].id }}</span>
<span
>Isochrone
{{
getCurrentIsochroneNumber(selectedCalculations[1])
}}</span
>
</template>
<v-spacer></v-spacer>
<v-btn-toggle
Expand Down Expand Up @@ -235,6 +245,10 @@ import { saveAs } from "file-saver";
import { debounce, numberSeparator } from "../../utils/Helpers";
import ApiService from "../../services/api.service";
import JSZip from "jszip";
import {
calculateCalculationsLength,
calculateCurrentIndex
} from "../../utils/Helpers";
export default {
components: {
IsochroneAmenitiesLineChart,
Expand Down Expand Up @@ -394,6 +408,9 @@ export default {
timeout: 10000
});
});
},
getCurrentIsochroneNumber(calc) {
return calculateCalculationsLength() - calculateCurrentIndex(calc);
}
},
computed: {
Expand Down
30 changes: 11 additions & 19 deletions app/client/src/components/isochrones/Isochrones.vue
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,7 @@
style="font-size: 12px"
class="white--text fa-stack-1x mb-1"
>
{{
calculateCalculationsLength() -
calculateCurrentIndex(calculation)
}}
{{ getCurrentIsochroneNumber(calculation) }}
</strong>
</span>
<v-tooltip
Expand Down Expand Up @@ -815,7 +812,11 @@ import { mapGetters, mapMutations } from "vuex";
import { mapFields } from "vuex-map-fields";

//Helpers
import { secondsToHoursAndMins } from "../../utils/Helpers";
import {
secondsToHoursAndMins,
calculateCalculationsLength,
calculateCurrentIndex
} from "../../utils/Helpers";

//Ol imports
import VectorSource from "ol/source/Vector";
Expand Down Expand Up @@ -1714,9 +1715,9 @@ export default {
time = [calculation.rawData.get(x, y, depthIndex)];
}
if (time) {
overlayerInnerHtml += `<div>#${calculationId} ${this.$t(
"isochrones.options.time"
)}: ${time} min</div>`;
overlayerInnerHtml += `<div>#${this.getCurrentIsochroneNumber(
calculation
)} ${this.$t("isochrones.options.time")}: ${time} min</div>`;
}
if (features.length === 2 && index == 0) {
overlayerInnerHtml += `<br>`;
Expand Down Expand Up @@ -2003,17 +2004,8 @@ export default {
this.clear();
},
//! Clculate the real length of the calculations array
calculateCalculationsLength() {
let realArr = this.calculations.filter(
calculation => calculation !== "deleted"
);
return realArr.length;
},
calculateCurrentIndex(calc) {
let realArr = this.calculations.filter(
calculation => calculation !== "deleted"
);
return realArr.indexOf(calc);
getCurrentIsochroneNumber(calc) {
return calculateCalculationsLength() - calculateCurrentIndex(calc);
}
},
watch: {
Expand Down
6 changes: 6 additions & 0 deletions app/client/src/utils/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,9 @@ export function calculateRealCalculations() {
);
return realArr;
}
export function calculateCurrentIndex(calc) {
let realArr = store.state.isochrones.calculations.filter(
calculation => calculation !== "deleted"
);
return realArr.indexOf(calc);
}