Commit 18937cec authored by Evren Kutar's avatar Evren Kutar

menu rename to dashboard and get it with socket

parent 5c4f12cc
...@@ -25,10 +25,13 @@ angular.module('ulakbus.auth', ['ngRoute', 'ngCookies']) ...@@ -25,10 +25,13 @@ angular.module('ulakbus.auth', ['ngRoute', 'ngCookies'])
* @description LoginCtrl responsible to handle login process.<br> * @description LoginCtrl responsible to handle login process.<br>
* Using 'ulakbus.formService.get_form' function generates the login form and post it to the API with input datas. * Using 'ulakbus.formService.get_form' function generates the login form and post it to the API with input datas.
*/ */
.controller('LoginController', function ($scope, $q, $timeout, $location, $routeParams, $rootScope, $log, Generator, AuthService) { .controller('LoginController', function ($scope, $q, $timeout, $location, $routeParams, $rootScope, $log, WSOps, Generator, AuthService) {
$scope.url = 'login'; $scope.url = 'login';
$scope.form_params = {}; $scope.form_params = {};
$scope.form_params['clear_wf'] = 1; $scope.form_params['clear_wf'] = 1;
// if websocket status is open ---> ws close
try {WSOps.close()}
catch (e) {$log.error(e.message)}
AuthService.get_form($scope).then(function (data) { AuthService.get_form($scope).then(function (data) {
if (data.login) { $location.path('/'); } if (data.login) { $location.path('/'); }
$scope.form = [ $scope.form = [
......
...@@ -87,6 +87,7 @@ angular.module('ulakbus.auth') ...@@ -87,6 +87,7 @@ angular.module('ulakbus.auth')
$rootScope.loginAttempt = 0; $rootScope.loginAttempt = 0;
WSOps.request({wf: 'logout'}).then(function (data) { WSOps.request({wf: 'logout'}).then(function (data) {
$rootScope.loggedInUser = false; $rootScope.loggedInUser = false;
$rootScope.current_user = true;
$log.debug("loggedout"); $log.debug("loggedout");
$location.path("/login"); $location.path("/login");
WSOps.close(); WSOps.close();
......
...@@ -95,6 +95,9 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -95,6 +95,9 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
if (scope.meta['selective_listing'] === true) { if (scope.meta['selective_listing'] === true) {
angular.forEach(scope.objects, function (_v, _k) { angular.forEach(scope.objects, function (_v, _k) {
angular.forEach(_v.objects, function (value, key) { angular.forEach(_v.objects, function (value, key) {
if (_v.selected === true) {
scope.selected_key = _k;
}
if (key > 0) { if (key > 0) {
var linkIndexes = {}; var linkIndexes = {};
angular.forEach(value.actions, function (v, k) { angular.forEach(value.actions, function (v, k) {
...@@ -296,7 +299,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -296,7 +299,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
// selective listing for list page todo: add to documentation // selective listing for list page todo: add to documentation
$scope.update_selective_list = function (key) { $scope.update_selective_list = function (key) {
$scope.objects = $scope.all_objects[key]["objects"]; $scope.objects = key["objects"];
}; };
// end of selective listing // end of selective listing
$scope.listFormCmd = function () { $scope.listFormCmd = function () {
...@@ -330,9 +333,10 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -330,9 +333,10 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
} }
// if selective listing then change objects key to its first item // if selective listing then change objects key to its first item
if ($scope.meta.selective_listing) { if (angular.isDefined($scope.meta.selective_listing)) {
$scope.all_objects = angular.copy($scope.objects); $scope.all_objects = angular.copy($scope.objects);
$scope.objects = $scope.all_objects[0]["objects"]; $scope.selective_list_key = $scope.all_objects[$scope.selected_key];
$scope.objects = $scope.selective_list_key["objects"];
} }
}; };
$scope.reloadCmd = function () { $scope.reloadCmd = function () {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</div> </div>
<div ng-repeat="node in ListNode"> <div ng-repeat="node in ListNode">
<h3>{{ node.title }} <h3>{{ node.title }}
<span> <span ng-if="meta.allow_add_listnode !== false">
<a modal-for-nodes="{{node.schema.model_name}},ListNode,add"> <a modal-for-nodes="{{node.schema.model_name}},ListNode,add">
<i class="fa fa-plus-circle fa-fw"></i> <i class="fa fa-plus-circle fa-fw"></i>
</a> </a>
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
<select name="selective_list" id="selective_list" <select name="selective_list" id="selective_list"
ng-change="update_selective_list(selective_list_key)" ng-change="update_selective_list(selective_list_key)"
ng-model="selective_list_key" ng-model="selective_list_key"
ng-options="item as item.key for item in all_objects"
class="form-control"> class="form-control">
<option ng-repeat="item in all_objects" value="{{$index}}" ng-selected="selective_list_key">{{item.key}}</option> <!--<option ng-repeat="item in all_objects" value="{{$index}}">{{item.key}}</option>-->
</select> </select>
</div> </div>
<div class="tablescroll" ng-if="objects[1]"> <div class="tablescroll" ng-if="objects[1]">
......
...@@ -31,7 +31,6 @@ angular.module('ulakbus') ...@@ -31,7 +31,6 @@ angular.module('ulakbus')
}); });
var websocket; var websocket;
var ws_is_generated;
var refresh_count = 0; var refresh_count = 0;
var refresh_websocket = refresh_count < 5 ? 1000 : 5000; var refresh_websocket = refresh_count < 5 ? 1000 : 5000;
var isSupported = function() { var isSupported = function() {
...@@ -59,7 +58,6 @@ angular.module('ulakbus') ...@@ -59,7 +58,6 @@ angular.module('ulakbus')
websocket.onerror = function (evt) { websocket.onerror = function (evt) {
wsOps.onError(evt) wsOps.onError(evt)
}; };
ws_is_generated = true;
} else { } else {
var error = { var error = {
error: "Tarayıcınız websocket desteklememektedir. Lütfen güncel bir tarayıcı kullanınız.", error: "Tarayıcınız websocket desteklememektedir. Lütfen güncel bir tarayıcı kullanınız.",
...@@ -73,10 +71,22 @@ angular.module('ulakbus') ...@@ -73,10 +71,22 @@ angular.module('ulakbus')
}; };
var wsOps = {}; var wsOps = {};
var keepAlivePing = function (interval) {
return setInterval(function () {
if ($rootScope.websocketIsOpen) {
wsOps.doSend(angular.toJson({data: {view: "ping"}}));
} else {
$timeout(function () {
this(interval);
}, 1000);
}
}, interval);
};
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; keepAlivePing(30000);
wsOps.loggedOut = false;
}; };
wsOps.onClose = function (event) { wsOps.onClose = function (event) {
$rootScope.websocketIsOpen = false; $rootScope.websocketIsOpen = false;
...@@ -136,7 +146,7 @@ angular.module('ulakbus') ...@@ -136,7 +146,7 @@ angular.module('ulakbus')
}; };
// reactor with promise // reactor with promise
wsOps.request = function (data) { wsOps.request = function (data) {
if (ws_is_generated) { if ($rootScope.websocketIsOpen) {
var request = { var request = {
callbackID: Math.random().toString(36).substring(7), callbackID: Math.random().toString(36).substring(7),
data: data data: data
...@@ -152,7 +162,7 @@ angular.module('ulakbus') ...@@ -152,7 +162,7 @@ angular.module('ulakbus')
} }
); );
} else { } else {
// is ws_is_generated is not true try again in one second // is $rootScope.websocketIsOpen is not true try again in one second
$timeout(function () { $timeout(function () {
wsOps.request(data); wsOps.request(data);
}, 1000); }, 1000);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -200,7 +200,7 @@ angular.module("components/crud/templates/form.html", []).run(["$templateCache", ...@@ -200,7 +200,7 @@ angular.module("components/crud/templates/form.html", []).run(["$templateCache",
" </div>\n" + " </div>\n" +
" <div ng-repeat=\"node in ListNode\">\n" + " <div ng-repeat=\"node in ListNode\">\n" +
" <h3>{{ node.title }}\n" + " <h3>{{ node.title }}\n" +
" <span>\n" + " <span ng-if=\"meta.allow_add_listnode !== false\">\n" +
" <a modal-for-nodes=\"{{node.schema.model_name}},ListNode,add\">\n" + " <a modal-for-nodes=\"{{node.schema.model_name}},ListNode,add\">\n" +
" <i class=\"fa fa-plus-circle fa-fw\"></i>\n" + " <i class=\"fa fa-plus-circle fa-fw\"></i>\n" +
" </a>\n" + " </a>\n" +
...@@ -266,8 +266,9 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache", ...@@ -266,8 +266,9 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache",
" <select name=\"selective_list\" id=\"selective_list\"\n" + " <select name=\"selective_list\" id=\"selective_list\"\n" +
" ng-change=\"update_selective_list(selective_list_key)\"\n" + " ng-change=\"update_selective_list(selective_list_key)\"\n" +
" ng-model=\"selective_list_key\"\n" + " ng-model=\"selective_list_key\"\n" +
" ng-options=\"item as item.key for item in all_objects\"\n" +
" class=\"form-control\">\n" + " class=\"form-control\">\n" +
" <option ng-repeat=\"item in all_objects\" value=\"{{$index}}\" ng-selected=\"selective_list_key\">{{item.key}}</option>\n" + " <!--<option ng-repeat=\"item in all_objects\" value=\"{{$index}}\">{{item.key}}</option>-->\n" +
" </select>\n" + " </select>\n" +
" </div>\n" + " </div>\n" +
" <div class=\"tablescroll\" ng-if=\"objects[1]\">\n" + " <div class=\"tablescroll\" ng-if=\"objects[1]\">\n" +
......
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