Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions ydb/core/persqueue/common_app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#include "common_app.h"


namespace NKikimr::NPQ::NApp {

THtmlPart::THtmlPart(IOutputStream& str)
: Str(str) {
}

THtmlPart::~THtmlPart() {
}

THtmlAppPage::THtmlAppPage(IOutputStream& str, const TString& /*title*/)
: THtmlPart(str) {
Str << R"(
<STYLE>
.row {
--bs-gutter-x: 1.5rem;
--bs-gutter-y: 0;
display: flex;
flex-wrap: wrap;
margin-top: calc(-1 * var(--bs-gutter-y));
margin-right: calc(-0.5 * var(--bs-gutter-x));
margin-left: calc(-0.5 * var(--bs-gutter-x));
}

.row > * {
box-sizing: border-box;
flex-shrink: 0;
width: 100%;
max-width: 100%;
padding-right: calc(var(--bs-gutter-x) * 0.5);
padding-left: calc(var(--bs-gutter-x) * 0.5);
margin-top: var(--bs-gutter-y);
}

.col {
flex: 1 0 0%;
}

.properties {
border-bottom-style: solid;
border-top-style: solid;
border-width: 1px;
border-color: darkgrey;
padding-bottom: 10px;
width: 100%;
}

.tgrid {
width: 100%;
border: 0;
}
</STYLE>)";
}

THtmlAppPage::~THtmlAppPage() {
}

TNavigationBar::TNavigationBar(IOutputStream& str)
: THtmlPart(str) {
Str << R"(<UL CLASS="nav nav-tabs">)";
}

TNavigationBar::~TNavigationBar() {
if (FirstContent) {
Str << R"(</UL>)";
} else {
Str << R"(</DIV>)";
}
}

void TNavigationBar::Add(const TString& code, const TString& caption) {
auto& __stream = Str;

auto link = [&]() {
__stream << "<a href=\"#" << code << "\" data-toggle=\"tab\">" << caption << "</a>";
};

if (FirstTab) {
FirstTab = false;
LI_CLASS("active") {
link();
}
} else {
LI() {
link();
}
}
}

TNavigationBarContent::TNavigationBarContent(TNavigationBar& navigationBar, const TString& id)
: NavigationBar(navigationBar) {

auto& __stream = NavigationBar.Str;
if (NavigationBar.FirstContent) {
__stream << R"(
</UL>
<DIV CLASS="tab-content">
<DIV CLASS="tab-pane fade in active container" id=")" << id << R"(">)";
} else {
__stream << R"(<DIV CLASS="tab-pane fade" id=")" << id << R"(">)";
}
}

TNavigationBarContent::~TNavigationBarContent() {
auto& __stream = NavigationBar.Str;
__stream << R"(</DIV>)";
NavigationBar.FirstContent = false;
}

TNavigationBarContentPart::TNavigationBarContentPart(IOutputStream& str, const TString& id)
: THtmlPart(str) {
Str << R"(<DIV CLASS="tab-pane fade" id=")" << id << R"(">)";
}

TNavigationBarContentPart::~TNavigationBarContentPart() {
Str << R"(</DIV>)";
}

TProperties::TProperties(IOutputStream& str, const TString& caption)
: THtmlPart(str) {

Str << R"(
<TABLE CLASS="properties">
<CAPTION>)" << caption << R"(</CAPTION>
<TBODY>
)";
}

TProperties::~TProperties() {
Str << R"(
</TBODY>
</TABLE>
)";
}

void TProperties::Add(const TString& name, const TString& value) {
auto& __stream = Str;

TABLER() {
TABLED() { __stream << name;}
TABLED() { __stream << value; }
}
}

TConfiguration::TConfiguration(IOutputStream& str, const TString& value)
: THtmlPart(str) {

auto& __stream = Str;
DIV() {
DIV() {
Str << "Configuration";
}
PRE() {
Str << value;
}
}
}


}
81 changes: 81 additions & 0 deletions ydb/core/persqueue/common_app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#pragma once

#include <library/cpp/monlib/service/pages/templates.h>
#include <util/string/builder.h>


#define HTML_APP_PAGE(str, title) WITH_SCOPED(__stream, ::NKikimr::NPQ::NApp::THtmlAppPage(str, TStringBuilder() << title))
#define HTML_PART(str) WITH_SCOPED(__stream, ::NKikimr::NPQ::NApp::THtmlPart(str))

#define NAVIGATION_BAR() WITH_SCOPED(__navigationBar, ::NKikimr::NPQ::NApp::TNavigationBar(__stream))
#define NAVIGATION_TAB(id, caption) __navigationBar.Add(TStringBuilder() << id, TStringBuilder() << caption)
#define NAVIGATION_TAB_CONTENT(id) WITH_SCOPED(__navigationContent, ::NKikimr::NPQ::NApp::TNavigationBarContent(__navigationBar, id))
#define NAVIGATION_TAB_CONTENT_PART(id) WITH_SCOPED(__navigationContent, ::NKikimr::NPQ::NApp::TNavigationBarContentPart(__stream, TStringBuilder() << id))

#define PROPERTIES(caption) WITH_SCOPED(__properties, ::NKikimr::NPQ::NApp::TProperties(__stream, caption))
#define PROPERTY(caption, value) __properties.Add(caption, TStringBuilder() << value)

#define LAYOUT() DIV()
#define LAYOUT_ROW() DIV_CLASS("row")
#define LAYOUT_COLUMN() DIV_CLASS("col")

#define CONFIGURATION(val) WITH_SCOPED(__configuration, ::NKikimr::NPQ::NApp::TConfiguration(__stream, val)) {}


namespace NKikimr::NPQ::NApp {

struct THtmlPart {
THtmlPart(IOutputStream&);
~THtmlPart();

inline operator IOutputStream&() noexcept {
return Str;
}

protected:
IOutputStream& Str;
};

struct THtmlAppPage : public THtmlPart {
THtmlAppPage(IOutputStream&, const TString& title);
~THtmlAppPage();
};

struct TNavigationBar : public THtmlPart {
friend struct TNavigationBarContent;

TNavigationBar(IOutputStream&);
~TNavigationBar();

void Add(const TString& id, const TString& caption);

private:
bool FirstTab = true;
bool FirstContent = true;
};

struct TNavigationBarContent {
TNavigationBarContent(TNavigationBar&, const TString& id);
~TNavigationBarContent();
private:
TNavigationBar& NavigationBar;
};

struct TNavigationBarContentPart : public THtmlPart {
TNavigationBarContentPart(IOutputStream&, const TString& id);
~TNavigationBarContentPart();
};

struct TProperties : public THtmlPart {
TProperties(IOutputStream&, const TString& caption);
~TProperties();

void Add(const TString& name, const TString& value);
};

struct TConfiguration : public THtmlPart {
TConfiguration(IOutputStream&, const TString& value);
~TConfiguration() = default;
};

}
9 changes: 3 additions & 6 deletions ydb/core/persqueue/events/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,16 @@ struct TEvPQ {
};

struct TEvMonResponse : public TEventLocal<TEvMonResponse, EvMonResponse> {
TEvMonResponse(const NPQ::TPartitionId& partition, const TVector<TString>& res, const TString& str)
TEvMonResponse(const NPQ::TPartitionId& partition, const TString& str)
: Partition(partition)
, Res(res)
, Str(str)
{}

TEvMonResponse(const TVector<TString>& res, const TString& str)
: Res(res)
, Str(str)
TEvMonResponse(const TString& str)
: Str(str)
{}

TMaybe<NPQ::TPartitionId> Partition;
TVector<TString> Res;
TString Str;
};

Expand Down
Loading
Loading