Webdar 1.0.0
Web user interface to libdar
html_statistics.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_STATISTICS_HPP
25#define HTML_STATISTICS_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <string>
36#include <dar/libdar.hpp>
37
38
39 // webdar headers
40#include "body_builder.hpp"
41#include "html_table.hpp"
42#include "html_text.hpp"
43
45
47{
48public:
50 html_statistics(const html_statistics & ref) = delete;
51 html_statistics(html_statistics && ref) noexcept = delete;
52 html_statistics operator = (const html_statistics & ref) = delete;
53 html_statistics operator = (html_statistics && ref) noexcept = delete;
54 ~html_statistics() { unbuild(); };
55
56 void clear_counters();
57 void clear_labels();
58
59 // fields that do not get a label are not shown
60 void set_treated_label(const std::string & label) { treated_lbl.clear(); treated_lbl.add_text(0, label); unbuild(); };
61 void set_hard_links_label(const std::string & label) { hard_links_lbl.clear(); hard_links_lbl.add_text(0, label); unbuild(); };
62 void set_skipped_label(const std::string & label) { skipped_lbl.clear(); skipped_lbl.add_text(0, label); unbuild(); };
63 void set_ignored_label(const std::string & label) { ignored_lbl.clear(); ignored_lbl.add_text(0, label); unbuild(); };
64 void set_tooold_label(const std::string & label) { tooold_lbl.clear(); tooold_lbl.add_text(0, label); unbuild(); };
65 void set_errored_label(const std::string & label) { errored_lbl.clear(); errored_lbl.add_text(0, label); unbuild(); };
66 void set_deleted_label(const std::string & label) { deleted_lbl.clear(); deleted_lbl.add_text(0, label); unbuild(); };
67 void set_ea_treated_label(const std::string & label) { ea_treated_lbl.clear(); ea_treated_lbl.add_text(0, label); unbuild(); };
68 void set_byte_amount_label(const std::string & label) { byte_amount_lbl.clear(); byte_amount_lbl.add_text(0, label); unbuild(); };
69 void set_total_label(const std::string & label) { total_lbl.clear(); total_lbl.add_text(0, label); unbuild(); };
70
72 libdar::statistics *get_libdar_statistics() { return & stats; };
73
74
75protected:
80 virtual std::string inherited_get_body_part(const chemin & path,
81 const request & req) override;
82
83 // inherited from body_builder
84 virtual void new_css_library_available() override;
85
86
87private:
88 libdar::statistics stats;
89
90 html_table *table;
91
92 html_text treated_lbl;
93 html_text hard_links_lbl;
94 html_text skipped_lbl;
95 html_text ignored_lbl;
96 html_text tooold_lbl;
97 html_text errored_lbl;
98 html_text deleted_lbl;
99 html_text ea_treated_lbl;
100 html_text byte_amount_lbl;
101 html_text total_lbl;
102
103 html_text treated_count;
104 html_text hard_links_count;
105 html_text skipped_count;
106 html_text ignored_count;
107 html_text tooold_count;
108 html_text errored_count;
109 html_text deleted_count;
110 html_text ea_treated_count;
111 html_text byte_amount_count;
112 html_text total_count;
113
115 void build();
116
118 void unbuild();
119
121 void update_html_counters();
122};
123
124#endif
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
html component to display libdar returned statistics object
Definition: html_statistics.hpp:47
virtual void new_css_library_available() override
Definition: html_statistics.cpp:108
libdar::statistics * get_libdar_statistics()
the address of the object to be updated by libdar
Definition: html_statistics.hpp:72
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
Definition: html_statistics.cpp:97
html component implementing the html table structure
Definition: html_table.hpp:52
class html_text manage text and header in html document
Definition: html_text.hpp:52
void clear()
clear the whole component value (gets as if it was just created)
Definition: html_text.hpp:79
void add_text(unsigned int level, const std::string &text)
Definition: html_text.cpp:44
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45