Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / raptor / popup_semaphore.jsp
1 <%--
2   ================================================================================
3   eCOMP Portal SDK
4   ================================================================================
5   Copyright (C) 2017 AT&T Intellectual Property
6   ================================================================================
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10   
11        http://www.apache.org/licenses/LICENSE-2.0
12   
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18   ================================================================================
19   --%>
20 <%@ page import="java.util.*" %>
21
22 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.*" %>
23 <%@ page import="org.openecomp.portalsdk.analytics.model.base.*" %>
24 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.*" %>
25 <%@ page import="org.openecomp.portalsdk.analytics.system.*" %>
26 <%@ page import="org.openecomp.portalsdk.analytics.util.*" %>
27
28 <%      ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); 
29         
30         String semaphoreId = AppUtils.getRequestNvlValue(request, "semaphoreId");
31         String semaphoreType = AppUtils.getRequestNvlValue(request, "semaphoreType");   
32         SemaphoreType semaphore = rdef.getSemaphoreById(semaphoreId);
33         String semaphoreName = null;
34         List listColumns = rdef.getAllColumns();
35         if(semaphore!=null)
36                 semaphoreName = semaphore.getSemaphoreName();
37         else
38                 if(rdef.getSemaphoreList()!=null)
39                         semaphoreName = "Display Formatting "+(rdef.getSemaphoreList().getSemaphore().size()+1);
40                 else
41                         semaphoreName = "Display Formatting 1"; 
42         
43         String submitBtn = AppUtils.getRequestNvlValue(request, "submit_btn"); %>
44
45 <html>
46 <head>
47         <title>Advanced Display Formatting</title>
48         <link rel="stylesheet" type="text/css" href="<%= AppUtils.getBaseFolderURL() %>css/raptor.css">
49         
50 <% if(submitBtn.startsWith("Save")) { %>
51 <script language=JavaScript>
52 <!--
53         function updateOpenerList() {   // Returns the position of the current semaphore in the list
54                 return window.opener.updateSemaphoreList("<%= semaphoreId %>", "<%= semaphoreName %>");
55         }       // updateOpenerList
56         
57         function saveAndClose() {
58                 var idx = 0;
59                 idx = updateOpenerList();
60                 window.opener.document.forma.semaphore.selectedIndex = idx;
61                 window.opener.document.forma.semaphoreTypeHidden.value='<%=semaphoreType%>';
62                 window.close();
63         }       // saveAndClose
64 //-->
65 </script>
66 <% } %>
67         
68 <% if(submitBtn.equals("Save")) { %>
69 </head>
70 <body onLoad="saveAndClose()">
71         <b class=rerrortext>Please wait...</b>
72 <% } else { %>
73
74 <script language=JavaScript>
75 <!--
76         function setBold(iCount) {
77                 var flag = document.dataform.boldChk[iCount].checked;
78                 document.dataform.bold[iCount].value = (flag?"Y":"N");
79                 document.getElementById("preview"+iCount).style.fontWeight = (flag?"bold":"normal");
80         }   // setBold
81         
82         function setItalic(iCount) {
83                 var flag = document.dataform.italicChk[iCount].checked;
84                 document.dataform.italic[iCount].value = (flag?"Y":"N");
85                 document.getElementById("preview"+iCount).style.fontStyle = (flag?"italic":"normal");
86         }   // setItalic
87         
88         function setUnderline(iCount) {
89                 var flag = document.dataform.underlineChk[iCount].checked;
90                 document.dataform.underline[iCount].value = (flag?"Y":"N");
91                 document.getElementById("preview"+iCount).style.textDecorationUnderline = flag;
92         }   // setUnderline
93         
94         function setBgColor(iCount) {
95                 var value = document.dataform.bgColor[iCount].options[document.dataform.bgColor[iCount].selectedIndex].value;
96                 document.getElementById("preview"+iCount).style.backgroundColor = value;
97         }   // setBgColor
98         
99         function setFontColor(iCount) {
100                 var value = document.dataform.fontColor[iCount].options[document.dataform.fontColor[iCount].selectedIndex].value;
101                 document.getElementById("preview"+iCount).style.color = value;
102         }   // setFontColor
103         
104         function setFontFace(iCount) {
105                 var value = document.dataform.fontFace[iCount].options[document.dataform.fontFace[iCount].selectedIndex].value;
106                 document.getElementById("preview"+iCount).style.fontFamily = value;
107         }   // setFontFace
108         
109         function setFontSize(iCount) {
110                 var value = document.dataform.fontSize[iCount].options[document.dataform.fontSize[iCount].selectedIndex].value;
111                 document.getElementById("preview"+iCount).style.fontSize = value+"px";
112         }   // setFontSize
113         
114 /*      function setAlignment(iCount) {
115                 var value = document.dataform.alignment[iCount].options[document.dataform.alignment[iCount].selectedIndex].value;
116                 document.getElementById("preview"+iCount).style.textAlign = value;
117         }   // setAlignment
118 */      
119         var semaphoreIds   = new Array(<%= 2+((rdef.getSemaphoreList()==null)?0:rdef.getSemaphoreList().getSemaphore().size()) %>);
120         var semaphoreNames = new Array(<%= 2+((rdef.getSemaphoreList()==null)?0:rdef.getSemaphoreList().getSemaphore().size()) %>);
121         <%      int iCount = 0;
122                 if(rdef.getSemaphoreList()!=null)
123                         for(Iterator iter=rdef.getSemaphoreList().getSemaphore().iterator(); iter.hasNext(); iCount++) {
124                                 SemaphoreType sem = (SemaphoreType) iter.next(); %>
125         semaphoreIds[<%= iCount %>]   = "<%= sem.getSemaphoreId() %>";
126         semaphoreNames[<%= iCount %>] = "<%= sem.getSemaphoreName() %>";
127         <%              }       // for 
128         %>
129         semaphoreIds[<%= iCount %>]     = "-";
130         semaphoreNames[<%= iCount++ %>] = "-";
131         semaphoreIds[<%= iCount %>]     = "-";
132         semaphoreNames[<%= iCount++ %>] = "-";
133         
134         function dataValidate() {
135                 if(document.dataform.semaphoreName.value=="") {
136                         alert("Please enter Display Name");
137                         document.forma.semaphoreName.focus();
138                         document.forma.semaphoreName.select();
139                         
140                         return false;
141                 }       // if
142                 
143                 for(var i=0; i<semaphoreIds.length; i++)
144                         if((document.dataform.semaphoreName.value==semaphoreNames[i])&&(semaphoreIds[i]!="<%= semaphoreId %>")) {
145                                 alert("Advanced Formatting with that name already exists.\nPlease select another name");
146                                 document.dataform.semaphoreName.focus();
147                                 document.dataform.semaphoreName.select();
148                                 
149                                 return false;
150                         }   // if
151                 
152                 for(var i=0; i<document.dataform.lessThanValue.length; i++)
153                         for(var j=i+1; j<document.dataform.lessThanValue.length; j++)
154                                 if(     document.dataform.lessThanValue[i].value!=""&&
155                                         document.dataform.lessThanValue[j].value!=""&&
156                                         document.dataform.lessThanValue[i].value==document.dataform.lessThanValue[j].value) {
157                                         alert("You cannot have duplicate values in the list.\nPlease change one of the values ["+document.dataform.lessThanValue[j].value+"]");
158                                         document.dataform.lessThanValue[j].focus();
159                                         document.dataform.lessThanValue[j].select();
160                                         
161                                         return false;
162                                 }   // if
163                 
164                 return true;
165         }       // dataValidate
166         
167         function doInit() {
168         <% if(submitBtn.startsWith("Save")) { %>
169                 updateOpenerList();
170         <% } %>
171                 
172 <%      for(int i = 0; i<3+((semaphore==null)?2:semaphore.getFormatList().getFormat().size()); i++) { 
173                 FormatType ft = null;
174                 if(semaphore!=null&&i<semaphore.getFormatList().getFormat().size())
175                         ft = (FormatType) semaphore.getFormatList().getFormat().get(i);
176                 if(ft!=null) { %>
177                 setBold(<%= i %>);
178                 setItalic(<%= i %>);
179                 setUnderline(<%= i %>);
180                 setBgColor(<%= i %>);
181                 setFontColor(<%= i %>);
182                 setFontFace(<%= i %>);
183                 setFontSize(<%= i %>);
184                 //setAlignment(<%= i %>);
185         <%      }       // if
186         }       // for 
187 %>
188         }   // doInit
189 //-->
190 </script>
191
192 </head>
193 <body onLoad="doInit()">
194
195 <form name="dataform" action="<%= AppUtils.getBaseURL() %>" method="post" onSubmit="return dataValidate()">
196         <input type="hidden" name="action" value="raptor">
197         <input type="hidden" name="<%= AppConstants.RI_ACTION %>" value="report.popup.semaphore.save">
198
199 <table class="mTAB" width=94% border=0 cellspacing=1 align=center>
200         <tr class=rbg1>
201                 <td valign="middle" colspan="10" height="24"><b class=rtableheader>&nbsp;Advanced Display Formatting Definition</b></td>
202         </tr>
203         <tr>
204                 <td class=rbg2 colspan="4" align="right" height="30" style="background-image:url(<%= AppUtils.getImgFolderURL() %>required.gif); background-position:top right; background-repeat:no-repeat;"><font class=rtabletext>Display Name: </font></td> 
205                 <td class=rbg3 colspan="6" align="left"><font class=rtabletext>
206                         <input type="hidden" name="semaphoreId" value="<%= semaphoreId %>">
207                         <input type="text" size="30" maxlength="30" name="semaphoreName" value="<%= semaphoreName %>"></font></td>
208         </tr>
209         <tr>
210                 <td class=rbg2 colspan="4" align="right" height="30"><font class=rtabletext>Apply Formatting To: </font></td> 
211                 <td class=rbg3 colspan="6" align="left"><font class=rtabletext>
212                         <%      String sValue = AppConstants.ST_CELL; 
213                                 if(semaphore!=null)
214                                         sValue = nvl(semaphore.getSemaphoreType(), AppConstants.ST_CELL); %>
215                         <select name="semaphoreType">
216                           <%
217                                 for (Iterator iterC = listColumns.iterator(); iterC.hasNext();) {
218                                         DataColumnType dc = (DataColumnType) iterC.next();
219                                         if(dc.isVisible()) {
220                           %>
221                              <option value="<%= AppConstants.ST_CELL+"|"+dc.getColId() %>"<%= sValue.equals(AppConstants.ST_CELL+"|"+dc.getColId() )?" selected":"" %>><%=dc.getColName() %>
222                           <%                    
223                                     }
224                         }
225                           %>
226                                 <option value="<%= AppConstants.ST_CELL %>"<%= sValue.equals(AppConstants.ST_CELL)?" selected":"" %>>Current Value Only
227                                 <option value="<%= AppConstants.ST_ROW %>"<%=  sValue.equals(AppConstants.ST_ROW) ?" selected":"" %>>The Entire Row
228                         </select></font></td>
229         </tr>
230         <tr>
231                 <td colspan="10">&nbsp;</td>
232         </tr>
233         <tr class=rbg1>
234                 <td align="center" valign="middle" colspan=2 height="30"><b class=rtableheader>Column Value Is</b></td>
235                 <td align="center" valign="middle"><b class=rtableheader>Bold?</b></td>
236                 <td align="center" valign="middle"><b class=rtableheader>Italic?</b></td>
237                 <td align="center" valign="middle"><b class=rtableheader>Under-<br>line?</b></td>
238                 <td align="center" valign="middle"><b class=rtableheader>Background Color</b></td>
239                 <td align="center" valign="middle"><b class=rtableheader>Font Color</b></td>
240                 <td align="center" valign="middle"><b class=rtableheader>Font Face</b></td>
241                 <td align="center" valign="middle"><b class=rtableheader>Font Size</b></td>
242                 <!--td align="center" valign="middle"><b class=rtableheader>Alignment</b></td-->
243                 <td align="center" valign="middle"><b class=rtableheader>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Preview&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
244         </tr>
245 <%      for(int i = 0; i<3+((semaphore==null)?2:semaphore.getFormatList().getFormat().size()); i++) { 
246                 FormatType ft = null;
247                 if(semaphore!=null&&i<semaphore.getFormatList().getFormat().size())
248                         ft = (FormatType) semaphore.getFormatList().getFormat().get(i); %>
249         <tr<%= (i%2==0)?" class=rowalt1":" class=rowalt2" %>>
250                 <% if(i==0) { %>
251                 <td align="center" valign="middle" colspan=2 height="30">
252                         <font class=rtabletext>Any Other</font>
253                         <input type="hidden" name="formatId" value="<%= (ft==null)?"":ft.getFormatId() %>">
254                         <input type="hidden" name="expression" value="">
255                         <input type="hidden" name="lessThanValue" value="">
256                         <!-- <input type="hidden" name="anyFmt" value="Y"> -->
257                 </td>
258                 <% } else { %>
259                 <!-- <input type="hidden" name="anyFmt" value="N"> -->
260                 <td align="center" valign="middle" height="30">
261                         <input type="hidden" name="formatId" value="<%= (ft==null)?"":ft.getFormatId() %>">
262                         <%      sValue = "="; 
263                                 if(ft!=null)
264                                         sValue = nvl(ft.getExpression(), "="); %>
265                         <select name="expression">
266                                 <option value="="<%=        sValue.equals("=") ?" selected":"" %>>=
267                                 <option value="&lt;&gt;"<%= sValue.equals("<>")?" selected":"" %>>&lt;&gt;
268                                 <option value="&gt;"<%=     sValue.equals(">") ?" selected":"" %>>&gt;
269                                 <option value="&gt;="<%=    sValue.equals(">=")?" selected":"" %>>&gt;=
270                                 <option value="&lt;"<%=     sValue.equals("<") ?" selected":"" %>>&lt;
271                                 <option value="&lt;="<%=    sValue.equals("<=")?" selected":"" %>>&lt;=
272                         </select>
273                 </td>
274                 <td align="center" valign="middle">
275                         <input type="text" size="10" name="lessThanValue" value="<%= (ft==null)?"":ft.getLessThanValue() %>">
276                 </td>
277                 <% } %>
278                 <td align="center" valign="middle">
279                         <%      boolean bValue = false; 
280                                 if(ft!=null)
281                                         bValue = ft.isBold(); %>
282                         <input type="hidden" name="bold" value="<%= bValue?"Y":"N" %>">
283                         <input type="checkbox" name="boldChk" value="Y"<%= bValue?" checked":"" %> onClick="setBold(<%= i %>)">
284                 </td>
285                 <td align="center" valign="middle">
286                         <%      bValue = false; 
287                                 if(ft!=null)
288                                         bValue = ft.isItalic(); %>
289                         <input type="hidden" name="italic" value="<%= bValue?"Y":"N" %>">
290                         <input type="checkbox" name="italicChk" value="Y"<%= bValue?" checked":"" %> onClick="setItalic(<%= i %>)">
291                 </td>
292                 <td align="center" valign="middle">
293                         <%      bValue = false; 
294                                 if(ft!=null)
295                                         bValue = ft.isUnderline(); %>
296                         <input type="hidden" name="underline" value="<%= bValue?"Y":"N" %>">
297                         <input type="checkbox" name="underlineChk" value="Y"<%= bValue?" checked":"" %> onClick="setUnderline(<%= i %>)">
298                 </td>
299                 <td align="center" valign="middle">
300                         <%      sValue = ""; 
301                                 if(ft!=null)
302                                         sValue = nvl(ft.getBgColor()); %>
303                         <select name="bgColor" onChange="setBgColor(<%= i %>)">
304                                 <option value=""<%=        sValue.equals("")       ?" selected":"" %>>
305                                 <option value="#00FFFF"<%= sValue.equals("#00FFFF")?" selected":"" %>>Aqua
306                                 <option value="#000000"<%= sValue.equals("#000000")?" selected":"" %>>Black
307                                 <option value="#0000FF"<%= sValue.equals("#0000FF")?" selected":"" %>>Blue
308                                 <option value="#FF00FF"<%= sValue.equals("#FF00FF")?" selected":"" %>>Fuchsia
309                                 <option value="#808080"<%= sValue.equals("#808080")?" selected":"" %>>Gray
310                                 <option value="#008000"<%= sValue.equals("#008000")?" selected":"" %>>Green
311                                 <option value="#00FF00"<%= sValue.equals("#00FF00")?" selected":"" %>>Lime
312                                 <option value="#800000"<%= sValue.equals("#800000")?" selected":"" %>>Maroon
313                                 <option value="#000080"<%= sValue.equals("#000080")?" selected":"" %>>Navy
314                                 <option value="#808000"<%= sValue.equals("#808000")?" selected":"" %>>Olive
315                                 <option value="#FF9900"<%= sValue.equals("#FF9900")?" selected":"" %>>Orange
316                                 <option value="#800080"<%= sValue.equals("#800080")?" selected":"" %>>Purple
317                                 <option value="#FF0000"<%= sValue.equals("#FF0000")?" selected":"" %>>Red
318                                 <option value="#C0C0C0"<%= sValue.equals("#C0C0C0")?" selected":"" %>>Silver
319                                 <option value="#008080"<%= sValue.equals("#008080")?" selected":"" %>>Teal
320                                 <option value="#FFFFFF"<%= sValue.equals("#FFFFFF")?" selected":"" %>>White
321                                 <option value="#FFFF00"<%= sValue.equals("#FFFF00")?" selected":"" %>>Yellow
322                         </select>
323                 </td>
324                 <td align="center" valign="middle">
325                         <%      sValue = ""; 
326                                 if(ft!=null)
327                                         sValue = nvl(ft.getFontColor()); %>
328                         <select name="fontColor" onChange="setFontColor(<%= i %>)">
329                                 <option value=""<%=        sValue.equals("")       ?" selected":"" %>>
330                                 <option value="#00FFFF"<%= sValue.equals("#00FFFF")?" selected":"" %>>Aqua
331                                 <option value="#000000"<%= sValue.equals("#000000")?" selected":"" %>>Black
332                                 <option value="#0000FF"<%= sValue.equals("#0000FF")?" selected":"" %>>Blue
333                                 <option value="#FF00FF"<%= sValue.equals("#FF00FF")?" selected":"" %>>Fuchsia
334                                 <option value="#808080"<%= sValue.equals("#808080")?" selected":"" %>>Gray
335                                 <option value="#008000"<%= sValue.equals("#008000")?" selected":"" %>>Green
336                                 <option value="#00FF00"<%= sValue.equals("#00FF00")?" selected":"" %>>Lime
337                                 <option value="#800000"<%= sValue.equals("#800000")?" selected":"" %>>Maroon
338                                 <option value="#000080"<%= sValue.equals("#000080")?" selected":"" %>>Navy
339                                 <option value="#808000"<%= sValue.equals("#808000")?" selected":"" %>>Olive
340                                 <option value="#FF9900"<%= sValue.equals("#FF9900")?" selected":"" %>>Orange
341                                 <option value="#800080"<%= sValue.equals("#800080")?" selected":"" %>>Purple
342                                 <option value="#FF0000"<%= sValue.equals("#FF0000")?" selected":"" %>>Red
343                                 <option value="#C0C0C0"<%= sValue.equals("#C0C0C0")?" selected":"" %>>Silver
344                                 <option value="#008080"<%= sValue.equals("#008080")?" selected":"" %>>Teal
345                                 <option value="#FFFFFF"<%= sValue.equals("#FFFFFF")?" selected":"" %>>White
346                                 <option value="#FFFF00"<%= sValue.equals("#FFFF00")?" selected":"" %>>Yellow
347                         </select>
348                 </td>
349                 <td align="center" valign="middle">
350                         <%      sValue = ""; 
351                                 if(ft!=null)
352                                         sValue = nvl(ft.getFontFace()); %>
353                         <select name="fontFace" onChange="setFontFace(<%= i %>)">
354                                 <option value=""<%=                                    sValue.equals("")                                   ?" selected":"" %>>--- Default ---
355                                 <option value="Arial,Helvetica,sans-serif"<%=          sValue.equals("Arial,Helvetica,sans-serif")         ?" selected":"" %>>Arial
356                                 <option value="Courier New,Courier,mono"<%=            sValue.equals("Courier New,Courier,mono")           ?" selected":"" %>>Courier New
357                                 <option value="Geneva,Arial,Helvetica,sans-serif"<%=   sValue.equals("Geneva,Arial,Helvetica,sans-serif")  ?" selected":"" %>>Geneva
358                                 <option value="Georgia,Times New Roman,Times,serif"<%= sValue.equals("Georgia,Times New Roman,Times,serif")?" selected":"" %>>Georgia
359                                 <option value="Times New Roman,Times,serif"<%=         sValue.equals("Times New Roman,Times,serif")        ?" selected":"" %>>Times New Roman
360                                 <option value="Verdana,Arial,Helvetica,sans-serif"<%=  sValue.equals("Verdana,Arial,Helvetica,sans-serif") ?" selected":"" %>>Verdana
361                         </select>
362                 </td>
363                 <td align="center" valign="middle">
364                         <%      sValue = "11"; 
365                                 if(ft!=null)
366                                         sValue = nvl(ft.getFontSize(), "11"); %>
367                         <select name="fontSize" onChange="setFontSize(<%= i %>)">
368                                 <option value="6"<%=  sValue.equals("6") ?" selected":"" %>>6
369                                 <option value="8"<%=  sValue.equals("8") ?" selected":"" %>>8
370                                 <option value="9"<%=  sValue.equals("9") ?" selected":"" %>>9
371                                 <option value="10"<%= sValue.equals("10")?" selected":"" %>>10
372                                 <option value="11"<%= sValue.equals("11")?" selected":"" %>>11
373                                 <option value="12"<%= sValue.equals("12")?" selected":"" %>>12
374                                 <option value="14"<%= sValue.equals("14")?" selected":"" %>>14
375                                 <option value="16"<%= sValue.equals("16")?" selected":"" %>>16
376                                 <option value="18"<%= sValue.equals("18")?" selected":"" %>>18
377                                 <option value="24"<%= sValue.equals("24")?" selected":"" %>>24
378                                 <option value="36"<%= sValue.equals("36")?" selected":"" %>>36
379                                 <option value="48"<%= sValue.equals("48")?" selected":"" %>>48
380                                 <option value="72"<%= sValue.equals("72")?" selected":"" %>>72
381                         </select>
382                 </td>
383                 <!--td align="center" valign="middle">
384                         < %     sValue = "left"; 
385                                 if(ft!=null)
386                                         sValue = nvl(ft.getAlignment(), "left"); % >
387                         <select name="alignment" onChange="setAlignment(< %= i % >)">
388                                 <option value="left"  < %= sValue.equals("left")  ?" selected":"" % >>Left
389                                 <option value="center"< %= sValue.equals("center")?" selected":"" % >>Center
390                                 <option value="right" < %= sValue.equals("right") ?" selected":"" % >>Right
391                         </select>
392                 </td-->
393                 <td valign="middle">
394                         <span id="preview<%= i %>" style="font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#000000;width:100">Sample</span>
395                 </td>
396         </tr>
397 <%      }       // for 
398 %>
399         <tr>
400                 <td colspan="10" align="center">
401                         <br>
402                         <input type="Submit" class=button name="submit_btn" value="Save">
403                         <input type="Submit" class=button name="submit_btn" value="Save & More Rows">
404                         <input type="Button" class=button value="Cancel" onClick="window.close();">
405                 </td>
406         </tr>
407 </table>
408
409 </form>
410
411 <% }    // if(submitBtn.equals("Save")) { ... } else { 
412 %>
413
414 </body>
415 </html>
416
417 <%!     private String nvl(String s)                  { return (s==null)?"":s; }
418         private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } %>
419