Commit 12e3097e authored by Evren Kutar's avatar Evren Kutar

Merge branch 'issue14_notifications'

parents 60b9cca1 bc2bedf1
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<!-- end of right-sidebar-title --> <!-- end of right-sidebar-title -->
<div class="right-sidebar-message-block" ng-repeat="notify in notifications[2] | limitTo:5"> <div class="right-sidebar-message-block" ng-repeat="notify in notifications[2] | limitTo:5">
<a class="clearfix" href="javascript:void(0)"> <a class="clearfix" href="javascript:void(0)" ng-click="markAsRead(notify)">
<img src="../../../img/sample-profile-pic.jpg"> <img src="../../../img/sample-profile-pic.jpg">
<div class="right-sidebar-message-content"> <div class="right-sidebar-message-content">
<div>{{notify.title}}</div> <div>{{notify.title}}</div>
...@@ -110,8 +110,8 @@ ...@@ -110,8 +110,8 @@
<!-- end of right-sidebar-task-block --> <!-- end of right-sidebar-task-block -->
<div class="right-sidebar-task-block"> <div class="right-sidebar-task-block">
<div class="task-type">Onay Bekleyen Görevler</div> <!--<div class="task-type">Onay Bekleyen Görevler</div>-->
<a href="javascript:void(0)" ng-repeat="notify in notifications[1] | limitTo:5"> <a href="javascript:void(0)" ng-click="markAsRead(notify)" ng-repeat="notify in notifications[1] | limitTo:5">
<div class="task-title">{{notify.title}}</div> <div class="task-title">{{notify.title}}</div>
</a> </a>
</div> </div>
...@@ -133,7 +133,9 @@ ...@@ -133,7 +133,9 @@
<!-- end of right-sidebar-title --> <!-- end of right-sidebar-title -->
<div class="right-sidebar-announcement-block"> <div class="right-sidebar-announcement-block">
<a href="javascript:void(0)" ng-repeat="notify in notifications[3] | limitTo:5">{{notify.body}}</a> <a href="javascript:void(0)" ng-click="markAsRead(notify)"
ng-repeat="notify in notifications[3] | limitTo:5">{{notify
.body}}</a>
</div> </div>
<!-- end of right-sidebar-status-block --> <!-- end of right-sidebar-status-block -->
...@@ -152,10 +154,10 @@ ...@@ -152,10 +154,10 @@
</div> </div>
<!-- end of right-sidebar-title --> <!-- end of right-sidebar-title -->
<div class="right-sidebar-last-action-block"> <!--<div class="right-sidebar-last-action-block">-->
<a href="javascript:void(0)">Birinci dönem bitimine 10 gün kaldı.</a> <!--<a href="javascript:void(0)">Birinci dönem bitimine 10 gün kaldı.</a>-->
<a href="javascript:void(0)">Ders seçimi işlemleri xx tarihinde başlayacaktır.</a> <!--<a href="javascript:void(0)">Ders seçimi işlemleri xx tarihinde başlayacaktır.</a>-->
</div> <!--</div>-->
<!-- end of right-sidebar-status-block --> <!-- end of right-sidebar-status-block -->
</div> </div>
......
...@@ -73,6 +73,10 @@ angular.module('ulakbus.dashboard', ['ngRoute']) ...@@ -73,6 +73,10 @@ angular.module('ulakbus.dashboard', ['ngRoute'])
$scope.notifications = data; $scope.notifications = data;
}); });
$scope.markAsRead = function (items) {
$rootScope.$broadcast("markasread", items);
}
}) })
.directive('sidebarNotifications', function () { .directive('sidebarNotifications', function () {
......
...@@ -17,7 +17,7 @@ var wf = angular.module('ulakbus.wf', ['ui.bootstrap', 'schemaForm', 'formServic ...@@ -17,7 +17,7 @@ var wf = angular.module('ulakbus.wf', ['ui.bootstrap', 'schemaForm', 'formServic
*/ */
wf.controller('WFAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams) { wf.controller('WFAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams) {
$scope.url = ""; debugger; $scope.url = "";
$scope.form_params = {'model': $routeParams.model}; $scope.form_params = {'model': $routeParams.model};
//if ($routeParams.id) { //if ($routeParams.id) {
// $scope.form_params['object_id'] = $routeParams.id; // $scope.form_params['object_id'] = $routeParams.id;
......
...@@ -32,7 +32,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST ...@@ -32,7 +32,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
restrict: 'E', restrict: 'E',
replace: true, replace: true,
link: function ($scope) { link: function ($scope) {
$interval(function () { $scope.getNotifications = function () {
// ignore loading bar here // ignore loading bar here
$http.get(RESTURL.url+"notify", {ignoreLoadingBar: true}).success(function (data) { $http.get(RESTURL.url+"notify", {ignoreLoadingBar: true}).success(function (data) {
// notification categories: // notification categories:
...@@ -44,7 +44,28 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST ...@@ -44,7 +44,28 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
}); });
$rootScope.$broadcast("notifications", $scope.notifications); $rootScope.$broadcast("notifications", $scope.notifications);
}); });
};
$scope.getNotifications();
// check notifications every 5 seconds
$interval(function () {
$scope.getNotifications();
}, 5000); }, 5000);
// when clicked mark as read notification
// it can be list of notifications
$scope.markAsRead = function (items) {
$http.post(RESTURL.url+"notify", {ignoreLoadingBar: true, read: items})
.success(function (data) {
console.log(data);
});
};
// if markasread triggered outside the directive
$scope.$on("markasread", function (event, data) {
$scope.markAsRead(data);
});
} }
}; };
}); });
......
...@@ -4,21 +4,21 @@ ...@@ -4,21 +4,21 @@
<div class="badge" ng-if="notifications[2].length > 0">{{notifications[2].length}}</div> <div class="badge" ng-if="notifications[2].length > 0">{{notifications[2].length}}</div>
<i class="fa fa-envelope fa-fw"></i> <i class="fa fa-caret-down"></i> <i class="fa fa-envelope fa-fw"></i> <i class="fa fa-caret-down"></i>
</a> </a>
<ul class="dropdown-menu dropdown-messages"> <ul class="dropdown-menu dropdown-messages" ng-if="notifications[2].length > 0">
<li> <li ng-repeat="notify in notifications[2] | limitTo: '8'">
<a href="#"> <a href="javascript:void(0)" ng-click="markAsRead(notify)">
<div> <div>
<strong>John Smith</strong> <strong>{{notify.title}}</strong>
<span class="pull-right text-muted"> <span class="pull-right text-muted">
<em>Yesterday</em> <em>22 Ekim 2015</em>
</span> </span>
</div> </div>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...</div> <div>{{notify.body}}...</div>
</a> </a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li> <li>
<a class="text-center" href="#"> <a class="text-center" href="javascript:void(0)">
<strong>Read All Messages</strong> <strong>Read All Messages</strong>
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
...@@ -32,30 +32,32 @@ ...@@ -32,30 +32,32 @@
<div class="badge" ng-if="notifications[1].length > 0">{{notifications[1].length}}</div> <div class="badge" ng-if="notifications[1].length > 0">{{notifications[1].length}}</div>
<i class="fa fa-tasks fa-fw"></i> <i class="fa fa-caret-down"></i> <i class="fa fa-tasks fa-fw"></i> <i class="fa fa-caret-down"></i>
</a> </a>
<!--<ul class="dropdown-menu dropdown-tasks">--> <ul class="dropdown-menu dropdown-tasks" ng-if="notifications[1].length > 0">
<!--<li>--> <li ng-repeat="notify in notifications[1] | limitTo: '8'">
<!--<a href="#">--> <a href="javascript:void(0)" ng-click="markAsRead(notify)">
<!--<div>--> <div>
<!--<p>--> <p>
<!--<strong>Task 1</strong>--> <strong>{{notify.title}}</strong>
<!--<span class="pull-right text-muted">40% Complete</span>--> <span class="pull-right text-muted">{{notify.body}}</span>
<!--</p>--> </p>
<!-- todo: progress bar will be used in future developments-->
<!--<div class="progress progress-striped active">--> <!--<div class="progress progress-striped active">-->
<!--<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">--> <!--<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">-->
<!--<span class="sr-only">40% Complete (success)</span>--> <!--<span class="sr-only">40% Complete (success)</span>-->
<!--</div>--> <!--</div>-->
<!--</div>--> <!--</div>-->
<!--</div>-->
<!--</a>--> </div>
<!--</li>--> </a>
<!--<li class="divider"></li>--> </li>
<!--<li>--> <li class="divider"></li>
<!--<a class="text-center" href="#">--> <li>
<!--<strong>See All Tasks</strong>--> <a class="text-center" href="javascript:void(0)">
<!--<i class="fa fa-angle-right"></i>--> <strong>See All Tasks</strong>
<!--</a>--> <i class="fa fa-angle-right"></i>
<!--</li>--> </a>
<!--</ul>--> </li>
</ul>
<!-- /.dropdown-tasks --> <!-- /.dropdown-tasks -->
</li> </li>
<!-- /.dropdown --> <!-- /.dropdown -->
...@@ -64,59 +66,16 @@ ...@@ -64,59 +66,16 @@
<div class="badge" ng-if="notifications[3].length > 0">{{notifications[3].length}}</div> <div class="badge" ng-if="notifications[3].length > 0">{{notifications[3].length}}</div>
<i class="fa fa-bell fa-fw"></i> <i class="fa fa-caret-down"></i> <i class="fa fa-bell fa-fw"></i> <i class="fa fa-caret-down"></i>
</a> </a>
<!--<ul class="dropdown-menu dropdown-alerts">--> <ul class="dropdown-menu dropdown-alerts" ng-if="notifications[3].length > 0">
<!--<li>--> <li>
<!--<a href="#">--> <a href="javascript:void(0)">
<!--<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>
<!--</div>--> </div>
<!--</a>--> </a>
<!--</li>--> </li>
<!--<li class="divider"></li>--> </ul>
<!--<li>-->
<!--<a href="#">-->
<!--<div>-->
<!--<i class="fa fa-twitter fa-fw"></i> 3 New Followers-->
<!--<span class="pull-right text-muted small">12 minutes ago</span>-->
<!--</div>-->
<!--</a>-->
<!--</li>-->
<!--<li class="divider"></li>-->
<!--<li>-->
<!--<a href="#">-->
<!--<div>-->
<!--<i class="fa fa-envelope fa-fw"></i> Message Sent-->
<!--<span class="pull-right text-muted small">4 minutes ago</span>-->
<!--</div>-->
<!--</a>-->
<!--</li>-->
<!--<li class="divider"></li>-->
<!--<li>-->
<!--<a href="#">-->
<!--<div>-->
<!--<i class="fa fa-tasks fa-fw"></i> New Task-->
<!--<span class="pull-right text-muted small">4 minutes ago</span>-->
<!--</div>-->
<!--</a>-->
<!--</li>-->
<!--<li class="divider"></li>-->
<!--<li>-->
<!--<a href="#">-->
<!--<div>-->
<!--<i class="fa fa-upload fa-fw"></i> Server Rebooted-->
<!--<span class="pull-right text-muted small">4 minutes ago</span>-->
<!--</div>-->
<!--</a>-->
<!--</li>-->
<!--<li class="divider"></li>-->
<!--<li>-->
<!--<a class="text-center" href="#">-->
<!--<strong>See All Alerts</strong>-->
<!--<i class="fa fa-angle-right"></i>-->
<!--</a>-->
<!--</li>-->
<!--</ul>-->
<!-- /.dropdown-alerts --> <!-- /.dropdown-alerts -->
</li> </li>
<!-- /.dropdown --> <!-- /.dropdown -->
...@@ -125,9 +84,9 @@ ...@@ -125,9 +84,9 @@
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i> <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
</a> </a>
<ul class="dropdown-menu dropdown-user"> <ul class="dropdown-menu dropdown-user">
<li><a href="#"><i class="fa fa-user fa-fw"></i> Profil</a> <li><a href="javascript:void(0)"><i class="fa fa-user fa-fw"></i> Profil</a>
</li> </li>
<li><a href="#"><i class="fa fa-gear fa-fw"></i> Ayarlar</a> <li><a href="javascript:void(0)"><i class="fa fa-gear fa-fw"></i> Ayarlar</a>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
<li><a ui-sref="login" href="javascript:void(0);" logout><i class="fa fa-sign-out fa-fw"></i> Çıkış</a> <li><a ui-sref="login" href="javascript:void(0);" logout><i class="fa fa-sign-out fa-fw"></i> Çıkış</a>
......
...@@ -56,12 +56,12 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form ...@@ -56,12 +56,12 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
if (v.type === 'submit' || v.type === 'button') { if (v.type === 'submit' || v.type === 'button') {
//k.type = 'button'; //k.type = 'button';
angular.forEach(scope.form, function (value, key) { debugger;
if (value === v) { scope.form[scope.form.indexOf(k)] = {
v.type = 'button'; type: v.type,
scope.form[key] = {type: v.type, title: v.title, onClick: function(){scope.model[v]=1;generator.submit(scope);}}; title: v.title,
} onClick: function(){scope.model[v]=1;generator.submit(scope);}
}); };
} }
if (v.type === 'date') { if (v.type === 'date') {
...@@ -185,7 +185,8 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form ...@@ -185,7 +185,8 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
// generically change _id fields model value // generically change _id fields model value
if (k == scope.form_params.param) { if (k == scope.form_params.param) { debugger;
scope.model[k] = scope.form_params.id; scope.model[k] = scope.form_params.id;
scope.form.splice(scope.form.indexOf(k), 1); scope.form.splice(scope.form.indexOf(k), 1);
} }
......
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