| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/New folder/New folder/software/Services/citygists/pages/chatgroups/ |
Upload File : |
<template>
<f7-page>
<f7-navbar
:title="`Online: ${number_online}`"
:subtitle="`Messages sent: ${total_group_messages}`"
back-link="Back"
>
<f7-nav-right>
<span v-if="app_state">Open</span>
<span v-else>locked</span>
<f7-link popover-open=".popover-menu" v-if="user_status=='2'">
<i class="f7-icons">ellipsis_vertical</i>
</f7-link>
</f7-nav-right>
</f7-navbar>
<f7-messagebar
:placeholder="placeholder"
ref="messagebar"
:attachments-visible="attachmentsVisible"
:sheet-visible="sheetVisible"
>
<f7-link
icon-ios="f7:folder"
icon-aurora="f7:folder"
icon-md="material:folder"
slot="inner-start"
@click="launchFilePicker"
></f7-link>
<f7-link
icon-ios="f7:camera_fill"
icon-aurora="f7:camera_fill"
icon-md="material:camera_alt"
slot="inner-start"
@click="sheetVisible = !sheetVisible"
></f7-link>
<f7-link
icon-ios="f7:arrow_up_fill"
icon-aurora="f7:arrow_up_fill"
icon-md="material:send"
slot="inner-end"
@click="sendMessage"
></f7-link>
<f7-messagebar-attachments>
<f7-messagebar-attachment
v-for="(image, index) in attachments"
:key="index"
:image="image"
@attachment:delete="deleteAttachment(image)"
></f7-messagebar-attachment>
</f7-messagebar-attachments>
<f7-messagebar-sheet>
<f7-messagebar-sheet-image
v-for="(image, index) in images"
:key="index"
:image="image"
:checked="attachments.indexOf(image) >= 0"
@change="handleAttachment"
></f7-messagebar-sheet-image>
</f7-messagebar-sheet>
</f7-messagebar>
<f7-messages ref="messages">
<div class="messages" v-for="(messages,index) in group_messages" :key="index">
<f7-messages-title>
<b>{{index}}</b>
</f7-messages-title>
<f7-message
v-for="(message, i) in messages"
:key="i"
:type="message.type"
:image="message.image"
:name="message.displayName"
:avatar="message.avatar"
:first="isFirstMessage(message, index)"
:last="isLastMessage(message, index)"
:tail="isTailMessage(message, index)"
>
<span slot="text" v-if="message.text" v-html="message.text"></span>
<span class="chat-time" slot="text" v-if="message.text" v-html="message.smalldate"></span>
</f7-message>
<f7-message
v-if="typing_message_group > 0"
type="received"
:typing="true"
:first="true"
:last="true"
:tail="true"
:header="`${typing_message_group} Person(s) typing`"
></f7-message>
</div>
</f7-messages>
<input type="file" ref="file" style="display:none;" @change="onFilePicked" multiple />
<f7-popover class="popover-menu">
<f7-list>
<f7-list-item @click="lockApp()" popover-close title="Close Gateway"></f7-list-item>
<f7-list-item @click="openApp()" popover-close title="Open Gate"></f7-list-item>
<f7-list-item @click="sendBroadCast()" popover-close title="Send Broadcast Message"></f7-list-item>
</f7-list>
</f7-popover>
</f7-page>
</template>
<script>
import firebase from "firebase";
export default {
data() {
return {
user_uid: null,
chatgroup: null,
attachments: [],
sheetVisible: false,
typingMessage: null,
messagesData: [],
responseInProgress: false,
appState: 1,
moderator: true
//user_status: null
};
},
computed: {
total_group_messages() {
return this.$store.getters.total_group_messages;
},
number_online() {
return this.$store.getters.number_online;
},
typing_message_group() {
return this.$store.getters.typing_message_group;
},
app_state() {
return this.$store.getters.app_state;
},
user_status() {
return this.$store.getters.user_status;
},
chat_group_name() {
return this.$store.getters.chat_group_name;
},
group_messages() {
return this.$store.getters.group_messages;
},
images() {
return this.$store.getters.images;
},
attachmentsVisible() {
const self = this;
return self.attachments.length > 0;
},
placeholder() {
const self = this;
return self.attachments.length > 0 ? "Add comment or Send" : "Message";
}
},
watch: {
typing_message_group(value) {
console.log("am here nosa", value);
if (value == 1) {
//this.resetTypingMessageGroup();
}
}
},
beforeDestroy() {
//console.log("Yes man");
this.$store.dispatch("statisticsUsersOnlineRemove");
},
mounted() {
const self = this;
self.$f7ready(() => {
self.messagebar = self.$refs.messagebar.f7Messagebar;
self.messages = self.$refs.messages.f7Messages;
});
this.$store.dispatch("getGroupName2");
},
methods: {
sendBroadCast() {
console.log("BroadCast Message");
this.$f7.popover.close();
var dialog = this.$f7.dialog
.create({
title: "Send Broadcast Message",
text: "",
content:
'<div class="dialog-input-field item-input"><div class="item-input-wrap"><input class="dialog-input" type="text" placeholder="Enter Title" required maxlength="50"> <div class="item-input-wrap"><input class="dialog-input body" type="textarea" placeholder="Enter Message" resizable required maxlength="200"></div></div></div>',
buttons: [{ text: "Cancel", close: true }, { text: "Send" }],
onClick: (dialog, index) => {
//console.log("nosa");
// console.log(dialog.$el.find(".body").val());
var title_field = dialog.$el
.find(".dialog-input")
.val()
.trim();
var body_field = dialog.$el
.find(".body")
.val()
.trim();
if (title_field != "" && body_field != "") {
var payload = {};
payload.title = title_field;
payload.message_details = body_field;
this.$store.dispatch("pushNotifications", payload);
var payloadMessage = {
group_name: this.chat_group_name,
message:
"Broadcast: Title: " +
title_field +
" Message: " +
body_field,
img: null
};
this.$store.dispatch("sendGroupMessage", payloadMessage);
this.$f7.dialog.close();
} else {
//console.log("response", response);
if (index == 1) {
this.$store.commit("setAlertMessage", "Fields cannot be empty");
}
}
},
on: {
open: function() {
//console.log("OPEN");
}
}
})
.open();
},
lockApp() {
this.$store.dispatch("closeAppState");
this.$store.dispatch("getAppState");
// console.log("Lock routine");
this.$f7.popover.close();
},
openApp() {
this.$store.dispatch("openAppState");
this.$store.dispatch("getAppState");
//console.log("open routine");
this.$f7.popover.close();
},
launchFilePicker() {
this.$refs.file.click();
},
onFilePicked() {
this.$store.dispatch("readFileMessage");
},
leaveGroup() {
var payload = {};
payload.group_name = this.chat_group_name;
this.$store.dispatch("leaveGroup", payload);
},
goto(page) {
this.$f7router.navigate(page);
},
isFirstMessage(message, index) {
const self = this;
const previousMessage = self.messagesData[index - 1];
if (message.isTitle) return false;
if (
!previousMessage ||
previousMessage.type !== message.type ||
previousMessage.name !== message.name
)
return true;
return false;
},
isLastMessage(message, index) {
const self = this;
const nextMessage = self.messagesData[index + 1];
if (message.isTitle) return false;
if (
!nextMessage ||
nextMessage.type !== message.type ||
nextMessage.name !== message.name
)
return true;
return false;
},
isTailMessage(message, index) {
const self = this;
const nextMessage = self.messagesData[index + 1];
if (message.isTitle) return false;
if (
!nextMessage ||
nextMessage.type !== message.type ||
nextMessage.name !== message.name
)
return true;
return false;
},
deleteAttachment(image) {
const self = this;
const index = self.attachments.indexOf(image);
self.attachments.splice(index, 1)[0]; // eslint-disable-line
},
handleAttachment(e) {
const self = this;
const index = self
.$$(e.target)
.parents("label.checkbox")
.index();
const image = self.images[index];
if (e.target.checked) {
// Add to attachments
self.attachments.unshift(image);
} else {
// Remove from attachments
self.attachments.splice(self.attachments.indexOf(image), 1);
}
},
sendMessage() {
this.$store.dispatch("getUserStatus");
this.$store.dispatch("getAppState");
console.log("chat app state", this.app_state);
if (!this.app_state && this.user_status == "1") {
this.$store.commit(
"setAlertMessage",
"Only moderators can send messages now"
);
return;
}
if (this.user_status == "0") {
this.$store.commit(
"setAlertMessage",
"You have been banned from using this service"
);
return;
}
const self = this;
const text = self.messagebar
.getValue()
.replace(/\n/g, "<br>")
.trim();
const messagesToSend = [];
self.attachments.forEach(attachment => {
messagesToSend.push({
image: attachment
});
});
if (text.trim().length) {
messagesToSend.push({
text
});
}
if (messagesToSend.length === 0) {
return;
}
if (self.attachments.length > 0) {
_.forEach(self.attachments, attachment => {
self.$store.dispatch("uploadChatImages", attachment).then(url => {
var payload = {
group_name: this.chat_group_name,
message: text,
img: url
};
self.$store.dispatch("sendGroupMessage", payload);
// self.$store.dispatch("sendLatestGroupMessage", payload);
});
});
} else {
var payload = {
group_name: this.chat_group_name,
message: text,
img: null
};
self.$store.dispatch("sendGroupMessage", payload);
//self.$store.dispatch("sendLatestGroupMessage", payload);
}
// Reset attachments
self.attachments = [];
// Hide sheet
self.sheetVisible = false;
// Clear area
self.messagebar.clear();
// Focus area
if (text.length) self.messagebar.focus();
if (self.responseInProgress) {
console.log("am here oga");
}
}
},
created() {
this.user_uid = firebase.auth().currentUser.uid;
//let param = decodeURIComponent(this.$f7route.params.group);
// this.chatgroup = JSON.parse(param);
this.$store.commit("setShowTabs", false);
this.$store.dispatch("getGroupMessages");
this.$store.dispatch("getAppState");
this.$store.dispatch("getUserStatus");
//this.$store.dispatch("getTypingMessagesGroup");
this.$store.dispatch("statisticsUsersOnline");
this.$store.dispatch("getTotalGroupMessages");
}
};
</script>
<style scoped>
.chat-time {
display: block;
font-size: 0.6em;
}
</style>