Skip to content

Commit

Permalink
group name modal change works.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian committed Nov 21, 2023
1 parent 95f69b3 commit 6f8b814
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 30 deletions.
4 changes: 2 additions & 2 deletions frontend/components/ThreadList/ThreadList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export default {
this.activeThread = activeConversation;
}
},
beforeUpdate() {
afterUpdate() {
// document.querySelector("#active").removeAttribute('id');
// document.getElementsByClassName(".threadlist_container")[0].setAttribute('id','active')
console.log("now threadlist is active")
console.log(this.props)
},
}
Expand Down
17 changes: 10 additions & 7 deletions frontend/components/ThreadPreview/ThreadPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export type ThreadPreviewInterface = {
}
const updateActiveComponent = (event) => {
var ele = document.querySelector('.active');
ele.classList.remove('active');
var threadie = document.getElementById("THREAD");
console.log(ele);
console.log(`thread : ${threadie}`);
threadie.classList.add('active');
// var ele = document.querySelector('.active');
// ele.classList.remove('active');
// var threadie = document.getElementById("THREAD");
// console.log(ele);
// console.log(`thread : ${threadie}`);
// threadie.classList.add('active');
}
export default {
Expand Down Expand Up @@ -110,7 +110,10 @@ export default {
}
},
}
},
afterUpdate() {
console.log(this.props)
},
}
</script>

