1 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq-core/Macros/TablePluginMacros.h"
3 #include "otsdaq-core/TablePlugins/DesktopIconTable.h"
4 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
11 #define DESKTOP_ICONS_FILE \
12 std::string(__ENV__("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());
44 DesktopIconTable::~DesktopIconTable(
void) {}
54 auto childrenMap = configManager->__SELF_NODE__.getChildren();
56 activeDesktopIcons_.clear();
62 for(
auto& child : childrenMap)
64 if(!child.second.getNode(COL_STATUS).getValue<
bool>())
68 icon = &(activeDesktopIcons_.back());
70 icon->caption_ = child.second.getNode(COL_CAPTION).getValue<std::string>();
71 icon->alternateText_ =
72 child.second.getNode(COL_ALTERNATE_TEXT).getValue<std::string>();
73 icon->enforceOneWindowInstance_ =
74 child.second.getNode(COL_FORCE_ONLY_ONE_INSTANCE).getValue<
bool>();
75 icon->permissionThresholdString_ =
76 child.second.getNode(COL_REQUIRED_PERMISSION_LEVEL).getValue<std::string>();
77 icon->imageURL_ = child.second.getNode(COL_IMAGE_URL).getValue<std::string>();
78 icon->windowContentURL_ =
79 child.second.getNode(COL_WINDOW_CONTENT_URL).getValue<std::string>();
80 icon->folderPath_ = child.second.getNode(COL_FOLDER_PATH).getValue<std::string>();
82 if(icon->folderPath_ == TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
83 icon->folderPath_ =
"";
85 if(icon->permissionThresholdString_ ==
86 TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
87 icon->permissionThresholdString_ =
91 for(i = 0; i < icon->permissionThresholdString_.size(); ++i)
92 if(!(icon->permissionThresholdString_[i] >=
'0' &&
93 icon->permissionThresholdString_[i] <=
'9'))
101 icon->permissionThresholdString_ =
102 WebUsers::DEFAULT_USER_GROUP +
":" + icon->permissionThresholdString_;
106 icon->caption_ = removeCommas(
107 icon->caption_,
false ,
true );
108 icon->alternateText_ = removeCommas(
109 icon->alternateText_,
false ,
true );
110 icon->imageURL_ = removeCommas(icon->imageURL_,
true );
111 icon->windowContentURL_ =
112 removeCommas(icon->windowContentURL_,
true );
113 icon->folderPath_ = removeCommas(
114 icon->folderPath_,
false ,
true );
118 if(!child.second.getNode(COL_APP_LINK).isDisconnected())
122 if(icon->windowContentURL_[icon->windowContentURL_.size() - 1] !=
'=')
123 icon->windowContentURL_ +=
"?urn=";
126 child.second.getNode(COL_APP_LINK).getNode(COL_APP_ID).getValue(intVal);
127 icon->windowContentURL_ += std::to_string(intVal);
134 if(!child.second.getNode(COL_PARAMETER_LINK).isDisconnected())
138 if(icon->windowContentURL_.find(
'?') == std::string::npos)
139 icon->windowContentURL_ +=
'?';
140 else if(addedAppId ||
141 icon->windowContentURL_[icon->windowContentURL_.size() - 1] !=
143 icon->windowContentURL_ +=
'&';
146 auto paramGroupMap = child.second.getNode(COL_PARAMETER_LINK).getChildren();
147 bool notFirst =
false;
148 for(
const auto param : paramGroupMap)
151 icon->windowContentURL_ +=
'&';
154 icon->windowContentURL_ +=
155 ConfigurationManager::encodeURIComponent(
156 param.second.getNode(COL_PARAMETER_KEY).getValue<std::string>()) +
158 ConfigurationManager::encodeURIComponent(
159 param.second.getNode(COL_PARAMETER_VALUE)
160 .getValue<std::string>());
266 std::string DesktopIconTable::removeCommas(
const std::string& str,
270 std::string retStr =
"";
271 retStr.reserve(str.length());
273 for(
unsigned int i = 0; i < str.length(); ++i)
276 else if(andHexReplace)
278 else if(andHTMLReplace)