瀏覽代碼

Got advanced search to the point of being functional for the person card view.

jalbr74 6 年之前
父節點
當前提交
e4390736f9

+ 1 - 1
client/package.json

@@ -13,7 +13,7 @@
         "test": "karma start test/karma.conf.js --mode=development",
         "test": "karma start test/karma.conf.js --mode=development",
         "test-single-run": "karma start test/karma.conf.js --mode=development --singleRun --no-auto-watch",
         "test-single-run": "karma start test/karma.conf.js --mode=development --singleRun --no-auto-watch",
         "start": "webpack-dev-server --mode=development --port 4000 --history-api-fallback --colors",
         "start": "webpack-dev-server --mode=development --port 4000 --history-api-fallback --colors",
-        "sync": "webpack --mode=production --output-path=../webapp/target/pwm-1.8.0-SNAPSHOT/public/resources/webjars/pwm-client --watch --progress --colors"
+        "sync": "webpack --env.disableMinimize=true --mode=production --output-path=../webapp/target/pwm-1.8.0-SNAPSHOT/public/resources/webjars/pwm-client --watch --progress --colors"
     },
     },
     "author": "",
     "author": "",
     "license": "ISC",
     "license": "ISC",

+ 5 - 4
client/src/modules/peoplesearch/peoplesearch-base.component.ts

@@ -42,7 +42,7 @@ abstract class PeopleSearchBaseComponent {
     searchMessage: string;
     searchMessage: string;
     searchResult: SearchResult;
     searchResult: SearchResult;
     query: string;
     query: string;
-    queries = [{name: null, value: ''}];
+    queries = [{key: null, value: ''}];
     searchTextLocalStorageKey: string;
     searchTextLocalStorageKey: string;
     searchViewLocalStorageKey: string;
     searchViewLocalStorageKey: string;
 
 
@@ -98,7 +98,7 @@ abstract class PeopleSearchBaseComponent {
         this.queries.splice(tagIndex, 1);
         this.queries.splice(tagIndex, 1);
     }
     }
     addSearchTag(): void {
     addSearchTag(): void {
-        this.queries.push({name: null, value: ''});
+        this.queries.push({key: null, value: ''});
     }
     }
 
 
     selectPerson(person: IPerson): void {
     selectPerson(person: IPerson): void {
@@ -152,6 +152,7 @@ abstract class PeopleSearchBaseComponent {
 
 
     protected clearSearch(): void {
     protected clearSearch(): void {
         this.query = null;
         this.query = null;
+        this.queries = [{key: null, value: ''}];
         this.searchResult = null;
         this.searchResult = null;
         this.clearErrorMessage();
         this.clearErrorMessage();
         this.clearSearchMessage();
         this.clearSearchMessage();
@@ -168,7 +169,7 @@ abstract class PeopleSearchBaseComponent {
         this.abortPendingRequests();
         this.abortPendingRequests();
         this.searchResult = null;
         this.searchResult = null;
 
 
-        if (!this.query) {
+        if (!this.query && !this.queries) {
             this.clearSearch();
             this.clearSearch();
             return null;
             return null;
         }
         }
@@ -256,7 +257,7 @@ abstract class PeopleSearchBaseComponent {
     }
     }
 
 
     toggleAdvancedSearch(): void {
     toggleAdvancedSearch(): void {
-        this.query = '';
+        this.clearSearch();
         this.advancedSearch = !this.advancedSearch;
         this.advancedSearch = !this.advancedSearch;
     }
     }
 
 

+ 3 - 8
client/src/modules/peoplesearch/peoplesearch-cards.component.html

@@ -56,9 +56,9 @@
     </ias-button>
     </ias-button>
 </div>
 </div>
 
 
-<div ng-if="$ctrl.advancedSearch">
-    <div ng-repeat="query in $ctrl.queries">
-        <select ng-model="query.name">
+<div class="advanced-search-container" ng-if="$ctrl.advancedSearch">
+    <div class="attribute-row" ng-repeat="query in $ctrl.queries">
+        <select ng-model="query.key">
             <option value="" selected disabled>{{ 'Display_SelectAttribute' | translate }}</option>
             <option value="" selected disabled>{{ 'Display_SelectAttribute' | translate }}</option>
             <option ng-repeat="tag in $ctrl.advancedSearchTags" ng-attr-value="{{tag.attribute}}">{{tag.label}}</option>
             <option ng-repeat="tag in $ctrl.advancedSearchTags" ng-attr-value="{{tag.attribute}}">{{tag.label}}</option>
         </select>
         </select>
@@ -68,19 +68,14 @@
             <ias-icon icon="close_thin"></ias-icon>
             <ias-icon icon="close_thin"></ias-icon>
         </ias-button>
         </ias-button>
     </div>
     </div>
-
-    <br>
     <ias-button id="advanced-search-icon" class="ias-icon-button" ng-click="$ctrl.addSearchTag()"
     <ias-button id="advanced-search-icon" class="ias-icon-button" ng-click="$ctrl.addSearchTag()"
                 ng-if="$ctrl.queries.length < $ctrl.advancedSearchMaxRows"
                 ng-if="$ctrl.queries.length < $ctrl.advancedSearchMaxRows"
                 ng-attr-title="{{ 'Button_AddSearchAttribute' | translate }}">
                 ng-attr-title="{{ 'Button_AddSearchAttribute' | translate }}">
         <ias-icon icon="new_thin"></ias-icon>
         <ias-icon icon="new_thin"></ias-icon>
     </ias-button>
     </ias-button>
-
-    <br><br>
     <ias-button id="advanced-search-button" ng-click="$ctrl.initiateSearch()"
     <ias-button id="advanced-search-button" ng-click="$ctrl.initiateSearch()"
                 ng-bind="'Placeholder_Search' | translate">
                 ng-bind="'Placeholder_Search' | translate">
     </ias-button>
     </ias-button>
-
 </div>
 </div>
 
 
 <div class="search-info-container">
 <div class="search-info-container">

+ 15 - 1
client/src/modules/peoplesearch/peoplesearch-cards.component.scss

@@ -77,6 +77,20 @@ people-search-cards {
       }
       }
     }
     }
   }
   }
