course details changes done
This commit is contained in:
parent
003a3c9927
commit
47903de676
228
Apollo/assets/js/controllers/sessionMasterCtrl.js
Normal file
228
Apollo/assets/js/controllers/sessionMasterCtrl.js
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
'use strict';
|
||||||
|
/**
|
||||||
|
* controllers for ng-table
|
||||||
|
* Simple table with sorting and filtering on AngularJS
|
||||||
|
*/
|
||||||
|
|
||||||
|
app.controller('sessionMasterCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
|
||||||
|
$scope.myModel = {
|
||||||
|
"sessionName": "",
|
||||||
|
"switchsetting": true
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* edit session details
|
||||||
|
* created by kms
|
||||||
|
* */
|
||||||
|
$scope.editId = -1;
|
||||||
|
$scope.setEditId = function (p) {
|
||||||
|
|
||||||
|
$scope.editId = p.SessionID;
|
||||||
|
$scope.viewId = -1;
|
||||||
|
$scope.splitUnivertyToArray = p.UniversityID.split(',');
|
||||||
|
|
||||||
|
$scope.editUniverSity = [];
|
||||||
|
angular.forEach($scope.splitUnivertyToArray, function (values, keys) {
|
||||||
|
|
||||||
|
$scope.editUniverSity.push(values);
|
||||||
|
})
|
||||||
|
$scope.viewUniversity = {
|
||||||
|
list: $scope.editUniverSity,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cancel edit div
|
||||||
|
* created by kms
|
||||||
|
* */
|
||||||
|
$scope.cancel = function () {
|
||||||
|
$scope.init();
|
||||||
|
$scope.editId = -1;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// sorting function for table params
|
||||||
|
$scope.sort = function(keyname){
|
||||||
|
$scope.sortKey = keyname; //set the sortKey to the param passed
|
||||||
|
$scope.reverse = !$scope.reverse; //if true make it false and vice versa
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Submit,update and reset session details
|
||||||
|
* @params myModel
|
||||||
|
* created by kms
|
||||||
|
* */
|
||||||
|
$scope.sessionForm = {
|
||||||
|
|
||||||
|
submit: function (form, myModel,loading) {
|
||||||
|
var firstError = null;
|
||||||
|
if (form.$invalid) {
|
||||||
|
var field = null, firstError = null;
|
||||||
|
for (field in form) {
|
||||||
|
if (field[0] != '$') {
|
||||||
|
if (firstError === null && !form[field].$valid) {
|
||||||
|
firstError = form[field].$name;
|
||||||
|
}
|
||||||
|
if (form[field].$pristine) {
|
||||||
|
form[field].$dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
||||||
|
// swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$scope.ldloading1 = {};
|
||||||
|
|
||||||
|
$scope.ldloading1[loading.replace('-', '_')] = true;
|
||||||
|
|
||||||
|
|
||||||
|
var addSession = {
|
||||||
|
method: 'POST',
|
||||||
|
url: apiPoint.url + 'addSessionMaterDetails/',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
sessionName: myModel.sessionName,
|
||||||
|
universityName: myModel.universityName,
|
||||||
|
status: myModel.switchsetting,
|
||||||
|
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$http(addSession).then(function (response) {
|
||||||
|
if (response.data.status==200 && response.data.sessionStatus) {
|
||||||
|
$scope.ldloading1[loading.replace('-', '_')] = false;
|
||||||
|
swal("", response.data.message, "success");
|
||||||
|
$state.go($state.current, {}, {reload: true});
|
||||||
|
} else {
|
||||||
|
$scope.ldloading1[loading.replace('-', '_')] = false;
|
||||||
|
swal("", response.data.message, "error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
reset: function (form) {
|
||||||
|
|
||||||
|
$scope.myModel = {
|
||||||
|
"sessionName": "",
|
||||||
|
"switchsetting": true
|
||||||
|
};
|
||||||
|
form.$setPristine(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
* update the session details
|
||||||
|
* created by kms
|
||||||
|
* */
|
||||||
|
$scope.updateSession = function (myModel,university, form, loading) {
|
||||||
|
var firstError = null;
|
||||||
|
if (form.$invalid) {
|
||||||
|
var field = null, firstError = null;
|
||||||
|
for (field in form) {
|
||||||
|
if (field[0] != '$') {
|
||||||
|
if (firstError === null && !form[field].$valid) {
|
||||||
|
firstError = form[field].$stop_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form[field].$pristine) {
|
||||||
|
form[field].$dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
||||||
|
} else {
|
||||||
|
$scope.ldloading = {};
|
||||||
|
|
||||||
|
$scope.ldloading[loading.replace('-', '_')] = true;
|
||||||
|
|
||||||
|
|
||||||
|
var update = {
|
||||||
|
method: 'POST',
|
||||||
|
url: apiPoint.url + 'updateSessionMaterDetails/',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
sessionID: myModel.SessionID,
|
||||||
|
sessionName: myModel.SessionName,
|
||||||
|
status: myModel.IsActive,
|
||||||
|
university: university.list,
|
||||||
|
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$http(update).then(function (response) {
|
||||||
|
if (response.data.status==200 && response.data.sessionStatus) {
|
||||||
|
$scope.ldloading[loading.replace('-', '_')] = false;
|
||||||
|
$scope.editId = -1;
|
||||||
|
$scope.init();
|
||||||
|
swal("", response.data.message, "success");
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$scope.ldloading[loading.replace('-', '_')] = false;
|
||||||
|
swal("", response.data.message, "error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
*get session details when page loading
|
||||||
|
*
|
||||||
|
* created by kms
|
||||||
|
* */
|
||||||
|
$scope.loader='';
|
||||||
|
|
||||||
|
$scope.emptyData='';
|
||||||
|
|
||||||
|
$rootScope.init = function () {
|
||||||
|
$scope.universityList = [];
|
||||||
|
var getSession = {
|
||||||
|
method: 'POST',
|
||||||
|
url: apiPoint.url + 'getSessionMaterDetails/',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http(getSession).then(function (response) {
|
||||||
|
if (response.data.status==200 && response.data.sessionStatus) {
|
||||||
|
|
||||||
|
$scope.emptyData=true;
|
||||||
|
$scope.loader=true;
|
||||||
|
|
||||||
|
$scope.data = response.data.details;
|
||||||
|
|
||||||
|
// $scope.university=response.data.universityDetails;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$scope.emptyData=false;
|
||||||
|
$scope.loader=true;
|
||||||
|
// $scope.university=response.data.universityDetails;
|
||||||
|
|
||||||
|
}
|
||||||
|
angular.forEach(response.data.universityDetails, function (values, keys) {
|
||||||
|
$scope.arrayData = {
|
||||||
|
UniversityName: values.UniversityName,
|
||||||
|
UniversityID: values.UniversityID
|
||||||
|
};
|
||||||
|
$scope.universityList.push($scope.arrayData);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}]);
|
||||||
Loading…
Reference in New Issue
Block a user