Add the filter option in results page 09/49609/3
authorthuva4 <tharma.thuva@gmail.com>
Sat, 30 Dec 2017 03:59:03 +0000 (09:29 +0530)
committerthuva4 <tharma.thuva@gmail.com>
Sat, 30 Dec 2017 04:05:22 +0000 (09:35 +0530)
apply multiple filter in results page.
Add e2e tests for results page.

Change-Id: Ia55407d921136756ab5f15507c92775f95a761dc
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js [new file with mode: 0644]
testapi/opnfv_testapi/ui/Gruntfile.js
testapi/opnfv_testapi/ui/components/results/results.html
testapi/opnfv_testapi/ui/components/results/resultsController.js

diff --git a/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js
new file mode 100644 (file)
index 0000000..a14f8ea
--- /dev/null
@@ -0,0 +1,363 @@
+'use strict';
+
+var mock = require('protractor-http-mock');
+var baseURL = "http://localhost:8000/"
+
+describe('testing the result page for anonymous user', function () {
+    beforeEach(function(){
+        mock([
+            {
+                request: {
+                    path: '/api/v1/results',
+                    method: 'GET',
+                    queryString: {
+                        page: '1'
+                    }
+                },
+                response: {
+                    data: {
+                        "pagination": {
+                            "current_page": 1,
+                            "total_pages": 1
+                        },
+                        "results": [
+                            {
+                                "project_name": "testproject",
+                                "description": "Demo results",
+                                "stop_date": "2017-12-28 16:08:43",
+                                "case_name": "testcase",
+                                "build_tag": null,
+                                "user": null,
+                                "installer": "fuel",
+                                "scenario": "test-scenario",
+                                "trust_indicator": null,
+                                "public": "true",
+                                "version": "euphrates",
+                                "details": "",
+                                "criteria": "PASS",
+                                "_id": "5a45170bbb2092000e2643f4",
+                                "start_date": "2017-12-28 14:44:27",
+                                "pod_name": "testPod"
+                            }
+                        ]
+                    }
+                }
+            },
+            {
+                request: {
+                    path: '/api/v1/results',
+                    method: 'GET',
+                    queryString: {
+                        page: '1',
+                        project: 'testproject'
+                      }
+                },
+                response: {
+                    data: {
+                        "pagination": {
+                            "current_page": 1,
+                            "total_pages": 1
+                        },
+                        "results": [
+                            {
+                                "project_name": "testproject",
+                                "description": "Demo results",
+                                "stop_date": "2017-12-28 16:08:43",
+                                "case_name": "testcase",
+                                "build_tag": null,
+                                "user": null,
+                                "installer": "fuel",
+                                "scenario": "test-scenario",
+                                "trust_indicator": null,
+                                "public": "true",
+                                "version": "euphrates",
+                                "details": "",
+                                "criteria": "PASS",
+                                "_id": "5a45170bbb2092000e2643f5",
+                                "start_date": "2017-12-28 14:44:27",
+                                "pod_name": "testPod"
+                            }
+                        ]
+                    }
+                }
+            },
+            {
+                request: {
+                    path: '/api/v1/results',
+                    method: 'GET',
+                    queryString: {
+                        page: '1',
+                        project: 'testproject',
+                        case: 'testcase'
+                      }
+                },
+                response: {
+                    data: {
+                        "pagination": {
+                            "current_page": 1,
+                            "total_pages": 1
+                        },
+                        "results": [
+                            {
+                                "project_name": "testproject",
+                                "description": "Demo results",
+                                "stop_date": "2017-12-28 16:08:43",
+                                "case_name": "testcase",
+                                "build_tag": null,
+                                "user": null,
+                                "installer": "fuel",
+                                "scenario": "test-scenario",
+                                "trust_indicator": null,
+                                "public": "true",
+                                "version": "euphrates",
+                                "details": "",
+                                "criteria": "PASS",
+                                "_id": "5a45170bbb2092000e2643f6",
+                                "start_date": "2017-12-28 14:44:27",
+                                "pod_name": "testPod"
+                            }
+                        ]
+                    }
+                }
+            }
+        ]);
+    });
+
+    afterEach(function(){
+        mock.teardown();
+    });
+
+    it( 'should show the results page for anonymous user', function() {
+        browser.get(baseURL+"#/results");
+        expect(element(by.cssContainingText(".ng-binding.ng-scope","Test Results")).isDisplayed()).toBe(true);
+    });
+
+    it( 'navigate anonymous user to testCase page', function() {
+        browser.get(baseURL);
+        var resultLink = element(by.linkText('Results')).click();
+        var EC = browser.ExpectedConditions;
+        browser.wait(EC.urlContains(baseURL+ '#/results'), 10000);
+    });
+
+    it('Should show the results in results page for anonymous user ', function () {
+        browser.get(baseURL+"#/results");
+        var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+        var cells = row.all(by.tagName('td'));
+        expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f4");
+    });
+
+    it('Should show the results in results page related to the filters for anonymous user ', function () {
+        browser.get(baseURL+"#/results");
+        var filter = element(by.model('ctrl.filter'));
+        var filterText = element(by.model('ctrl.filterText'));
+        filter.sendKeys('project');
+        filterText.sendKeys('testproject');
+        var buttonFilter = element(by.buttonText('Filter'));
+        buttonFilter.click();
+        var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+        var cells = row.all(by.tagName('td'));
+        expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f5");
+        filter.sendKeys('case');
+        filterText.sendKeys('testcase')
+        buttonFilter.click();
+        expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f6");
+    });
+    it('Should not show the results in results page related to the filters for anonymous user ', function () {
+        browser.get(baseURL+"#/results");
+        var filter = element(by.model('ctrl.filter'));
+        var filterText = element(by.model('ctrl.filterText'));
+        filter.sendKeys('project');
+        filterText.sendKeys('testproject1');
+        var buttonFilter = element(by.buttonText('Filter'));
+        buttonFilter.click();
+        expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope'))
+            .isDisplayed()).toBe(true);
+    });
+
+});
+
+describe('testing the result page for user', function () {
+    beforeEach(function(){
+        mock([
+            {
+                request: {
+                path: '/api/v1/profile',
+                method: 'GET'
+                },
+                response: {
+                    data: {
+                        "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+                        "user": "testUser", "groups": ["opnfv-testapi-users"],
+                        "email": "testuser@test.com"
+                    }
+                }
+            },
+            {
+                request: {
+                    path: '/api/v1/results',
+                    method: 'GET',
+                    queryString: {
+                        page: '1'
+                    }
+                },
+                response: {
+                    data: {
+                        "pagination": {
+                            "current_page": 1,
+                            "total_pages": 1
+                        },
+                        "results": [
+                            {
+                                "project_name": "testproject",
+                                "description": "Demo results",
+                                "stop_date": "2017-12-28 16:08:43",
+                                "case_name": "testcase",
+                                "build_tag": null,
+                                "user": null,
+                                "installer": "fuel",
+                                "scenario": "test-scenario",
+                                "trust_indicator": null,
+                                "public": "true",
+                                "version": "euphrates",
+                                "details": "",
+                                "criteria": "PASS",
+                                "_id": "5a45170bbb2092000e2643f4",
+                                "start_date": "2017-12-28 14:44:27",
+                                "pod_name": "testPod"
+                            }
+                        ]
+                    }
+                }
+            },
+            {
+                request: {
+                    path: '/api/v1/results',
+                    method: 'GET',
+                    queryString: {
+                        page: '1',
+                        project: 'testproject'
+                      }
+                },
+                response: {
+                    data: {
+                        "pagination": {
+                            "current_page": 1,
+                            "total_pages": 1
+                        },
+                        "results": [
+                            {
+                                "project_name": "testproject",
+                                "description": "Demo results",
+                                "stop_date": "2017-12-28 16:08:43",
+                                "case_name": "testcase",
+                                "build_tag": null,
+                                "user": null,
+                                "installer": "fuel",
+                                "scenario": "test-scenario",
+                                "trust_indicator": null,
+                                "public": "true",
+                                "version": "euphrates",
+                                "details": "",
+                                "criteria": "PASS",
+                                "_id": "5a45170bbb2092000e2643f5",
+                                "start_date": "2017-12-28 14:44:27",
+                                "pod_name": "testPod"
+                            }
+                        ]
+                    }
+                }
+            },
+            {
+                request: {
+                    path: '/api/v1/results',
+                    method: 'GET',
+                    queryString: {
+                        page: '1',
+                        project: 'testproject',
+                        case: 'testcase'
+                      }
+                },
+                response: {
+                    data: {
+                        "pagination": {
+                            "current_page": 1,
+                            "total_pages": 1
+                        },
+                        "results": [
+                            {
+                                "project_name": "testproject",
+                                "description": "Demo results",
+                                "stop_date": "2017-12-28 16:08:43",
+                                "case_name": "testcase",
+                                "build_tag": null,
+                                "user": null,
+                                "installer": "fuel",
+                                "scenario": "test-scenario",
+                                "trust_indicator": null,
+                                "public": "true",
+                                "version": "euphrates",
+                                "details": "",
+                                "criteria": "PASS",
+                                "_id": "5a45170bbb2092000e2643f6",
+                                "start_date": "2017-12-28 14:44:27",
+                                "pod_name": "testPod"
+                            }
+                        ]
+                    }
+                }
+            }
+        ]);
+    });
+
+    afterEach(function(){
+        mock.teardown();
+    });
+
+    it( 'should show the results page for user', function() {
+        browser.get(baseURL+"#/results");
+        expect(element(by.cssContainingText(".ng-binding.ng-scope","Test Results")).isDisplayed()).toBe(true);
+    });
+
+    it( 'navigate user to testCase page', function() {
+        browser.get(baseURL);
+        var resultLink = element(by.linkText('Results')).click();
+        var EC = browser.ExpectedConditions;
+        browser.wait(EC.urlContains(baseURL+ '#/results'), 10000);
+    });
+
+    it('Should show the results in results page for user ', function () {
+        browser.get(baseURL+"#/results");
+        var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+        var cells = row.all(by.tagName('td'));
+        expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f4");
+    });
+
+    it('Should show the results in results page related to the filters for user ', function () {
+        browser.get(baseURL+"#/results");
+        var filter = element(by.model('ctrl.filter'));
+        var filterText = element(by.model('ctrl.filterText'));
+        filter.sendKeys('project');
+        filterText.sendKeys('testproject');
+        var buttonFilter = element(by.buttonText('Filter'));
+        buttonFilter.click();
+        var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+        var cells = row.all(by.tagName('td'));
+        expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f5");
+        filter.sendKeys('case');
+        filterText.sendKeys('testcase')
+        buttonFilter.click();
+        expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f6");
+    });
+    it('Should not show the results in results page related to the filters for user ', function () {
+        browser.get(baseURL+"#/results");
+        var filter = element(by.model('ctrl.filter'));
+        var filterText = element(by.model('ctrl.filterText'));
+        filter.sendKeys('project');
+        filterText.sendKeys('testproject1');
+        var buttonFilter = element(by.buttonText('Filter'));
+        buttonFilter.click();
+        expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope'))
+            .isDisplayed()).toBe(true);
+    });
+
+});
\ No newline at end of file
index 56aaa6e..72a47e1 100644 (file)
 
 module.exports = function (grunt) {
-       require('load-grunt-tasks')(grunt);
-       require('grunt-protractor-coverage')(grunt);
-       grunt.loadNpmTasks('grunt-shell-spawn');
-       grunt.loadNpmTasks('grunt-wait');
-       grunt.loadNpmTasks('grunt-contrib-copy');
-       grunt.loadNpmTasks('grunt-contrib-connect');
-       grunt.initConfig({
-               connect: {
-                       server: {
-                               options: {
-                                       port: 8000,
-                                       base: './',
-                                       middleware: function(connect, options, middlewares) {
-                                               middlewares.unshift(function(req, res, next) {
-                                                       if (req.method.toUpperCase() == 'POST' || req.method.toUpperCase() == "PUT" ||
-                                                               req.method.toUpperCase() == "DELETE")
-                                                               {
-                                                                       req.method='GET';
-                                                               }
-                                                       return next();
-                                               });
-                                               return middlewares;
-                                       }
-                               }
-                       }
-               },
-               copy: {
-                       assets: {
-                         expand: true,
-                         cwd: '../../3rd_party/static/testapi-ui/assets',
-                         src: '**',
-                         dest: 'testapi-ui/assets',
-                       },
-                       components: {
-                               expand: true,
-                               cwd: 'components',
-                               src: '**',
-                               dest: 'testapi-ui/components',
-                       },
-                       shared: {
-                               expand: true,
-                               cwd: 'shared',
-                               src: '**',
-                               dest: 'testapi-ui/shared',
-                       },
-                       filesPng: {
-                               expand: true,
-                               src: '*.png',
-                               dest: 'testapi-ui/',
-                       },
-                       filesIco: {
-                               expand: true,
-                               src: '*.ico',
-                               dest: 'testapi-ui/',
-                       },
-                       filesJs: {
-                               expand: true,
-                               src: 'app.js',
-                               dest: 'testapi-ui/',
-                       },
-                       filesJson: {
-                               expand: true,
-                               src: 'config.json',
-                               dest: 'testapi-ui/',
-                       }
-               },
-               wait: {
-                       default: {
-                               options: {
-                                       delay: 3000
-                               }
-                       }
-               },
-               shell: {
-                       updateSelenium: {
-                               command: 'node_modules/protractor/bin/webdriver-manager update',
-                               options: {
-                               async: false
-                       }
-                       },
-                       startSelenium: {
-                               command: 'node_modules/protractor/bin/webdriver-manager start',
-                               options: {
-                             async: true
-                           }
-                       },
-                       deleteFiles: {
-                               command: 'rm -r testapi-ui',
-                               options: {
-                             async: false
-                           }
-                       },
-                       options: {
-                       stdout: false,
-                       stderr: false
-                   }
-               },
-               instrument: {
-               files: ['components/**/*.js'],
-               options: {
-                       lazy: false,
-                               basePath: "./testapi-ui/"
-               }
-           },
-               karma: {
-                       unit: {
-                               configFile: 'karma.conf.js'
-                       }
-               },
-               protractor_coverage: {
-                   options: {
-                       keepAlive: true,
-                       noColor: false,
-                       coverageDir: '../tests/UI/coverage',
-                       args: {
-                                       specs: ['../tests/UI/e2e/testCasesControllerSpec.js']
-                       }
-                   },
-                   local: {
-                       options: {
-                           configFile: '../tests/UI/protractor-conf.js'
-                       }
-                   }
-               },
-               makeReport: {
-               src: '../tests/UI/coverage/*.json',
-               options: {
-                   print: 'detail'
-               }
-           }
-       });
-       grunt.registerTask('test', [
-               'karma:unit'
-       ]);
-       grunt.registerTask('e2e', [
-               'copy:assets',
-               'copy:components',
-               'copy:shared',
-               'copy:filesPng',
-               'copy:filesIco',
-               'copy:filesJs',
-               'copy:filesJson',
-               'instrument',
-               'connect',
-               'shell:updateSelenium',
-               'shell:startSelenium',
-               'wait:default',
-               'protractor_coverage',
-               'makeReport',
-               'shell:deleteFiles'
-       ]);
+    require('load-grunt-tasks')(grunt);
+    require('grunt-protractor-coverage')(grunt);
+    grunt.loadNpmTasks('grunt-shell-spawn');
+    grunt.loadNpmTasks('grunt-wait');
+    grunt.loadNpmTasks('grunt-contrib-copy');
+    grunt.loadNpmTasks('grunt-contrib-connect');
+    grunt.initConfig({
+        connect: {
+            server: {
+                options: {
+                    port: 8000,
+                    base: './',
+                    middleware: function(connect, options, middlewares) {
+                        middlewares.unshift(function(req, res, next) {
+                            if (req.method.toUpperCase() == 'POST' || req.method.toUpperCase() == "PUT" ||
+                                req.method.toUpperCase() == "DELETE")
+                                {
+                                    req.method='GET';
+                                }
+                            return next();
+                        });
+                        return middlewares;
+                    }
+                }
+            }
+        },
+        copy: {
+            assets: {
+              expand: true,
+              cwd: '../../3rd_party/static/testapi-ui/assets',
+              src: '**',
+              dest: 'testapi-ui/assets',
+            },
+            components: {
+                expand: true,
+                cwd: 'components',
+                src: '**',
+                dest: 'testapi-ui/components',
+            },
+            shared: {
+                expand: true,
+                cwd: 'shared',
+                src: '**',
+                dest: 'testapi-ui/shared',
+            },
+            filesPng: {
+                expand: true,
+                src: '*.png',
+                dest: 'testapi-ui/',
+            },
+            filesIco: {
+                expand: true,
+                src: '*.ico',
+                dest: 'testapi-ui/',
+            },
+            filesJs: {
+                expand: true,
+                src: 'app.js',
+                dest: 'testapi-ui/',
+            },
+            filesJson: {
+                expand: true,
+                src: 'config.json',
+                dest: 'testapi-ui/',
+            }
+        },
+        wait: {
+            default: {
+                options: {
+                    delay: 3000
+                }
+            }
+        },
+        shell: {
+            updateSelenium: {
+                command: 'node_modules/protractor/bin/webdriver-manager update',
+                options: {
+                      async: false
+                }
+            },
+            startSelenium: {
+                command: 'node_modules/protractor/bin/webdriver-manager start',
+                options: {
+                  async: true
+                }
+            },
+            deleteFiles: {
+                command: 'rm -r testapi-ui',
+                options: {
+                  async: false
+                }
+            },
+            options: {
+                stdout: false,
+                stderr: false
+            }
+        },
+        instrument: {
+            files: ['components/**/*.js'],
+            options: {
+                lazy: false,
+                basePath: "./testapi-ui/"
+            }
+        },
+        karma: {
+            unit: {
+                configFile: 'karma.conf.js'
+            }
+        },
+        protractor_coverage: {
+            options: {
+                keepAlive: true,
+                noColor: false,
+                coverageDir: '../tests/UI/coverage',
+                args: {
+                    specs: ['../tests/UI/e2e/testCasesControllerSpec.js',
+                            '../tests/UI/e2e/resultsControllerSpec.js']
+                }
+            },
+            local: {
+                options: {
+                    configFile: '../tests/UI/protractor-conf.js'
+                }
+            }
+        },
+        makeReport: {
+            src: '../tests/UI/coverage/*.json',
+            options: {
+                print: 'detail'
+            }
+        }
+    });
+    grunt.registerTask('test', [
+        'karma:unit'
+    ]);
+    grunt.registerTask('e2e', [
+        'copy:assets',
+        'copy:components',
+        'copy:shared',
+        'copy:filesPng',
+        'copy:filesIco',
+        'copy:filesJs',
+        'copy:filesJson',
+        'instrument',
+        'connect',
+        'shell:updateSelenium',
+        'shell:startSelenium',
+        'wait:default',
+        'protractor_coverage',
+        'makeReport',
+        'shell:deleteFiles'
+    ]);
 }
