Skip to content

Commit

Permalink
feat(webui): order apps alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Sep 28, 2024
1 parent 1071f13 commit cfde73a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/confighttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,23 @@ namespace confighttp {
fileTree.erase("apps");
fileTree.push_back(std::make_pair("apps", newApps));
}

// Sort the apps array by name
std::vector<pt::ptree> apps_vector;
for (const auto &[key, value] : fileTree.get_child("apps")) {
apps_vector.push_back(value);
}
std::ranges::sort(apps_vector, [](const pt::ptree &a, const pt::ptree &b) {
return a.get<std::string>("name") < b.get<std::string>("name");
});

Check warning on line 416 in src/confighttp.cpp

View check run for this annotation

Codecov / codecov/patch

src/confighttp.cpp#L416

Added line #L416 was not covered by tests

pt::ptree sorted_apps;
for (const auto &app : apps_vector) {
sorted_apps.push_back(std::make_pair("", app));
}
fileTree.erase("apps");
fileTree.add_child("apps", sorted_apps);

pt::write_json(config::stream.file_apps, fileTree);
}
catch (std::exception &e) {
Expand Down

0 comments on commit cfde73a

Please sign in to comment.