1 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq-core/Macros/TablePluginMacros.h"
3 #include "otsdaq-core/TablePluginDataFormats/DesktopIconTable.h"
4 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
11 #define DESKTOP_ICONS_FILE \
12 std::string(getenv("SERVICE_DATA_PATH")) + "/OtsWizardData/iconList.dat"
15 #define COL_NAME "IconName"
16 #define COL_STATUS TableViewColumnInfo::COL_NAME_STATUS
17 #define COL_CAPTION "Caption"
18 #define COL_ALTERNATE_TEXT "AlternateText"
19 #define COL_FORCE_ONLY_ONE_INSTANCE "ForceOnlyOneInstance"
20 #define COL_REQUIRED_PERMISSION_LEVEL "RequiredPermissionLevel"
21 #define COL_IMAGE_URL "ImageURL"
22 #define COL_WINDOW_CONTENT_URL "WindowContentURL"
23 #define COL_APP_LINK "LinkToApplicationTable"
24 #define COL_PARAMETER_LINK "LinkToParameterTable"
25 #define COL_PARAMETER_KEY "windowParameterKey"
26 #define COL_PARAMETER_VALUE "windowParameterValue"
27 #define COL_FOLDER_PATH "FolderPath"
30 #define COL_APP_ID "Id"
33 DesktopIconTable::DesktopIconTable(
void) :
TableBase(
"DesktopIconTable")
36 std::system((
"rm -rf " + (std::string)DESKTOP_ICONS_FILE).c_str());
86 DesktopIconTable::~DesktopIconTable(
void) {}
96 auto childrenMap = configManager->__SELF_NODE__.getChildren();
98 activeDesktopIcons_.clear();
104 for(
auto& child : childrenMap)
106 if(!child.second.getNode(COL_STATUS).getValue<
bool>())
110 icon = &(activeDesktopIcons_.back());
112 icon->caption_ = child.second.getNode(COL_CAPTION).getValue<std::string>();
113 icon->alternateText_ =
114 child.second.getNode(COL_ALTERNATE_TEXT).getValue<std::string>();
115 icon->enforceOneWindowInstance_ =
116 child.second.getNode(COL_FORCE_ONLY_ONE_INSTANCE).getValue<
bool>();
117 icon->permissionThresholdString_ =
118 child.second.getNode(COL_REQUIRED_PERMISSION_LEVEL).getValue<std::string>();
119 icon->imageURL_ = child.second.getNode(COL_IMAGE_URL).getValue<std::string>();
120 icon->windowContentURL_ =
121 child.second.getNode(COL_WINDOW_CONTENT_URL).getValue<std::string>();
122 icon->folderPath_ = child.second.getNode(COL_FOLDER_PATH).getValue<std::string>();
124 if(icon->folderPath_ == TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
125 icon->folderPath_ =
"";
128 for(i = 0; i < icon->permissionThresholdString_.size(); ++i)
129 if(!(icon->permissionThresholdString_[i] >=
'0' &&
130 icon->permissionThresholdString_[i] <=
'9'))
138 icon->permissionThresholdString_ =
139 WebUsers::DEFAULT_USER_GROUP +
":" + icon->permissionThresholdString_;
143 icon->caption_ = removeCommas(
144 icon->caption_,
false ,
true );
145 icon->alternateText_ = removeCommas(
146 icon->alternateText_,
false ,
true );
147 icon->imageURL_ = removeCommas(icon->imageURL_,
true );
148 icon->windowContentURL_ =
149 removeCommas(icon->windowContentURL_,
true );
150 icon->folderPath_ = removeCommas(
151 icon->folderPath_,
false ,
true );
155 if(!child.second.getNode(COL_APP_LINK).isDisconnected())
159 if(icon->windowContentURL_[icon->windowContentURL_.size() - 1] !=
'=')
160 icon->windowContentURL_ +=
"?urn=";
163 child.second.getNode(COL_APP_LINK).getNode(COL_APP_ID).getValue(intVal);
164 icon->windowContentURL_ += std::to_string(intVal);
171 if(!child.second.getNode(COL_PARAMETER_LINK).isDisconnected())
175 if(icon->windowContentURL_.find(
'?') == std::string::npos)
176 icon->windowContentURL_ +=
'?';
177 else if(addedAppId ||
178 icon->windowContentURL_[icon->windowContentURL_.size() - 1] !=
180 icon->windowContentURL_ +=
'&';
183 auto paramGroupMap = child.second.getNode(COL_PARAMETER_LINK).getChildren();
184 bool notFirst =
false;
185 for(
const auto param : paramGroupMap)
188 icon->windowContentURL_ +=
'&';
191 icon->windowContentURL_ +=
192 ConfigurationManager::encodeURIComponent(
193 param.second.getNode(COL_PARAMETER_KEY).getValue<std::string>()) +
195 ConfigurationManager::encodeURIComponent(
196 param.second.getNode(COL_PARAMETER_VALUE)
197 .getValue<std::string>());
303 std::string DesktopIconTable::removeCommas(
const std::string& str,
307 std::string retStr =
"";
308 retStr.reserve(str.length());
310 for(
unsigned int i = 0; i < str.length(); ++i)
313 else if(andHexReplace)
315 else if(andHTMLReplace)