Commit 5840d749 authored by Vladimir Baranov's avatar Vladimir Baranov

rref #5392. Show public channels list

parent 2619b847
......@@ -2579,6 +2579,13 @@ table.dataTable thead .sorting:after {
outline: none;
}
.chat-app-close-btn {
display: block;
position: absolute;
right: 5px;
top: 5px;
}
/* END OF CHAT APPLICATION */
......
......@@ -118,6 +118,7 @@
<script src="zetalib/action_service.js"></script>
<script src="zetalib/error_service.js"></script>
<script src="zetalib/socket.js"></script>
<script src="zetalib/utils_service.js"></script>
<!-- components -->
......
......@@ -125,6 +125,7 @@
<script src="zetalib/action_service.js"></script>
<script src="zetalib/error_service.js"></script>
<script src="zetalib/socket.js"></script>
<script src="zetalib/utils_service.js"></script>
<!-- components -->
......
......@@ -673,6 +673,19 @@ angular.module('ulakbus')
replace: true,
scope: {},
controller: function ($scope) {
var dismissWatcher = $scope.$watch(function(){
return $rootScope.websocketIsOpen
}, function(isOpen){
if (isOpen){
dismissWatcher();
MessagingService.list_channels().then(function (groupedChannels){
$scope.publicChannels = groupedChannels[MessagingService.CHANNEL_TYPE.PUBLIC];
$scope.notificationsChannels = groupedChannels[MessagingService.CHANNEL_TYPE.NOTIFICATION];
$scope.directChannels = groupedChannels[MessagingService.CHANNEL_TYPE.DIRECT];
});
}
});
$scope.messages = [];
$scope.$on("messages", function (event, data) {
$log.debug("Message List Received", data);
......
<div class="chat-app">
<div class="chat-app" ng-hide="hidden">
<div class="chat-app-container">
<div class="side-navigation">
......@@ -55,6 +55,5 @@
</div>
</div>
<!-- end of create-new-message-window -->
</div>
</div>
......@@ -15,8 +15,15 @@ angular.module('ulakbus.messagingService', ['ui.bootstrap'])
* @name Generator
* @description form service's Generator factory service handles all generic form operations
*/
.factory('MessagingService', function ($q, $timeout, $sce, $location, $route, $compile, $log, $rootScope, Moment, WSOps) {
.factory('MessagingService', function ($q, $timeout, $sce, $location, $route, $compile, $log, $rootScope, Moment, WSOps, Utils) {
var msg = {};
msg.CHANNEL_TYPE = {
"PUBLIC": 15,
"DIRECT": 10,
"NOTIFICATION": 5
};
msg.send = function (msg) {
/**
* send the message as following structure;
......@@ -157,5 +164,37 @@ angular.module('ulakbus.messagingService', ['ui.bootstrap'])
return data;
});
};
msg.list_channels = function list_channels (){
/**
* request channels list as below;
* {
* 'view':'_zops_list_channels',
* }
*
* wait for response
*
* {
* 'channels': [
* {'name': string, // name of channel
* 'key': key, // key of channel
* 'unread': int, // unread message count
* 'type': int, // channel type,
* // 15: public channels (chat room/broadcast channel distinction comes from "read_only" flag)
* // 10: direct channels
* // 5: one and only private channel which can be "Notifications"
* 'read_only': boolean, // true if this is a read-only subscription to a broadcast channel
* // false if it's a public chat room
*
* 'actions':[('action name', 'view name'),]
* }
*
*/
var outgoing = {
view: '_zops_list_channels'
};
return WSOps.request(outgoing).then(function (data) {
return Utils.groupBy(data.channels||[], "type");
});
};
return msg;
});
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*
* @author Vladimir Baranov
*/
angular.module("ulakbus")
.service("Utils", function(){
var self = this;
/**
* @param list {Array} Array of objects to group
* @param propName {String} property name to group array by
* @returns {Object}
*/
this.groupBy = function (list, propName) {
return list.reduce(function(acc, item) {
(acc[item[propName]] = acc[item[propName]] || []).push(item);
return acc;
}, {});
};
});
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