Skip to content

Commit

Permalink
Hide notifications and disable new notification creation (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinasr authored Nov 28, 2018
1 parent 64811d7 commit 35903e9
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 86 deletions.
1 change: 0 additions & 1 deletion mcm/HTML/batches.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/batches_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/campaigns.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/campaigns_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>

<body ng-controller="mainCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/chained_campaigns.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/chainedCampaigns_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/chained_requests.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/chainRequests_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/dashboard_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
2 changes: 0 additions & 2 deletions mcm/HTML/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
<script src="scripts/main_controller.js"></script>
<script src="scripts/edit.js"></script>
<script src="scripts/edit_controller.js"></script>
<script src="scripts/notifications.js"></script>

<!-- angularui is needed for codemirror -->
<script src="scripts/codemirror-3.11/lib/codemirror-compressed.js"></script>
<script src="scripts/angular-ui.min.js"></script>
Expand Down
2 changes: 0 additions & 2 deletions mcm/HTML/edit_many.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
<script src="scripts/main_controller.js"></script>
<script src="scripts/edit.js"></script>
<script src="scripts/edit_many_controller.js"></script>
<script src="scripts/notifications.js"></script>

<!-- // <script src="scripts/codemirror-3.11/lib/codemirror.js"></script> -->
<!-- // <script src="scripts/codemirror-3.11/mode/python/python.js"></script> -->
<script src="scripts/codemirror-3.11/lib/codemirror-compressed.js"></script>
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/flows.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/flows_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>

<body ng-controller="mainCtrl">
Expand Down
2 changes: 0 additions & 2 deletions mcm/HTML/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>McM</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="scripts/build/mcmcss.css" rel="stylesheet"/>

<script type="text/javascript" src="scripts/build/mcm.deps1.js"></script>

<!--[IF IE]>
Expand All @@ -20,7 +19,6 @@

<script src="scripts/main_controller.js"></script>
<script src="scripts/index_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<div ng-include="'HTML/navbar_template.html'"></div>
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/injection_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/injection_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/invalidations.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/invalidations_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/lists.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/lists_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/mccms.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/mccms_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
50 changes: 1 addition & 49 deletions mcm/HTML/navbar_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,55 +82,7 @@
<li class="divider-vertical" ></li>
<ul class="nav pull-right">
<li>
<a ng-href='users?prepid={{user.name}}' target="_blank">{{user.name}} : {{user.role}} </a>
</li>
<li ng-controller="notificator">
<div class="notification-overlay" ng-style="{ 'height': overlay_height }">
<a href="javascript:void(0)" class="closebtn" ng-click="overlay_height = '0%';">&times;</a>
<h3 style="color: white; overflow-y: scroll;">{{overlay_title}}</h3>
<pre class="overlay-text">{{overlay_message}}</pre>
</div>
<span style=" position: absolute; right: -16px; cursor: pointer;" ng-click="displayNotifications();">
<img style="width: 30px" src="scripts/img/notification_icon.png"></img>
<div class="circle" ng-show="notification_numbers.All > 0">
<h5 style="color: white; width: 25px; text-align: center;" id="notification_number">{{unseen > 99 ? '99+' : unseen}}</h5>
</div>
</span>
<div id="mySidenav" class="sidenav" ng-show="display_notifications">
<a href="#" ng-style="{ 'left': search_on ? -520 : -233, 'background-color': '#63CCCA' }" ng-click="search_on = !search_on" ng-init="search_on = false">
<i ng-class="!search_on ? 'icon-search' : 'icon-chevron-right'"></i>
<input ng-change="search()" ng-model-options="{debounce:1000}" ng-click="search_on = false" type="text" class="notification-search-bar" name="input" ng-model="search_text">
</a>
</div>
<div class="notification-dropdown" ng-show="display_notifications" ng-style="!search_on ? {} : { 'background-color': '#FAFAFA' }">
<div ng-if="!search_on" class="notification-group" ng-repeat="group in sorted_groups" >
<div ng-click="showGroup(group);" class="notification-header">
<h3>{{group.split('_').join(' ') + ' (' + notification_numbers[group] + ')'}}</h3>
<i ng-if="group_object.hasOwnProperty(group)" rel="tooltip" title="See all related objects" ng-click="showGroupActions(group, $event);" class="icon-chevron-right"></i>
<i ng-click="markGroupAsSeen(group, $event);" rel="tooltip" title="Marked as seen" class="icon-eye-open"></i>
</div>
<div class="notification" ng-show="notifications[group].is_selected" ng-repeat="notification in notifications[group].notifications" ng-style="notification.seen ? {} : { 'background-color': '#B0D0D3' }" ng-click="showNotification(notification);">
<img class="notification-eye" ng-if="notification.seen" src="scripts/img/seen.png"></img>
<img class="notification-eye" ng-if="!notification.seen" src="scripts/img/unseen.png"></img>
<h5>{{notification.title}}</h5>
<span class="notification-date">{{notification.created_at}}</span>
<i ng-if="notification.action_objects.length > 0" ng-click="showActions(notification.object_type, notification._id, notification.seen, $event)" rel="tooltip" title="See all related objects" class="icon-chevron-right"></i>
</div>
<div ng-if="notifications[group].more_to_fetch && notifications[group].is_selected" style="background-color: white;" ng-click="fetchNotifications(group);">
<i class="icon-chevron-down"></i>
</div>
</div>
<div class="notification" ng-if="search_on" ng-repeat="notification in searched_notifications" ng-style="notification.seen ? {} : { 'background-color': '#B0D0D3' }" ng-click="showNotification(notification);">
<img class="notification-eye" ng-if="notification.seen" src="scripts/img/seen.png"></img>
<img class="notification-eye" ng-if="!notification.seen" src="scripts/img/unseen.png"></img>
<h5>{{notification.title}}</h5>
<span class="notification-date">{{notification.created_at}}</span>
<i ng-if="notification.action_objects.length > 0" ng-click="showActions(notification.object_type, notification._id, notification.seen, $event)" rel="tooltip" title="See all related objects" class="icon-chevron-right"></i>
</div>
<div style="text-align: center; cursor: pointer;" ng-if="search_on && search_items_left" style="background-color: white;" ng-click="continueSearch();">
<i class="icon-chevron-down"></i>
</div>
</div>
<a ng-href='users?prepid={{user.name}}' target="_blank">{{user.name}} ({{user.role}})</a>
</li>
</ul>
</ul>
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/priority_change.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/priority_change_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/requests.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/requests_ctrl.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/settings_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
1 change: 0 additions & 1 deletion mcm/HTML/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<![endif]>
<script src="scripts/main_controller.js"></script>
<script src="scripts/users_controller.js"></script>
<script src="scripts/notifications.js"></script>
</head>
<body ng-controller="mainCtrl">
<span ng-controller="resultsCtrl">
Expand Down
35 changes: 18 additions & 17 deletions mcm/json_layer/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@ class notification(json_base):
}

