1 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq/Macros/TablePluginMacros.h"
3 #include "otsdaq/TablePlugins/DesktopIconTable.h"
5 #include "otsdaq/WebUsersUtilities/WebUsers.h"
12 #define DESKTOP_ICONS_FILE \
13 std::string(__ENV__("SERVICE_DATA_PATH")) + "/OtsWizardData/iconList.dat"
17 const std::string DesktopIconTable::COL_NAME =
"IconName";
18 const std::string DesktopIconTable::COL_STATUS = TableViewColumnInfo::COL_NAME_STATUS;
19 const std::string DesktopIconTable::COL_CAPTION =
"Caption";
20 const std::string DesktopIconTable::COL_ALTERNATE_TEXT =
"AlternateText";
21 const std::string DesktopIconTable::COL_FORCE_ONLY_ONE_INSTANCE =
"ForceOnlyOneInstance";
22 const std::string DesktopIconTable::COL_PERMISSIONS =
"RequiredPermissionLevel";
23 const std::string DesktopIconTable::COL_IMAGE_URL =
"ImageURL";
24 const std::string DesktopIconTable::COL_WINDOW_CONTENT_URL =
"WindowContentURL";
25 const std::string DesktopIconTable::COL_APP_LINK =
"LinkToApplicationTable";
26 const std::string DesktopIconTable::COL_APP_LINK_UID =
"LinkToApplicationUID";
28 const std::string DesktopIconTable::COL_PARAMETER_LINK =
"LinkToParameterTable";
29 const std::string DesktopIconTable::COL_PARAMETER_LINK_GID =
"LinkToParameterGroupID";
30 const std::string DesktopIconTable::COL_FOLDER_PATH =
"FolderPath";
32 const std::string DesktopIconTable::COL_PARAMETER_GID =
"windowParameterGroupID";
33 const std::string DesktopIconTable::COL_PARAMETER_KEY =
"windowParameterKey";
34 const std::string DesktopIconTable::COL_PARAMETER_VALUE =
"windowParameterValue";
36 const std::string DesktopIconTable::ICON_TABLE =
"DesktopIconTable";
37 const std::string DesktopIconTable::PARAMETER_TABLE =
"DesktopWindowParameterTable";
54 const std::string DesktopIconTable::COL_APP_ID =
"Id";
61 std::system((
"rm -rf " + (std::string)DESKTOP_ICONS_FILE).c_str());
69 DesktopIconTable::~DesktopIconTable(
void) {}
79 auto childrenMap = configManager->__SELF_NODE__.getChildren();
81 activeDesktopIcons_.clear();
87 for(
auto& child : childrenMap)
89 if(!child.second.getNode(COL_STATUS).getValue<
bool>())
93 icon = &(activeDesktopIcons_.back());
95 icon->caption_ = child.second.getNode(COL_CAPTION).getValue<std::string>();
96 icon->alternateText_ =
97 child.second.getNode(COL_ALTERNATE_TEXT).getValue<std::string>();
98 icon->enforceOneWindowInstance_ =
99 child.second.getNode(COL_FORCE_ONLY_ONE_INSTANCE).getValue<
bool>();
100 icon->permissionThresholdString_ =
101 child.second.getNode(COL_PERMISSIONS).getValue<std::string>();
102 icon->imageURL_ = child.second.getNode(COL_IMAGE_URL).getValue<std::string>();
103 icon->windowContentURL_ =
104 child.second.getNode(COL_WINDOW_CONTENT_URL).getValue<std::string>();
105 icon->folderPath_ = child.second.getNode(COL_FOLDER_PATH).getValue<std::string>();
107 if(icon->folderPath_ == TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
108 icon->folderPath_ =
"";
110 if(icon->permissionThresholdString_ ==
111 TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
112 icon->permissionThresholdString_ =
116 for(i = 0; i < icon->permissionThresholdString_.size(); ++i)
117 if(!(icon->permissionThresholdString_[i] >=
'0' &&
118 icon->permissionThresholdString_[i] <=
'9'))
126 icon->permissionThresholdString_ =
127 WebUsers::DEFAULT_USER_GROUP +
":" + icon->permissionThresholdString_;
131 icon->caption_ = removeCommas(
132 icon->caption_,
false ,
true );
133 icon->alternateText_ = removeCommas(
134 icon->alternateText_,
false ,
true );
135 icon->imageURL_ = removeCommas(icon->imageURL_,
true );
136 icon->windowContentURL_ =
137 removeCommas(icon->windowContentURL_,
true );
138 icon->folderPath_ = removeCommas(
139 icon->folderPath_,
false ,
true );
143 if(!child.second.getNode(COL_APP_LINK).isDisconnected())
147 if(icon->windowContentURL_[icon->windowContentURL_.size() - 1] !=
'=')
148 icon->windowContentURL_ +=
"?urn=";
151 child.second.getNode(COL_APP_LINK).getNode(COL_APP_ID).getValue(intVal);
152 icon->windowContentURL_ += std::to_string(intVal);
159 if(!child.second.getNode(COL_PARAMETER_LINK).isDisconnected())
163 if(icon->windowContentURL_.find(
'?') == std::string::npos)
164 icon->windowContentURL_ +=
'?';
165 else if(addedAppId ||
166 icon->windowContentURL_[icon->windowContentURL_.size() - 1] !=
168 icon->windowContentURL_ +=
'&';
171 auto paramGroupMap = child.second.getNode(COL_PARAMETER_LINK).getChildren();
172 bool notFirst =
false;
173 for(
const auto param : paramGroupMap)
175 if(!param.second.isEnabled())
179 icon->windowContentURL_ +=
'&';
182 icon->windowContentURL_ +=
183 StringMacros::encodeURIComponent(
184 param.second.getNode(COL_PARAMETER_KEY).getValue<std::string>()) +
186 StringMacros::encodeURIComponent(
187 param.second.getNode(COL_PARAMETER_VALUE)
188 .getValue<std::string>());
294 std::string DesktopIconTable::removeCommas(
const std::string& str,
298 std::string retStr =
"";
299 retStr.reserve(str.length());
301 for(
unsigned int i = 0; i < str.length(); ++i)
304 else if(andHexReplace)
306 else if(andHTMLReplace)