ENDRPrint_12CRelease/web/js/ctrl/mainController.js
2024-08-14 10:58:03 +07:00

107 lines
3.4 KiB
JavaScript

// create the controller and inject Angular's $scope
scotchApp.controller('mainController',
// create a message to display in our view
function ($scope, $location, $templateCache, mainPostFactory, $route, commonService) {
//alert("mainController");
init();
function init() {
mainPostFactory.doCheckLogin()
.success(
function (data) {
// alert($location.path());
// alert("doCheckLogin Sesssion >>>"+data[0]);
if (data == null) {
$templateCache.removeAll();
$location.path("login");
$location.url('login').replace();
$scope.$apply();
}
else {
// alert(JSON.stringify(data));
$route.reload();//Session not null
}
}
);
// try {
// mainPostFactory.doAjaxPost('/json/doCheckLogin.json', {}).success(
// function () {
// $location.path("/logout");
// $scope.$apply();
// }
// ).error(
// function () {
// $location.path("/login");
// $scope.$apply();
// });
// } catch (e) {
// //
// }
}
// try {
// var actLoadData = $.ajax(doGetPath('/json/doCheckLogin.json'),
// {
// ajax: true,
// dataType: 'json',
// type: "POST"
// }).error(
// function (data) {
// $location.path("/login");
// $scope.$apply();
// });
//
// actLoadData.success(
// function (data) {
//// $location.path("/");
// $scope.$apply();
// }
// );
// alert("mainController");
// mainPostFactory.doCheckLogin().success(
// mainPostFactory.doAjaxPost('/json/doCheckLogin.json', {}).success(
// function () {
// alert(commonService.urlPath);
// commonService.setDv(data[0]);
// alert(commonService.dv);
// $location.path(commonService.urlPath);
// $location.path("/logout");
// $scope.$apply();
// }
// ).error(
// function () {
// $location.path("/login");
// $scope.$apply();
// });
// } catch (e) {
// //
// }
// }
// $scope.printing = function(url){
// //alert("printing");
// $scope.urlPath = url;
// $location.path(url+"/"+new Date().getTime());
// $scope.$apply();
// };
//
// $scope.redirectMainPage = function(url){
// $location.path(url+"/"+new Date().getTime());
// $scope.$apply();
// };
//
// $scope.doLogout = function () {
// $location.path("/logout");
// };
})
;