aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-build-configs.cxx78
-rw-r--r--mod/mod-builds.cxx3
-rw-r--r--mod/mod-package-details.cxx2
-rw-r--r--mod/mod-packages.cxx2
-rw-r--r--mod/options.cli22
5 files changed, 87 insertions, 20 deletions
diff --git a/mod/mod-build-configs.cxx b/mod/mod-build-configs.cxx
index d3d5191..99a092d 100644
--- a/mod/mod-build-configs.cxx
+++ b/mod/mod-build-configs.cxx
@@ -59,21 +59,24 @@ handle (request& rq, response& rs)
if (build_conf_ == nullptr)
throw invalid_request (501, "not implemented");
+ const size_t page_configs (options_->build_config_page_entries ());
const dir_path& root (options_->root ());
- // Make sure no parameters passed.
- //
+ params::build_configs params;
+
try
{
name_value_scanner s (rq.parameters (1024));
- params::build_configs (s, unknown_mode::fail, unknown_mode::fail);
+ params = params::build_configs (s, unknown_mode::fail, unknown_mode::fail);
}
catch (const cli::exception& e)
{
throw invalid_request (400, e.what ());
}
- static const string title ("Build Configurations");
+ size_t page (params.page ());
+
+ const char* title ("Build Configurations");
xml::serializer s (rs.content (), title);
s << HTML
@@ -83,20 +86,71 @@ handle (request& rq, response& rs)
<< ~HEAD
<< BODY
<< DIV_HEADER (options_->logo (), options_->menu (), root, tenant)
- << DIV(ID="content")
- << TABLE(CLASS="proplist")
- << TBODY;
+ << DIV(ID="content");
+ // Print build configurations that belong to the 'all' class.
+ //
+ // We will calculate the total configuration count and cache configurations
+ // for printing (skipping an appropriate number of them for page number
+ // greater than one) on the same pass. Note that we need to print the count
+ // before printing the configurations.
+ //
+ size_t count (0);
+ vector<const build_config*> configs;
+ configs.reserve (page_configs);
+
+ size_t skip (page * page_configs);
+ size_t print (page_configs);
for (const build_config& c: *build_conf_)
{
if (belongs (c, "all"))
- s << TR(CLASS="config")
- << TD << SPAN(CLASS="value") << c.name << ~SPAN << ~TD
- << ~TR;
+ {
+ if (skip != 0)
+ --skip;
+ else if (print != 0)
+ {
+ configs.emplace_back (&c);
+ --print;
+ }
+
+ ++count;
+ }
+ }
+
+ // Print configuration count.
+ //
+ s << DIV_COUNTER (count, "Build Configuration", title);
+
+ // Finally, print the cached build configurations.
+ //
+ // Enclose the subsequent tables to be able to use nth-child CSS selector.
+ //
+ s << DIV;
+ for (const build_config* c: configs)
+ {
+ string classes;
+ for (const string& cls: c->classes)
+ {
+ if (!classes.empty ())
+ classes += ' ';
+ classes += cls;
+ }
+
+ s << TABLE(CLASS="proplist config")
+ << TBODY
+ << TR_VALUE ("name", c->name)
+ << TR_VALUE ("target", c->target.string ())
+ << TR_VALUE ("classes", classes)
+ << ~TBODY
+ << ~TABLE;
}
+ s << ~DIV;
- s << ~TBODY
- << ~TABLE
+ s << DIV_PAGER (page,
+ count,
+ page_configs,
+ options_->build_config_pages (),
+ root.string () + "?build-configs")
<< ~DIV
<< ~BODY
<< ~HTML;
diff --git a/mod/mod-builds.cxx b/mod/mod-builds.cxx
index 91a4aa6..6ad5a0e 100644
--- a/mod/mod-builds.cxx
+++ b/mod/mod-builds.cxx
@@ -292,7 +292,7 @@ handle (request& rq, response& rs)
if (build_db_ == nullptr)
throw invalid_request (501, "not implemented");
- const size_t page_configs (options_->build_configurations ());
+ const size_t page_configs (options_->build_page_entries ());
const string& host (options_->host ());
const dir_path& root (options_->root ());
const string& tenant_name (options_->tenant_name ());
@@ -478,6 +478,7 @@ handle (request& rq, response& rs)
//
count = 0;
vector<shared_ptr<build>> builds;
+ builds.reserve (page_configs);
// Prepare the package build prepared query.
//
diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx
index df69614..18b2286 100644
--- a/mod/mod-package-details.cxx
+++ b/mod/mod-package-details.cxx
@@ -75,7 +75,7 @@ handle (request& rq, response& rs)
HANDLER_DIAG;
- const size_t res_page (options_->search_results ());
+ const size_t res_page (options_->search_page_entries ());
const dir_path& root (options_->root ());
params::package_details params;
diff --git a/mod/mod-packages.cxx b/mod/mod-packages.cxx
index 27e1270..8c2084e 100644
--- a/mod/mod-packages.cxx
+++ b/mod/mod-packages.cxx
@@ -86,7 +86,7 @@ handle (request& rq, response& rs)
HANDLER_DIAG;
- const size_t res_page (options_->search_results ());
+ const size_t res_page (options_->search_page_entries ());
const dir_path& root (options_->root ());
const string& title (options_->search_title ());
const string& tenant_name (options_->tenant_name ());
diff --git a/mod/options.cli b/mod/options.cli
index 8020f95..93f2ead 100644
--- a/mod/options.cli
+++ b/mod/options.cli
@@ -286,10 +286,10 @@ namespace brep
class search
{
- uint16_t search-results = 20
+ uint16_t search-page-entries = 20
{
"<num>",
- "Number of package search results per page. The default is 20."
+ "Number of packages per page. The default is 20."
}
uint16_t search-pages = 5
@@ -385,10 +385,10 @@ namespace brep
class builds: build, package_db, build_db, page, handler
{
- uint16_t build-configurations = 20
+ uint16_t build-page-entries = 20
{
"<num>",
- "Number of package build configurations per page. The default is 20."
+ "Number of builds per page. The default is 20."
}
uint16_t build-pages = 5
@@ -400,6 +400,17 @@ namespace brep
class build_configs: build, page, handler
{
+ uint16_t build-config-page-entries = 20
+ {
+ "<num>",
+ "Number of build configurations per page. The default is 20."
+ }
+
+ uint16_t build-config-pages = 5
+ {
+ "<num>",
+ "Number of pages in navigation (pager). The default is 5."
+ }
};
class submit: page, handler
@@ -727,8 +738,9 @@ namespace brep
class build_configs
{
- // No parameters so far.
+ // Display build configurations list starting from this page.
//
+ uint16_t page | p;
};
// Parameters, except simulate, must either be all present (actual