Remoto - VFS: admin.cpp Source File
Remoto - VFS
admin.cpp
Go to the documentation of this file.
1 
2 #include "VFS.h"
3 #include "VFS_icons.h"
4 #include "utilities/rutils.h"
6 
7 #include "admin.h"
8 #include "cpuUsage.h"
9 #include "sessionsList.h"
10 #include "aclEditor.h"
11 #include "logView.h"
12 
25 admin::admin(QString authPaths, QString sessionsPath, QString browserURL)
27 {
28  append("CPU", new cpuUsage() );
29  append("Sessions", new sessionsList(authPaths,sessionsPath));
30  append("ACL Editor", new aclEditor());
31  append("Logs", new logView());
32 
33  if (!browserURL.isEmpty())
34  append("Browser", new VFS_iframe(browserURL, VFS_icons::get("gear")));
35 }
36 
38 {
39 }
40 
46 QByteArray admin::icon()
47 {
48  //return "data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><g id=\"vfs\"><path d=\"M3,25.95a1,1,0,0,1-.55-1.84l6.16-4A1,1,0,0,1,9.48,20l5.38,2.11,2.51-9.21A1,1,0,0,1,19,12.47l6.29,6.15L28.68,4.87a1,1,0,1,1,1.94.47L26.85,20.8a1,1,0,0,1-1.67.48l-6.33-6.19L16.5,23.73a1,1,0,0,1-.52.63,1,1,0,0,1-.81,0L9.23,22.07,3.51,25.79A1,1,0,0,1,3,25.95Z\"/><circle fill=\"rgb(27,186,217)\" class=\"iconColor\" cx=\"18.38\" cy=\"13.71\" r=\"1.66\" transform=\"translate(-4.31 17.01) rotate(-45)\"/><circle fill=\"rgb(27,186,217)\" class=\"iconColor\" cx=\"29.65\" cy=\"5.11\" r=\"1.66\" transform=\"translate(5.08 22.46) rotate(-45)\"/><circle fill=\"rgb(27,186,217)\" class=\"iconColor\" cx=\"25.96\" cy=\"20.23\" r=\"1.66\" transform=\"translate(-6.7 24.29) rotate(-45)\"/><circle fill=\"rgb(27,186,217)\" class=\"iconColor\" cx=\"15.78\" cy=\"23.52\" r=\"1.66\" transform=\"translate(-12.01 18.05) rotate(-45)\"/><circle fill=\"rgb(27,186,217)\" class=\"iconColor\" cx=\"2.6\" cy=\"24.95\" r=\"1.66\" transform=\"translate(-16.88 9.14) rotate(-45)\"/><circle fill=\"rgb(27,186,217)\" class=\"iconColor\" cx=\"9.09\" cy=\"21.3\" r=\"1.66\" transform=\"translate(-12.4 12.67) rotate(-45)\"/></g></svg>";
49  //return "data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 268.765 268.765\"><path d=\"M267.92 119.461c-.425-3.778-4.83-6.617-8.639-6.617-12.315 0-23.243-7.231-27.826-18.414-4.682-11.454-1.663-24.812 7.515-33.231a7.463 7.463 0 0 0 .817-10.133 132.977 132.977 0 0 0-21.289-21.5c-3.063-2.458-7.557-2.116-10.213.825-8.01 8.871-22.398 12.168-33.516 7.529-11.57-4.867-18.866-16.591-18.152-29.176a7.455 7.455 0 0 0-6.595-7.849 134.163 134.163 0 0 0-30.232-.08 7.478 7.478 0 0 0-6.654 7.689c.438 12.461-6.946 23.98-18.401 28.672-10.985 4.487-25.272 1.218-33.266-7.574-2.642-2.896-7.063-3.252-10.141-.853a133.478 133.478 0 0 0-21.74 21.493c-2.481 3.086-2.116 7.559.802 10.214 9.353 8.47 12.373 21.944 7.514 33.53-4.639 11.046-16.109 18.165-29.24 18.165-4.261-.137-7.296 2.723-7.762 6.597a134.618 134.618 0 0 0-.058 30.561c.422 3.794 4.961 6.608 8.812 6.608 11.702-.299 22.937 6.946 27.65 18.415 4.698 11.454 1.678 24.804-7.514 33.23a7.469 7.469 0 0 0-.817 10.126 133.459 133.459 0 0 0 21.259 21.508c3.079 2.481 7.559 2.131 10.228-.81 8.04-8.893 22.427-12.184 33.501-7.536 11.599 4.852 18.895 16.575 18.181 29.167a7.464 7.464 0 0 0 6.595 7.85 133.572 133.572 0 0 0 30.233.081 7.479 7.479 0 0 0 6.653-7.696c-.451-12.454 6.946-23.973 18.386-28.657 11.059-4.517 25.286-1.211 33.281 7.572a7.51 7.51 0 0 0 10.142.848 133.787 133.787 0 0 0 21.74-21.494 7.461 7.461 0 0 0-.803-10.213c-9.353-8.47-12.388-21.946-7.529-33.524 4.568-10.899 15.612-18.217 27.491-18.217l1.662.043c3.853.313 7.398-2.655 7.865-6.588a134.504 134.504 0 0 0 .06-30.561zm-133.325 60.03c-24.718 0-44.824-20.106-44.824-44.824 0-24.717 20.106-44.824 44.824-44.824 24.717 0 44.823 20.107 44.823 44.824 0 24.718-20.106 44.824-44.823 44.824z\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>";
50  return VFS_icons::get("gear");
51 }
52 
59 {
60  VFS_node::read(r);
61 }
62 
69 {
70  if (r->_path == "")
71  {
72  QJsonObject a;
73  a["type"] = "openLayout";
74 
75  r->_metadata["icon"] = QString(icon());
76  r->_metadata["action"] = a;
77 
78  QJsonObject l = rutils::jsonResource(":/admin/templates/adminLayout.json");
79  l["icon"] = "@icon@";
80  QJsonObject t;
81  t["openLayout"] = l;
82 
83  r->_metadata["template"] = t;
84  r->_metadata["where"] = "nearest";
85  r->_success = true;
86  return;
87  }
88 
90 }
91 
93 {
94  QJsonObject acl;
95 
96  addACLDefault( acl, true, "Access to the VFS admin tools.\n\nIt is recommended to turn the default to off once admin groups have been added." );
97  addACLGroup( acl, "developer", true );
98  addACLGroup( acl, "admin", true );
99 
100  r->_data.setObject(acl);
101  r->_success = true;
102 }
A common base class for all things that want to act like an application or include ACL support.
static char * get(QString which="")
Fetch an icon from the library.
Definition: VFS_icons.cpp:34
VFS_iframe is a button for opening an iframe in a panel.
Definition: VFS_iframe.h:9
virtual VFS_node * append(QString name, VFS_node *node, bool containerCheck=true, QString user="server")
Append a VFS_node as a child of this node.
Definition: VFS_node.cpp:1566
virtual void read(VFS_request *r)
Return the data contents of this node, or if it's a container call ls()
Definition: VFS_node.cpp:724
void addACLGroup(QJsonObject &acl, QString group, bool value)
Add a group to the acl object.
Definition: VFS_node.cpp:2148
virtual void metadata(VFS_request *r)
Fetch the metadata of this node.
Definition: VFS_node.cpp:797
void addACLDefault(QJsonObject &acl, bool value, QString description="")
Add a default value to the acl object.
Definition: VFS_node.cpp:2131
The base class for all requests between nodes.
Definition: VFS_node.h:54
QString _path
the target path remnant... the remaining path element once the request has found its target
Definition: VFS_node.h:95
bool _success
if the request was successfully completed
Definition: VFS_node.h:107
QJsonDocument _data
the request payload
Definition: VFS_node.h:102
QJsonObject _metadata
the request payload
Definition: VFS_node.h:101
An editor for ACL files.
Definition: aclEditor.h:7
virtual ~admin()
Definition: admin.cpp:37
virtual void aclDefaults(VFS_request *r)
Return default values and features associated wth this node.
Definition: admin.cpp:92
Q_INVOKABLE admin(QString authPaths, QString sessions, QString browserURL="")
admin constructor
Definition: admin.cpp:25
virtual void read(VFS_request *r)
Read the list of admin modules.
Definition: admin.cpp:58
virtual void metadata(VFS_request *r)
Return metadata about this node.
Definition: admin.cpp:68
virtual QByteArray icon()
Return the icon.
Definition: admin.cpp:46
A VFS_application plugin for reporting CPU and RAM usage over time.
Definition: cpuUsage.h:13
The logView node is a VFS_application plugin for viewing logs.
Definition: logView.h:8
A VFS_application plugin for reporting current and registered.
Definition: sessionsList.h:8
QJsonObject jsonResource(QString resource, bool *ok=nullptr)
Fetch the contents of a Qt resource as a QJsonObject.
Definition: rutils.cpp:90