def __init__(self, title, message, targets, target_role='', action_objects=[], object_type='', group='', base_object=None):
if base_object is not None:
targets.extend(base_object.get_actors())
targets = list(set(targets))
json_input = deepcopy(notification._json_base__schema)
json_input.pop('_id')
json_input['message'] = message
json_input['title'] = title
json_input['targets'] = targets
json_input['target_role'] = target_role
json_input['action_objects'] = action_objects
json_input['object_type'] = object_type
json_input['group'] = group
json_input['seen_by'] = []
json_input['created_at'] = str(datetime.now()).split('.')[0]
notification_db = database('notifications')
if not notification_db.save(json_input):
self.logger.error('Failed to save notification: \n' + dumps(json_input))
self.logger.info('Not saving notification %s %s' % (title, message))
# if base_object is not None:
# targets.extend(base_object.get_actors())
# targets = list(set(targets))
# json_input = deepcopy(notification._json_base__schema)
# json_input.pop('_id')
# json_input['message'] = message
# json_input['title'] = title
# json_input['targets'] = targets
# json_input['target_role'] = target_role
# json_input['action_objects'] = action_objects
# json_input['object_type'] = object_type
# json_input['group'] = group
# json_input['seen_by'] = []
# json_input['created_at'] = str(datetime.now()).split('.')[0]
# notification_db = database('notifications')
# if not notification_db.save(json_input):
# self.logger.error('Failed to save notification: \n' + dumps(json_input))

0 comments on commit 35903e9

Please sign in to comment.