Webdar 1.0.0
Web user interface to libdar
guichet.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 GUICHET_HPP
25#define GUICHET_HPP
26
27#include "my_config.h"
28
29 // C system header files
30extern "C"
31{
32
33}
34
35 // C++ system header files
36
37
38 // webdar headers
39#include "body_builder.hpp"
40#include "jsoner.hpp"
41#include "bibliotheque.hpp"
42#include "bibliotheque_subconfig.hpp"
43#include "actor.hpp"
44#include "html_form.hpp"
45#include "html_form_fieldset.hpp"
46#include "html_form_select.hpp"
47#include "html_double_button.hpp"
48#include "html_form_input.hpp"
49#include "html_text.hpp"
50
52
60
91class guichet: public body_builder, public jsoner, public bibliotheque_subconfig, public actor
92{
93public:
94
96
101 guichet(bool subcomponent = false);
102
103 guichet(const guichet & ref) = delete;
104 guichet(guichet && ref) noexcept = delete;
105 guichet & operator = (const guichet & ref) = delete;
106 guichet & operator = (guichet && ref) noexcept = delete;
107 virtual ~guichet();
108
109
111
128 void set_child(const std::shared_ptr<bibliotheque> & ptr,
130 const std::shared_ptr<body_builder> & to_adopt,
131 bool add_form_around);
132
133
135 virtual void load_json(const json & source) override;
136
138 virtual json save_json() const override;
139
141 virtual void clear_json() override;
142
144 virtual bibliotheque::using_set get_using_set() const override;
145
147 virtual void on_event(const std::string & event_name) override;
148
150
152 void load_from_bibliotheque(const std::string & name) { select.set_selected_id(name); };
153
155 virtual void bind_to_anchor(const std::string & val) override;
156
157
158protected:
160 virtual std::string inherited_get_body_part(const chemin & path,
161 const request & req) override;
162
164 virtual void new_css_library_available() override;
165
166private:
167 std::string anchor_to;
169 std::shared_ptr<bibliotheque> biblio;
170 std::shared_ptr<body_builder> adopted;
171 jsoner* adopted_jsoner;
172 bibliotheque_subconfig* adopted_subconfig;
173 bool ignore_events;
174 body_builder* adopted_frame;
175 bool clear_adopted;
176 bool is_sub;
177 std::string currently_locked;
178
179 html_div box;
180 html_form select_form;
181 html_form_fieldset select_fs;
182 html_form_select select;
183 html_form around_adopted;
184 html_form_fieldset around_adopted_fs;
186 html_double_button clear;
187 html_form saveas_form;
188 html_text saveas_text;
189 html_form_fieldset saveas_fs;
190 html_form_input saveas_name;
191
192 void update_selected();
193 void set_adopted();
194 void set_visibility();
195
196 void check_adopted() const { if(!adopted) throw WEBDAR_BUG; };
197
198 static constexpr const char* event_select = "select";
199 static constexpr const char* event_edit = "edit";
200 static constexpr const char* event_clear = "clear";
201 static constexpr const char* event_saveas = "saveas";
202
203 static constexpr const unsigned int format_version = 1;
204 static constexpr const char* myclass_id = "guichet";
205
206 static constexpr const char* class_id = "guichet";
207 static constexpr const char* jlabel_mode = "manual-mode"; // boolean (either categ+name or config)
208 static constexpr const char* jlabel_categ = "category"; // string: config category
209 static constexpr const char* jlabel_name = "configname"; // string: config name
210 static constexpr const char* jlabel_conf = "config"; ; // json; object configuration
211
212 static constexpr const char* css_left_margin = "guichet_left_margin";
213 static constexpr const char* css_below_margin = "guichet_below_margin";
214 static constexpr const char* css_above_margin = "guichet_above_margin";
215 static constexpr const char* css_border_left = "guichet_border_left";
216
217 static constexpr const char* fs_title_subcomp = "Matches configuration named";
218
219};
220
221
222#endif
defines bibliotheque class
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class bibliotheque_subconfig is an interface (pure virtual class)
Definition: bibliotheque_subconfig.hpp:50
std::set< coordinates > using_set
list of configs a given config depends on
Definition: bibliotheque.hpp:117
category
change event is replaced by a static method with category in argument
Definition: bibliotheque.hpp:63
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
class guichet let one fetch config from a bibliotheque, save as or setup manually for a given compone...
Definition: guichet.hpp:92
virtual void clear_json() override
inherited from jsoner (used when this object is used as subconfig of another object)
Definition: guichet.cpp:298
virtual void bind_to_anchor(const std::string &val) override
inherited from body_builder
Definition: guichet.cpp:438
void load_from_bibliotheque(const std::string &name)
load a config of given name (in the category defined by set_child)*
Definition: guichet.hpp:152
virtual bibliotheque::using_set get_using_set() const override
inherited from bibliotheque_subconfig
Definition: guichet.cpp:308
virtual void new_css_library_available() override
inherited from body_builder
Definition: guichet.cpp:458
void set_child(const std::shared_ptr< bibliotheque > &ptr, bibliotheque::category cat, const std::shared_ptr< body_builder > &to_adopt, bool add_form_around)
mandatory call to provide the object to adopt and use to display configurations
Definition: guichet.cpp:86
guichet(bool subcomponent=false)
constructor
Definition: guichet.cpp:43
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: guichet.cpp:326
virtual void load_json(const json &source) override
inherited from jsoner (used when this object is used as subconfig of another object)
Definition: guichet.cpp:192
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: guichet.cpp:450
virtual json save_json() const override
inherited from jsoner (used when this object is used as subconfig of another object)
Definition: guichet.cpp:270
class html_div is the implementation of
Definition: html_div.hpp:46
html_button equivalent with changing path to trigger the button event
Definition: html_double_button.hpp:48
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_input implements HTML input feature
Definition: html_form_input.hpp:57
void set_selected_id(const std::string &id)
set the radio buttons to the item id given in argument
Definition: html_form_radio.cpp:89
class html_form_select implements HTML input of type "select"
Definition: html_form_select.hpp:53
class html_form implements HTML form feature
Definition: html_form.hpp:51
class html_text manage text and header in html document
Definition: html_text.hpp:52
class jsoner
Definition: jsoner.hpp:73
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines jsoner class and class exception_json