index 2ae5339..0e7b8d5 100644 (file)
 </div>
 </form>
 <div class="row" style="margin-bottom:24px;"></div>
-<div class="result-filters">
-    <h4>Filters</h4>
-    <div class="row">
-        <div class="col-md-3">
-            <label for="cpid">Start Date</label>
-            <p class="input-group">
+<div class="result-filters" style="border-top: none;">
+    <div class="row podTable" style="vertical-align:middle">
+            <div class="col-sm-1 pull-right">
+                    <button type="button" class="btn btn-danger" ng-click="ctrl.clearFilters()">
+                      <i class="fa fa-search"></i> Clear
+                    </button>
+            </div>
+        <div class="col-sm-1 pull-right">
+            <button type="button" class="btn btn-success" ng-click="ctrl.filterList()">
+              <i class="fa fa-search"></i> Filter</button>
+        </div>
+        <div class="col-sm-2 pull-right" ng-class="{'hidden': ctrl.filter=='start_date' || ctrl.filter=='end_date'}">
+            <span style="margin-top:6px">Search:&nbsp;&nbsp;</span>
+            <input type="text" class="form-control search" style="display:inline;width:105px;padding-left:6px;"
+                ng-Model="ctrl.filterText" placeholder="Search String">
+        </div>
+        <div class="col-sm-3 pull-right" style="width:20%" ng-class="{'hidden': ctrl.filter!='start_date'}">
+            <span style="margin-top:6px">Start&nbsp;Date:&nbsp;&nbsp;</span>
+            <p class="input-group" style="width:48%;display:inline-flex;">
                 <input type="text" class="form-control"
                     uib-datepicker-popup="{{ctrl.format}}"
