96 lines
3.1 KiB
JavaScript
96 lines
3.1 KiB
JavaScript
'use strict';
|
|
/**
|
|
* controllers for ng-table
|
|
* Simple table with sorting and filtering on AngularJS
|
|
*/
|
|
// var helloApp = angular.module("helloApp", []);
|
|
app.controller("activityCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$localStorage", "$http", "$state", function ($scope, toaster, $filter, apiPoint, $localStorage, $http, $state) {
|
|
|
|
$scope.companies = {
|
|
"ActivityID": "",
|
|
"ActivityName": "",
|
|
"Description": "",
|
|
"switchsetting": true
|
|
|
|
};
|
|
|
|
$scope.addRow = function (myModel) {
|
|
var addactivity = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'addActivityDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
activityID: myModel.ActivityID,
|
|
activityName: myModel.ActivityName,
|
|
description: myModel.Description,
|
|
status: myModel.switchsetting,
|
|
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(addactivity).then(function (response) {
|
|
if (response.data.status == 200 && response.data.activityStatus) {
|
|
$scope.init();
|
|
swal("Success!", response.data.message, "success");
|
|
$state.go($state.current, {}, { reload: true });
|
|
} else {
|
|
swal("Failed!", response.data.message, "error");
|
|
}
|
|
});
|
|
|
|
};
|
|
|
|
$scope.onclick = function (id, status) {
|
|
status = status === true ? 1 : 0;
|
|
var addactivity = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'updateActivityStatus/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
status: status,
|
|
updateFor: id,
|
|
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(addactivity).then(function (response) {
|
|
if (response.data.status == 200 && response.data.activityUpdateStatus) {
|
|
$scope.init();
|
|
} else {
|
|
swal("Failed!", response.data.message, "error");
|
|
}
|
|
});
|
|
}
|
|
/*
|
|
*get Activity details when page loading called from view file
|
|
*
|
|
* created by surendiran
|
|
* */
|
|
$scope.loader = '';
|
|
$scope.emptyData = '';
|
|
$scope.init = function () {
|
|
var getActivity = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getActivityDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(getActivity).then(function (response) {
|
|
if (response.data.status == 200 && response.data.activityStatus) {
|
|
$scope.emptyData = true;
|
|
$scope.loader = true;
|
|
$scope.activityInfo = response.data.details;
|
|
} else {
|
|
$scope.emptyData = false;
|
|
$scope.loader = false;
|
|
$scope.activityInfo = "";
|
|
}
|
|
});
|
|
};
|
|
}]); |