mon_page.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "mon_page.h"
  2. using namespace NMonitoring;
  3. IMonPage::IMonPage(const TString& path, const TString& title)
  4. : Path(path)
  5. , Title(title)
  6. {
  7. Y_ABORT_UNLESS(!Path.StartsWith('/'));
  8. Y_ABORT_UNLESS(!Path.EndsWith('/'));
  9. }
  10. void IMonPage::OutputNavBar(IOutputStream& out) {
  11. TVector<const IMonPage*> parents;
  12. for (const IMonPage* p = this; p; p = p->Parent) {
  13. parents.push_back(p);
  14. }
  15. std::reverse(parents.begin(), parents.end());
  16. out << "<ol class='breadcrumb'>\n";
  17. TString absolutePath;
  18. for (size_t i = 0; i < parents.size(); ++i) {
  19. const TString& title = parents[i]->GetTitle();
  20. if (i == parents.size() - 1) {
  21. out << "<li>" << title << "</li>\n";
  22. } else {
  23. if (!absolutePath.EndsWith('/')) {
  24. absolutePath += '/';
  25. }
  26. absolutePath += parents[i]->GetPath();
  27. out << "<li class='active'><a href='" << absolutePath << "'>" << title << "</a></li>\n";
  28. }
  29. }
  30. out << "</ol>\n";
  31. }