Parent: [74c62d] (diff)

Child: [489239] (diff)

Download this file

rulesCtrl.js    53 lines (46 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*made by Miguel Rodrigues @ KBZ miguel.rodrigues@knowledgebiz.pt*/
console.log("Defining rulesCtrl");
angular.module('mainApp')
.controller('rulesCtrl', function($scope, $routeParams, $http, appService) {
$scope.appId = $routeParams.appid;
$scope.description = null;
$scope.parameter = null;
$scope.conditionValue = null;
$scope.controlValue = null;
$scope.notificationType = null;
console.log(" Running rulesCtrl... ");
appService.getAppRules($routeParams.appid).then(function(response){
if(response.data.success){
console.log("getAppRules response: " + JSON.stringify(response.data));
$scope.rules = response.data.data;
}else{
console.log("Something went wrong...");
}
}).then(function(){
console.log("getAppRules timed out");
});
$scope.postdata = function (description, parameter, conditionValue, controlValue, notificationType) {
var data = {
appID: $routeParams.appid,
description: description,
parameter: parameter,
conditionValue: conditionValue,
controlValue: controlValue,
notificationType: notificationType
};
appService.postAppRules(data).then(function(res) {
if(res.data.success){
console.log("Post Data Submitted Successfully!");
window.location = '/'+$routeParams.developerid
}else{
console.log("Failed to Register");
}
}).then(function(){
console.log("postAppRules timed out");
});
};
$scope.redirect = function (rulesid) {
window.location = '/'+$routeParams.developerid+'/'+$routeParams.appid+'/'+rulesid
};
console.log("Loading rulesCtrl");
});