+
+  .advanced-search-container {
+    display: flex;
+    flex-direction: column;
+    align-items: flex-start;
+
+    > * + * {
+      margin-top: 5px;
+    }
+
+    &+ div {
+      margin-top: 15px;
+    }
+  }
 }
 }
 
 
 [dir="rtl"] {
 [dir="rtl"] {
@@ -94,4 +108,4 @@ people-search-cards {
       }
       }
     }
     }
   }
   }
-}
+}

+ 37 - 2
client/src/services/people.service.ts

@@ -29,7 +29,7 @@ import SearchResult from '../models/search-result.model';
 import {IPeopleSearchConfigService} from './peoplesearch-config.service';
 import {IPeopleSearchConfigService} from './peoplesearch-config.service';
 
 
 export interface IQuery {
 export interface IQuery {
- name: string;
+ key: string;
  value: string;
  value: string;
 }
 }
 
 
@@ -71,7 +71,41 @@ export default class PeopleService implements IPeopleService {
     }
     }
 
 
     advancedSearch(queries: IQuery[]): IPromise<SearchResult> {
     advancedSearch(queries: IQuery[]): IPromise<SearchResult> {
-        return null;
+        console.log('queries: %O', queries);
+
+        // Deferred object used for aborting requests. See promise.service.ts for more information
+        let httpTimeout = this.$q.defer();
+
+        let formID: string = encodeURIComponent('&pwmFormID=' + this.PWM_GLOBAL['pwmFormID']);
+        let url: string = this.pwmService.getServerUrl('search')
+            + '&pwmFormID=' + this.PWM_GLOBAL['pwmFormID'];
+        let request = this.$http
+            .post(url, {
+                mode: 'advanced',
+                pwmFormID: formID,
+                searchValues: queries
+            }, {
+                cache: true,
+                timeout: httpTimeout.promise,
+                headers: {'Content-Type': 'multipart/form-data'},
+            });
+
+        let promise = request.then(
+            (response) => {
+                if (response.data['error']) {
+                    return this.handlePwmError(response);
+                }
+
+                let receivedData: any = response.data['data'];
+                let searchResult: SearchResult = new SearchResult(receivedData);
+
+                return searchResult;
+            },
+            this.handleHttpError.bind(this));
+
+        promise['_httpTimeout'] = httpTimeout;
+
+        return promise;
     }
     }
 
 
     autoComplete(query: string): IPromise<IPerson[]> {
     autoComplete(query: string): IPromise<IPerson[]> {
@@ -200,6 +234,7 @@ export default class PeopleService implements IPeopleService {
             + '&pwmFormID=' + this.PWM_GLOBAL['pwmFormID'];
             + '&pwmFormID=' + this.PWM_GLOBAL['pwmFormID'];
         let request = this.$http
         let request = this.$http
             .post(url, {
             .post(url, {
+                mode: 'simple',
                 username: query,
                 username: query,
                 pwmFormID: formID
                 pwmFormID: formID
             }, {
             }, {

+ 13 - 9
client/webpack.config.js

@@ -11,6 +11,7 @@ const srcDir = path.resolve(__dirname, 'src');
 
 
 module.exports = function (env, argv) {
 module.exports = function (env, argv) {
     const isProductionMode = (argv["mode"] === "production");
     const isProductionMode = (argv["mode"] === "production");
+    const disableMinimize = (env && env.disableMinimize) || false;
 
 
     const commonConfig = {
     const commonConfig = {
         devtool: 'source-map',
         devtool: 'source-map',
@@ -100,15 +101,18 @@ module.exports = function (env, argv) {
                 'peoplesearch.ng': './src/modules/peoplesearch/main',
                 'peoplesearch.ng': './src/modules/peoplesearch/main',
                 'helpdesk.ng': './src/modules/helpdesk/main'
                 'helpdesk.ng': './src/modules/helpdesk/main'
             },
             },
-            plugins: [
-                new UglifyJsPlugin({
-                    sourceMap: true,
-                    uglifyOptions: {
-                        compress: {warnings: false},
-                        comments: false
-                    }
-                })
-            ]
+            optimization:{
+                minimize: !disableMinimize,
+                minimizer: [
+                    new UglifyJsPlugin({
+                        sourceMap: true,
+                        uglifyOptions: {
+                            compress: {warnings: false},
+                            comments: false
+                        }
+                    })
+                ]
+            }
         });
         });
     }
     }
     else {
     else {