Commit c04385ca authored by Evren Kutar's avatar Evren Kutar

ADD socket.js for first implementation

FIX gruntfile to dist generation for websocket
rref #5120
parent 4cea22e8
...@@ -125,6 +125,7 @@ module.exports = function (grunt) { ...@@ -125,6 +125,7 @@ module.exports = function (grunt) {
"app/zetalib/general.js", "app/zetalib/general.js",
"app/zetalib/form_service.js", "app/zetalib/form_service.js",
"app/zetalib/action_service.js", "app/zetalib/action_service.js",
"app/zetalib/socket.js",
"app/shared/directives.js", "app/shared/directives.js",
"app/components/auth/auth_controller.js", "app/components/auth/auth_controller.js",
"app/components/auth/auth_service.js", "app/components/auth/auth_service.js",
......
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
<script src="zetalib/interceptors.js"></script> <script src="zetalib/interceptors.js"></script>
<script src="zetalib/form_service.js"></script> <script src="zetalib/form_service.js"></script>
<script src="zetalib/action_service.js"></script> <script src="zetalib/action_service.js"></script>
<script src="zetalib/socket.js"></script>
<!-- components --> <!-- components -->
......
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
<script src="zetalib/interceptors.js"></script> <script src="zetalib/interceptors.js"></script>
<script src="zetalib/form_service.js"></script> <script src="zetalib/form_service.js"></script>
<script src="zetalib/action_service.js"></script> <script src="zetalib/action_service.js"></script>
<script src="zetalib/socket.js"></script>
<!-- components --> <!-- components -->
......
...@@ -29,7 +29,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -29,7 +29,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @name Generator * @name Generator
* @description form service's Generator factory service handles all generic form operations * @description form service's Generator factory service handles all generic form operations
*/ */
.factory('Generator', function ($http, $q, $timeout, $sce, $location, $route, $compile, $log, RESTURL, $rootScope, Moment) { .factory('Generator', function ($http, $q, $timeout, $sce, $location, $route, $compile, $log, RESTURL, $rootScope, Moment, WSOps) {
var generator = {}; var generator = {};
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
...@@ -839,43 +839,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -839,43 +839,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
return generator.pathDecider(res.data.client_cmd, scope, res.data); return generator.pathDecider(res.data.client_cmd, scope, res.data);
}); });
}; };
///**
// * @memberof ulakbus.formService
// * @ngdoc function
// * @name isValidEmail
// * @description checks if given value is a valid email address.
// * @param email
// * @returns {boolean}
// */
//generator.isValidEmail = function (email) {
// var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
// return re.test(email);
//};
///**
// * @memberof ulakbus.formService
// * @ngdoc function
// * @name isValidTCNo
// * @description checks if given value is a valid identity number for Turkey.
// * @param tcno
// * @returns {boolean}
// */
//generator.isValidTCNo = function (tcno) {
// var re = /^([1-9]{1}[0-9]{9}[0,2,4,6,8]{1})$/i;
// return re.test(tcno);
//};
///**
// * @memberof ulakbus.formService
// * @ngdoc function
// * @name isValidDate
// * @description checks if given value can be parsed as Date object
// * @param dateValue
// * @returns {boolean}
// */
//generator.isValidDate = function (dateValue) {
// //return !isNaN(Date.parse(dateValue));
// return moment(dateValue)._d.toString() !== 'Invalid Date'
//};
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc property * @ngdoc property
...@@ -891,8 +854,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -891,8 +854,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
generator.setPageData = function (value) { generator.setPageData = function (value) {
generator.pageData = value; generator.pageData = value;
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
...@@ -959,7 +920,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -959,7 +920,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
dispatchClientCmd(); dispatchClientCmd();
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
......
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*
* @author Evren Kutar
*/
angular.module('ulakbus')
/**
* WSUri returns websocket uri
*/
.service('WSUri', function () {
return {url: 'ws://localhost:9001/ws'}
})
/**
* WSOps operates all websocket interactions
*/
.service('WSOps', function (WSUri, $log) {
var websocket = new WebSocket(WSUri.url);
websocket.onopen = function (evt) {
wsOps.onOpen(evt)
};
websocket.onclose = function (evt) {
wsOps.onClose(evt)
};
websocket.onmessage = function (evt) {
wsOps.onMessage(evt)
};
websocket.onerror = function (evt) {
wsOps.onError(evt)
};
var wsOps = {};
wsOps.onOpen = function(evt) {
$log.info("CONNECTED", evt);
};
wsOps.onClose = function(event) {
$log.info("DISCONNEDTED", event);
};
wsOps.onMessage = function(event) {
$log.info("MESSAGE:", event.data);
};
wsOps.onError = function(evt) {
$log.error("Error :: " + evt);
};
wsOps.doSend = function(data) {
websocket.send(data);
$log.info('SENT:', data);
};
return wsOps;
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
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