aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/frontend/html/pages/project.js
blob: 42ae30c8ca16f6014be81da9697a7054bb2a1f35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright Epic Games, Inc. All Rights Reserved.

"use strict";

import { ZenPage } from "./page.js"
import { Fetcher } from "../util/fetcher.js"
import { Friendly } from "../util/friendly.js"
import { Modal } from "../util/modal.js"
import { Table, PropTable, Toolbar } from "../util/widgets.js"

////////////////////////////////////////////////////////////////////////////////
export class Page extends ZenPage
{
	async main()
	{
		// info
		var section = this.add_section("info");

		const project = this.get_param("project");

		this.set_title("project - " + project);

		var info = await new Fetcher().resource("prj", project).json();
		var prop_table = section.add_widget(PropTable);
		for (const key in info)
		{
			if (key == "oplogs")
				continue;

			prop_table.add_property(key, info[key]);
		}

		// oplog
		section = this.add_section("oplogs");

		var oplog_table = section.add_widget(
			Table,
			["name", "marker", "size", "ops", "expired", "actions"],
			Table.Flag_PackRight
		)

		var count = 0;
		for (const oplog of info["oplogs"])
		{
			const name = oplog["id"];

			var info = new Fetcher().resource("prj", project, "oplog", name).json();

			var row = oplog_table.add_row(name);

			var cell = row.get_cell(0);
			this.as_link(cell, "oplog", name)

			cell = row.get_cell(-1);
			const action_tb = new Toolbar(cell, true).left();
			this.as_link(action_tb.add("list"), "oplog", name);
			this.as_link(action_tb.add("tree"), "tree", name);
			action_tb.add("drop").on_click((x) => this.drop_oplog(x), name);

			info = await info;
			row.get_cell(1).text(info["markerpath"]);
			row.get_cell(2).text(Friendly.kib(info["totalsize"]));
			row.get_cell(3).text(Friendly.sep(info["opcount"]));
			row.get_cell(4).text(info["expired"]);
		}
	}

	as_link(component, page, oplog_id)
	{
		component.link("", {
			"page" : page,
			"project" : this.get_param("project"),
			"oplog" : oplog_id,
		});
	}

	drop_oplog(oplog_id)
	{
		const drop = async () => {
			await new Fetcher()
				.resource("prj", this.get_param("project"), "oplog", oplog_id)
				.delete();
			this.reload();
		};

		new Modal()
			.title("Confirmation")
			.message(`Drop oplog '${oplog_id}'?`)
			.option("Yes", () => drop())
			.option("No");
	}
}