Skip to content

Commit

Permalink
add about tab to show version and config paths
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcottle committed Jun 2, 2024
1 parent d55e2b4 commit e512198
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 7 deletions.
74 changes: 74 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@
</a>
</li>

<!-- info -->
<li>
<button @click="showAboutTab" type="button" :class="[ tab === 'about' ? 'bg-blue-100 text-blue-800 group:text-blue-800 hover:bg-blue-100' : '']" class="w-full text-gray-800 hover:bg-gray-100 group flex gap-x-3 rounded-r-full p-2 mr-2 text-sm leading-6 font-semibold focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600">
<span class="my-auto">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" />
</svg>
</span>
<span class="my-auto">About</span>
</button>
</li>

</ul>
</div>

Expand Down Expand Up @@ -1027,6 +1039,53 @@

</div>

<!-- about tab -->
<div v-if="tab === 'about'" class="overflow-y-auto space-y-2 p-2">

<!-- app info -->
<div v-if="appInfo" class="bg-white rounded shadow">
<div class="flex border-b border-gray-300 text-gray-700 p-2 font-semibold">App Info</div>
<div class="divide-y text-gray-900">
<div class="p-1">
<div>Version</div>
<div class="text-sm text-gray-700">v{{ appInfo.version }}</div>
</div>
<div class="p-1">
<div>Reticulum Config Path</div>
<div class="text-sm text-gray-700">{{ appInfo.reticulum_config_path }}</div>
</div>
<div class="p-1">
<div>Database Path</div>
<div class="text-sm text-gray-700">{{ appInfo.database_path }}</div>
</div>
<div class="p-1">
<div>Database File Size</div>
<div class="text-sm text-gray-700">{{ formatBytes(appInfo.database_file_size) }}</div>
</div>
</div>
</div>

<!-- my addresses -->
<div v-if="config" class="bg-white rounded shadow">
<div class="flex border-b border-gray-300 text-gray-700 p-2 font-semibold">My Addresses</div>
<div class="divide-y text-gray-900">
<div class="p-1">
<div>Identity Hash</div>
<div class="text-sm text-gray-700">{{ config.identity_hash }}</div>
</div>
<div class="p-1">
<div>LXMF Address</div>
<div class="text-sm text-gray-700">{{ config.lxmf_address_hash }}</div>
</div>
<div class="p-1">
<div>Audio Call Address</div>
<div class="text-sm text-gray-700">{{ config.audio_call_address_hash }}</div>
</div>
</div>
</div>

</div>

</div>

</div>
Expand All @@ -1053,6 +1112,7 @@

displayName: "Anonymous Peer",
config: null,
appInfo: null,

audioCalls: [],
lxmfDeliveryAnnounces: [],
Expand Down Expand Up @@ -1112,6 +1172,7 @@
},
mounted: function() {

this.getAppInfo();
this.connectWebsocket();
this.getLxmfDeliveryAnnounces();
this.getNomadnetworkNodeAnnounces();
Expand Down Expand Up @@ -1325,6 +1386,15 @@
container.scrollTop = container.scrollHeight;
});
},
async getAppInfo() {
try {
const response = await window.axios.get(`/api/v1/app/info`);
this.appInfo = response.data.app_info;
} catch(e) {
// do nothing if failed to load app info
console.log(e);
}
},
async getConfig() {
try {
const response = await window.axios.get(`/api/v1/config`);
Expand Down Expand Up @@ -2291,6 +2361,10 @@
await this.getConversations();

},
showAboutTab() {
this.tab = "about";
this.getAppInfo();
},
async enableInterface(interfaceName) {

// enable interface
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
],
# files that are required
'include_files': [
'package.json', # used to determine app version from python
'public/', # static files served by web server
],
# slim down the build by excluding these unused libs
Expand Down
33 changes: 26 additions & 7 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ def __init__(self, identity: RNS.Identity, storage_dir, reticulum_config_dir):
# ./storage/identities/<identity_hex>/database.db

# ensure a storage path exists for the loaded identity
base_storage_dir = storage_dir or os.path.join("storage")
storage_path = os.path.join(base_storage_dir, "identities", identity.hash.hex())
print("Using Storage Path: {}".format(storage_path))
os.makedirs(storage_path, exist_ok=True)
self.storage_dir = storage_dir or os.path.join("storage")
self.storage_path = os.path.join(self.storage_dir, "identities", identity.hash.hex())
print("Using Storage Path: {}".format(self.storage_path))
os.makedirs(self.storage_path, exist_ok=True)

# define path to files based on storage path
database_path = os.path.join(storage_path, "database.db")
lxmf_router_path = os.path.join(storage_path, "lxmf_router")
self.database_path = os.path.join(self.storage_path, "database.db")
lxmf_router_path = os.path.join(self.storage_path, "lxmf_router")

# init database
sqlite_database = SqliteDatabase(database_path)
sqlite_database = SqliteDatabase(self.database_path)
database.database.initialize(sqlite_database)
self.db = database.database
self.db.connect()
Expand Down Expand Up @@ -109,6 +109,12 @@ def __init__(self, identity: RNS.Identity, storage_dir, reticulum_config_dir):
thread.daemon = True
thread.start()

# gets app version from package.json
def get_app_version(self) -> str:
with open(get_file_path("package.json")) as f:
package_json = json.load(f)
return package_json["version"]

# automatically announces based on user config
async def announce_loop(self):
while True:
Expand Down Expand Up @@ -443,6 +449,19 @@ async def ws(request):

return websocket_response

# get app info
@routes.get("/api/v1/app/info")
async def index(request):
return web.json_response({
"app_info": {
"version": self.get_app_version(),
"storage_path": self.storage_path,
"database_path": self.database_path,
"database_file_size": os.path.getsize(self.database_path),
"reticulum_config_path": self.reticulum.configpath,
},
})

# get config
@routes.get("/api/v1/config")
async def index(request):
Expand Down

0 comments on commit e512198

Please sign in to comment.