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'])
* @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.
*/
.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.form_params = {};
$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) {
if (data.login) { $location.path('/'); }
$scope.form = [
......
......@@ -87,6 +87,7 @@ angular.module('ulakbus.auth')
$rootScope.loginAttempt = 0;
WSOps.request({wf: 'logout'}).then(function (data) {
$rootScope.loggedInUser = false;
$rootScope.current_user = true;
$log.debug("loggedout");
$location.path("/login");
WSOps.close();
......
......@@ -95,6 +95,9 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
if (scope.meta['selective_listing'] === true) {
angular.forEach(scope.objects, function (_v, _k) {
angular.forEach(_v.objects, function (value, key) {
if (_v.selected === true) {
scope.selected_key = _k;
}
if (key > 0) {
var linkIndexes = {};
angular.forEach(value.actions, function (v, k) {
......@@ -296,7 +299,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
// selective listing for list page todo: add to documentation
$scope.update_selective_list = function (key) {
$scope.objects = $scope.all_objects[key]["objects"];
$scope.objects = key["objects"];
};
// end of selective listing
$scope.listFormCmd = function () {
......@@ -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 ($scope.meta.selective_listing) {
if (angular.isDefined($scope.meta.selective_listing)) {
$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 () {
......
......@@ -20,7 +20,7 @@
</div>
<div ng-repeat="node in ListNode">
<h3>{{ node.title }}
<span>
<span ng-if="meta.allow_add_listnode !== false">
<a modal-for-nodes="{{node.schema.model_name}},ListNode,add">
<i class="fa fa-plus-circle fa-fw"></i>
</a>
......
......@@ -14,8 +14,9 @@
<select name="selective_list" id="selective_list"
ng-change="update_selective_list(selective_list_key)"
ng-model="selective_list_key"
ng-options="item as item.key for item in all_objects"
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>
</div>
<div class="tablescroll" ng-if="objects[1]">
......
......@@ -31,7 +31,6 @@ angular.module('ulakbus')
});
var websocket;
var ws_is_generated;
var refresh_count = 0;
var refresh_websocket = refresh_count < 5 ? 1000 : 5000;
var isSupported = function() {
......@@ -59,7 +58,6 @@ angular.module('ulakbus')
websocket.onerror = function (evt) {
wsOps.onError(evt)
};
ws_is_generated = true;
} else {
var error = {
error: "Tarayıcınız websocket desteklememektedir. Lütfen güncel bir tarayıcı kullanınız.",
......@@ -73,10 +71,22 @@ angular.module('ulakbus')
};
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) {
$rootScope.websocketIsOpen = true;
$log.info("CONNECTED", evt);
wsOps.loggedOut === false;
keepAlivePing(30000);
wsOps.loggedOut = false;
};
wsOps.onClose = function (event) {
$rootScope.websocketIsOpen = false;
......@@ -136,7 +146,7 @@ angular.module('ulakbus')
};
// reactor with promise
wsOps.request = function (data) {
if (ws_is_generated) {
if ($rootScope.websocketIsOpen) {
var request = {
callbackID: Math.random().toString(36).substring(7),
data: data
......@@ -152,7 +162,7 @@ angular.module('ulakbus')
}
);
} 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 () {
wsOps.request(data);
}, 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",
" </div>\n" +
" <div ng-repeat=\"node in ListNode\">\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" +
" <i class=\"fa fa-plus-circle fa-fw\"></i>\n" +
" </a>\n" +
......@@ -266,8 +266,9 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache",
" <select name=\"selective_list\" id=\"selective_list\"\n" +
" ng-change=\"update_selective_list(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" +
" <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" +
" </div>\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