-                    ng-model="ctrl.startDate" is-open="ctrl.startOpen"
+                    ng-model="ctrl.filterText" is-open="ctrl.startOpen"
                     close-text="Close" />
                 <span class="input-group-btn">
                     <button type="button" class="btn btn-default" ng-click="ctrl.open($event, 'startOpen')">
                 </span>
             </p>
         </div>
-        <div class="col-md-3">
-            <label for="cpid">End Date</label>
-            <p class="input-group">
+        <div class="col-sm-3 pull-right" style="width:20%" ng-class="{'hidden': ctrl.filter!='end_date'}">
+            <span style="margin-top:6px">End&nbsp;Date:&nbsp;&nbsp;</span>
+            <p class="input-group" style="width:48%;display:inline-flex;">
                 <input type="text" class="form-control"
                     uib-datepicker-popup="{{ctrl.format}}"
-                    ng-model="ctrl.endDate" is-open="ctrl.endOpen"
+                    ng-model="ctrl.filterText" is-open="ctrl.endOpen"
                     close-text="Close" />
                 <span class="input-group-btn">
                     <button type="button" class="btn btn-default" ng-click="ctrl.open($event, 'endOpen')">
                 </span>
             </p>
         </div>
-        <div class="col-md-3" style="margin-top:24px;">
-            <button type="submit" class="btn btn-primary" ng-click="ctrl.update()">Filter</button>
-            <button type="submit" class="btn btn-primary btn-danger" ng-click="ctrl.clearFilters()">Clear</button>
+        <div class="col-md-2 row pull-right" style="width: 20%;">
+            <span style="margin-top:6px">Filter:&nbsp;&nbsp;</span>
+            <select ng-model="ctrl.filter" class="form-control" style="display:inline; width:150px;">
+                    <option value="pod" ng-disabled="ctrl.testFilter('pod')" >Pod Name</option>
+                    <option value="project" ng-disabled="ctrl.testFilter('project')" >Project Name</option>
+                    <option value="case" ng-disabled="ctrl.testFilter('case')">Case Name</option>
+                    <option value="installer" ng-disabled="ctrl.testFilter('installer')">Installer</option>
+                    <option value="version" ng-disabled="ctrl.testFilter('version')">Version</option>
+                    <option value="scenario" ng-disabled="ctrl.testFilter('scenario')">Scenario</option>
+                    <option value="build_tag" ng-disabled="ctrl.testFilter('build_tag')">Build Tag</option>
+                    <option value="criteria" ng-disabled="ctrl.testFilter('criteria')">Criteria</option>
+                    <option value="start_date" ng-disabled="ctrl.testFilter('start_date')">Start Date</option>
+                    <option value="end_date" ng-disabled="ctrl.testFilter('end_date')">End Date</option>
+            </select>
+        </div>
+
+        <div class='filter-box'>
+            <div class='filter-tag' ng-repeat="(key, tag) in ctrl.tagArray">
+                {{key}}&nbsp:&nbsp{{tag}}
+                <div class='delete-tag' ng-click='ctrl.deleteTag(key)'>
+                    &times;
+                </div>
+            </div>
         </div>
     </div>
 </div>
             boundary-links="true"
             rotate="false"
             num-pages="ctrl.numPages"
