summaryrefslogtreecommitdiffstats
path: root/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
diff options
context:
space:
mode:
authorgrakiss <grakiss.wanglei@huawei.com>2017-11-09 11:01:00 +0000
committerLeo wang <grakiss.wanglei@huawei.com>2017-11-09 11:55:20 +0000
commitf88b298c17a3dac9e6b2882d3f10f274572fc29d (patch)
tree13eeba65fbbb0a6f97e08d3afca6107d7a1157fc /cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
parent135db0c9860db436a2036f2bcb6f45b164f5b848 (diff)
[cvp-web] Bugfix: use '_id' as the primary key of the data rather than the 'Test ID'
JIRA: DOVETAIL-554 It allows different users to upload the same results now. So the 'Test ID' is not unique in this situation. Use '_id' as the primary key which can uniquely identify one data. Change-Id: I852ee116f36a6a86e9b4350183e39ee00f8b99de Signed-off-by: grakiss <grakiss.wanglei@huawei.com>
Diffstat (limited to 'cvp/3rd_party/static/testapi-ui/components/results/resultsController.js')
-rw-r--r--cvp/3rd_party/static/testapi-ui/components/results/resultsController.js123
1 files changed, 64 insertions, 59 deletions
diff --git a/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js b/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
index 86f7c5d6..4476618c 100644
--- a/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
+++ b/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
@@ -62,6 +62,7 @@
ctrl.gotoSUT = gotoSUT;
ctrl.gotoResultDetail = gotoResultDetail;
ctrl.toggleCheck = toggleCheck;
+ ctrl.changeLabel = changeLabel;
ctrl.toReview = toReview;
ctrl.toPrivate = toPrivate;
ctrl.removeSharedUser = removeSharedUser;
@@ -103,7 +104,7 @@
/** The date format for the date picker. */
ctrl.format = 'yyyy-MM-dd';
- ctrl.userName = null;
+ ctrl.userName = null;
/** Check to see if this page should display user-specific results. */
// ctrl.isUserResults = $state.current.name === 'userResults';
@@ -168,44 +169,48 @@
}
function toggleCheck(result, item, newValue) {
- var id = result.id;
- var updateUrl = testapiApiUrl + "/tests/"+id;
-
- var data = {};
- data['item'] = item;
- data[item] = newValue;
-
- $http.put(updateUrl, JSON.stringify(data), {
- transformRequest: angular.identity,
- headers: {'Content-Type': 'application/json'}})
- .then( function(ret) {
- if(ret.data.code && ret.data.code != 0) {
- alert(ret.data.msg);
- }
- else {
- result[item] = newValue;
- console.log('update success');
- }
- }, function(response){
+ var id = result._id;
+ var updateUrl = testapiApiUrl + "/tests/"+ id;
+
+ var data = {};
+ data['item'] = item;
+ data[item] = newValue;
+
+ $http.put(updateUrl, JSON.stringify(data), {
+ transformRequest: angular.identity,
+ headers: {'Content-Type': 'application/json'}}).then(function(ret){
+ if(ret.data.code && ret.data.code != 0) {
+ alert(ret.data.msg);
+ }
+ else {
+ result[item] = newValue;
+ console.log('update success');
+ }
+ }, function(error){
+ alert("Error when update data");
});
}
- function toReview(result, value){
- var resp = confirm('Once you submit a test result for review, it will become readable to all CVP reviewers. Do you want to proceed?');
- if(resp){
- toggleCheck(result, 'status', value);
- }
- }
-
- function toPrivate(result, value){
- var resp = confirm('Do you want to proceed?');
- if(resp){
- toggleCheck(result, 'status', value);
- }
- }
-
- function openSharedModal(result){
- ctrl.tempResult = result;
+ function changeLabel(result, data){
+ toggleCheck(result, 'label', data);
+ }
+
+ function toReview(result, value){
+ var resp = confirm('Once you submit a test result for review, it will become readable to all CVP reviewers. Do you want to proceed?');
+ if(resp){
+ toggleCheck(result, 'status', value);
+ }
+ }
+
+ function toPrivate(result, value){
+ var resp = confirm('Do you want to proceed?');
+ if(resp){
+ toggleCheck(result, 'status', value);
+ }
+ }
+
+ function openSharedModal(result){
+ ctrl.tempResult = result;
ngDialog.open({
preCloseCallback: function(value) {
},
@@ -216,31 +221,31 @@
showClose: true,
closeByDocument: true
});
- }
+ }
+
+ function addSharedUser(result, userId){
+ var tempList = copy(result.shared);
+ tempList.push(userId);
+ toggleCheck(result, 'shared', tempList);
+ ngDialog.close();
+ }
- function addSharedUser(result, userId){
+ function removeSharedUser(result, userId){
var tempList = copy(result.shared);
- tempList.push(userId);
- toggleCheck(result, 'shared', tempList);
- ngDialog.close();
- }
-
- function removeSharedUser(result, userId){
- var tempList = copy(result.shared);
- var idx = tempList.indexOf(userId);
- if(idx != -1){
- tempList.splice(idx, 1);
- toggleCheck(result, 'shared', tempList);
- }
- }
-
- function copy(arrList){
- var tempList = [];
- angular.forEach(arrList, function(ele){
- tempList.push(ele);
- });
- return tempList;
- }
+ var idx = tempList.indexOf(userId);
+ if(idx != -1){
+ tempList.splice(idx, 1);
+ toggleCheck(result, 'shared', tempList);
+ }
+ }
+
+ function copy(arrList){
+ var tempList = [];
+ angular.forEach(arrList, function(ele){
+ tempList.push(ele);
+ });
+ return tempList;
+ }
function uploadFileToUrl(file, uploadUrl){
var fd = new FormData();