Commit 915a9d1f authored by Davide Vernassa's avatar Davide Vernassa
Browse files

Added services for unread messages in menu

parent 0879056c
......@@ -43,9 +43,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<head>
<!-- include libraries(jQuery, bootstrap) -->
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<link href="<%=urlBuilder.getResourceLink(request, "node_modules/bootstrap/dist/css/bootstrap.min.css")%>"href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="<%=urlBuilder.getResourceLink(request, "node_modules/jquery/dist/jquery.min.js")%>"></script>
<script src="<%=urlBuilder.getResourceLink(request, "node_modules/bootstrap/dist/js/bootstrap.min.js")%>"></script>
<%@include file="/WEB-INF/jsp/commons/angular/angularImport.jsp"%>
<script type="text/javascript" src="<%=urlBuilder.getResourceLink(request, "js/src/angular_1.4/tools/news/newsManagement.js")%>"></script>
......
......@@ -28,6 +28,7 @@ myApp.controller('menuCtrl', ['$scope','$mdDialog',
$scope.openAside = false;
$scope.toggleMenu = function(){
if(!$scope.openAside) $scope.setNewsBadge();
$scope.openAside = !$scope.openAside;
}
    }]);
......@@ -62,17 +63,17 @@ myApp.directive('menuAside', ['$http','$mdDialog','sbiModule_config', 'sbiModule
curr_country: Sbi.config.curr_country,
curr_language: Sbi.config.curr_language
}
}).success(function(data){
$scope.links = data.userMenu;
$scope.fixed = data.fixedMenu;
$scope.userName = data.userName;
}).then(function(response){
$scope.links = response.data.userMenu;
$scope.fixed = response.data.fixedMenu;
$scope.userName = response.data.userName;
$scope.i18n.loadI18nMap().then(function() {
if (data.customMenu != undefined && data.customMenu != null && data.customMenu.length > 0){
if (response.data.customMenu != undefined && response.data.customMenu != null && response.data.customMenu.length > 0){
if(data.customMenu[0].menu != undefined){
$scope.customs = data.customMenu[0].menu;
if(response.data.customMenu[0].menu != undefined){
$scope.customs = response.data.customMenu[0].menu;
}
else{
$scope.customs = {};
......@@ -87,11 +88,10 @@ myApp.directive('menuAside', ['$http','$mdDialog','sbiModule_config', 'sbiModule
}
}); // end of load I 18n
}).
error(function(error){
},function(error){
$scope.showAlert('Attention, ' + $scope.userName,"Error Calling REST service for Menu. Please check if the server or connection is working.")
});
......@@ -394,7 +394,15 @@ myApp.directive('menuAside', ['$http','$mdDialog','sbiModule_config', 'sbiModule
}
}
$scope.setNewsBadge = function(){
sbiModule_restServices.promiseGet("2.0", "newsRead/unread").then(function(response){
$scope.unreadNewsNumber = response.data;
})
}
$scope.news = function(){
$scope.toggleMenu();
var parentEl = angular.element(document.body);
$mdDialog.show({
......@@ -405,32 +413,44 @@ myApp.directive('menuAside', ['$http','$mdDialog','sbiModule_config', 'sbiModule
function newsDialogController(scope, $mdDialog, sbiModule_translate) {
scope.translate = sbiModule_translate;
scope.openDetail = function(message, index){
scope.loadingInfo = false;
scope.openDetail = function(category,message, index){
if(!message.opened){
sbiModule_restServices.promisePost("2.0", "newsRead/"+message.id).then(function(response){
})
scope.loadingInfo = true;
if(!message.read) sbiModule_restServices.promisePost("2.0", "newsRead/" + message.id).then(function(response){})
sbiModule_restServices.promiseGet("2.0", "news/" + message.id + "?isTechnical=false").then(function(response){
scope.news[index].html = response.data.html;
message.html = response.data.html;
message.read = true;
scope.loadingInfo = false;
})
message.opened = !message.opened;
}
message.opened = !message.opened;
}
sbiModule_restServices.promiseGet("2.0", "news")
.then(function(response) {
scope.news = [];
for(var n in response.data){
if(response.data[n].type){}
}
scope.news = response.data;
sbiModule_restServices.promiseGet("2.0", "newsRead").then(function(readNews){
})
}, function(response) {
sbiModule_messaging.showErrorMessage(response.data.errors[0].message, $scope.translate.load('sbi.general.error'));
});
sbiModule_restServices.promiseGet("2.0", "newsRead").then(function(readNews){
scope.updateNews(readNews.data);
})
scope.updateNews = function(readNews){
sbiModule_restServices.promiseGet("2.0", "news")
.then(function(response) {
scope.news = [{id:1, label:'News',messages:[]},{id:2,label:'Notifications',messages:[]},{id:3,label:'Warnings',messages:[]}];
for(var n in response.data){
for(var c in scope.news){
if(response.data[n].type == scope.news[c].id){
var tempNews = response.data[n];
if(readNews.indexOf(tempNews.id) != -1) tempNews.read = true;
scope.news[c].messages.push(tempNews);
}
}
}
}, function(response) {
sbiModule_messaging.showErrorMessage(response.data.errors[0].message, $scope.translate.load('sbi.general.error'));
});
}
scope.closeDialog = function() {
......
......@@ -14,12 +14,12 @@
<div class="container-fluid" >
<!-- User Menu -->
<ul class="row iconBar" >
<!-- <li class="dropdown">
<ul id=settings-dropdown class=dropdown-menu >
<li data-ng-repeat="fix in fixed"><a href="#" title="{{fix.tooltip}}" data-ng-click="menuCall(fix.firstUrl,fix.linkType)"> <i aria-hidden="true" class="sidebar-icon material-icons md-32">{{fix.iconCls}}</i> {{fix.tooltip}}</a> </li>
</ul>
</li>-->
<li class="col-md-3 col-xs-6" data-ng-repeat="link in links"><a href="#" title="{{link.tooltip}}" data-ng-click="menuCall(link.firstUrl,link.linkType)"> <i aria-hidden="true" class="navbar-icon material-icons-row md-32">{{link.iconCls}}</i></a> </li>
<li class="col-md-3 col-xs-6" data-ng-repeat="link in links">
<a href="#" title="{{link.tooltip}}" data-ng-click="menuCall(link.firstUrl,link.linkType)">
<i aria-hidden="true" class="navbar-icon material-icons-row md-32">{{link.iconCls}}</i>
</a>
<span ng-if="link.iconCls == 'inbox' && unreadNewsNumber" class="newsBadge">{{unreadNewsNumber}}</span>
</li>
</ul>
<!-- End User Menu -->
<!-- Custom Menu -->
......
......@@ -159,7 +159,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
.show(confirm)
.then(function(){
sbiModule_restServices.promiseDelete("2.0", "news/" + item ).then(function(){
if(item == $scope.selectedNews.id) delete $scope.selectedNews;
if($scope.selectedNews && item == $scope.selectedNews.id) delete $scope.selectedNews;
$scope.getNews();
})
},
......
......@@ -149,6 +149,11 @@
"tweetnacl": "^0.14.3"
}
},
"bootstrap": {
"version": "3.3.5",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.3.5.tgz",
"integrity": "sha1-F3ereSmbEo2H3OfL2G/cRqxpwLE="
},
"canvg": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/canvg/-/canvg-1.5.3.tgz",
......@@ -366,6 +371,11 @@
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"jquery": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz",
"integrity": "sha1-XE2d5lKvbNCncBVKYxu6ErAVx4c="
},
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
......
......@@ -38,18 +38,20 @@
"angular-material": "1.1.10",
"angular-messages": "1.7.2",
"angular-sanitize": "1.7.2",
"angular-summernote": "^0.8.1",
"angular-summernote": "0.8.1",
"angular-ui-codemirror": "0.3.0",
"angular-xregexp": "1.0.0",
"canvg": "^1.5.3",
"bootstrap": "3.3.5",
"canvg": "1.5.3",
"codemirror": "5.32.0",
"file-saver": "2.0.0",
"font-awesome": "4.7.0",
"html2canvas": "1.0.0-alpha.12",
"jquery": "3.2.1",
"jsonformatter": "0.6.0",
"moment": "2.22.2",
"ngdraggable": "0.1.10",
"summernote": "^0.8.11",
"summernote": "0.8.11",
"xregexp": "4.2.0"
},
"author": "knowage labs <knowage@eng.it>",
......
......@@ -587,6 +587,19 @@
vertical-align: baseline;
top: 5px;
}
.newsBadge {
background-color: $fabPrimaryColor;
color: white;
position:absolute;
right: 5px;
top:5px;
padding: 4px;
font-size: $mediumFontSize;
height: auto;
width: auto;
min-width: 24px;
border-radius: 50px;
}
}
.centered {
......
......@@ -30,11 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{{::translate.load('sbi.home.news.nonews')}}
</div>
</div>
<!-- md-tabs ng-if="news.length > 0">
<md-tab label="{{category.label}}" ng-repeat="category in news" -->
<md-content ng-if="news.length > 0">
<md-tabs ng-if="news.length > 0">
<md-tab label="{{category.label}}" ng-repeat="category in news" ng-if="category.messages.length > 0">
<md-content>
<md-list flex class="noPadding">
<md-list-item class="md-2-line" ng-class="{'newMessage': news.unread}" ng-repeat-start="n in news | orderBy: 'time'" ng-click="openDetail(n, $index)">
<md-list-item class="md-2-line" ng-class="{'newMessage': !n.read}" ng-repeat-start="n in category.messages | orderBy: 'time'" ng-click="openDetail(category,n)">
<div class="md-avatar fa fa-2x fa-envelope" ></div>
<div class="md-list-item-text" layout="column">
<h3>{{ n.title }}</h3>
......@@ -42,13 +42,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
<md-divider ></md-divider>
</md-list-item>
<div class="newsContainer" ng-repeat-end ng-if="n.opened" ng-bind-html="n.html | trustAsHtml">
<md-progress-linear md-mode="indeterminate" ng-if="n.opened && loadingInfo"></md-progress-linear>
<div class="newsContainer" ng-repeat-end ng-if="n.opened && !loadingInfo" ng-bind-html="n.html | trustAsHtml">
<md-progress-linear md-mode="indeterminate"></md-progress-linear>
</div>
</md-list>
</md-content>
<!-- /md-tab>
</md-tabs-->
</md-tab>
</md-tabs>
</md-dialog-content>
<md-dialog-actions>
......
Supports Markdown
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