-            ng-change="ctrl.update()">
+            ng-change="ctrl.filterList()">
         </uib-pagination>
     </div>
 </div>
index cc6cc0b..e9b4443 100644 (file)
@@ -51,7 +51,6 @@
         var ctrl = this;
 
         ctrl.uploadFile=uploadFile;
-        ctrl.update = update;
         ctrl.open = open;
         ctrl.clearFilters = clearFilters;
         ctrl.associateMeta = associateMeta;
         ctrl.associateProductVersion = associateProductVersion;
         ctrl.getProductVersions = getProductVersions;
         ctrl.prepVersionEdit = prepVersionEdit;
+        ctrl.deleteTag = deleteTag;
+        ctrl.filterList= filterList;
+        ctrl.testFilter = testFilter
+
+        ctrl.tagArray = {}
 
         /** Mappings of Interop WG components to marketing program names. */
         ctrl.targetMappings = {
             $state.go('home');
         }
 
-        ctrl.pageHeader = ctrl.isUserResults ?
-            'Private test results' : 'Community test results';
+        ctrl.pageHeader = "Test Results"
 
         ctrl.pageParagraph = ctrl.isUserResults ?
             'Your most recently uploaded test results are listed here.' :
 
         if (ctrl.isUserResults) {
             ctrl.authRequest = $scope.auth.doSignCheck()
-                .then(ctrl.update);
+                .then(ctrl.filterList);
             // ctrl.getUserProducts();
         } else {
-            ctrl.update();
+            ctrl.filterList();
+        }
+
+        function deleteTag(index){
+            delete  ctrl.tagArray[index];
+            ctrl.filterList();
+        }
+
+        function testFilter(text){
+            for (var filter in ctrl.tagArray){
+                if(text==filter){
+                    return true;
+                }
+            }
+            return false;
         }
 
 
            .success(function(data){
               var id = data.href.substr(data.href.lastIndexOf('/')+1);
               ctrl.uploadState = "Upload succeed. Result id is " + id;
-              ctrl.update();
+              ctrl.filterList();
            })
 
            .error(function(data, status){
          * This will contact the TestAPI API to get a listing of test run
          * results.
          */
-        function update() {
+        function filterList(){
+            if(ctrl.filter && ctrl.filterText!=""){
+                ctrl.tagArray[ctrl.filter] =  ctrl.filterText;
+            }
             ctrl.showError = false;
-            // Construct the API URL based on user-specified filters.
             var content_url = testapiApiUrl + '/results' +
                 '?page=' + ctrl.currentPage;
-            var start = $filter('date')(ctrl.startDate, 'yyyy-MM-dd');
-            if (start) {
-                content_url =
-                    content_url + '&from=' + start + ' 00:00:00';
-            }
-            var end = $filter('date')(ctrl.endDate, 'yyyy-MM-dd');
-            if (end) {
-                content_url = content_url + '&to=' + end + ' 23:59:59';
-            }
-            if (ctrl.isUserResults) {
-                content_url = content_url + '&signed';
+            for(var key in ctrl.tagArray){
+                if(key=="start_date"){
+                    var start = $filter('date')(ctrl.tagArray[key], 'yyyy-MM-dd');
+                    if (start) {
+                        content_url =
+                            content_url + '&from=' + start + ' 00:00:00';
+                    }
+                }
+                else if(key=="end_date"){
+                    var end = $filter('date')(ctrl.tagArray[key], 'yyyy-MM-dd');
+                    if (end) {
+                        content_url = content_url + '&to=' + end + ' 23:59:59';
+                    }
+                }
+                else{
+                    content_url = content_url + "&" + key + "=" + ctrl.tagArray[key]
+                }
+                if (ctrl.isUserResults) {
+                    content_url = content_url + '&signed';
+                }
             }
             ctrl.resultsRequest =
-                $http.get(content_url).success(function (data) {
-                    ctrl.data = data;
-                    ctrl.totalItems = ctrl.data.pagination.total_pages * ctrl.itemsPerPage;
-                    ctrl.currentPage = ctrl.data.pagination.current_page;
-                }).error(function (error) {
-                    ctrl.data = null;
-                    ctrl.totalItems = 0;
-                    ctrl.showError = true;
-                    ctrl.error =
-                        'Error retrieving results listing from server: ' +
-                        angular.toJson(error);
-                });
+                    $http.get(content_url).success(function (data) {
+                        ctrl.data = data;
+                        ctrl.totalItems = ctrl.data.pagination.total_pages * ctrl.itemsPerPage;
+                        ctrl.currentPage = ctrl.data.pagination.current_page;
+                    }).error(function (error) {
+                        ctrl.data = null;
+                        ctrl.totalItems = 0;
+                        ctrl.showError = true;
+                        ctrl.error =
+                            'Error retrieving results listing from server: ' +
+                            angular.toJson(error);
+                    });
+            ctrl.filterText = ''
         }
+        ctrl.filterList();
 
         /**
          * This is called when the date filter calendar is opened. It
          * listing.
          */
         function clearFilters() {
-            ctrl.startDate = null;
-            ctrl.endDate = null;
-            ctrl.update();
+            ctrl.tagArray = {}
+            ctrl.filter = undefined
+            ctrl.filterList();
         }
 
         /**