aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-12-03 21:25:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-12-04 17:19:14 +0300
commit7dabb6e931740b2777be5dca53c3cec0b984f0fb (patch)
treee89348003d3161d1a93ef2aa0bd7d293c7e55075
parentbc899becb66e37df6dc93aeca885c68b96e33a1a (diff)
Print configuration target and classes on build configurations page
-rw-r--r--etc/brep-module.conf19
-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
-rw-r--r--www/build-configs-body.css52
7 files changed, 152 insertions, 26 deletions
diff --git a/etc/brep-module.conf b/etc/brep-module.conf
index b4c0ee4..458261e 100644
--- a/etc/brep-module.conf
+++ b/etc/brep-module.conf
@@ -28,9 +28,9 @@ menu Packages=
menu About=?about
-# Number of package search results per page.
+# Number of packages per page.
#
-# search-results 20
+# search-page-entries 20
# Number of pages in navigation (pager).
@@ -83,6 +83,16 @@ menu About=?about
# build-config
+# Number of build configurations per page.
+#
+# build-config-page-entries 20
+
+
+# Number of pages in navigation (pager).
+#
+# build-config-pages 5
+
+
# Directory containing build bot agent public keys. If specified, then brep
# will perform agent authentication and will reject build results from
# unauthenticated ones. If not specified, then build results are accepted from
@@ -97,15 +107,14 @@ menu About=?about
# build-bot-agent-keys
-# Number of package build configurations per page.
+# Number of builds per page.
#
-# build-configurations 20
+# build-page-entries 20
# Number of pages in navigation (pager).
#
# build-pages 5
-#
# Time to wait before considering a package for a forced rebuild. Must be
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
diff --git a/www/build-configs-body.css b/www/build-configs-body.css
index 5250573..83bdf6e 100644
--- a/www/build-configs-body.css
+++ b/www/build-configs-body.css
@@ -1,6 +1,56 @@
-tr.config td .value
+/*
+ * Config count.
+ */
+#count
+{
+ font-size: 1.32em;
+ line-height: 1.4em;
+ color: #555;
+
+ margin: 1.2em 0 0 0;
+}
+
+/*
+ * Config table.
+ */
+.config
+{
+ margin-top: .8em;
+ margin-bottom: .8em;
+
+ padding-top: .4em;
+ padding-bottom: .4em;
+}
+.config:nth-child(even) {background-color: rgba(0, 0, 0, 0.07);}
+
+.config th
+{
+ width: 5.7em;
+}
+
+.config tr.name td .value,
+.config tr.target td .value,
+.config tr.classes td .value
{
/* <code> style. */
font-family: monospace;
font-size: 0.94em;
}
+
+/* Re-styling of the classes row not to truncate the class list. */
+
+.classes th
+{
+ vertical-align: top;
+}
+
+.classes td
+{
+ flex-wrap: wrap;
+ -webkit-flex-wrap: wrap;
+}
+
+.classes td .value
+{
+ white-space: normal;
+}