Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / jsp / post_search.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 <%@ page import="com.fasterxml.jackson.databind.ObjectMapper" %>
22 <%@ page import="org.json.JSONObject" %>
23 <%@ taglib prefix="c"      uri="http://java.sun.com/jsp/jstl/core" %>
24 <%@ taglib prefix="fmt"    uri="http://java.sun.com/jsp/jstl/fmt" %>
25 <%@ taglib prefix="fn"     uri="http://java.sun.com/jsp/jstl/functions" %>
26 <%@ include file="/WEB-INF/fusion/jsp/popup_modal.html" %>
27 <%@ include file="/WEB-INF/fusion/jsp/popup_modal_rolefunction.html" %>
28 <%@ include file="/WEB-INF/fusion/jsp/popup_modal_role.html" %>
29 <link rel="stylesheet" type="text/css" href="static/fusion/css/jquery-ui.css">
30
31 <div ng-controller="postSearchController" >
32
33 <h1 class="heading1" style="margin-top:20px;">WEBPHONE Search</h1>
34       <br>
35                 Please enter search criteria below:<br/>
36
37             <div class="fn-ebz-container">
38                   Last Name:<br/>
39                   <input class="fn-ebz-text" type="text"   ng-model="postSearchBean.lastName" value="" size="25">
40             </div>
41           
42             <div class="fn-ebz-container">
43                   First Name:<br/>
44                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.firstName" value="" size="25">
45             </div>
46          
47             <div class="fn-ebz-container">
48                   UserId:<br/>
49                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.orgUserId" value="" size="25">
50             </div>
51            
52             <div class="fn-ebz-container">
53                   Manager OrgUserId:<br/>
54                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.orgManagerUserId" value="" size="25">
55             </div>
56            <br>
57             <div class="fn-ebz-container">
58                   Organization:<br/>
59                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.orgCode" value="" size="25">
60             </div>
61            
62             <div class="fn-ebz-container">
63                   Email:<br/>
64                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.email" value="" size="25">
65             </div>
66      <br>
67 <!--      Sort By: <br/>
68                 <div class="fn-ebz-container" >
69        
70                 <div class="fn-ebz-container">  
71                         <div class="form-field" att-select="sortByList" ng-model="postSearchBean.sortBy1"></div>
72                 </div>
73         </div>
74         
75        
76         
77
78             <div class="fn-ebz-container" >
79            <br/>
80             &nbsp;
81
82                 <div class="fn-ebz-container">  
83                         <div class="form-field" att-select="sortByList" ng-model="postSearchBean.sortBy2"></div>
84                 </div>
85        </div>
86         
87
88             <div class="fn-ebz-container" >
89             <br/> &nbsp;
90
91                 <div class="fn-ebz-container">  
92                         <div class="form-field" att-select="sortByList" ng-model="postSearchBean.sortBy3"></div>
93                 </div>
94         </div> -->
95                 <div>
96                         <input att-button btn-type="primary" size="small" class="button" type="submit" value="Search" ng-click="search(postSearchBean);" />
97                 
98                      <input att-button btn-type="primary" size="small" class="button" type="submit" value="Reset"  ng-click="reset();"/>
99                 </div>
100                 <br>
101                 {{noResultsString}}
102       <div ng-if="profileList.length != 0">
103             <table att-table table-data="profileList" view-per-page="viewPerPage" current-page="currentPage" search-category="searchCategory" search-string="searchString" total-page="totalPage">
104                   <thead att-table-row type="header" >
105                     <tr>
106                         <th att-table-header  width="5%" align="left">No</th>
107                         <th att-table-header  width="30%" key="lastName" align="left">Name</th>
108                         <th att-table-header  width="5%"  key="orgUserId" align="left">OrgUserId</th>
109                         <th att-table-header  width="10%" key="orgCode" align="left">Organization</th>
110                         <th att-table-header  width="20%" align="left">Phone</th>
111                         <th att-table-header  width="20%" key="email" align="left">Email</th>
112                         <th att-table-header  width="10%" align="left">Import?</th>
113                         </tr>
114                   </thead>
115                 
116             <tbody att-table-row type="body" row-repeat="profile in profileList" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->  
117               <tr >
118                 <td att-table-body width="5%" align="left">
119                 {{$index + 1}}
120                 </td>
121                 <td att-table-body width="30%" align="left">                    
122                       <div ng-if="ngexistingUsers[profile.orgUserId] == null">
123                           {{profile.lastName}},&nbsp;{{profile.firstName}}
124                   </div>
125                       <div ng-if="ngexistingUsers[profile.orgUserId] != null">
126                       <a href="profile.htm?profile_id={{ngexistingUsers[profile.orgUserId]}}" alt="View/Edit Profile">
127                           {{profile.lastName}},&nbsp;{{profile.firstName}}
128                           </a>
129                    </div>
130                
131                 </td>
132                 <td att-table-body width="5%" align="left">
133                 {{profile.orgUserId}}
134                 </td>
135                 <td att-table-body width="10%" align="left">
136                 {{profile.orgCode}}
137                 </td>
138                 <td att-table-body width="20%" align="left">
139                 {{profile.phone}}
140                 </td>
141                 <td att-table-body width="20%" align="left">
142                 {{profile.email}}
143                 </td>
144                 
145                 <td att-table-body width="10%" align="left">
146                             <div ng-if="ngexistingUsers[profile.orgUserId] == null">
147                                 <div ng-click="toggleSelection(profile);">
148                                 <input name="selected" type="checkbox" ng-model="profile.selected" att-checkbox/>
149                                 </div>
150                              </div>
151                              <div ng-if="ngexistingUsers[profile.orgUserId] != null">
152                                 Exists
153                              </div>
154                 </td>
155               </tr>
156               </tbody>
157             </table>
158             <div class="fn-ebz-container">
159                   Rows Per Page:
160                   <input class="fn-ebz-text" type="text" ng-model="viewPerPage" size="5" style="width: 47px;">
161         </div>
162                 <div class="fn-ebz-container">
163                   Current Page:
164                   <input class="fn-ebz-text" type="text" ng-model="currentPage" size="5" style="width: 47px;">
165         </div>
166         <div class="fn-ebz-container">
167                   Total Page(s):
168                   <input class="fn-ebz-text" type="text" ng-model="totalPage" size="5" readonly="true" style="width: 47px;">
169         </div>
170                 
171         <div ng-if="profileList.length != 0">
172           <input att-button btn-type="primary" size="small" class="button" type="submit" value="Import" ng-click="process();"/>
173         </div>
174
175       </div>
176
177
178
179
180 </div>
181 <script>
182         app.controller('postSearchController', function ($scope,modalService){ 
183
184                 $scope.viewPerPage = 200;
185                 $scope.currentPage = 1;
186                 $scope.totalPage;
187                 $scope.searchCategory = "";
188                 $scope.searchString = "";
189                 
190                 $scope.noResultsString = "";
191                 
192                 $scope.postSearchBean=${postSearchBean};
193                 $scope.profileList=${profileList};
194                 //console.log($scope.postSearchBean);
195                 
196                 $scope.ngexistingUsers=${existingUsers};
197                 console.log($scope.ngexistingUsers);
198                 
199                 $scope.ocisortByList=${sortByList};
200                 $scope.sortByList = [];
201                 if($scope.ocisortByList)
202                 $.each($scope.ocisortByList, function(i, a){ 
203                         var sortBy = {"index":i, "value":a.value, "title":a.label};
204                     $scope.sortByList.push(sortBy);
205                 });     
206                 ;
207         
208                 $scope.search = function(postSearchBean) {
209                                 console.log(postSearchBean);
210                                 var uuu = "post_search/search";
211                                   var postData={postSearchBean:postSearchBean};
212                                   $.ajax({
213                                          type : 'POST',
214                                          url : uuu,
215                                          dataType: 'json',
216                                          contentType: 'application/json',
217                                          data: JSON.stringify(postData),
218                                          success : function(data){
219                                                 $scope.$apply(function(){
220                                                         $scope.profileList=data.postSearchBean.searchResult;
221                                                         //$scope.postSearchBean={};
222                                                         console.log($scope.profileList);
223                                                         if($scope.profileList.length == 0)
224                                                                 $scope.noResultsString = "There is currently no one in WEBPHONE matching your search criteria.";
225                                                         else
226                                                                 $scope.noResultsString = "";
227                                                         });  
228                                          },
229                                          error : function(data){
230                                                  console.log(data);
231                                                  modalService.showFailure("Fail","Error while searching: "+ data.responseText);
232                                          }
233                                   });
234                         
235                 };
236                 
237                 $scope.reset = function() {
238                                 $scope.postSearchBean={};
239                                 $scope.profileList=[];
240                                 $scope.noResultsString = "";
241                                 //console.log($scope.postSearchBean);
242                 };
243                 
244                 $scope.process = function() {
245                         $scope.prepareProfileSelection();
246                         var uuu = "post_search/process";
247                           var postData={postSearchBean:$scope.postSearchBean};
248                           $.ajax({
249                                  type : 'POST',
250                                  url : uuu,
251                                  dataType: 'json',
252                                  contentType: 'application/json',
253                                  data: JSON.stringify(postData),
254                                  success : function(data){
255                                         $scope.$apply(function(){
256                                                 $scope.profileList=data.postSearchBean.searchResult;
257                                                 //$scope.postSearchBean={};
258                                                 $scope.ngexistingUsers=data.existingUsers;
259                                                 $scope.postSearchBean.selected=null;                                            
260                                                 });  
261                                  },
262                                  error : function(data){
263                                          console.log(data);
264                                          modalService.showFailure("Fail","Error while searching: "+ data.responseText);
265                                  }
266                           });
267                 
268         };
269         $scope.importProfileList=[];
270         $scope.toggleSelection = function(profile) {
271                 if(profile.selected)
272                         $scope.importProfileList.push(profile);
273                 else{                   
274                         var index = $scope.importProfileList.indexOf(profile);
275                         if(index>=0)
276                                 $scope.importProfileList.splice(index, 1);
277                 }
278         };
279         
280         $scope.prepareProfileSelection = function() {
281                 if($scope.importProfileList)
282                         $.each($scope.importProfileList, function(i, profile){ 
283                             $scope.preparePostSearchBean(profile);
284                         });     
285                         ;
286         }
287         
288         $scope.preparePostSearchBean = function(profile) {
289                 //console.log('Importing: '+profile.orgUserId);
290                 //console.log('ngexistinguser:'+$scope.ngexistingUsers[profile.orgUserId])
291                 if($scope.postSearchBean.selected==null){
292                         $scope.postSearchBean.selected=[];
293                         $scope.postSearchBean.postOrgUserId=[];
294                         $scope.postSearchBean.postHrid=[];
295                         $scope.postSearchBean.postFirstName=[];
296                         $scope.postSearchBean.postLastName=[];
297                         $scope.postSearchBean.postOrgCode=[];
298                         $scope.postSearchBean.postPhone=[];
299                         $scope.postSearchBean.postEmail=[];
300                         $scope.postSearchBean.postAddress1=[];
301                         $scope.postSearchBean.postAddress2=[];
302                         $scope.postSearchBean.postCity=[];
303                         $scope.postSearchBean.postState=[];
304                         $scope.postSearchBean.postZipCode=[];
305                         $scope.postSearchBean.postLocationClli=[];
306                         $scope.postSearchBean.postBusinessCountryCode=[];
307                         $scope.postSearchBean.postBusinessCountryName=[];
308                         $scope.postSearchBean.postDepartment=[];
309                         $scope.postSearchBean.postDepartmentName=[];
310                         $scope.postSearchBean.postBusinessUnit=[];
311                         $scope.postSearchBean.postBusinessUnitName=[];
312                         $scope.postSearchBean.postJobTitle=[];
313                         $scope.postSearchBean.postOrgManagerUserId=[];
314                         $scope.postSearchBean.postCommandChain=[];
315                         $scope.postSearchBean.postCompanyCode=[];
316                         $scope.postSearchBean.postCompany=[];
317                         $scope.postSearchBean.postCostCenter=[];
318                         $scope.postSearchBean.postSiloStatus=[];
319                         $scope.postSearchBean.postFinancialLocCode=[];
320                 }
321                         
322                 $scope.postSearchBean.selected.push(profile.orgUserId); 
323                 $scope.postSearchBean.postOrgUserId.push(profile.orgUserId);
324                 $scope.postSearchBean.postHrid.push(profile.hrid);
325                 $scope.postSearchBean.postFirstName.push(profile.firstName);
326                 $scope.postSearchBean.postLastName.push(profile.lastName);
327                 $scope.postSearchBean.postOrgCode.push(profile.orgCode);
328                 $scope.postSearchBean.postPhone.push(profile.phone);
329                 $scope.postSearchBean.postEmail.push(profile.email);
330                 $scope.postSearchBean.postAddress1.push(profile.address1);
331                 $scope.postSearchBean.postAddress2.push(profile.address2);
332                 $scope.postSearchBean.postCity.push(profile.city);
333                 $scope.postSearchBean.postState.push(profile.state);
334                 if(profile.zipCodeSuffix==null)
335                         $scope.postSearchBean.postZipCode.push(profile.zipCode);
336                 else
337                         $scope.postSearchBean.postZipCode.push(profile.zipCode+'-'+profile.zipCodeSuffix);
338                 $scope.postSearchBean.postLocationClli.push(profile.locationClli);
339                 $scope.postSearchBean.postBusinessCountryCode.push(profile.businessCountryCode);
340                 $scope.postSearchBean.postBusinessCountryName.push(profile.businessCountryName);
341                 $scope.postSearchBean.postDepartment.push(profile.department);
342                 $scope.postSearchBean.postDepartmentName.push(profile.departmentName);
343                 $scope.postSearchBean.postBusinessUnit.push(profile.businessUnit);
344                 $scope.postSearchBean.postBusinessUnitName.push(profile.businessUnitName);
345                 $scope.postSearchBean.postJobTitle.push(profile.jobTitle);
346                 $scope.postSearchBean.postOrgManagerUserId.push(profile.orgManagerUserId);
347                 $scope.postSearchBean.postCommandChain.push(profile.commandChain);
348                 $scope.postSearchBean.postCompanyCode.push(profile.companyCode);
349                 $scope.postSearchBean.postCompany.push(profile.company);
350                 $scope.postSearchBean.postCostCenter.push(profile.costCenter);
351                 $scope.postSearchBean.postSiloStatus.push(profile.siloStatus);
352                 $scope.postSearchBean.postFinancialLocCode.push(profile.financialLocCode);
353         };
354                 
355         });     
356 </script>