Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
0dca3c1f
Commit
0dca3c1f
authored
Jul 25, 2016
by
Vladimir Baranov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rref #5392. Add header indicators for unread messages and notifications
parent
54e0861f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
101 deletions
+58
-101
directives.js
app/shared/directives.js
+13
-63
header-notification.html
app/shared/templates/directives/header-notification.html
+45
-38
No files found.
app/shared/directives.js
View file @
0dca3c1f
...
@@ -32,78 +32,28 @@ angular.module('ulakbus')
...
@@ -32,78 +32,28 @@ angular.module('ulakbus')
* @ngdoc directive
* @ngdoc directive
* @name headerNotification
* @name headerNotification
* @description This directive is responsible to get and show notification.
* @description This directive is responsible to get and show notification.
* It calls API's /notify path with given interval and broadcasts `notifications` application-wide.
* It calls API's '_zops_unread_count' view to init its state and updates state when 'message' or 'notifications' broadcast message received *
* There are 4 types of notifications:
* 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
(
WSOps
,
$rootScope
,
$cookies
,
$interval
,
RESTURL
,
$uibModal
)
{
.
directive
(
'headerNotification'
,
function
(
$rootScope
,
$uibModal
,
MessagingService
)
{
return
{
return
{
templateUrl
:
'shared/templates/directives/header-notification.html'
,
templateUrl
:
'shared/templates/directives/header-notification.html'
,
restrict
:
'E'
,
restrict
:
'E'
,
replace
:
true
,
replace
:
true
,
scope
:
{},
scope
:
{},
controller
:
function
(
$scope
,
$log
)
{
controller
:
function
(
$scope
,
$log
)
{
// notification categories:
$scope
.
count
=
{
// 1: tasks, 2: messages, 3: announcements, 4: recents
messages
:
0
,
$scope
.
notifications
=
{
1
:
[],
2
:
[],
3
:
[],
4
:
[]};
notifications
:
0
/**
};
* Group notifications
function
initCounters
(){
* @param notifications
MessagingService
.
get_unread_messages_count
()
*/
.
then
(
function
(
result
){
$scope
.
count
.
messages
=
result
.
messages
;
$scope
.
popModal
=
function
(
item
){
$scope
.
count
.
notifiations
=
result
.
notifications
;
var
modalInstance
=
$uibModal
.
open
({
})
animation
:
true
,
templateUrl
:
'shared/templates/notificationsModalContent.html'
,
controller
:
function
(
$scope
){
$scope
.
notification
=
item
;
$scope
.
cancel
=
function
()
{
modalInstance
.
dismiss
(
'cancel'
);
};
},
size
:
'lg'
});
}
}
initCounters
();
$scope
.
groupNotifications
=
function
(
notifications
)
{
$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
)
{
$log
.
debug
(
"Notification!"
,
data
);
$scope
.
groupNotifications
(
data
);
});
/**
* When clicked mark the notification as read.
* @param items
* @todo: do it in detail page of notification
*/
$scope
.
markAsRead
=
function
(
event
,
item
,
group
,
index
)
{
//Added event parameter to stop propagate, so that behaviour of outsideClick won't be interrupted.
event
.
stopPropagation
();
WSOps
.
doSend
(
angular
.
toJson
({
data
:
{
view
:
'notify'
,
id
:
item
.
id
}}));
$scope
.
notifications
[
group
].
splice
(
index
,
1
);
$event
.
preventDefault
();
$event
.
stopPropagation
();
return
false
;
};
// if markasread triggered outside the directive
// $scope.$on("markasread", function (event, data) {
// $scope.markAsRead(data);
// });
}
}
};
};
})
})
...
...
app/shared/templates/directives/header-notification.html
View file @
0dca3c1f
...
@@ -32,9 +32,9 @@
...
@@ -32,9 +32,9 @@
</li>-->
</li>-->
<li
uib-dropdown
auto-close=
"outsideClick"
>
<li
uib-dropdown
auto-close=
"outsideClick"
>
<a
uib-dropdown-toggle
>
<a
uib-dropdown-toggle
>
<div
class=
"badge"
ng-show=
"
notifications[2].length > 0"
>
{{notifications[2].length
}}
</div>
<div
class=
"badge"
ng-show=
"
count.messages > 0"
>
{{count.messages
}}
</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>
class=
"fa fa-caret-down"
></i
>
<!--<i class="fa fa-caret-down"></i>--
>
</a>
</a>
<ul
class=
"dropdown-messages"
uib-dropdown-menu
ng-show=
"notifications[2].length > 0"
>
<ul
class=
"dropdown-messages"
uib-dropdown-menu
ng-show=
"notifications[2].length > 0"
>
<li
ng-repeat=
"notify in notifications[2] | limitTo: '8'"
>
<li
ng-repeat=
"notify in notifications[2] | limitTo: '8'"
>
...
@@ -62,47 +62,47 @@
...
@@ -62,47 +62,47 @@
<!-- /.dropdown-messages -->
<!-- /.dropdown-messages -->
</li>
</li>
<!-- /.dropdown -->
<!-- /.dropdown -->
<
li
uib-dropdown
auto-close=
"outsideClick"
>
<
!--<li uib-dropdown auto-close="outsideClick">--
>
<
a
uib-dropdown-toggle
>
<
!--<a uib-dropdown-toggle>--
>
<
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"
tooltip-placement=
"bottom"
uib-tooltip=
"Görevler"
></i>
<i
<
!--<i class="fa fa-tasks fa-fw" tooltip-placement="bottom" uib-tooltip="Görevler"></i> <i-->
class=
"fa fa-caret-down"
></i
>
<!--class="fa fa-caret-down"></i>--
>
<
/a
>
<
!--</a>--
>
<
ul
class=
"dropdown-tasks"
uib-dropdown-menu
ng-if=
"notifications[1].length > 0"
>
<
!--<ul class="dropdown-tasks" uib-dropdown-menu 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
href=
"{{notify.url}}"
>
<
!--<a href="{{notify.url}}">--
>
<
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($event,notify, 1, $index)"
class=
"pull-right fa fa-times"
></span
>
<
!--<span ng-click="markAsRead($event,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">–>
-->
<!--
<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
>
<
!--</div>--
>
<
/a
>
<
!--</a>--
>
<
/li
>
<
!--</li>--
>
<
li
class=
"divider"
></li
>
<
!--<li class="divider"></li>--
>
<
li
>
<
!--<li>--
>
<
a
class=
"text-center"
>
<
!--<a class="text-center">--
>
<
strong>
See All Tasks
</strong
>
<
!--<strong>See All Tasks</strong>--
>
<
i
class=
"fa fa-angle-right"
></i
>
<
!--<i class="fa fa-angle-right"></i>--
>
<
/a
>
<
!--</a>--
>
<
/li
>
<
!--</li>--
>
<
/ul
>
<
!--</ul>--
>
<!-- /.dropdown-tasks -->
<!-- /.dropdown-tasks -->
</li>
</li>
<!-- /.dropdown -->
<!-- /.dropdown -->
<li
uib-dropdown
auto-close=
"outsideClick"
>
<li
uib-dropdown
auto-close=
"outsideClick"
>
<a
uib-dropdown-toggle
>
<a
uib-dropdown-toggle
>
<div
class=
"badge"
ng-if=
"
notifications[3].length > 0"
>
{{notifications[3].length
}}
</div>
<div
class=
"badge"
ng-if=
"
count.notifications > 0"
>
{{count.notifications
}}
</div>
<i
class=
"fa fa-bell fa-fw"
tooltip-placement=
"bottom"
uib-tooltip=
"Duyurular"
></i>
<i
<i
class=
"fa fa-bell fa-fw"
tooltip-placement=
"bottom"
uib-tooltip=
"Duyurular"
></i>
class=
"fa fa-caret-down"
></i
>
<!--<i class="fa fa-caret-down"></i>--
>
</a>
</a>
<ul
class=
"dropdown-alerts"
uib-dropdown-menu
ng-if=
"notifications[3].length > 0"
>
<ul
class=
"dropdown-alerts"
uib-dropdown-menu
ng-if=
"notifications[3].length > 0"
>
<li
ng-repeat=
"notify in notifications[3] | limitTo: '8'"
>
<li
ng-repeat=
"notify in notifications[3] | limitTo: '8'"
>
...
@@ -114,6 +114,13 @@
...
@@ -114,6 +114,13 @@
</div>
</div>
</a>
</a>
</li>
</li>
<li
class=
"divider"
></li>
<li>
<a
class=
"text-center"
>
<strong>
See All Notifications
</strong>
<i
class=
"fa fa-angle-right"
></i>
</a>
</li>
</ul>
</ul>
<!-- /.dropdown-alerts -->
<!-- /.dropdown-alerts -->
</li>
</li>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment