Commit d7aeee26 authored by Evren Kutar's avatar Evren Kutar

notifications handling

crud ugly unrendered template masking on refresh
parent 0365916a
...@@ -2182,3 +2182,12 @@ table.dataTable thead .sorting:after { ...@@ -2182,3 +2182,12 @@ table.dataTable thead .sorting:after {
#toast-container { #toast-container {
margin-top: 90px; margin-top: 90px;
} }
.crud-mask {
width: 100%;
height: 100%;
background: #fff;
position: absolute;
top:43px; left:0;
z-index: 1000;
}
\ No newline at end of file
...@@ -31,7 +31,7 @@ angular.module('ulakbus') ...@@ -31,7 +31,7 @@ angular.module('ulakbus')
// use crud without selected user // use crud without selected user
// important: regex urls must be defined later than static ones // important: regex urls must be defined later than static ones
.when('/:wf/', { .when('/:wf/', {
templateUrl: 'components/crud/templates/crud.html', templateUrl: 'components/crud/templates/crud-preload.html',
controller: 'CRUDController' controller: 'CRUDController'
}) })
.when('/:wf/do/:cmd', { .when('/:wf/do/:cmd', {
...@@ -43,7 +43,7 @@ angular.module('ulakbus') ...@@ -43,7 +43,7 @@ angular.module('ulakbus')
controller: 'CRUDListFormController' controller: 'CRUDListFormController'
}) })
.when('/:wf/:model', { .when('/:wf/:model', {
templateUrl: 'components/crud/templates/crud.html', templateUrl: 'components/crud/templates/crud-preload.html',
controller: 'CRUDController' controller: 'CRUDController'
}) })
.when('/:wf/:model/do/:cmd', { .when('/:wf/:model/do/:cmd', {
......
...@@ -156,6 +156,14 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -156,6 +156,14 @@ 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) {
// below show crud and $on --> $viewContentLoaded callback is for masking the view with unrendered and ugly html
$scope.show_crud = false;
$scope.$on('$viewContentLoaded', function () {
$timeout(function () {
$scope.show_crud = true;
}, 500);
});
$scope.wf_step = $routeParams.step; $scope.wf_step = $routeParams.step;
$scope.paginate = function (reloadData) { $scope.paginate = function (reloadData) {
...@@ -179,6 +187,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -179,6 +187,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
// object by its name. to manage to locate the form to controllers scope we use a directive called form locator // object by its name. to manage to locate the form to controllers scope we use a directive called form locator
// a bit dirty way to find form working on but solves our problem // a bit dirty way to find form working on but solves our problem
$scope.$on('formLocator', function (event) { $scope.$on('formLocator', function (event) {
$scope.formgenerated = event.targetScope.formgenerated; $scope.formgenerated = event.targetScope.formgenerated;
}); });
...@@ -204,6 +213,12 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi ...@@ -204,6 +213,12 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
return new Array(num); return new Array(num);
}; };
// trust as html for using markdown support
$scope.trustAsHtml = function (value) {
return $sce.trustAsHtml(value);
}
// inline edit fields // inline edit fields
$scope.datepickerstatuses = {}; $scope.datepickerstatuses = {};
......
<div class="crud-mask">
<span class="loader"></span>
</div>
\ No newline at end of file
<div class="container-fluid"> <div ng-hide="show_crud === false" class="container-fluid">
<div ng-class="{'col-md-8': meta.allow_filters}"> <div ng-class="{'col-md-8': meta.allow_filters}">
<msgbox ng-show="msgbox"></msgbox> <msgbox ng-show="msgbox"></msgbox>
<h3 ng-class="{'mid-h3': !objects}">{{ schema.title }}</h3> <h3 ng-class="{'mid-h3': !objects}">{{ schema.title }}</h3>
...@@ -8,3 +8,6 @@ ...@@ -8,3 +8,6 @@
</div> </div>
<crud-filters ng-show="meta.allow_filters === true" class="col-md-4 filtre"></crud-filters> <crud-filters ng-show="meta.allow_filters === true" class="col-md-4 filtre"></crud-filters>
</div> </div>
<div ng-show="show_crud === false" class="crud-mask">
<span class="loader"></span>
</div>
\ No newline at end of file
...@@ -44,8 +44,11 @@ ...@@ -44,8 +44,11 @@
<td ng-repeat="field in object.fields track by $index"> <td ng-repeat="field in object.fields track by $index">
<a role="button" ng-if="field.type==='link'" <a role="button" ng-if="field.type==='link'"
ng-click="do_action(object.key, field)" ng-bind-html="field.content || '' | markdown"></a> ng-click="do_action(object.key, field)"><markdown ng-bind-html="field.content"></markdown></a>
<span ng-if="field.type==='str'" ng-bind-html="field.content || '' | markdown"></span> <span ng-if="field.type==='str'" ng-bind-html="field.content || '' | markdown"></span>
<!--<a role="button" ng-if="field.type==='link'"-->
<!--ng-click="do_action(object.key, field)">{{trustashtml(field.content) | markdown}}</a>-->
<!--<span ng-if="field.type==='str'">{{trustashtml(field.content) | markdown}}</span>-->
</td> </td>
<td> <td>
......
...@@ -171,9 +171,9 @@ ...@@ -171,9 +171,9 @@
<!-- STUDENT MESSAGES --> <!-- STUDENT MESSAGES -->
<div class="col-lg-6 col-md-12 student-message-list"> <div class="col-lg-6 col-md-12 student-message-list">
<div class="panel panel-default"> <div class="panel panel-d efault">
<div class="panel-heading"> <div class="panel-heading">
<div class="panel-title">Görevler</div> <div class="panel-title">Mesajlar</div>
</div> </div>
<div class="panel-body"> <div class="panel-body">
......
...@@ -37,31 +37,35 @@ angular.module('ulakbus') ...@@ -37,31 +37,35 @@ angular.module('ulakbus')
* 1: tasks, 2: messages, 3: announcements, 4: recents * 1: tasks, 2: messages, 3: announcements, 4: recents
* - Notifications can be disabled in /dev/settings page * - Notifications can be disabled in /dev/settings page
*/ */
.directive('headerNotification', function ($http, $rootScope, $cookies, $interval, RESTURL) { .directive('headerNotification', function (WSOps, $rootScope, $cookies, $interval, RESTURL) {
return { return {
templateUrl: 'shared/templates/directives/header-notification.html', templateUrl: 'shared/templates/directives/header-notification.html',
restrict: 'E', restrict: 'E',
replace: true, replace: true,
link: function ($scope) { scope: {},
controller: function ($scope) {
// notification categories:
// 1: tasks, 2: messages, 3: announcements, 4: recents
$scope.notifications = {1: [], 2: [], 3: [], 4: []};
/** /**
* Group notifications * Group notifications
* @param notifications * @param notifications
*/ */
$scope.groupNotifications = function (notifications) { $scope.groupNotifications = function (notifications) {
// notification categories:
// 1: tasks, 2: messages, 3: announcements, 4: recents // $scope.notifications = {1: [], 2: [], 3: [], 4: []};
$scope.notifications = {1: [], 2: [], 3: [], 4: []};
angular.forEach(notifications, function (value, key) { angular.forEach(notifications, function (value, key) {
$scope.notifications[value.type].push(value); $scope.notifications[value.type].push(value);
}); });
$scope.$apply();
}; };
/** /**
* When "notifications" send via websocket, parse notifications by type. * When "notifications" send via websocket, parse notifications by type.
*/ */
$scope.$on("notifications", function (event, data) { $scope.$on("notifications", function (event, data) {
$scope.groupNotifications(data.notifications); $scope.groupNotifications(data);
}); });
/** /**
...@@ -69,18 +73,15 @@ angular.module('ulakbus') ...@@ -69,18 +73,15 @@ angular.module('ulakbus')
* @param items * @param items
* @todo: do it in detail page of notification * @todo: do it in detail page of notification
*/ */
$scope.markAsRead = function (items) { $scope.markAsRead = function (item, group, index) {
//$http.post(RESTURL.url + "notify", {ignoreLoadingBar: true, read: [items]}) WSOps.doSend(angular.toJson({data: {view: 'notify', id:item.id}}));
// .success(function (data) { $scope.notifications[group].splice(index,1);
// $scope.groupNotifications(data.notifications);
// $rootScope.$broadcast("notifications", $scope.notifications);
// });
}; };
// if markasread triggered outside the directive // if markasread triggered outside the directive
$scope.$on("markasread", function (event, data) { // $scope.$on("markasread", function (event, data) {
$scope.markAsRead(data); // $scope.markAsRead(data);
}); // });
} }
}; };
}) })
......
<ul class="nav navbar-top-links navbar-right"> <ul class="nav navbar-top-links navbar-right">
<li class="dropdown"> <li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown">
<div class="badge" ng-if="notifications[2].length > 0">{{notifications[2].length}}</div> <div class="badge" ng-show="notifications[2].length > 0">{{notifications[2].length}}</div>
<i class="fa fa-envelope fa-fw" tooltip-placement="bottom" uib-tooltip="Mesajlar"></i> <i <i class="fa fa-envelope fa-fw" tooltip-placement="bottom" uib-tooltip="Mesajlar"></i> <i
class="fa fa-caret-down"></i> class="fa fa-caret-down"></i>
</a> </a>
<ul class="dropdown-menu dropdown-messages" ng-if="notifications[2].length > 0"> <ul class="dropdown-menu dropdown-messages" ng-show="notifications[2].length > 0">
<li ng-repeat="notify in notifications[2] | limitTo: '8'"> <li ng-repeat="notify in notifications[2] | limitTo: '8'">
<a ng-click="markAsRead(notify)"> <a>
<div> <div>
<strong>{{notify.title}}</strong> <strong>{{notify.title}}</strong>
<span class="pull-right text-muted"> <span class="pull-right text-muted">
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
</span> </span>
</div> </div>
<div>{{notify.body}}...</div> <div>{{notify.body}}...</div>
<span ng-click="markAsRead(notify, 2, $index)" class="pull-right fa fa-times"></span>
</a> </a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
...@@ -36,11 +37,12 @@ ...@@ -36,11 +37,12 @@
</a> </a>
<ul class="dropdown-menu dropdown-tasks" ng-if="notifications[1].length > 0"> <ul class="dropdown-menu dropdown-tasks" ng-if="notifications[1].length > 0">
<li ng-repeat="notify in notifications[1] | limitTo: '8'"> <li ng-repeat="notify in notifications[1] | limitTo: '8'">
<a ng-click="markAsRead(notify)"> <a>
<div> <div>
<p> <p>
<strong>{{notify.title}}</strong> <strong>{{notify.title}}</strong>
<span class="pull-right text-muted">{{notify.body}}</span> <span class="pull-right text-muted">{{notify.body}}</span>
<span ng-click="markAsRead(notify, 1, $index)" class="pull-right fa fa-times"></span>
</p> </p>
<!-- todo: progress bar will be used in future developments--> <!-- todo: progress bar will be used in future developments-->
<!--<div class="progress progress-striped active">--> <!--<div class="progress progress-striped active">-->
...@@ -70,11 +72,12 @@ ...@@ -70,11 +72,12 @@
class="fa fa-caret-down"></i> class="fa fa-caret-down"></i>
</a> </a>
<ul class="dropdown-menu dropdown-alerts" ng-if="notifications[3].length > 0"> <ul class="dropdown-menu dropdown-alerts" ng-if="notifications[3].length > 0">
<li> <li ng-repeat="notify in notifications[3] | limitTo: '8'">
<a role="button"> <a role="button">
<div> <div>
<i class="fa fa-comment fa-fw"></i> New Comment <i class="fa fa-comment fa-fw"></i> New Comment
<span class="pull-right text-muted small">4 minutes ago</span> <span class="pull-right text-muted small">4 minutes ago</span>
<span ng-click="markAsRead(notify, 3, $index)" class="pull-right fa fa-times"></span>
</div> </div>
</a> </a>
</li> </li>
......
...@@ -720,6 +720,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -720,6 +720,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
generate_fields[v.type][v.widget || 'default'](scope, v, k); generate_fields[v.type][v.widget || 'default'](scope, v, k);
} }
catch (e) { catch (e) {
// raise not implemented
console.log(v.type) console.log(v.type)
} }
}); });
...@@ -877,6 +878,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -877,6 +878,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}); });
} else { } else {
$timeout(function () { $timeout(function () {
// todo: loop restrict listen ws open
generator.get_wf(scope); generator.get_wf(scope);
}, 500); }, 500);
} }
......
...@@ -96,11 +96,11 @@ angular.module('ulakbus') ...@@ -96,11 +96,11 @@ angular.module('ulakbus')
$log.info("Data without callback: %o", data); $log.info("Data without callback: %o", data);
} }
}, },
error: function (data) { error: function () {
ErrorService.handle(data, 'ws'); ErrorService.handle(msg_data, 'ws');
}, },
notification: function () { notification: function () {
$rootScope.$broadcast('notifications', data["notifications"]); $rootScope.$broadcast('notifications', msg_data["notifications"]);
} }
}; };
// do_action is the dispatcher function for incoming events // do_action is the dispatcher function for incoming events
...@@ -115,7 +115,7 @@ angular.module('ulakbus') ...@@ -115,7 +115,7 @@ angular.module('ulakbus')
return msg_methods[action](args[0]); return msg_methods[action](args[0]);
}; };
var msg_data = angular.fromJson(event.data); var msg_data = angular.fromJson(event.data);
do_action(msg_data, msg_data.error || msg_data.notification); do_action(msg_data, msg_data.cmd || 'error');
$log.info("MESSAGE:", event, "Data:", JSON.parse(event.data)); $log.info("MESSAGE:", event, "Data:", JSON.parse(event.data));
}; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -2197,6 +2197,15 @@ table.dataTable thead .sorting:after { ...@@ -2197,6 +2197,15 @@ table.dataTable thead .sorting:after {
margin-top: 90px; margin-top: 90px;
} }
.crud-mask {
width: 100%;
height: 100%;
background: #fff;
position: absolute;
top:43px; left:0;
z-index: 1000;
}
/* /*
* metismenu - v1.1.3 * metismenu - v1.1.3
* Easy menu jQuery plugin for Twitter Bootstrap 3 * Easy menu jQuery plugin for Twitter Bootstrap 3
......
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