Expand Down
24 changes: 23 additions & 1 deletion frontend/components/WebTextingContainer/WebTextingContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ export default {
threadPreviews:Array<Object>
},
components: { Conversation, ThreadList },
beforeUpdate() {
console.log(this.props.threadPreviews);
},
methods:{
calculateDisplayName(){
if(this.$route.query.group){
for(let m in this.$props.threadPreviews){
console.log(`group: ${m}`);
}
}
else{
for(let m in this.$props.threadPreviews){
console.log(`contact: ${m}`);
}
}
console.log("display name calculated");
return "tested";
}
}
}
</script>
Expand All @@ -62,7 +81,10 @@ The blank space should notify the user that they can select a thread to display
<RouterView name="rightSide"
:extension_uuid="this.$route.query.extension_uuid"
:remoteNumber="this.$route.query.number"
:ownNumber="this.$props.ownNumber" />
:groupUUID="this.$route.query.group"
:ownNumber="this.$props.ownNumber"
:displayName="this.$props.threadPreviews"
v-bind="calculateDisplayName"/>
</suspense>
</div>
</RouterView>
Expand Down
17 changes: 12 additions & 5 deletions frontend/components/conversation/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import { MessageData, emitter, state } from '../../lib/global';
import { CPIM } from '../../lib/CPIM'
import { ref } from "vue";
import { backfillMessages } from '../../lib/backfill';
import Message from '../message/Message.vue';
import moment from 'moment';
import SendBox from '../SendBox/SendBox.vue';
Expand Down Expand Up @@ -163,12 +161,15 @@ export default {
mounted() {
if (this.$route.query.number) {
backfillMessages(this.$route.query.extension_uuid, this.$route.query.number);
this.conversationKey = this.$route.query.number;
emitter.emit('backfill-requested', this.conversationKey);
}
else if (this.$route.query.group) {
backfillMessages(this.$route.query.extension_uuid, this.$route.query.group);
this.conversationKey = this.$route.query.group
emitter.emit('backfill-requested', this.conversationKey);
const groupTag = document.getElementsByName("group");
groupTag[0].value = this.$route.query.group;
}
emitter.on('scroll-to-bottom', this.toBottom);
Expand Down Expand Up @@ -213,6 +214,11 @@ export default {
// document.querySelector("#active").removeAttribute('id');
// this.$ref.convoContainer.addAttribute('id','active');
//console.log("changing active component");
if(this.$route.query.group){
const groupTag = document.getElementsByName("group");
groupTag[0].value = this.$route.query.group;
}
},
watch: {
//this fires when we set remoteNumber to null or w/e
Expand Down Expand Up @@ -255,7 +261,8 @@ export default {
// group: gUUID });
//console.log(observedChangeQueryParams)
this.messages = this.state.conversations[this.$route.query.group];
this.title = this.$route.query.group;
//this.title = this.$route.query.group;
}
this.conversationKey = this.$route.query.group;
this.backfillAvailable = true;
Expand Down
6 changes: 4 additions & 2 deletions frontend/components/message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ export default {
this.text = this.message.cpim.bodyText;
return;
}
console.log(this.message.cpim.fileContentType);
switch (this.message.cpim.fileContentType) {
case "text/plain":
this.text = await this.message.cpim.getTextBody()
this.message.cpim.bodyText = this.text;
break
case "image/png":
case "image/jpg":
this.embedImage = this.message.cpim.previewURL || this.message.cpim.fileURL;
case "image/jpeg":
this.embedImage = this.message.cpim.previewURL || this.message.cpim.fileURL;
break;
case "image/gif":
this.embedImage = this.message.cpim.previewURL || this.message.cpim.fileURL;
default:
if (this.message.cpim.fileURL) {
this.download = this.message.cpim.fileURL;
Expand Down
7 changes: 6 additions & 1 deletion frontend/lib/backfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export async function backfillMessages(extensionUUID: string, remoteNumber?: str
console.log("skipping duplicate backfill request");
return;
}

if(group){
console.log(`group = ${group}`);
}
if(remoteNumber){
console.log(`group = ${remoteNumber}`);
}
fetching = true;
try {
let params: backfillQuery = { extension_uuid: extensionUUID };
Expand Down
14 changes: 8 additions & 6 deletions frontend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ export const initializeWebTextingContainer = function initializeWebTextingContai
RunSIPConnection(opts.username, opts.password, opts.server, opts.ownNumber, opts.remoteNumber, opts.groupUUID);

emitter.on('backfill-requested', (key:string) => {
console.log(`main.ts backfill key ${key}`)
//key is either a uuid or phone number uuid length is at least 16
if(key.length<12){
backfillMessages(opts.extensionUUID, null, key);
}
else if(key.length>12){
//console.log(`main.ts backfill key ${key}`)
//key is either a uuid or phone number. uuid length is at least 16
if(key.length<15){
//console.log("backfill using remotenumber")
backfillMessages(opts.extensionUUID, key, null);
}
else{
//console.log("backfill using group")
backfillMessages(opts.extensionUUID, null, key);
}

})
}
Expand Down
38 changes: 38 additions & 0 deletions group-rename.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/header.php";
require_once "resources/paging.php";

foreach ($_SESSION['user']['extension'] as $ext) {
if ($ext['extension_uuid'] == $_POST['extension_uuid']) {
$extension = $ext;
break;
}
}

if (!$extension) {
echo "invalid extension, please <a href='index.php'>try again</a>";
include "footer.php";
die();
}

if($_POST['action']) {
$sql = "UPDATE webtexting_groups SET name = :name WHERE group_uuid = :group_uuid AND extension_uuid = :extension_uuid AND domain_uuid = :domain_uuid";
$parameters['name'] = $_POST['name'];
$parameters['group_uuid'] = $_POST['group'];
$parameters['extension_uuid'] = $_POST['extension_uuid'];
$parameters['domain_uuid'] = $domain_uuid;
if($database->execute($sql, $parameters)) {
message::add("group renamed");
} else {
message::add("error renaming group", 'negative');
}
unset($parameters);

// redirect to the same page so the user's request to the page is a GET and refreshing doesn't re-run the action
header("Location: /app/webtexting/threadlist.php?extension_uuid=".$_POST['extension_uuid']);
die();
}
?>
3 changes: 2 additions & 1 deletion thread.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
$url = $_SERVER["HTTP_REFERER"]."threadlist.php?extension_uuid=".$_GET["extension_uuid"];

$url = $_SERVER["HTTP_ORIGIN"]."/app/webtexting/threadlist.php?extension_uuid=".$_GET["extension_uuid"];
header("Location: ".$url);
?>
29 changes: 24 additions & 5 deletions threadlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
die();
}
?>
<form method='get' action="thread.php" onsubmit="clean_number()">
<form method='get' action="new-message.php" onsubmit="clean_number()">
<input type="hidden" name="extension_uuid" value="<?php echo $extension['extension_uuid']; ?>" />
<div id='modal-new-thread' class='modal-window'>
<div>
Expand Down Expand Up @@ -165,11 +165,12 @@
}
}
}
//need to put group name in here too lol
$frontendOpts['server'] = $extension['user_context'];
$frontendOpts['username'] = $extensionDetails['extension'];
$frontendOpts['password'] = $extensionDetails['password'];
$frontendOpts["extensionUUID"] = $extension['extension_uuid'];
$frontendOpts['ownNumber'] = $ownNumber;
$frontendOpts['username'] = $extensionDetails['extension'];
$frontendOpts['password'] = $extensionDetails['password'];
$frontendOpts["extensionUUID"] = $extension['extension_uuid'];
$frontendOpts['ownNumber'] = $ownNumber;

$link = "thread.php?extension_uuid=".$extension['extension_uuid']."&";
if ($group_uuid != null) {
Expand All @@ -182,6 +183,7 @@
$body_preview = $last_message['content_type'] == "text/plain" ? $last_message['message'] : "[media]";
$thread_preview_opts[$z]['bodyPreview'] = $body_preview;
$thread_preview_opts[$z]['ownNumber'] = $ownNumber;
$thread_preview_opts[$z]['displayName']= $display_name;
$z++;
}
$frontendOpts['$thread_preview_opts'] = $thread_preview_opts;
Expand All @@ -203,6 +205,23 @@ function clean_number() { // clean any non-digits out of the phone number box
<script type="text/javascript">
WebTexting.initializeWebTextingContainer(<?php echo json_encode($frontendOpts); ?>);
</script>
<form method='post' action='group-rename.php' value="rename-group">
<input type="hidden" name="action" value="group_name_change"/>
<input type="hidden" name="extension_uuid" value="<?php echo $extension['extension_uuid']; ?>" />
<input type="hidden" name="group" value="<?php echo $_GET['group']; ?>" />
<div id='modal-rename-group' class='modal-window'>
<div>
<span title="" class='modal-close' onclick="modal_close(); ">&times</span>
<span class='modal-title'>Rename Group</span>
<span class='modal-message'>New name: <input type="text" name="name" placeholder="My besties" value="<?php if($group['name']) {echo $group['name'];} ?>" /></span>
<span class='modal-actions'>
<button type='button' alt='Cancel' title='Cancel' onclick='modal_close();' class='btn btn-default' ><span class='fas fa-times fa-fw'></span><span class='button-label never pad'>Cancel</span></button>
<button type='submit' value='Ok' id='btn_ok' alt='ok' title='ok' onclick='modal_close();' class='btn btn-default' style='float: right; margin-left: 15px' ><span class='fas fa-check fa-fw'></span><span class='button-label never pad'>Start</span></button>
</span>
</div>
</div>
<input type='hidden' name='key_uuid' id='key_uuid'/>
</form>

<style type="text/css">
/* .container-fluid {
Expand Down

0 comments on commit 6f8b814

Please sign in to comment.