1 #include "otsdaq-core/ConfigurationPluginDataFormats/DesktopIconConfiguration.h"
2 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
3 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
4 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
11 #define DESKTOP_ICONS_FILE std::string(getenv("SERVICE_DATA_PATH")) + "/OtsWizardData/iconList.dat"
14 #define COL_NAME "IconName"
15 #define COL_STATUS ViewColumnInfo::COL_NAME_STATUS
16 #define COL_CAPTION "Caption"
17 #define COL_ALTERNATE_TEXT "AlternateText"
18 #define COL_FORCE_ONLY_ONE_INSTANCE "ForceOnlyOneInstance"
19 #define COL_REQUIRED_PERMISSION_LEVEL "RequiredPermissionLevel"
20 #define COL_IMAGE_URL "ImageURL"
21 #define COL_WINDOW_CONTENT_URL "WindowContentURL"
22 #define COL_APP_LINK "LinkToApplicationConfiguration"
23 #define COL_PARAMETER_LINK "LinkToParameterConfiguration"
24 #define COL_PARAMETER_KEY "windowParameterKey"
25 #define COL_PARAMETER_VALUE "windowParameterValue"
26 #define COL_FOLDER_PATH "FolderPath"
29 #define COL_APP_ID "Id"
34 DesktopIconConfiguration::DesktopIconConfiguration(
void) :
38 std::system((
"rm -rf " + (std::string)DESKTOP_ICONS_FILE).c_str());
69 DesktopIconConfiguration::~DesktopIconConfiguration(
void)
81 auto childrenMap = configManager->__SELF_NODE__.getChildren();
83 activeDesktopIcons_.clear();
89 for(
auto &child:childrenMap)
91 if(!child.second.getNode(COL_STATUS ).getValue<
bool>())
continue;
94 icon = &(activeDesktopIcons_.back());
96 icon->caption_ = child.second.getNode(COL_CAPTION ).getValue<std::string>();
97 icon->alternateText_ = child.second.getNode(COL_ALTERNATE_TEXT ).getValue<std::string>();
98 icon->enforceOneWindowInstance_ = child.second.getNode(COL_FORCE_ONLY_ONE_INSTANCE ).getValue<
bool>();
99 icon->permissionThresholdString_ = child.second.getNode(COL_REQUIRED_PERMISSION_LEVEL).getValue<std::string>();
100 icon->imageURL_ = child.second.getNode(COL_IMAGE_URL ).getValue<std::string>();
101 icon->windowContentURL_ = child.second.getNode(COL_WINDOW_CONTENT_URL ).getValue<std::string>();
102 icon->folderPath_ = child.second.getNode(COL_FOLDER_PATH ).getValue<std::string>();
104 if(icon->folderPath_ == ViewColumnInfo::DATATYPE_STRING_DEFAULT) icon->folderPath_ =
"";
107 for(i=0;i<icon->permissionThresholdString_.size();++i)
108 if(!(icon->permissionThresholdString_[i] >=
'0' &&
109 icon->permissionThresholdString_[i] <=
'9'))
117 icon->permissionThresholdString_ = WebUsers::DEFAULT_USER_GROUP +
":" + icon->permissionThresholdString_;
120 icon->caption_ = removeCommas(icon->caption_,
false ,
true );
121 icon->alternateText_ = removeCommas(icon->alternateText_,
false ,
true );
122 icon->imageURL_ = removeCommas(icon->imageURL_,
true );
123 icon->windowContentURL_ = removeCommas(icon->windowContentURL_,
true );
124 icon->folderPath_ = removeCommas(icon->folderPath_,
false ,
true );
128 if(!child.second.getNode(COL_APP_LINK ).isDisconnected())
132 if(icon->windowContentURL_[icon->windowContentURL_.size()-1] !=
'=')
133 icon->windowContentURL_ +=
"?urn=";
136 child.second.getNode(COL_APP_LINK ).getNode(COL_APP_ID ).getValue(intVal);
137 icon->windowContentURL_ += std::to_string(intVal);
144 if(!child.second.getNode(COL_PARAMETER_LINK ).isDisconnected())
148 if(icon->windowContentURL_.find(
'?') == std::string::npos)
149 icon->windowContentURL_ +=
'?';
150 else if(addedAppId ||
151 icon->windowContentURL_[icon->windowContentURL_.size()-1] !=
'?')
152 icon->windowContentURL_ +=
'&';
155 auto paramGroupMap = child.second.getNode(COL_PARAMETER_LINK ).getChildren();
156 bool notFirst =
false;
157 for(
const auto param:paramGroupMap)
160 icon->windowContentURL_ +=
'&';
163 icon->windowContentURL_ += ConfigurationManager::encodeURIComponent(
164 param.second.getNode(COL_PARAMETER_KEY).getValue<std::string>()) +
165 "=" + ConfigurationManager::encodeURIComponent(
166 param.second.getNode(COL_PARAMETER_VALUE).getValue<std::string>());
268 std::string DesktopIconConfiguration::removeCommas(
const std::string &str,
269 bool andHexReplace,
bool andHTMLReplace)
271 std::string retStr =
"";
272 retStr.reserve(str.length());
274 for(
unsigned int i=0;i<str.length();++i)
277 else if(andHexReplace)
279 else if(andHTMLReplace)