summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/components/projects/projectsController.js
diff options
context:
space:
mode:
authorthuva4 <tharma.thuva@gmail.com>2017-11-23 12:44:38 +0530
committerthuva4 <tharma.thuva@gmail.com>2017-11-23 15:05:46 +0530
commit368428217fd182ab7a939b69c5abd7adc6bc30eb (patch)
treeacb6d367467478778ce4d6206d39877a7115856f /testapi/opnfv_testapi/ui/components/projects/projectsController.js
parent2b0da4f9ccdd488005f8b01c94153b4b41cad59c (diff)
Add filter option in projects page
Implemented the filter option for the projects by following params. name - Check the project's name. Edit the Error message view. Change-Id: Ib2f0e0ccd9726353dbbedbc44d98747ec8e2d4f9 Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/ui/components/projects/projectsController.js')
-rw-r--r--testapi/opnfv_testapi/ui/components/projects/projectsController.js49
1 files changed, 31 insertions, 18 deletions
diff --git a/testapi/opnfv_testapi/ui/components/projects/projectsController.js b/testapi/opnfv_testapi/ui/components/projects/projectsController.js
index 16002f6..468407b 100644
--- a/testapi/opnfv_testapi/ui/components/projects/projectsController.js
+++ b/testapi/opnfv_testapi/ui/components/projects/projectsController.js
@@ -34,6 +34,7 @@
ctrl.url = testapiApiUrl + '/projects';
ctrl.create = create;
ctrl.update = update;
+ ctrl.clearFilters = clearFilters;
ctrl.createRequirements = [
{label: 'name', type: 'text', required: true},
@@ -42,13 +43,13 @@
ctrl.name = '';
ctrl.details = '';
-
+ ctrl.filterName='';
/**
* This will contact the TestAPI to create a new project.
*/
function create() {
- ctrl.showError = false;
- ctrl.showSuccess = false;
+ ctrl.showCreateError = false;
+ ctrl.showCreateSuccess = false;
if(ctrl.name != ""){
var projects_url = ctrl.url;
var body = {
@@ -57,18 +58,17 @@
};
ctrl.projectsRequest =
$http.post(projects_url, body).success(function (data){
- ctrl.showSuccess = true ;
+ ctrl.showCreateSuccess = true ;
ctrl.update();
- })
- .error(function (data) {
- ctrl.showError = true;
- ctrl.error = 'Error creating the new Project from server:' + angular.toJson(data);
+ }).catch(function (data) {
+ ctrl.showCreateError = true;
+ ctrl.error = data.statusText;
});
ctrl.name = "";
ctrl.description="";
}
else{
- ctrl.showError = true;
+ ctrl.showCreateError = true;
ctrl.error = 'Name is missing.'
}
}
@@ -77,18 +77,31 @@
* This will contact the TestAPI to get a listing of declared projects.
*/
function update() {
- ctrl.showError = false;
- ctrl.projectsRequest =
- $http.get(ctrl.url).success(function (data) {
+ ctrl.showUpdateError = false;
+ var content_url = ctrl.url + '?';
+ var name = ctrl.filterName;
+ if(name){
+ content_url = content_url + 'name=' +
+ name;
+ }
+ ctrl.resultsRequest =
+ $http.get(content_url).success(function (data) {
ctrl.data = data;
- }).error(function (error) {
+ }).catch(function (data) {
ctrl.data = null;
- ctrl.showError = true;
- ctrl.error =
- 'Error retrieving projects from server: ' +
- angular.toJson(error);
+ ctrl.showUpdateError = true;
+ ctrl.error = data.statusText;
});
}
- ctrl.update();
+
+ /**
+ * This function will clear all filters and update the projects
+ * listing.
+ */
+ function clearFilters() {
+ ctrl.filterName = null;
+ ctrl.showUpdateError = false;
+ ctrl.update();
+ }
}
})();