API CHANGE

Modify the output fields for the sysadm/services, "list_services" action:
Now each service entry will look like this:
"accounting": {
        "description": "",
        "is_enabled": "false",
        "name": "accounting",
        "path": "/etc/rc.d/accounting",
        "tag": "accounting_enable"
      }

I will probably be adding an "is_running" [true/false] field here soon as well - the backend for that still needs to be written first.
This commit is contained in:
Ken Moore
2016-08-29 14:09:20 -04:00
parent 1bf0ec425f
commit 2f7bfe06aa
3 changed files with 84 additions and 1 deletions

View File

@@ -1004,11 +1004,15 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmServiceRequest(const QJsonVa
sysadm::ServiceManager SMGR;
if(action=="list_services"){
QList<sysadm::Service> list = SMGR.GetServices();
QList<bool> listEnabled = SMGR.isEnabled(list);
QJsonObject services;
for(int i=0; i<list.length(); i++){
QJsonObject S;
S.insert("name", list[i].Name);
S.insert("tag", list[i].Tag);
S.insert("path", list[i].Path);
S.insert("description", list[i].Description);
S.insert("is_enabled", listEnabled[i] ? "true" : "false" );
//S.insert("filename", list[i].Directory);
//Need to add status info as well (isRunning, isEnabled);
services.insert(list[i].Name, S);