A web dashboard for Flecs
First, make sure you clone and build the required dependencies:
When you are using bake, you can run the following command to install and build all modules:
bake clone flecs-hub/flecs-systems-admin
The easiest way to run the admin is by passing arguments to the commandline. This lets you run the admin for any project without explicitly adding it to the code. For this to work, initialize your Flecs application like this:
ecs_init_w_args(world, argc, argv);
When you start your application, add the following arguments:
my_app --admin 9090
If you always want to run the admin with your project, you can enable it in code. To do this you need to include the following modules in your project:
If you are using bake, you can simply add these modules to the "use"
property, like this:
{
"id": "my_project",
"type": "application",
"value": {
"use": ["flecs", "flecs.components.http", "flecs.systems.civetweb", "flecs.systems.admin"]
}
}
In your main function, now add the following lines of code:
ecs_world_t *world = ecs_init();
/* Import modules for admin */
ECS_IMPORT(world, FlecsComponentsHttp, 0);
ECS_IMPORT(world, FlecsSystemsCivetweb, 0);
ECS_IMPORT(world, FlecsSystemsAdmin, 0);
/* Create the admin entity */
ecs_set(world, 0, EcsAdmin, {.port = 9090});
When you run your project, you should be able to see the admin in localhost:9090
.
Currently the admin needs certain features from bake to run. This dependency will be removed in the future, but if you would like to use the admin today without bake, you will have to change the ut_locate
call to something that tells the code where to find the HTML / JS / CSS files.