Commit d7aeee26 authored by Evren Kutar's avatar Evren Kutar

notifications handling

crud ugly unrendered template masking on refresh
parent 0365916a
......@@ -2181,4 +2181,13 @@ table.dataTable thead .sorting:after {
#toast-container {
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')
// use crud without selected user
// important: regex urls must be defined later than static ones
.when('/:wf/', {
templateUrl: 'components/crud/templates/crud.html',
templateUrl: 'components/crud/templates/crud-preload.html',
controller: 'CRUDController'
})
.when('/:wf/do/:cmd', {
......@@ -43,7 +43,7 @@ angular.module('ulakbus')
controller: 'CRUDListFormController'
})
.when('/:wf/:model', {
templateUrl: 'components/crud/templates/crud.html',
templateUrl: 'components/crud/templates/crud-preload.html',
controller: 'CRUDController'
})
.when('/:wf/:model/do/:cmd', {
......
......@@ -156,6 +156,14 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
* @returns {object}
*/
.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.paginate = function (reloadData) {
......@@ -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
// a bit dirty way to find form working on but solves our problem
$scope.$on('formLocator', function (event) {
$scope.formgenerated = event.targetScope.formgenerated;
});
......@@ -203,6 +212,12 @@ angular.module('ulakbus.crud', ['schemaForm', 'ui.bootstrap', 'ulakbus.formServi
$scope.getNumber = function (num) {
return new Array(num);
};
// trust as html for using markdown support
$scope.trustAsHtml = function (value) {
return $sce.trustAsHtml(value);
}
// inline edit fields
$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}">
<msgbox ng-show="msgbox"></msgbox>
<h3 ng-class="{'mid-h3': !objects}">{{ schema.title }}</h3>
......@@ -7,4 +7,7 @@
<crud-list-directive ng-if="objects"></crud-list-directive>
</div>
<crud-filters ng-show="meta.allow_filters === true" class="col-md-4 filtre"></crud-filters>
</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 @@
<td ng-repeat="field in object.fields track by $index">
<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>
<!--<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>
......
......@@ -171,9 +171,9 @@
<!-- STUDENT MESSAGES -->
<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-title">Görevler</div>
<div class="panel-title">Mesajlar</div>
</div>
<div class="panel-body">
......
......@@ -37,31 +37,35 @@ angular.module('ulakbus')
* 1: tasks, 2: messages, 3: announcements, 4: recents
* - 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 {
templateUrl: 'shared/templates/directives/header-notification.html',
restrict: 'E',
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
* @param 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) {
$scope.notifications[value.type].push(value);
});
$scope.$apply();
};
/**
* When "notifications" send via websocket, parse notifications by type.
*/
$scope.$on("notifications", function (event, data) {
$scope.groupNotifications(data.notifications);
$scope.groupNotifications(data);
});
/**
......@@ -69,18 +73,15 @@ angular.module('ulakbus')
* @param items
* @todo: do it in detail page of notification
*/
$scope.markAsRead = function (items) {
//$http.post(RESTURL.url + "notify", {ignoreLoadingBar: true, read: [items]})
// .success(function (data) {
// $scope.groupNotifications(data.notifications);
// $rootScope.$broadcast("notifications", $scope.notifications);
// });
$scope.markAsRead = function (item, group, index) {
WSOps.doSend(angular.toJson({data: {view: 'notify', id:item.id}}));
$scope.notifications[group].splice(index,1);
};
// if markasread triggered outside the directive
$scope.$on("markasread", function (event, data) {
$scope.markAsRead(data);
});
// $scope.$on("markasread", function (event, data) {
// $scope.markAsRead(data);
// });
}
};
})
......
<ul class="nav navbar-top-links navbar-right">
<li class="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
class="fa fa-caret-down"></i>
</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'">
<a ng-click="markAsRead(notify)">
<a>
<div>
<strong>{{notify.title}}</strong>
<span class="pull-right text-muted">
......@@ -15,6 +15,7 @@
</span>
</div>
<div>{{notify.body}}...</div>
<span ng-click="markAsRead(notify, 2, $index)" class="pull-right fa fa-times"></span>
</a>
</li>
<li class="divider"></li>
......@@ -36,11 +37,12 @@
</a>
<ul class="dropdown-menu dropdown-tasks" ng-if="notifications[1].length > 0">
<li ng-repeat="notify in notifications[1] | limitTo: '8'">
<a ng-click="markAsRead(notify)">
<a>
<div>
<p>
<strong>{{notify.title}}</strong>
<span class="pull-right text-muted">{{notify.body}}</span>
<span ng-click="markAsRead(notify, 1, $index)" class="pull-right fa fa-times"></span>
</p>
<!-- todo: progress bar will be used in future developments-->
<!--<div class="progress progress-striped active">-->
......@@ -70,11 +72,12 @@
class="fa fa-caret-down"></i>
</a>
<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">
<div>
<i class="fa fa-comment fa-fw"></i> New Comment
<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>
</a>
</li>
......
......@@ -720,6 +720,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
generate_fields[v.type][v.widget || 'default'](scope, v, k);
}
catch (e) {
// raise not implemented
console.log(v.type)
}
});
......@@ -877,6 +878,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
});
} else {
$timeout(function () {
// todo: loop restrict listen ws open
generator.get_wf(scope);
}, 500);
}
......
......@@ -96,11 +96,11 @@ angular.module('ulakbus')
$log.info("Data without callback: %o", data);
}
},
error: function (data) {
ErrorService.handle(data, 'ws');
error: function () {
ErrorService.handle(msg_data, 'ws');
},
notification: function () {
$rootScope.$broadcast('notifications', data["notifications"]);
$rootScope.$broadcast('notifications', msg_data["notifications"]);
}
};
// do_action is the dispatcher function for incoming events
......@@ -115,7 +115,7 @@ angular.module('ulakbus')
return msg_methods[action](args[0]);
};
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));
};
......
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 {
margin-top: 90px;
}
.crud-mask {
width: 100%;
height: 100%;
background: #fff;
position: absolute;
top:43px; left:0;
z-index: 1000;
}
/*
* metismenu - v1.1.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