Commit 04c0d62b authored by Evren Kutar's avatar Evren Kutar

close socket on logout and reconnect on login

parent 98fb6cad
...@@ -76,6 +76,7 @@ angular.module('ulakbus.auth') ...@@ -76,6 +76,7 @@ angular.module('ulakbus.auth')
$rootScope.loggedInUser = false; $rootScope.loggedInUser = false;
$log.debug("loggedout"); $log.debug("loggedout");
$location.path("/login"); $location.path("/login");
WSOps.close();
}); });
}; };
......
...@@ -128,8 +128,11 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -128,8 +128,11 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
* *
* @returns {object} * @returns {object}
*/ */
.controller('CRUDController', function ($scope, $routeParams, Generator, CrudUtility) { .controller('CRUDController', function ($scope, $routeParams, $location, Generator, CrudUtility) {
// get required params by calling CrudUtility.generateParam function // get required params by calling CrudUtility.generateParam function
if ($location.url().indexOf('?=') > 0) {
return $location.url($location.url().replace('?=', ''));
}
CrudUtility.generateParam($scope, $routeParams); CrudUtility.generateParam($scope, $routeParams);
Generator.get_wf($scope); Generator.get_wf($scope);
}) })
...@@ -153,6 +156,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -153,6 +156,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
* @returns {object} * @returns {object}
*/ */
.controller('CRUDListFormController', function ($scope, $rootScope, $location, $sce, $http, $log, $uibModal, $timeout, Generator, $routeParams, CrudUtility) { .controller('CRUDListFormController', function ($scope, $rootScope, $location, $sce, $http, $log, $uibModal, $timeout, Generator, $routeParams, CrudUtility) {
$scope.wf_step = $routeParams.step;
$scope.paginate = function (reloadData) { $scope.paginate = function (reloadData) {
$scope.form_params.cmd = $scope.reload_cmd; $scope.form_params.cmd = $scope.reload_cmd;
......
...@@ -307,7 +307,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -307,7 +307,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
url: scope.url, url: scope.url,
wf: scope.wf, wf: scope.wf,
nodeModelChange: function (item) { nodeModelChange: function (item) {
//debugger;
} }
}); });
......
...@@ -31,15 +31,22 @@ angular.module('ulakbus') ...@@ -31,15 +31,22 @@ angular.module('ulakbus')
}); });
var websocket; var websocket;
var refresh_count = 0;
var refresh_websocket = refresh_count < 5 ? 1000 : 5000;
var generate_ws = function () { var generate_ws = function () {
$log.info('Openning web socket...'); $log.info('Openning web socket...');
websocket = new WS(WSUri.url); websocket = new WS(WSUri.url);
websocket.onopen = function (evt) { websocket.onopen = function (evt) {
wsOps.onOpen(evt) wsOps.onOpen(evt);
refresh_count = 0;
}; };
websocket.onclose = function (evt) { websocket.onclose = function (evt) {
wsOps.onClose(evt); wsOps.onClose(evt);
generate_ws(); if (wsOps.loggedOut === true) {return;}
$timeout(function () {
generate_ws();
refresh_count += 1;
}, refresh_websocket);
}; };
websocket.onmessage = function (evt) { websocket.onmessage = function (evt) {
wsOps.onMessage(evt) wsOps.onMessage(evt)
...@@ -53,6 +60,7 @@ angular.module('ulakbus') ...@@ -53,6 +60,7 @@ angular.module('ulakbus')
wsOps.onOpen = function (evt) { wsOps.onOpen = function (evt) {
$rootScope.websocketIsOpen = true; $rootScope.websocketIsOpen = true;
$log.info("CONNECTED", evt); $log.info("CONNECTED", evt);
wsOps.loggedOut === false;
}; };
wsOps.onClose = function (event) { wsOps.onClose = function (event) {
$rootScope.websocketIsOpen = false; $rootScope.websocketIsOpen = false;
...@@ -85,7 +93,6 @@ angular.module('ulakbus') ...@@ -85,7 +93,6 @@ angular.module('ulakbus')
websocket.send(data); websocket.send(data);
$log.info('SENT:', data); $log.info('SENT:', data);
}; };
wsOps.retryCount = 0;
// reactor with promise // reactor with promise
wsOps.request = function (data) { wsOps.request = function (data) {
var request = { var request = {
...@@ -103,6 +110,13 @@ angular.module('ulakbus') ...@@ -103,6 +110,13 @@ angular.module('ulakbus')
); );
}; };
wsOps.close = function () {
wsOps.loggedOut = true;
websocket.close();
$log.info("CLOSED");
delete websocket;
}
wsOps.waitForSocketConnection = function (socket, callback) { wsOps.waitForSocketConnection = function (socket, callback) {
$timeout( $timeout(
function () { function () {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"angular-cookies": "1.4.7", "angular-cookies": "1.4.7",
"angular-bootstrap": "0.14.3", "angular-bootstrap": "0.14.3",
"angular-i18n": "1.4.7", "angular-i18n": "1.4.7",
"angular-markdown-filter": "1.3.2",
"font-awesome": "4.3.0", "font-awesome": "4.3.0",
"angular-schema-form": "0.8.3", "angular-schema-form": "0.8.3",
"angular-loading-bar": "~0.8.0", "angular-loading-bar": "~0.8.0",
...@@ -24,7 +25,8 @@ ...@@ -24,7 +25,8 @@
"angular-chart.js": "~0.5.2", "angular-chart.js": "~0.5.2",
"angular-gettext": "2.1.0", "angular-gettext": "2.1.0",
"intro.js": "1.1.1", "intro.js": "1.1.1",
"moment": "2.10.6" "moment": "2.10.6",
"toastr": "*"
}, },
"resolutions": { "resolutions": {
"angular": "1.4.7" "angular": "1.4.7"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment