Skip to content

Commit

Permalink
Front end changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JbannisterScottLogic committed May 3, 2024
1 parent 1172ce7 commit 4648ae2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
8 changes: 5 additions & 3 deletions application/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
fact,
guidance_,
about_,
tiles_,
osMapOAuth,
)
from application.settings import get_settings
Expand Down Expand Up @@ -269,6 +270,7 @@ def add_routers(app):
app.include_router(map_.router, prefix="/map", include_in_schema=False)
app.include_router(guidance_.router, prefix="/guidance", include_in_schema=False)
app.include_router(about_.router, prefix="/about", include_in_schema=False)
app.include_router(tiles_.router, prefix="/tiles", include_in_schema=False)


def add_static(app):
Expand All @@ -291,9 +293,9 @@ def add_middleware(app):
@app.middleware("http")
async def add_strict_transport_security_header(request: Request, call_next):
response = await call_next(request)
response.headers[
"Strict-Transport-Security"
] = f"max-age={SECONDS_IN_TWO_YEARS}; includeSubDomains; preload"
response.headers["Strict-Transport-Security"] = (
f"max-age={SECONDS_IN_TWO_YEARS}; includeSubDomains; preload"
)
return response

@app.middleware("http")
Expand Down
2 changes: 1 addition & 1 deletion application/routers/tiles_.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def sql_to_pbf(sql):
# ============================================================


@router.get("/{dataset}/{z}/{x}/{y}.vector.{fmt}")
@router.get("/-/tiles/{dataset}/{z}/{x}/{y}.vector.{fmt}")
async def read_tiles_from_postgres(dataset: str, z: int, x: int, y: int, fmt: str):
tile = {"dataset": dataset, "zoom": z, "x": x, "y": y, "format": fmt}

Expand Down
2 changes: 1 addition & 1 deletion assets/javascripts/MapController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class MapController {
},
];
this.paint_options = params.paint_options || null;
this.customStyleJson = "/static/javascripts/OS_VTS_3857_3D.json";
this.customStyleJson = "/static/javascripts/base-tile.json";
this.customStyleLayersToBringToFront = ["OS/Names/National/Country"];
this.useOAuth2 = params.useOAuth2 || false;
this.layers = params.layers || [];
Expand Down
46 changes: 22 additions & 24 deletions assets/javascripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import MapController from './MapController.js';
import MapController from "./MapController.js";

export const newMapController = (params = { layers: []}) => {

const datasetUrl = params.DATASETTE_TILES_URL || '';
export const newMapController = (params = { layers: [] }) => {
const datasetUrl = params.DATASETTE_TILES_URL || "";

let mapParams = {
...params,
vectorSource: `${datasetUrl}/-/tiles/dataset_tiles/{z}/{x}/{y}.vector.pbf`,
datasetVectorUrl: `${datasetUrl}/-/tiles/`,
datasets: params.layers.map(d => d.dataset),
sources: params.layers.map(d => {
vectorSource: `${datasetUrl}/dataset_tiles/{z}/{x}/{y}.vector.pbf`,
datasetVectorUrl: `${datasetUrl}/`,
datasets: params.layers.map((d) => d.dataset),
sources: params.layers.map((d) => {
return {
name: d.dataset + '-source',
vectorSource: `${datasetUrl}/-/tiles/"${d.dataset}/{z}/{x}/{y}.vector.pbf`,
}
name: d.dataset + "-source",
vectorSource: `${datasetUrl}/${d.dataset}/{z}/{x}/{y}.vector.pbf`,
};
}),
mapId: params.mapId || 'map',
mapId: params.mapId || "map",
};
return new MapController(mapParams);
}
};

export const capitalizeFirstLetter = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
}
};

export const convertNodeListToArray = (nl) => {
return Array.prototype.slice.call(nl)
}
return Array.prototype.slice.call(nl);
};

// Prevents scrolling of the page when the user triggers the wheel event on a div
// while still allowing scrolling of any specified scrollable child elements.
Expand All @@ -38,22 +37,21 @@ export const preventScroll = (scrollableChildElements = []) => {
return e.target.closest(c) != null;
});

if(!closestClassName){
if (!closestClassName) {
e.preventDefault();
return false
return false;
}

const list = e.target.closest(closestClassName);

if(!list){
if (!list) {
e.preventDefault();
return false
return false;
}

var verticalScroll = list.scrollHeight > list.clientHeight;
if(!verticalScroll)
e.preventDefault();
if (!verticalScroll) e.preventDefault();

return false;
}
}
};
};

0 comments on commit 4648ae2

Please sign in to comment.