add suport to add users
This commit is contained in:
parent
021139d669
commit
03f2c31989
@ -22,7 +22,8 @@ SOURCES += \
|
|||||||
view_info.cpp \
|
view_info.cpp \
|
||||||
controller_info.cpp \
|
controller_info.cpp \
|
||||||
view_user_info.cpp \
|
view_user_info.cpp \
|
||||||
controller_user_info.cpp
|
controller_user_info.cpp \
|
||||||
|
dialog_add_user.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
conexion.h \
|
conexion.h \
|
||||||
@ -39,4 +40,5 @@ HEADERS += \
|
|||||||
view_info.h \
|
view_info.h \
|
||||||
controller_info.h \
|
controller_info.h \
|
||||||
view_user_info.h \
|
view_user_info.h \
|
||||||
controller_user_info.h
|
controller_user_info.h \
|
||||||
|
dialog_add_user.h
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.8.2, 2020-05-20T00:08:38. -->
|
<!-- Written by QtCreator 4.8.2, 2020-05-23T19:59:00. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -9,7 +9,7 @@ container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application
|
|||||||
this->cont_inst=new controller_install(&install, sesion.get());
|
this->cont_inst=new controller_install(&install, sesion.get());
|
||||||
this->cont_rem=new controller_remove(&remove, sesion.get());
|
this->cont_rem=new controller_remove(&remove, sesion.get());
|
||||||
this->cont_info=new controller_info(&info, sesion.get());
|
this->cont_info=new controller_info(&info, sesion.get());
|
||||||
this->con_uinfo=new controller_user_info(&uinfo, sesion.get());
|
this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this);
|
||||||
this->app.reset();
|
this->app.reset();
|
||||||
this->app=Gtk::Application::create( "org.gtkmm.examples.base");
|
this->app=Gtk::Application::create( "org.gtkmm.examples.base");
|
||||||
this->add(this->book);
|
this->add(this->book);
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
#include "controller_user_info.h"
|
#include "controller_user_info.h"
|
||||||
|
#include "dialog_add_user.h"
|
||||||
|
|
||||||
|
#include <gtkmm/messagedialog.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
controller_user_info::controller_user_info(view_user_info *view, session_manager *sesion)
|
controller_user_info::controller_user_info(view_user_info *view, session_manager *sesion, Gtk::Window *container)
|
||||||
{
|
{
|
||||||
this->view=view;
|
this->view=view;
|
||||||
this->sesion=sesion;
|
this->sesion=sesion;
|
||||||
|
this->container=container;
|
||||||
this->load_info();
|
this->load_info();
|
||||||
|
this->add_controlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void controller_user_info::load_info(){
|
void controller_user_info::load_info(){
|
||||||
@ -17,6 +22,26 @@ void controller_user_info::load_info(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void controller_user_info::add_controlers(){
|
||||||
|
this->view->b_add_user.signal_clicked().connect(sigc::mem_fun(this,
|
||||||
|
&controller_user_info::on_button_clicked_add));
|
||||||
|
this->view->b_dell_user.signal_clicked().connect(sigc::mem_fun(this,
|
||||||
|
&controller_user_info::on_button_clicked_remove));
|
||||||
|
}
|
||||||
|
|
||||||
|
void controller_user_info::on_button_clicked_add(){
|
||||||
|
dialog_add_user dialog(this->container, sesion);
|
||||||
|
dialog.run();
|
||||||
|
this->view->restart_table();
|
||||||
|
this->load_info();
|
||||||
|
}
|
||||||
|
|
||||||
|
void controller_user_info::on_button_clicked_remove(){
|
||||||
|
Gtk::TreeModel::Row row = *this->view->tree.get_selection()->get_selected();
|
||||||
|
//row.get_value(this->view->m_Columns.r_user);
|
||||||
|
std::cout << row.get_value(this->view->m_Columns.r_user) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
std::string controller_user_info::get_first(std::string &info){
|
std::string controller_user_info::get_first(std::string &info){
|
||||||
int pos = info.find(":");
|
int pos = info.find(":");
|
||||||
std::string ret = info.substr(0, pos);
|
std::string ret = info.substr(0, pos);
|
||||||
|
@ -7,11 +7,15 @@
|
|||||||
class controller_user_info
|
class controller_user_info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
controller_user_info(view_user_info *view, session_manager *session);
|
controller_user_info(view_user_info *view, session_manager *session, Gtk::Window *container);
|
||||||
private:
|
private:
|
||||||
view_user_info *view;
|
view_user_info *view;
|
||||||
session_manager *sesion;
|
session_manager *sesion;
|
||||||
|
Gtk::Window *container;
|
||||||
void load_info();
|
void load_info();
|
||||||
|
void add_controlers();
|
||||||
|
void on_button_clicked_add();
|
||||||
|
void on_button_clicked_remove();
|
||||||
std::string get_first(std::string &info);
|
std::string get_first(std::string &info);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
37
dialog_add_user.cpp
Normal file
37
dialog_add_user.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "dialog_add_user.h"
|
||||||
|
|
||||||
|
dialog_add_user::dialog_add_user(Gtk::Window *win, session_manager *sesion)
|
||||||
|
: Gtk::Dialog("Create user", *win, false),
|
||||||
|
box_user(Gtk::ORIENTATION_HORIZONTAL), user("user"),
|
||||||
|
box_pass(Gtk::ORIENTATION_HORIZONTAL), pass("password"),
|
||||||
|
box_admin(Gtk::ORIENTATION_HORIZONTAL), l_admin("admin permision"),
|
||||||
|
b_add("create")
|
||||||
|
{
|
||||||
|
this->sesion=sesion;
|
||||||
|
this->entry_pass.set_visibility(false);
|
||||||
|
this->b_add.signal_clicked().connect(sigc::mem_fun(this,
|
||||||
|
&dialog_add_user::on_button_clicked));
|
||||||
|
this->add_elements();
|
||||||
|
this->show_all_children();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dialog_add_user::on_button_clicked(){
|
||||||
|
this->sesion->create_user(this->entry_user.get_text(), this->entry_pass.get_text(), this->c_admin.get_active());
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dialog_add_user::add_elements(){
|
||||||
|
this->box_user.add(this->user);
|
||||||
|
this->box_user.add(this->entry_user);
|
||||||
|
|
||||||
|
this->box_pass.add(this->pass);
|
||||||
|
this->box_pass.add(this->entry_pass);
|
||||||
|
|
||||||
|
this->box_admin.add(this->l_admin);
|
||||||
|
this->box_admin.add(this->c_admin);
|
||||||
|
|
||||||
|
this->get_content_area()->add(this->box_user);
|
||||||
|
this->get_content_area()->add(this->box_pass);
|
||||||
|
this->get_content_area()->add(this->box_admin);
|
||||||
|
this->get_content_area()->add(this->b_add);
|
||||||
|
}
|
37
dialog_add_user.h
Normal file
37
dialog_add_user.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef DIALOG_ADD_USER_H
|
||||||
|
#define DIALOG_ADD_USER_H
|
||||||
|
|
||||||
|
#include <gtkmm/window.h>
|
||||||
|
#include <gtkmm/dialog.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
#include <gtkmm/entry.h>
|
||||||
|
#include <gtkmm/checkbutton.h>
|
||||||
|
|
||||||
|
#include "session_manager.h"
|
||||||
|
|
||||||
|
class dialog_add_user : public Gtk::Dialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
dialog_add_user(Gtk::Window *win, session_manager *sesion);
|
||||||
|
private:
|
||||||
|
session_manager *sesion;
|
||||||
|
|
||||||
|
Gtk::Box box_user;
|
||||||
|
Gtk::Label user;
|
||||||
|
Gtk::Entry entry_user;
|
||||||
|
|
||||||
|
Gtk::Box box_pass;
|
||||||
|
Gtk::Label pass;
|
||||||
|
Gtk::Entry entry_pass;
|
||||||
|
|
||||||
|
Gtk::Box box_admin;
|
||||||
|
Gtk::Label l_admin;
|
||||||
|
Gtk::CheckButton c_admin;
|
||||||
|
|
||||||
|
Gtk::Button b_add;
|
||||||
|
|
||||||
|
void on_button_clicked();
|
||||||
|
void add_elements();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOG_ADD_USER_H
|
@ -60,3 +60,10 @@ std::list<std::string> session_manager::get_users_info(){
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void session_manager::create_user(std::string username, std::string password, bool admin){
|
||||||
|
this->con->write_string("cusr");
|
||||||
|
this->con->write_string(username);
|
||||||
|
this->con->write_string(password);
|
||||||
|
this->con->write_string(admin?"t":"f");
|
||||||
|
}
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
int remove_command(std::string package);
|
int remove_command(std::string package);
|
||||||
std::list<std::string> get_packages_info();
|
std::list<std::string> get_packages_info();
|
||||||
std::list<std::string> get_users_info();
|
std::list<std::string> get_users_info();
|
||||||
|
void create_user(std::string username, std::string password, bool admin);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SESSION_MANAGER_H
|
#endif // SESSION_MANAGER_H
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "view_user_info.h"
|
#include "view_user_info.h"
|
||||||
|
|
||||||
view_user_info::view_user_info()
|
view_user_info::view_user_info()
|
||||||
|
:Gtk::Box(Gtk::ORIENTATION_VERTICAL),
|
||||||
|
b_add_user("add user"), b_dell_user("delete user")
|
||||||
{
|
{
|
||||||
this->m_refTreeModel = Gtk::ListStore::create(this->m_Columns);
|
this->m_refTreeModel = Gtk::ListStore::create(this->m_Columns);
|
||||||
this->tree.set_model(this->m_refTreeModel);
|
this->tree.set_model(this->m_refTreeModel);
|
||||||
@ -8,4 +10,11 @@ view_user_info::view_user_info()
|
|||||||
tree.append_column("user", m_Columns.r_user);
|
tree.append_column("user", m_Columns.r_user);
|
||||||
tree.append_column("config", m_Columns.r_admin);
|
tree.append_column("config", m_Columns.r_admin);
|
||||||
this->add(this->tree);
|
this->add(this->tree);
|
||||||
|
this->add(this->b_add_user);
|
||||||
|
this->add(this->b_dell_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
void view_user_info::restart_table(){
|
||||||
|
this->m_refTreeModel = Gtk::ListStore::create(this->m_Columns);
|
||||||
|
this->tree.set_model(this->m_refTreeModel);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,12 @@ public:
|
|||||||
Gtk::TreeModelColumn<bool> r_admin;
|
Gtk::TreeModelColumn<bool> r_admin;
|
||||||
};
|
};
|
||||||
|
|
||||||
ModelColumns m_Columns;
|
ModelColumns m_Columns;
|
||||||
Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
|
Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
|
||||||
|
Gtk::Button b_add_user;
|
||||||
|
Gtk::Button b_dell_user;
|
||||||
|
|
||||||
|
void restart_table();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIEW_USER_INFO_H
|
#endif // VIEW_USER_INFO_H
|
||||||
|
Loading…
Reference in New Issue
Block a user