add ui to show my audio call destination hash

This commit is contained in:
liamcottle
2024-05-21 00:09:03 +12:00
parent b6ae483618
commit 6379168b10
2 changed files with 41 additions and 6 deletions

View File

@@ -94,7 +94,7 @@
</div>
<div class="my-auto">Start a new Call</div>
</div>
<div class="flex text-gray-900 p-2 space-x-2">
<div class="flex border-b border-gray-300 text-gray-900 p-2 space-x-2">
<div class="flex-1">
<input v-model="destinationHash" type="text" placeholder="Enter Destination Hash" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2">
</div>
@@ -102,6 +102,10 @@
<span>Initiate Call</span>
</button>
</div>
<div class="p-1">
<div>My Destination Hash</div>
<div class="text-sm text-gray-700">{{ myAudioCallAddressHash || "Unknown" }}</div>
</div>
</div>
<!-- call log -->
@@ -152,6 +156,8 @@
audioCalls: [],
myAudioCallAddressHash: null,
destinationHash: null,
isInitiatingCall: false,
@@ -173,6 +179,9 @@
},
mounted: function() {
// update config
this.getConfig();
// update calls list
this.updateCallsList();
@@ -439,6 +448,20 @@
return parseFloat((bytes / Math.pow(k, i)).toFixed(decimals)) + ' ' + sizes[i];
},
async getConfig() {
try {
// fetch calls
const response = await axios.get("/api/v1/config");
// update ui
this.myAudioCallAddressHash = response.data.config.audio_call_address_hash;
} catch(e) {
// do nothing on error
console.error(e);
}
},
async updateCallsList() {
try {

18
web.py
View File

@@ -240,6 +240,13 @@ class ReticulumWebChat:
return websocket_response
# get config
@routes.get("/api/v1/config")
async def index(request):
return web.json_response({
"config": self.get_config_dict(),
})
# get calls
@routes.get("/api/v1/calls")
async def index(request):
@@ -753,12 +760,17 @@ class ReticulumWebChat:
async def send_config_to_websocket_clients(self):
await self.websocket_broadcast(json.dumps({
"type": "config",
"config": {
"config": self.get_config_dict(),
}))
# returns a dictionary of config
def get_config_dict(self):
return {
"display_name": self.config.display_name.get(),
"identity_hash": self.identity.hexhash,
"lxmf_address_hash": self.local_lxmf_destination.hexhash,
},
}))
"audio_call_address_hash": self.audio_call_manager.audio_call_receiver.destination.hexhash,
}
# convert app data to string, or return none unable to do so
def convert_app_data_to_string(self, app_data):