diff options
author | Sascha Roloff <sascha.roloff@huawei.com> | 2025-05-09 20:00:56 +0200 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2025-05-12 12:15:23 +0200 |
commit | f8a1a6a4a2f585db5cb1f20aad540cdf75b389aa (patch) | |
tree | 9989bf7e2cd4ebebc44475a9dc1d117690302317 /doc | |
parent | 5aba3e6394a665d3c11973424c59d603134a3fbd (diff) | |
download | justbuild-f8a1a6a4a2f585db5cb1f20aad540cdf75b389aa.tar.gz |
Invocation server: add filter selector to overview page
Diffstat (limited to 'doc')
-rwxr-xr-x | doc/invocations-http-server/server.py | 30 | ||||
-rw-r--r-- | doc/invocations-http-server/templates/invocations.html | 32 |
2 files changed, 56 insertions, 6 deletions
diff --git a/doc/invocations-http-server/server.py b/doc/invocations-http-server/server.py index 138c5f2e..7121ec75 100755 --- a/doc/invocations-http-server/server.py +++ b/doc/invocations-http-server/server.py @@ -112,6 +112,15 @@ class InvocationServer: invocations = [] count = 0 entries = sorted(os.listdir(self.logsdir), reverse=True) + context_filters = {} + remote_props_filters = {} + def add_filter(data, filters): + for k, v in data.items(): + key = json.dumps(k) + value = json.dumps(v) + if key not in filters: + filters[key] = set() + filters[key].add(value) for e in entries: profile = os.path.join(self.logsdir, e, self.profile) if not os.path.exists(profile): @@ -137,7 +146,10 @@ class InvocationServer: count += 1 target = profile_data.get("target") config = core_config(profile_data.get("configuration", {})) - context = meta_data.get("context") + context = meta_data.get("context", {}) + remote_props = profile_data.get('remote', {}).get('properties', {}) + add_filter(context, context_filters) + add_filter(remote_props, remote_props_filters) invocation = { "name": e, "subcommand": profile_data.get("subcommand"), @@ -146,15 +158,25 @@ class InvocationServer: "context": json.dumps(context) if context else None, "exit_code": profile_data.get('exit code', 0), "remote_address": profile_data.get('remote', {}).get('address'), - "remote_props": json.dumps( - profile_data.get('remote', {}).get('properties', {})), + "remote_props": json.dumps(remote_props) if remote_props else None, } invocations.append(invocation) if count >= 100: break + def convert_filters(filters): + return [{ + "key": key, + "key_hex": key.encode().hex(), + "values": [{ + "value": v, + "value_hex": v.encode().hex(), + } for v in values] + } for key, values in filters.items() if len(values) > 1] return self.render("invocations.html", {"invocations": invocations, - "filter_info": filter_info}) + "filter_info": filter_info, + "context_filters": convert_filters(context_filters), + "remote_props_filters": convert_filters(remote_props_filters)}) def do_filter_remote_prop(self, key, value): filter_info = "remote-execution property" diff --git a/doc/invocations-http-server/templates/invocations.html b/doc/invocations-http-server/templates/invocations.html index 1417a3c4..a98babae 100644 --- a/doc/invocations-http-server/templates/invocations.html +++ b/doc/invocations-http-server/templates/invocations.html @@ -8,8 +8,36 @@ Recent Invocations <h1>Invocations filtered by {{ filter_info | e }}</h1> {% else %} <h1>Recent Invocations</h1> - -Filter: <a href="/filterinvocations/noncached">only not fully cached</a> +<b>Filter by:</b> + <a href="/filterinvocations/noncached">only not fully cached</a> + {% if context_filters %} + <details> + <summary>Context</summary> + {% for entry in context_filters %} + <tt>{{ entry.key | e }}</tt>: + {% for value in entry["values"] %} + {% if loop.index > 1 %} + , + {% endif %} + <a href="/filterinvocations/context/{{ entry["key_hex"] | e }}/{{ value["value_hex"] }}"><tt>{{ value["value"] | e }}</tt></a> + {% endfor %}<br> + {% endfor %} + </details> + {% endif %} + {% if remote_props_filters %} + <details> + <summary>Remote properties</summary> + {% for entry in remote_props_filters %} + <tt>{{ entry.key | e }}</tt>: + {% for value in entry["values"] %} + {% if loop.index > 1 %} + , + {% endif %} + <a href="/filterinvocations/remote/prop/{{ entry["key_hex"] | e }}/{{ value["value_hex"] }}"><tt>{{ value["value"] | e }}</tt></a> + {% endfor %}<br> + {% endfor %} + </details> + {% endif %} {% endif %} {% if invocations %} <ul> |