Checkpoint. Need to add an easy way to read route params to render a single sealious item
parent
5261a3140d
commit
dd9362f9e4
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
mkdir -p osrm
|
||||||
|
cd osrm || exit 1
|
||||||
|
wget http://download.geofabrik.de/europe/poland/wielkopolskie-latest.osm.pbf &
|
||||||
|
wget_pid=$!
|
||||||
|
docker pull osrm/osrm-backend &
|
||||||
|
pull_pid=$!
|
||||||
|
wait $wget_pid $pull_pid
|
||||||
|
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/wielkopolskie-latest.osm.pbf
|
||||||
|
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition /data/wielkopolskie-latest.osrm
|
||||||
|
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize /data/wielkopolskie-latest.osrm
|
||||||
|
|
@ -0,0 +1,8 @@
|
|||||||
|
import { Collection, FieldTypes, Policies } from "sealious";
|
||||||
|
|
||||||
|
export default class Places extends Collection {
|
||||||
|
fields = {
|
||||||
|
content: new FieldTypes.Text(),
|
||||||
|
};
|
||||||
|
defaultPolicy = new Policies.Public();
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
import { Collection, FieldTypes, Policies } from "sealious";
|
||||||
|
|
||||||
|
export default class Routes extends Collection {
|
||||||
|
fields = {
|
||||||
|
name: FieldTypes.Required(new FieldTypes.Text()),
|
||||||
|
};
|
||||||
|
defaultPolicy = new Policies.Owner();
|
||||||
|
policies = {
|
||||||
|
create: new Policies.LoggedIn(),
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import { BaseContext } from "koa";
|
||||||
|
import { tempstream } from "tempstream";
|
||||||
|
import { Page } from "../../page/page";
|
||||||
|
|
||||||
|
export const actionName = "ShowRoute";
|
||||||
|
|
||||||
|
export default new (class ShowRoutePage extends Page {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
async canAccess(_: BaseContext) {
|
||||||
|
return { canAccess: true, message: "" };
|
||||||
|
}
|
||||||
|
|
||||||
|
async render(ctx: BaseContext) {
|
||||||
|
const id = ctx.params.id;
|
||||||
|
return tempstream/* HTML */ `<div></div>`;
|
||||||
|
}
|
||||||
|
})();
|
@ -0,0 +1,17 @@
|
|||||||
|
import { withProdApp } from "../../test_utils/with-prod-app";
|
||||||
|
import { LONG_TEST_TIMEOUT, webhintURL } from "../../test_utils/webhint";
|
||||||
|
import { ShowRouteURL } from "../routes";
|
||||||
|
|
||||||
|
describe("ShowRoute", () => {
|
||||||
|
it("doesn't crash", async function () {
|
||||||
|
this.timeout(LONG_TEST_TIMEOUT);
|
||||||
|
return withProdApp(async ({ base_url, rest_api }) => {
|
||||||
|
await rest_api.get(ShowRouteURL);
|
||||||
|
await webhintURL(base_url + ShowRouteURL);
|
||||||
|
// alternatively you can use webhintHTML for faster but less precise scans
|
||||||
|
// or for scanning responses of requests that use some form of authorization:
|
||||||
|
// const response = await rest_api.get(ShowRouteURL);
|
||||||
|
// await webhintHTML(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,38 @@
|
|||||||
|
import { BaseContext } from "koa";
|
||||||
|
import { CollectionItem } from "sealious";
|
||||||
|
import { tempstream } from "tempstream";
|
||||||
|
import { Routes } from "../collections/collections";
|
||||||
|
import html from "../html";
|
||||||
|
import {
|
||||||
|
BaseListPageDefaultProps,
|
||||||
|
BaseListPageProps,
|
||||||
|
BaseListPagePropsShape,
|
||||||
|
SealiousItemListPage,
|
||||||
|
} from "../page/list";
|
||||||
|
import { AllQueryParams } from "../page/props-parser";
|
||||||
|
|
||||||
|
export const actionName = "ListRoutes";
|
||||||
|
|
||||||
|
export default new (class ListRoutesPage extends SealiousItemListPage<typeof Routes> {
|
||||||
|
propsParser = new AllQueryParams<BaseListPageProps>(
|
||||||
|
BaseListPagePropsShape,
|
||||||
|
BaseListPageDefaultProps
|
||||||
|
);
|
||||||
|
|
||||||
|
async render(ctx: BaseContext) {
|
||||||
|
return html(
|
||||||
|
ctx,
|
||||||
|
"Trasy",
|
||||||
|
tempstream/* HTML */ `<div>
|
||||||
|
<h2>Zapisane trasy</h2>
|
||||||
|
<ul>
|
||||||
|
${super.render(ctx)}
|
||||||
|
</ul>
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async renderItem(_: BaseContext, item: CollectionItem<typeof Routes>) {
|
||||||
|
return tempstream`<li><a href="">${item.get("name") as string}</a></li>`;
|
||||||
|
}
|
||||||
|
})(Routes);
|
@ -0,0 +1,17 @@
|
|||||||
|
import { withProdApp } from "../test_utils/with-prod-app";
|
||||||
|
import { LONG_TEST_TIMEOUT, webhintURL } from "../test_utils/webhint";
|
||||||
|
import { ListRoutesURL } from "./routes";
|
||||||
|
|
||||||
|
describe("ListRoutes", () => {
|
||||||
|
it("doesn't crash", async function () {
|
||||||
|
this.timeout(LONG_TEST_TIMEOUT);
|
||||||
|
return withProdApp(async ({ base_url, rest_api }) => {
|
||||||
|
await rest_api.get(ListRoutesURL);
|
||||||
|
await webhintURL(base_url + ListRoutesURL);
|
||||||
|
// alternatively you can use webhintHTML for faster but less precise scans
|
||||||
|
// or for scanning responses of requests that use some form of authorization:
|
||||||
|
// const response = await rest_api.get(ListRoutesURL);
|
||||||
|
// await webhintHTML(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,33 @@
|
|||||||
|
import { BaseContext } from "koa";
|
||||||
|
import { Routes } from "../../collections/collections";
|
||||||
|
import { FormHeader, SimpleInput } from "../../forms/controls";
|
||||||
|
import { FormField } from "../../forms/field";
|
||||||
|
import Form, { FormData } from "../../forms/form";
|
||||||
|
import { collectionFieldValidator } from "../../forms/validator";
|
||||||
|
import html from "../../html";
|
||||||
|
|
||||||
|
export const actionName = "AddRoute";
|
||||||
|
|
||||||
|
export default new (class AddRouteForm extends Form {
|
||||||
|
defaultSuccessMessage = "Pomyślnie utworzono użytkownika";
|
||||||
|
|
||||||
|
fields = [new FormField("name", true, collectionFieldValidator(Routes.fields.name))];
|
||||||
|
|
||||||
|
controls = [
|
||||||
|
new FormHeader("Dodaj nową trasę"),
|
||||||
|
new SimpleInput("name", { label: "Nazwa trasy", type: "text" }),
|
||||||
|
];
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
async canAccess(_: BaseContext) {
|
||||||
|
return { canAccess: true, message: "" };
|
||||||
|
}
|
||||||
|
|
||||||
|
async onSubmit(ctx: BaseContext, values: Record<"name", string>) {
|
||||||
|
await ctx.$app.collections.routes.create(ctx.$context, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
async render(ctx: BaseContext, data: FormData, path: string) {
|
||||||
|
return html(ctx, "Nowa trasa", await super.render(ctx, data, path));
|
||||||
|
}
|
||||||
|
})();
|
@ -0,0 +1,17 @@
|
|||||||
|
import { withProdApp } from "../../test_utils/with-prod-app";
|
||||||
|
import { LONG_TEST_TIMEOUT, webhintURL } from "../../test_utils/webhint";
|
||||||
|
import { AddRouteURL } from "../routes";
|
||||||
|
|
||||||
|
describe("AddRoute", () => {
|
||||||
|
it("doesn't crash", async function () {
|
||||||
|
this.timeout(LONG_TEST_TIMEOUT);
|
||||||
|
return withProdApp(async ({ base_url, rest_api }) => {
|
||||||
|
await rest_api.get(AddRouteURL);
|
||||||
|
await webhintURL(base_url + AddRouteURL);
|
||||||
|
// alternatively you can use webhintHTML for faster but less precise scans
|
||||||
|
// or for scanning responses of requests that use some form of authorization:
|
||||||
|
// const response = await rest_api.get(AddRouteURL);
|
||||||
|
// await webhintHTML(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,80 @@
|
|||||||
|
cliArgs:
|
||||||
|
geometry: false # retrieve geometry (-g)
|
||||||
|
planmode: false # run vroom in plan mode (-c) if set to true
|
||||||
|
threads: 4 # number of threads to use (-t)
|
||||||
|
explore: 5 # exploration level to use (0..5) (-x)
|
||||||
|
limit: '1mb' # max request size
|
||||||
|
logdir: '/..' # the path for the logs relative to ./src
|
||||||
|
logsize: '100M' # max log file size for rotation
|
||||||
|
maxlocations: 1000 # max number of jobs/shipments locations
|
||||||
|
maxvehicles: 200 # max number of vehicles
|
||||||
|
override: true # allow cli options override (-c, -g, -t and -x)
|
||||||
|
path: '' # VROOM path (if not in $PATH)
|
||||||
|
port: 3000 # expressjs port
|
||||||
|
router: 'osrm' # routing backend (osrm, libosrm or ors)
|
||||||
|
timeout: 300000 # milli-seconds
|
||||||
|
baseurl: '/' #base url for api
|
||||||
|
routingServers:
|
||||||
|
osrm:
|
||||||
|
car:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '5000'
|
||||||
|
bike:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '5001'
|
||||||
|
foot:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '5002'
|
||||||
|
ors:
|
||||||
|
driving-car:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
driving-hgv:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
cycling-regular:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
cycling-mountain:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
cycling-road:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
cycling-electric:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
foot-walking:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
foot-hiking:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8080'
|
||||||
|
valhalla:
|
||||||
|
auto:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
bicycle:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
pedestrian:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
motorcycle:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
motor_scooter:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
taxi:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
hov:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
truck:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
||||||
|
bus:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '8002'
|
@ -0,0 +1,7 @@
|
|||||||
|
FROM node:18
|
||||||
|
|
||||||
|
RUN git clone https://github.com/VROOM-Project/vroom-frontend.git /opt/vroom-frontend
|
||||||
|
WORKDIR /opt/vroom-frontend
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
CMD npm run serve
|
Loading…
Reference in New Issue