aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzousar <[email protected]>2025-03-21 22:53:59 -0600
committerzousar <[email protected]>2025-03-21 22:53:59 -0600
commit8878156f30e375b93ebe99f02d94c581bcbbf43c (patch)
tree5399a090e49d6398be34d7b292721d69ccac6c87 /src
parentdon't let auth env argument block other auth options (#316) (diff)
downloadzen-8878156f30e375b93ebe99f02d94c581bcbbf43c.tar.xz
zen-8878156f30e375b93ebe99f02d94c581bcbbf43c.zip
Add CookPackageArtifacts attachment to web ui
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/frontend/html/pages/entry.js69
-rw-r--r--src/zenserver/projectstore/projectstore.cpp43
2 files changed, 106 insertions, 6 deletions
diff --git a/src/zenserver/frontend/html/pages/entry.js b/src/zenserver/frontend/html/pages/entry.js
index 65a3ef39b..3891239f0 100644
--- a/src/zenserver/frontend/html/pages/entry.js
+++ b/src/zenserver/frontend/html/pages/entry.js
@@ -59,6 +59,63 @@ export class Page extends ZenPage
}
}
+ _find_iohash_field(container, name)
+ {
+ const found_field = container.find(name);
+ if (found_field != undefined)
+ {
+ var found_value = found_field.as_value();
+ if (found_value instanceof Uint8Array)
+ {
+ var ret = "";
+ for (var x of found_value)
+ ret += x.toString(16).padStart(2, "0");
+ return ret;
+ }
+ }
+ return null;
+ }
+
+ async _build_meta(section, entry)
+ {
+ var tree = {}
+ const cookart = this._find_iohash_field(entry, "CookPackageArtifacts");
+ if (cookart != null)
+ {
+ tree["cook"] = { CookPackageArtifacts: cookart};
+ }
+
+ if (Object.keys(tree).length == 0)
+ return;
+
+ const sub_section = section.add_section("meta");
+
+ for (const cat_name in tree)
+ {
+ const cat_section = sub_section.add_section(cat_name);
+ const table = cat_section.add_widget(
+ Table,
+ ["name", "actions"], Table.Flag_PackRight
+ );
+ Object.entries(tree[cat_name]).forEach(([key, value]) =>
+ {
+ const row = table.add_row(key);
+
+ const project = this.get_param("project");
+ const oplog = this.get_param("oplog");
+ const link = row.get_cell(0).link(
+ "/" + ["prj", project, "oplog", oplog, value+".json"].join("/")
+ );
+
+ const do_nothing = () => void(0);
+ const action_tb = new Toolbar(row.get_cell(-1), true);
+ action_tb.left().add("copy-hash").on_click(async (v) => {
+ await navigator.clipboard.writeText(v);
+ }, value);
+ });
+ }
+ }
+
async _build_page()
{
var entry = await this._entry;
@@ -78,8 +135,16 @@ export class Page extends ZenPage
delete tree["$id"];
- const sub_section = section.add_section("deps");
- this._build_deps(sub_section, tree);
+ if (Object.keys(tree).length != 0)
+ {
+ const sub_section = section.add_section("deps");
+ this._build_deps(sub_section, tree);
+ }
+ }
+
+ // meta
+ {
+ this._build_meta(section, entry);
}
// data
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp
index 86791e29a..1132e458e 100644
--- a/src/zenserver/projectstore/projectstore.cpp
+++ b/src/zenserver/projectstore/projectstore.cpp
@@ -4812,11 +4812,46 @@ ProjectStore::GetChunk(const std::string_view ProjectId,
}
}
- if (AcceptType == ZenContentType::kUnknownContentType || AcceptType == ZenContentType::kBinary)
+ if (AcceptType == ZenContentType::kUnknownContentType || AcceptType == ZenContentType::kBinary || AcceptType == ZenContentType::kJSON ||
+ AcceptType == ZenContentType::kYAML || AcceptType == ZenContentType::kCbObject)
{
- CompressedBuffer Compressed = CompressedBuffer::FromCompressedNoValidate(std::move(OutChunk));
- OutChunk = Compressed.Decompress().AsIoBuffer();
- OutChunk.SetContentType(ZenContentType::kBinary);
+ CompressedBuffer Compressed = CompressedBuffer::FromCompressedNoValidate(std::move(OutChunk));
+ IoBuffer DecompressedBuffer = Compressed.Decompress().AsIoBuffer();
+
+ if (AcceptType == ZenContentType::kJSON || AcceptType == ZenContentType::kYAML || AcceptType == ZenContentType::kCbObject)
+ {
+ CbValidateError CbErr = ValidateCompactBinary(DecompressedBuffer.GetView(), CbValidateMode::Default);
+ if (!!CbErr)
+ {
+ return {HttpResponseCode::NotAcceptable, fmt::format("chunk - '{}' WRONGTYPE", Cid)};
+ }
+
+ if (AcceptType == HttpContentType::kJSON || AcceptType == HttpContentType::kYAML)
+ {
+ CbObject ContainerObject = LoadCompactBinaryObject(DecompressedBuffer);
+ ExtendableStringBuilder<1024> Sb;
+ if (AcceptType == HttpContentType::kJSON)
+ {
+ ContainerObject.ToJson(Sb);
+ }
+ else if (AcceptType == HttpContentType::kYAML)
+ {
+ ContainerObject.ToYaml(Sb);
+ }
+ IoBuffer SerializedBuffer(IoBuffer::Clone, Sb.Data(), Sb.Size());
+ OutChunk = SerializedBuffer;
+ }
+ else
+ {
+ OutChunk = DecompressedBuffer;
+ }
+ OutChunk.SetContentType(AcceptType);
+ }
+ else
+ {
+ OutChunk = DecompressedBuffer;
+ OutChunk.SetContentType(ZenContentType::kBinary);
+ }
}
else
{