Commit b50f0193 by Lee Munkyeong

Modify JSfile

parent 080f365a
......@@ -19,7 +19,6 @@ import jp.agentec.abook.abv.bl.data.tables.MServiceOption;
import jp.agentec.abook.abv.bl.data.tables.MShopMember;
import jp.agentec.abook.abv.bl.data.tables.MWorkerGroup;
import jp.agentec.abook.abv.bl.data.tables.RChatRoomShopMember;
import jp.agentec.abook.abv.bl.data.tables.RChatUnreadMessage;
import jp.agentec.abook.abv.bl.data.tables.RCollaborationMember;
import jp.agentec.abook.abv.bl.data.tables.ROperationContent;
import jp.agentec.abook.abv.bl.data.tables.RContentCategory;
......@@ -120,7 +119,6 @@ public class ABVDataOpenHelper {
iTableScripts.add(new TArchive());
iTableScripts.add(new RShopMemberGroup());
iTableScripts.add(new RChatRoomShopMember());
iTableScripts.add(new RChatUnreadMessage());
iTableScripts.add(new RCollaborationMember());
return iTableScripts;
......
......@@ -35,32 +35,51 @@ public class ChatRoomDao extends AbstractDao {
if (column != -1) {
dto.type = cursor.getInt(column);
}
column = cursor.getColumnIndex("unread_count");
if (column != -1) {
dto.unreadCount = cursor.getInt(column);
}
column = cursor.getColumnIndex("user_count");
if (column != -1) {
dto.userCount = cursor.getInt(column);
}
column = cursor.getColumnIndex("favorite_register_date");
if (column != -1) {
dto.favoriteRegisterDate = cursor.getString(column);
}
column = cursor.getColumnIndex("message");
if (column != -1) {
dto.message = cursor.getString(column);
}
column = cursor.getColumnIndex("message_type");
if (column != -1) {
dto.messageType = cursor.getInt(column);
}
column = cursor.getColumnIndex("insert_date");
if (column != -1) {
dto.insertDate = cursor.getString(column);
}
return dto;
}
public List<ChatRoomDto> getAllChatRoom() {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cr.chat_room_id, ");
sql.append(" cr.chat_room_name, ");
sql.append(" cr.type, ");
sql.append(" cr.favorite_register_date ");
sql.append(" cr.chat_room_id ");
sql.append(" ,cr.chat_room_name ");
sql.append(" ,cr.type ");
sql.append(" ,coalesce (cr.favorite_register_date,'') favorite_register_date");
sql.append(" ,coalesce (cr.unread_count,0) unread_count");
sql.append(" ,coalesce (cm.message,'') message");
sql.append(" ,coalesce (cm.message_type,0) message_type");
sql.append(" ,coalesce (cm.insert_date,'') insert_date");
sql.append(" ,coalesce (cr.user_count,0)user_count ");
sql.append(" FROM ");
sql.append(" t_chat_room AS cr ");
sql.append(" INNER JOIN ");
sql.append(" ( SELECT max(insert_date) insert_date, message, message_type FROM t_chat_message GROUP BY chat_room_id ) AS cm ");
sql.append(" LEFT JOIN ");
sql.append(" ( SELECT max(insert_date) insert_date, message, message_type, chat_room_id FROM t_chat_message GROUP BY chat_room_id ) AS cm ");
sql.append(" ON cr.chat_room_id = cm.chat_room_id ");
sql.append(" INNER JOIN ");
sql.append(" r_chat_room_shop_member AS rctsm ");
sql.append(" ON cr.chat_room_id = rctsm.chat_room_id ");
sql.append(" INNER JOIN ");
sql.append(" m_shop_member AS sm ");
sql.append(" ON rctsm.shop_menber_id = sm.shop_menber_id ");
sql.append(" GROUP BY chat_room_id ");
sql.append(" GROUP BY cr.chat_room_id ");
List<ChatRoomDto> list = rawQueryGetDtoList(sql.toString(), null, ChatRoomDto.class);
return list;
}
......@@ -74,11 +93,11 @@ public class ChatRoomDao extends AbstractDao {
}
public void insertChatRoom(ChatRoomDto dto) {
insert("insert into t_chat_room (chat_room_id, chat_room_name, type, favorite_register_date) values (?,?,?,?)", dto.getInsertValues());
insert("insert into t_chat_room (chat_room_id, chat_room_name, type, unread_count, user_count, favorite_register_date) values (?,?,?,?)", dto.getInsertValues());
}
public boolean updateChatRoom(ChatRoomDto dto) {
long count = update("update t_chat_room set chat_room_name=?, type=?, favorite_register_date=? where chat_room_id=?", dto.getUpdateValues());
long count = update("update t_chat_room set chat_room_name=?, type=?, unread_count=?, user_count=?, favorite_register_date=? where chat_room_id=?", dto.getUpdateValues());
return count > 0;
}
......
......@@ -17,9 +17,9 @@ public class RChatRoomShopMember extends SQLiteTableScript {
StringBuffer sql = new StringBuffer();
sql.append(" create table r_chat_room_shop_member ( ");
sql.append(" room_id INTEGER NOT NULL ");
sql.append(" chat_room_id INTEGER NOT NULL ");
sql.append(" , shop_member_id INTEGER NOT NULL ");
sql.append(" , PRIMARY KEY (room_id, shop_member_id) ");
sql.append(" , PRIMARY KEY (chat_room_id, shop_member_id) ");
sql.append(" ) ");
ddl.add(sql.toString());
......
package jp.agentec.abook.abv.bl.data.tables;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
public class RChatUnreadMessage extends SQLiteTableScript {
public RChatUnreadMessage() {
super();
}
@Override
public List<String> getCreateScript(int version) {
List<String> ddl = new ArrayList<String>();
StringBuffer sql = new StringBuffer();
sql.append(" create table r_chat_unread_message ( ");
sql.append(" chat_message_id INTEGER NOT NULL ");
sql.append(" , shop_member_id INTEGER NOT NULL ");
sql.append(" , PRIMARY KEY (chat_message_id, shop_member_id) ");
sql.append(" ) ");
ddl.add(sql.toString());
return ddl;
}
@Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) {
return null;
}
@Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object... params) {
return null;
}
}
......@@ -19,6 +19,8 @@ public class TChatRoom extends SQLiteTableScript {
sql.append(" chat_room_id INTEGER NOT NULL ");
sql.append(" , chat_room_name VARCHAR2(64) ");
sql.append(" , type INTEGER NOT NULL ");
sql.append(" , unread_count INTEGER ");
sql.append(" , user_count INTEGER ");
sql.append(" , favorite_register_date VARCHAR2(64) ");
sql.append(" , PRIMARY KEY (chat_room_id) ");
sql.append(" ) ");
......
......@@ -8,20 +8,22 @@ public class ChatRoomDto extends AbstractDto {
public String chatRoomName;
public Integer type;
public String favoriteRegisterDate;
public Integer unreadCnt;
public ChatMessageDto message;
public List<ShopMemberDto> users;
public Integer unreadCount;
public Integer userCount;
public String message;
public Integer messageType;
public String insertDate;
@Override
public Object[] getInsertValues() {
return new Object[]{chatRoomId, chatRoomName, type, favoriteRegisterDate};
return new Object[]{chatRoomId, chatRoomName, type, unreadCount, userCount, favoriteRegisterDate};
}
@Override
public Object[] getUpdateValues() {
return new Object[]{favoriteRegisterDate, chatRoomName, type, chatRoomId};
return new Object[]{favoriteRegisterDate, chatRoomName, type, unreadCount, userCount, chatRoomId};
}
@Override
......
......@@ -70,6 +70,12 @@ public class CommunicationLogic extends AbstractLogic {
chatRoomMap.put("chatRoomId",chatRoomDto.chatRoomId);
chatRoomMap.put("chatRoomName",chatRoomDto.chatRoomName);
chatRoomMap.put("type",chatRoomDto.type);
chatRoomMap.put("favoriteRegisterDate",chatRoomDto.favoriteRegisterDate);
chatRoomMap.put("unreadCount",chatRoomDto.unreadCount);
chatRoomMap.put("message",chatRoomDto.message);
chatRoomMap.put("messageType",chatRoomDto.messageType);
chatRoomMap.put("insertDate",chatRoomDto.insertDate);
chatRoomMap.put("userCount",chatRoomDto.userCount);
JSONObject jsonObject =new JSONObject(chatRoomMap);
resultJsonArray.put(jsonObject);
}
......
......@@ -440,6 +440,7 @@
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
<script src="./js/chat-util.js"></script>
<script src="./js/chat-db.js"></script>
<script src="./js/chat-websocket.js"></script>
</body>
<script>
......
......@@ -6,8 +6,8 @@ var CHAT_DB = {};
CHAT_DB.getRoomList = function(input) {
if (CHAT_UTIL.isIOS()) {
//TODO IOS処理追加必要
} else (CHAT_UTIL.isAndroid()) {
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getRoomList());
}
}
\ No newline at end of file
};
\ No newline at end of file
......@@ -12,7 +12,7 @@ $(function(){
$('.roomListIcon').hide();
$('#userSelectionDeleteBtn').hide();
$('#createChatRoom').hide();
//$('#createChatRoom').hide();
});
// Rotate
......@@ -50,7 +50,9 @@ $('#createChatRoom').on('click', function(){
let isInvite = false;
CHAT.globalIsInvite = isInvite;
socket.emit('getGroupList', isInvite);
CHAT_UI.loadInviteScreen(isInvite);
//socket.emit('getGroupList', isInvite);
});
// Room Delete
......@@ -766,8 +768,12 @@ CHAT_UI.waitForLoadingImage = function(div, callback) {
});
}
CHAT_UI.refreshRoomList = function(rooms, activeRoomId = null){
CHAT_UI.refreshRoomList = function() {
var rooms = CHAT_DB.getRoomList();
console.log(rooms);
CHAT.globalIsInvite = false;
activeRoomId = null;
// #36146に対応
let keywordSearchMode = false;
if ($('#room-search').val().length > 0) {
......@@ -795,21 +801,25 @@ CHAT_UI.refreshRoomList = function(rooms, activeRoomId = null){
} else {
room.message = getLocalizedString("noMessages")
}
var displayMsg;
//TODO 協業の場合処理追加必要
if (room.messageType == 0 || room.messageType == 3) displayMsg = room.message;
if (room.messageType == 1 || room.messageType == 2) displayMsg = getLocalizedString("image");
console.log(displayMsg);
let html = Mustache.render(template, {
roomName: room.roomName,
roomId: room.roomId,
roomName: room.chatRoomName,
roomId: room.chatRoomId,
profileImage: room.profileImagePath,
active: activeRoomId === room.roomId ? 'active_chat' : null, // 現在、入っているルームだとhilight表示
lastMessage: room.message.includes('<img') ? getLocalizedString("image") : (keywordSearchMode ? `${room.message}${getLocalizedString("searchResult")}` : room.message) ,
time: room.time ? CHAT_UTIL.formatDate(room.time.time).createdAt : '',
unreadMsgCnt: room.unreadCnt,
userCnt: room.userCnt
active: activeRoomId === room.chatRoomId ? 'active_chat' : null, // 現在、入っているルームだとhilight表示
lastMessage: displayMsg ,
time: '',
unreadMsgCnt: room.unreadCount,
userCnt: room.userCount
});
console.log('TestPoint1');
// Click event
let obj = $(jQuery.parseHTML(html)).on('click',function(){
if (activeRoomId === room.roomId) {
/*if (activeRoomId === room.roomId) {
// 既存チャットルームをタッチする場合、チャット画面に遷移
$('#pills-chat-tab').tab('show');
} else {
......@@ -824,12 +834,14 @@ CHAT_UI.refreshRoomList = function(rooms, activeRoomId = null){
$('.titleRoomName').text(room.roomName).data('roomName', room.roomName);
});
}
}*/
});
// チャットルームリストに追加する
$('#room_list').append(obj);
});
console.log('TestPoint2');
if(rooms.length > 0) {
console.log('TestPoint3');
if(!keywordSearchMode) {
$(".roomListIcon").show()
$('#roomDeleteButton, #arrangeRooms').show()
......@@ -838,6 +850,7 @@ CHAT_UI.refreshRoomList = function(rooms, activeRoomId = null){
$('#roomDeleteButton, #arrangeRooms').hide()
}
} else {
console.log('TestPoint4');
if(!keywordSearchMode) {
$(".roomListIcon").hide()
} else {
......@@ -845,7 +858,9 @@ CHAT_UI.refreshRoomList = function(rooms, activeRoomId = null){
$('#roomDeleteButton, #arrangeRooms').hide()
}
}
$('#createChatRoom').show()
console.log('TestPoint5');
$('#createChatRoom').show();
console.log($('#createChatRoom'));
if(CHAT_UI.isLandscapeMode()) {
$(".chat_list").removeClass("col-12").addClass("col-6");
}
......@@ -853,5 +868,76 @@ CHAT_UI.refreshRoomList = function(rooms, activeRoomId = null){
// チャットルームリスト画面に遷移
$('#pills-chatlist-tab').tab('show');
// loadingIndicatorを表示しない
console.log('TestPoint6');
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.loadInviteScreen = function(isInvite){
var groups = [];
$('#group_list').html('');
const template = $('#group-template').html();
if (groups.length === 0) {
$('#group_list').append('<center class="text-secondary">'+ getLocalizedString('everyoneIsHere') +'</center>');
}
// グループ名と人数を表記する。
groups.forEach( function(group) {
let html = Mustache.render(template, {
name: group.groupName,
info: group.memberCnt + getLocalizedString("people")
});
// グループをクリックすると、該当グループのユーザーリストを読み込むようにイベントを与える
let obj = $(jQuery.parseHTML(html)).on('click',function(){
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
//TODO ソケットでなくローカルDBより画面を構成するように修正必要。
//socket.emit('getUserListInGroup', group.groupId, isInvite);
$('#groupName').text(group.groupName);
});
$('#group_list').append(obj);
});
// Rotate
if(CHAT_UI.isLandscapeMode()) {
$(".group_list").addClass("col-6").removeClass("col-12");
}
// Set Title
let memberSelectTitle = getLocalizedString("groupSearch")
$('#pills-group-tab').tab('show');
$('#backButton').show();
if (isInvite) {
$('.titleRoomName').text(memberSelectTitle);
$('#newRoomName, .roomListIcon, .chatRoomIcon').hide();
$('#userSelectionConfirmBtn').show();
$("#userSelectionConfirmBtn").off().on('click', function(){
CHAT_UI.setConfirmButtonEvent(isInvite);
});
} else {
$('.titleRoomName').text(memberSelectTitle);
$('.roomListIcon, .chatRoomIcon, #newRoomName').hide();
$('#userSelectionConfirmBtn').show();
$("#userSelectionConfirmBtn").off().on('click', function(){
CHAT_UI.setConfirmButtonEvent(isInvite);
});
}
if (CHAT.globalSelectedUserList.length > 0) {
$('#userSelectionLength').text(CHAT.globalSelectedUserList.length);
} else {
$('#userSelectionLength').text('');
}
$('#backButton').off().on('click', function() {
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
if (isInvite) {
$('#pills-chat-tab').tab('show');
} else {
CHAT_UI.refreshRoomList();
}
});
};
\ No newline at end of file
......@@ -17,6 +17,12 @@ CHAT_UTIL.formatDate = function(date) {
const REFERENCE = moment();
const TODAY = REFERENCE.clone().startOf('day');
let createdAt = moment(date);
if (date.length == 14) {
createdAt = moment(date,'YYYYMMDDhhmmss');
} else {
createdAt = moment(date);
}
// #36171
const createdAtDay = createdAt.format('MMM Do');
const createdAtTime = createdAt.format('HH:mm');
......
......@@ -11,11 +11,18 @@ function connectSocket(isOnline) {
} else {
//オフラインの場合、DBからルーム一覧を表示。
if (CHAT_UTIL.isIOS()) {
//TODO IOSの場合
//TODO IOSの場合
} else if (CHAT_UTIL.isAndroid()) {
$('.overlay').removeClass('active undismissable');
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
// チャットルームに入場する際、sid, loginId, shopName, roomId, roomNameの情報を取得しNodeJsに渡す
android.getLoginParameter();
var result = CHAT_DB.getRoomList();
console.log(result);
CHAT_UI.refreshRoomList();
$('#createChatRoom').show();
}
}
}
......
......@@ -230,32 +230,38 @@ getLoginParameter = function(sid, loginId, shopName, roomId = undefined, roomNam
}
CHAT_UI.htmlElementTextInitialize(languageCode)
socket.emit('join', loginParam, function (err) {
if (err) {
// #36174
$("#customAlertTitle").text(err);
$("#customAlertOk").text(getLocalizedString("yesTitle"));
$('#customAlert').appendTo("body").modal({
backdrop: 'static',
keyboard: false
})
.on('click', '#customAlertOk', function(e) {
});
if (IS_ONLINE == 'true') {
socket.emit('join', loginParam, function (err) {
if (err) {
// #36174
$("#customAlertTitle").text(err);
$("#customAlertOk").text(getLocalizedString("yesTitle"));
$('#customAlert').appendTo("body").modal({
backdrop: 'static',
keyboard: false
})
.on('click', '#customAlertOk', function(e) {
});
} else {
console.log('No error');
if (loginParam.roomName != undefined && loginParam.roomName != "null") {
$('.titleRoomName').text(loginParam.roomName).data('roomName', loginParam.roomName);
} else {
// 設定されていたroomNameがない場合
let roomListTitle = getLocalizedString("roomListTitle")
$('.titleRoomName').text(roomListTitle).data('roomName', roomListTitle);
}
}
// loadingIndicatorを表示しない
CHAT_UI.dismissLoadingIndicator();
});
} else {
// loadingIndicatorを表示しない
CHAT_UI.dismissLoadingIndicator();
}
} else {
console.log('No error');
if (loginParam.roomName != undefined && loginParam.roomName != "null") {
$('.titleRoomName').text(loginParam.roomName).data('roomName', loginParam.roomName);
} else {
// 設定されていたroomNameがない場合
let roomListTitle = getLocalizedString("roomListTitle")
$('.titleRoomName').text(roomListTitle).data('roomName', roomListTitle);
}
}
// loadingIndicatorを表示しない
CHAT_UI.dismissLoadingIndicator();
});
}
CHAT.leaveRoom = function() {
......
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