mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-08-28 19:38:17 +00:00
refactor(api): replace axios with window.api for all API calls in frontend components
This commit is contained in:
@@ -974,7 +974,7 @@ export default {
|
||||
},
|
||||
async getAppInfo() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/app/info`);
|
||||
const response = await window.api.get(`/api/v1/app/info`);
|
||||
this.appInfo = response.data.app_info;
|
||||
|
||||
if (this.appInfo.database_health_issues && this.appInfo.database_health_issues.length > 0) {
|
||||
@@ -1019,7 +1019,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/config`);
|
||||
const response = await window.api.get(`/api/v1/config`);
|
||||
this.config = response.data.config;
|
||||
GlobalState.config = response.data.config;
|
||||
this.displayName = response.data.config.display_name;
|
||||
@@ -1030,7 +1030,7 @@ export default {
|
||||
},
|
||||
async getBlockedDestinations() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/blocked-destinations");
|
||||
const response = await window.api.get("/api/v1/blocked-destinations");
|
||||
GlobalState.blockedDestinations = response.data.blocked_destinations || [];
|
||||
} catch (e) {
|
||||
console.log("Failed to load blocked destinations:", e);
|
||||
@@ -1045,7 +1045,7 @@ export default {
|
||||
},
|
||||
async sendAnnounce() {
|
||||
try {
|
||||
await window.axios.get(`/api/v1/announce`);
|
||||
await window.api.get(`/api/v1/announce`);
|
||||
} catch (e) {
|
||||
ToastUtils.error(this.$t("app.failed_announce"));
|
||||
console.log(e);
|
||||
@@ -1156,7 +1156,7 @@ export default {
|
||||
|
||||
// request sync
|
||||
try {
|
||||
await axios.get("/api/v1/lxmf/propagation-node/sync");
|
||||
await window.api.get("/api/v1/lxmf/propagation-node/sync");
|
||||
} catch (e) {
|
||||
const errorMessage = e.response?.data?.message ?? this.$t("app.sync_error_generic");
|
||||
ToastUtils.error(errorMessage);
|
||||
@@ -1194,7 +1194,7 @@ export default {
|
||||
async stopSyncingPropagationNode() {
|
||||
// stop sync
|
||||
try {
|
||||
await axios.get("/api/v1/lxmf/propagation-node/stop-sync");
|
||||
await window.api.get("/api/v1/lxmf/propagation-node/stop-sync");
|
||||
} catch {
|
||||
// do nothing on error
|
||||
}
|
||||
@@ -1204,7 +1204,7 @@ export default {
|
||||
},
|
||||
async updatePropagationNodeStatus() {
|
||||
try {
|
||||
const response = await axios.get("/api/v1/lxmf/propagation-node/status");
|
||||
const response = await window.api.get("/api/v1/lxmf/propagation-node/status");
|
||||
this.propagationNodeStatus = response.data.propagation_node_status;
|
||||
} catch {
|
||||
// do nothing on error
|
||||
@@ -1222,7 +1222,7 @@ export default {
|
||||
|
||||
if (this.config?.custom_ringtone_enabled) {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/ringtones/status");
|
||||
const response = await window.api.get("/api/v1/telephone/ringtones/status");
|
||||
const status = response.data;
|
||||
if (status.has_custom_ringtone && status.id) {
|
||||
this.ringtonePlayer = new Audio(`/api/v1/telephone/ringtones/${status.id}/audio`);
|
||||
@@ -1258,7 +1258,7 @@ export default {
|
||||
async updateTelephoneStatus() {
|
||||
try {
|
||||
// fetch status
|
||||
const response = await axios.get("/api/v1/telephone/status");
|
||||
const response = await window.api.get("/api/v1/telephone/status");
|
||||
const oldCall = this.activeCall;
|
||||
const newCall = response.data.active_call;
|
||||
|
||||
@@ -1337,7 +1337,7 @@ export default {
|
||||
this.isFetchingRingtone = true;
|
||||
try {
|
||||
const caller_hash = this.activeCall.remote_identity_hash;
|
||||
const ringResponse = await window.axios.get(
|
||||
const ringResponse = await window.api.get(
|
||||
`/api/v1/telephone/ringtones/status?caller_hash=${caller_hash}`
|
||||
);
|
||||
const status = ringResponse.data;
|
||||
|
||||
@@ -172,7 +172,7 @@ export default {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/app/changelog");
|
||||
const response = await window.api.get("/api/v1/app/changelog");
|
||||
this.version = response.data.version;
|
||||
|
||||
// Process HTML to make version headers look better
|
||||
@@ -192,7 +192,7 @@ export default {
|
||||
// mark as seen for current version automatically on close if not already marked
|
||||
if (!this.dontShowEver && !this.dontShowAgain) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/app/changelog/seen", {
|
||||
await window.api.post("/api/v1/app/changelog/seen", {
|
||||
version: this.currentVersion || "0.0.0",
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -206,7 +206,7 @@ export default {
|
||||
async markAsSeen() {
|
||||
if (this.dontShowEver) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/app/changelog/seen", {
|
||||
await window.api.post("/api/v1/app/changelog/seen", {
|
||||
version: "999.999.999",
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -214,7 +214,7 @@ export default {
|
||||
}
|
||||
} else if (this.dontShowAgain) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/app/changelog/seen", {
|
||||
await window.api.post("/api/v1/app/changelog/seen", {
|
||||
version: this.currentVersion,
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
@@ -432,13 +432,13 @@ export default {
|
||||
async loadPeersAndContacts() {
|
||||
try {
|
||||
// fetch announces for "lxmf.delivery" aspect to get peers
|
||||
const peerResponse = await window.axios.get(`/api/v1/announces`, {
|
||||
const peerResponse = await window.api.get(`/api/v1/announces`, {
|
||||
params: { aspect: "lxmf.delivery", limit: 20 },
|
||||
});
|
||||
this.peers = peerResponse.data.announces;
|
||||
|
||||
// fetch telephone contacts
|
||||
const contactResponse = await window.axios.get("/api/v1/telephone/contacts");
|
||||
const contactResponse = await window.api.get("/api/v1/telephone/contacts");
|
||||
this.contacts =
|
||||
contactResponse.data?.contacts ?? (Array.isArray(contactResponse.data) ? contactResponse.data : []);
|
||||
} catch (e) {
|
||||
@@ -486,7 +486,7 @@ export default {
|
||||
},
|
||||
async dialContact(hash) {
|
||||
try {
|
||||
await window.axios.get(`/api/v1/telephone/call/${hash}`);
|
||||
await window.api.get(`/api/v1/telephone/call/${hash}`);
|
||||
if (this.$route.name !== "call") {
|
||||
this.$router.push({ name: "call" });
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export default {
|
||||
},
|
||||
async acknowledgeAndReset() {
|
||||
try {
|
||||
await window.axios.post("/api/v1/app/integrity/acknowledge");
|
||||
await window.api.post("/api/v1/app/integrity/acknowledge");
|
||||
ToastUtils.success(this.$t("about.integrity_acknowledged_reset"));
|
||||
this.visible = false;
|
||||
} catch (e) {
|
||||
|
||||
@@ -228,7 +228,7 @@ export default {
|
||||
}
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/notifications`, {
|
||||
const response = await window.api.get(`/api/v1/notifications`, {
|
||||
params: {
|
||||
unread: true,
|
||||
limit: 10,
|
||||
@@ -258,7 +258,7 @@ export default {
|
||||
.map((n) => n.destination_hash);
|
||||
const notification_ids = this.notifications.filter((n) => n.type !== "lxmf_message").map((n) => n.id);
|
||||
|
||||
await window.axios.post("/api/v1/notifications/mark-as-viewed", {
|
||||
await window.api.post("/api/v1/notifications/mark-as-viewed", {
|
||||
destination_hashes: destination_hashes,
|
||||
notification_ids: notification_ids,
|
||||
});
|
||||
@@ -271,18 +271,18 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await window.axios.post("/api/v1/notifications/mark-as-viewed", {
|
||||
await window.api.post("/api/v1/notifications/mark-as-viewed", {
|
||||
destination_hashes: [],
|
||||
notification_ids: [],
|
||||
});
|
||||
|
||||
const response = await window.axios.get("/api/v1/lxmf/conversations");
|
||||
const response = await window.api.get("/api/v1/lxmf/conversations");
|
||||
const conversations = response.data.conversations || [];
|
||||
|
||||
for (const conversation of conversations) {
|
||||
if (conversation.is_unread) {
|
||||
try {
|
||||
await window.axios.get(
|
||||
await window.api.get(
|
||||
`/api/v1/lxmf/conversations/${conversation.destination_hash}/mark-as-read`
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -311,7 +311,7 @@ export default {
|
||||
const destination_hashes = notification.type === "lxmf_message" ? [notification.destination_hash] : [];
|
||||
const notification_ids = notification.type !== "lxmf_message" ? [notification.id] : [];
|
||||
|
||||
await window.axios.post("/api/v1/notifications/mark-as-viewed", {
|
||||
await window.api.post("/api/v1/notifications/mark-as-viewed", {
|
||||
destination_hashes: destination_hashes,
|
||||
notification_ids: notification_ids,
|
||||
});
|
||||
|
||||
@@ -1458,7 +1458,7 @@ export default {
|
||||
async toggleTheme() {
|
||||
const newTheme = this.config.theme === "dark" ? "light" : "dark";
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
theme: newTheme,
|
||||
});
|
||||
GlobalState.config.theme = newTheme;
|
||||
@@ -1468,7 +1468,7 @@ export default {
|
||||
},
|
||||
async onLanguageChange(langCode) {
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
language: langCode,
|
||||
});
|
||||
this.$i18n.locale = langCode;
|
||||
@@ -1495,7 +1495,7 @@ export default {
|
||||
async loadCommunityInterfaces() {
|
||||
this.loadingInterfaces = true;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/community-interfaces");
|
||||
const response = await window.api.get("/api/v1/community-interfaces");
|
||||
this.communityInterfaces = response.data.interfaces;
|
||||
} catch (e) {
|
||||
console.error("Failed to load community interfaces:", e);
|
||||
@@ -1506,7 +1506,7 @@ export default {
|
||||
async loadDiscoveredInterfaces() {
|
||||
this.loadingDiscovered = true;
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/reticulum/discovered-interfaces`);
|
||||
const response = await window.api.get(`/api/v1/reticulum/discovered-interfaces`);
|
||||
this.discoveredInterfaces = response.data?.interfaces ?? [];
|
||||
this.discoveredActive = response.data?.active ?? [];
|
||||
} catch (e) {
|
||||
@@ -1522,7 +1522,7 @@ export default {
|
||||
discover_interfaces: true,
|
||||
autoconnect_discovered_interfaces: 3, // default to 3 slots
|
||||
};
|
||||
await window.axios.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
await window.api.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
ToastUtils.success(this.$t("tutorial.discovery_enabled"));
|
||||
this.discoveryOption = "yes";
|
||||
this.nextStep();
|
||||
@@ -1536,7 +1536,7 @@ export default {
|
||||
async enableAutoPropagation() {
|
||||
this.savingPropagation = true;
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
lxmf_preferred_propagation_node_auto_select: true,
|
||||
});
|
||||
ToastUtils.success("Auto-propagation enabled");
|
||||
@@ -1599,7 +1599,7 @@ export default {
|
||||
},
|
||||
async selectCommunityInterface(iface) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/reticulum/interfaces/add", {
|
||||
await window.api.post("/api/v1/reticulum/interfaces/add", {
|
||||
name: iface.name,
|
||||
type: iface.type,
|
||||
target_host: iface.target_host,
|
||||
@@ -1651,7 +1651,7 @@ export default {
|
||||
if (this.markingSeen) return;
|
||||
this.markingSeen = true;
|
||||
try {
|
||||
await window.axios.post("/api/v1/app/tutorial/seen");
|
||||
await window.api.post("/api/v1/app/tutorial/seen");
|
||||
} catch (e) {
|
||||
console.error("Failed to mark tutorial as seen:", e);
|
||||
} finally {
|
||||
|
||||
@@ -900,7 +900,7 @@ export default {
|
||||
methods: {
|
||||
async listSnapshots() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/database/snapshots", {
|
||||
const response = await window.api.get("/api/v1/database/snapshots", {
|
||||
params: {
|
||||
limit: this.snapshotsLimit,
|
||||
offset: this.snapshotsOffset,
|
||||
@@ -914,7 +914,7 @@ export default {
|
||||
},
|
||||
async listAutoBackups() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/database/backups", {
|
||||
const response = await window.api.get("/api/v1/database/backups", {
|
||||
params: {
|
||||
limit: this.autoBackupsLimit,
|
||||
offset: this.autoBackupsOffset,
|
||||
@@ -928,7 +928,7 @@ export default {
|
||||
},
|
||||
async downloadSnapshot(filename) {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/database/snapshots/${filename}/download`, {
|
||||
const response = await window.api.get(`/api/v1/database/snapshots/${filename}/download`, {
|
||||
responseType: "blob",
|
||||
});
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
@@ -946,7 +946,7 @@ export default {
|
||||
},
|
||||
async downloadBackupFile(filename) {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/database/backups/${filename}/download`, {
|
||||
const response = await window.api.get(`/api/v1/database/backups/${filename}/download`, {
|
||||
responseType: "blob",
|
||||
});
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
@@ -965,7 +965,7 @@ export default {
|
||||
async deleteSnapshot(filename) {
|
||||
if (!(await DialogUtils.confirm(this.$t("about.delete_snapshot_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/database/snapshots/${filename}`);
|
||||
await window.api.delete(`/api/v1/database/snapshots/${filename}`);
|
||||
ToastUtils.success(this.$t("about.snapshot_deleted"));
|
||||
await this.listSnapshots();
|
||||
} catch {
|
||||
@@ -975,7 +975,7 @@ export default {
|
||||
async deleteBackup(filename) {
|
||||
if (!(await DialogUtils.confirm(this.$t("about.delete_backup_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/database/backups/${filename}`);
|
||||
await window.api.delete(`/api/v1/database/backups/${filename}`);
|
||||
ToastUtils.success(this.$t("about.backup_deleted"));
|
||||
await this.listAutoBackups();
|
||||
} catch {
|
||||
@@ -1012,7 +1012,7 @@ export default {
|
||||
this.snapshotMessage = "";
|
||||
this.snapshotError = "";
|
||||
try {
|
||||
await window.axios.post("/api/v1/database/snapshot", {
|
||||
await window.api.post("/api/v1/database/snapshot", {
|
||||
name: this.snapshotName || `snapshot-${Math.floor(Date.now() / 1000)}`,
|
||||
});
|
||||
this.snapshotMessage = "Snapshot created successfully";
|
||||
@@ -1029,7 +1029,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/database/restore", { path });
|
||||
const response = await window.api.post("/api/v1/database/restore", { path });
|
||||
if (response.data.status === "success") {
|
||||
ToastUtils.success(this.$t("about.database_restored"));
|
||||
if (this.isElectron) {
|
||||
@@ -1042,7 +1042,7 @@ export default {
|
||||
},
|
||||
async getAppInfo() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/app/info");
|
||||
const response = await window.api.get("/api/v1/app/info");
|
||||
this.appInfo = response.data.app_info;
|
||||
|
||||
if (this.isElectron) {
|
||||
@@ -1059,7 +1059,7 @@ export default {
|
||||
async acknowledgeIntegrity() {
|
||||
if (await DialogUtils.confirm(this.$t("about.integrity_acknowledge_confirm"))) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/app/integrity/acknowledge");
|
||||
await window.api.post("/api/v1/app/integrity/acknowledge");
|
||||
ToastUtils.success(this.$t("about.integrity_acknowledged"));
|
||||
await this.getAppInfo();
|
||||
} catch {
|
||||
@@ -1070,7 +1070,7 @@ export default {
|
||||
async getDatabaseHealth(showMessage = false) {
|
||||
this.healthLoading = true;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/database/health");
|
||||
const response = await window.api.get("/api/v1/database/health");
|
||||
this.databaseHealth = response.data.database;
|
||||
if (showMessage) {
|
||||
this.databaseActionMessage = "Database health refreshed";
|
||||
@@ -1091,7 +1091,7 @@ export default {
|
||||
this.databaseActionError = "";
|
||||
this.databaseRecoveryActions = [];
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/database/vacuum");
|
||||
const response = await window.api.post("/api/v1/database/vacuum");
|
||||
if (response.data.database?.health) {
|
||||
this.databaseHealth = response.data.database.health;
|
||||
}
|
||||
@@ -1111,7 +1111,7 @@ export default {
|
||||
this.backupMessage = "";
|
||||
this.backupError = "";
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/database/backup/download", {
|
||||
const response = await window.api.get("/api/v1/database/backup/download", {
|
||||
responseType: "blob",
|
||||
});
|
||||
const blob = new Blob([response.data], { type: "application/zip" });
|
||||
@@ -1149,7 +1149,7 @@ export default {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("file", this.restoreFile);
|
||||
const response = await window.axios.post("/api/v1/database/restore", formData, {
|
||||
const response = await window.api.post("/api/v1/database/restore", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
this.restoreMessage = response.data.message || "Database restored";
|
||||
@@ -1171,7 +1171,7 @@ export default {
|
||||
this.databaseActionMessage = "";
|
||||
this.databaseActionError = "";
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/database/recover");
|
||||
const response = await window.api.post("/api/v1/database/recover");
|
||||
if (response.data.database?.health) {
|
||||
this.databaseHealth = response.data.database.health;
|
||||
}
|
||||
@@ -1186,7 +1186,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
// do nothing if failed to load config
|
||||
@@ -1215,7 +1215,7 @@ export default {
|
||||
) {
|
||||
try {
|
||||
// try to notify backend first
|
||||
await window.axios.post("/api/v1/app/shutdown");
|
||||
await window.api.post("/api/v1/app/shutdown");
|
||||
} catch {
|
||||
// ignore errors if backend is already stopping
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ export default {
|
||||
async getArchives() {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/nomadnet/archives", {
|
||||
const response = await window.api.get("/api/v1/nomadnet/archives", {
|
||||
params: {
|
||||
page: 1,
|
||||
limit: 500,
|
||||
@@ -354,7 +354,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
await window.axios.delete("/api/v1/nomadnet/archives", {
|
||||
await window.api.delete("/api/v1/nomadnet/archives", {
|
||||
data: { ids: this.selectedArchives },
|
||||
});
|
||||
|
||||
@@ -381,7 +381,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
await window.axios.delete("/api/v1/nomadnet/archives", {
|
||||
await window.api.delete("/api/v1/nomadnet/archives", {
|
||||
data: { ids: [archive.id] },
|
||||
});
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ export default {
|
||||
methods: {
|
||||
async checkAuthStatus() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/auth/status");
|
||||
const response = await window.api.get("/api/v1/auth/status");
|
||||
const status = response.data;
|
||||
|
||||
if (!status.auth_enabled) {
|
||||
@@ -141,7 +141,7 @@ export default {
|
||||
|
||||
try {
|
||||
const endpoint = this.isSetup ? "/api/v1/auth/setup" : "/api/v1/auth/login";
|
||||
await window.axios.post(endpoint, {
|
||||
await window.api.post(endpoint, {
|
||||
password: this.password,
|
||||
});
|
||||
|
||||
|
||||
@@ -195,13 +195,13 @@ export default {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
// Load local blocked destinations
|
||||
const response = await window.axios.get("/api/v1/blocked-destinations");
|
||||
const response = await window.api.get("/api/v1/blocked-destinations");
|
||||
const blockedHashes = response.data.blocked_destinations || [];
|
||||
|
||||
// Load Reticulum blackholed identities
|
||||
let reticulumBlackholed = {};
|
||||
try {
|
||||
const rnsResponse = await window.axios.get("/api/v1/reticulum/blackhole");
|
||||
const rnsResponse = await window.api.get("/api/v1/reticulum/blackhole");
|
||||
reticulumBlackholed = rnsResponse.data.blackholed_identities || {};
|
||||
} catch (e) {
|
||||
console.error("Failed to load Reticulum blackhole", e);
|
||||
@@ -212,7 +212,7 @@ export default {
|
||||
let isNode = false;
|
||||
|
||||
try {
|
||||
const announceResponse = await window.axios.get("/api/v1/announces", {
|
||||
const announceResponse = await window.api.get("/api/v1/announces", {
|
||||
params: {
|
||||
identity_hash: hash,
|
||||
include_blocked: true,
|
||||
@@ -272,7 +272,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/blocked-destinations/${item.destination_hash}`);
|
||||
await window.api.delete(`/api/v1/blocked-destinations/${item.destination_hash}`);
|
||||
await this.loadBlockedDestinations();
|
||||
ToastUtils.success(this.$t("banishment.banishment_lifted"));
|
||||
} catch (e) {
|
||||
|
||||
@@ -416,7 +416,7 @@ export default {
|
||||
},
|
||||
async answerCall() {
|
||||
try {
|
||||
await window.axios.get("/api/v1/telephone/answer");
|
||||
await window.api.get("/api/v1/telephone/answer");
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_answer_call"));
|
||||
}
|
||||
@@ -424,14 +424,14 @@ export default {
|
||||
async hangupCall() {
|
||||
try {
|
||||
this.$emit("hangup");
|
||||
await window.axios.get("/api/v1/telephone/hangup");
|
||||
await window.api.get("/api/v1/telephone/hangup");
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_hangup_call"));
|
||||
}
|
||||
},
|
||||
async sendToVoicemail() {
|
||||
try {
|
||||
await window.axios.get("/api/v1/telephone/send-to-voicemail");
|
||||
await window.api.get("/api/v1/telephone/send-to-voicemail");
|
||||
ToastUtils.success(this.$t("call.call_sent_to_voicemail"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_send_to_voicemail"));
|
||||
@@ -449,7 +449,7 @@ export default {
|
||||
const endpoint = isCurrentlyMuted
|
||||
? "/api/v1/telephone/unmute-transmit"
|
||||
: "/api/v1/telephone/mute-transmit";
|
||||
await window.axios.get(endpoint);
|
||||
await window.api.get(endpoint);
|
||||
|
||||
setTimeout(() => {
|
||||
this.isMicMuting = false;
|
||||
@@ -473,7 +473,7 @@ export default {
|
||||
const endpoint = isCurrentlyMuted
|
||||
? "/api/v1/telephone/unmute-receive"
|
||||
: "/api/v1/telephone/mute-receive";
|
||||
await window.axios.get(endpoint);
|
||||
await window.api.get(endpoint);
|
||||
|
||||
setTimeout(() => {
|
||||
this.isSpeakerMuting = false;
|
||||
|
||||
@@ -2641,7 +2641,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -2649,7 +2649,7 @@ export default {
|
||||
},
|
||||
async updateConfig(config) {
|
||||
try {
|
||||
const response = await window.axios.patch("/api/v1/config", config);
|
||||
const response = await window.api.patch("/api/v1/config", config);
|
||||
if (response.data?.config) {
|
||||
this.config = response.data.config;
|
||||
}
|
||||
@@ -2660,7 +2660,7 @@ export default {
|
||||
},
|
||||
async getAudioProfiles() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/audio-profiles");
|
||||
const response = await window.api.get("/api/v1/telephone/audio-profiles");
|
||||
this.audioProfiles = response.data.audio_profiles;
|
||||
this.selectedAudioProfileId = response.data.default_audio_profile_id;
|
||||
} catch (e) {
|
||||
@@ -2669,7 +2669,7 @@ export default {
|
||||
},
|
||||
async getStatus() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/status");
|
||||
const response = await window.api.get("/api/v1/telephone/status");
|
||||
const oldCall = this.activeCall;
|
||||
const newCall = response.data.active_call;
|
||||
|
||||
@@ -2756,7 +2756,7 @@ export default {
|
||||
this.callHistoryOffset = 0;
|
||||
}
|
||||
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/telephone/history?limit=${this.callHistoryLimit}&offset=${this.callHistoryOffset}${
|
||||
this.callHistorySearch ? `&search=${encodeURIComponent(this.callHistorySearch)}` : ""
|
||||
}`
|
||||
@@ -2792,7 +2792,7 @@ export default {
|
||||
this.hasMoreDiscovery = true;
|
||||
}
|
||||
|
||||
const response = await window.axios.get("/api/v1/announces", {
|
||||
const response = await window.api.get("/api/v1/announces", {
|
||||
params: {
|
||||
aspect: "lxst.telephony",
|
||||
limit: this.discoveryLimit,
|
||||
@@ -2826,7 +2826,7 @@ export default {
|
||||
},
|
||||
async toggleDoNotDisturb(value) {
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
do_not_disturb_enabled: value,
|
||||
});
|
||||
if (this.config) {
|
||||
@@ -2839,7 +2839,7 @@ export default {
|
||||
},
|
||||
async toggleAllowCallsFromContactsOnly(value) {
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
telephone_allow_calls_from_contacts_only: value,
|
||||
});
|
||||
if (this.config) {
|
||||
@@ -2852,7 +2852,7 @@ export default {
|
||||
},
|
||||
async toggleCallRecording(value) {
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
call_recording_enabled: value,
|
||||
});
|
||||
if (this.config) {
|
||||
@@ -2866,7 +2866,7 @@ export default {
|
||||
async clearHistory() {
|
||||
if (!confirm(this.$t("common.delete_confirm"))) return;
|
||||
try {
|
||||
await window.axios.delete("/api/v1/telephone/history");
|
||||
await window.api.delete("/api/v1/telephone/history");
|
||||
this.callHistory = [];
|
||||
ToastUtils.success(this.$t("call.call_history_cleared"));
|
||||
} catch (e) {
|
||||
@@ -2877,7 +2877,7 @@ export default {
|
||||
async blockIdentity(hash) {
|
||||
if (!confirm(`Are you sure you want to banish this identity?`)) return;
|
||||
try {
|
||||
await window.axios.post("/api/v1/blocked-destinations", {
|
||||
await window.api.post("/api/v1/blocked-destinations", {
|
||||
destination_hash: hash,
|
||||
});
|
||||
ToastUtils.success(this.$t("call.identity_banished"));
|
||||
@@ -2888,7 +2888,7 @@ export default {
|
||||
},
|
||||
async getVoicemailStatus() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/voicemail/status");
|
||||
const response = await window.api.get("/api/v1/telephone/voicemail/status");
|
||||
this.voicemailStatus = response.data;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -2896,7 +2896,7 @@ export default {
|
||||
},
|
||||
async getRingtoneStatus() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/ringtones/status");
|
||||
const response = await window.api.get("/api/v1/telephone/ringtones/status");
|
||||
this.ringtoneStatus = response.data;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -2904,7 +2904,7 @@ export default {
|
||||
},
|
||||
async getRingtones() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/ringtones");
|
||||
const response = await window.api.get("/api/v1/telephone/ringtones");
|
||||
this.ringtones = response.data;
|
||||
} catch (e) {
|
||||
console.error("Failed to get ringtones:", e);
|
||||
@@ -2913,7 +2913,7 @@ export default {
|
||||
async deleteRingtone(ringtone) {
|
||||
if (!confirm(this.$t("common.delete_confirm"))) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/telephone/ringtones/${ringtone.id}`);
|
||||
await window.api.delete(`/api/v1/telephone/ringtones/${ringtone.id}`);
|
||||
ToastUtils.success(this.$t("call.ringtone_deleted"));
|
||||
await this.getRingtones();
|
||||
await this.getRingtoneStatus();
|
||||
@@ -2924,7 +2924,7 @@ export default {
|
||||
},
|
||||
async setPrimaryRingtone(ringtone) {
|
||||
try {
|
||||
await window.axios.patch(`/api/v1/telephone/ringtones/${ringtone.id}`, {
|
||||
await window.api.patch(`/api/v1/telephone/ringtones/${ringtone.id}`, {
|
||||
is_primary: true,
|
||||
});
|
||||
ToastUtils.success(this.$t("call.primary_ringtone_set"));
|
||||
@@ -2941,7 +2941,7 @@ export default {
|
||||
},
|
||||
async saveRingtoneName() {
|
||||
try {
|
||||
await window.axios.patch(`/api/v1/telephone/ringtones/${this.editingRingtoneId}`, {
|
||||
await window.api.patch(`/api/v1/telephone/ringtones/${this.editingRingtoneId}`, {
|
||||
display_name: this.editingRingtoneName,
|
||||
});
|
||||
this.editingRingtoneId = null;
|
||||
@@ -2960,7 +2960,7 @@ export default {
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
await window.axios.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
await window.api.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
@@ -3016,7 +3016,7 @@ export default {
|
||||
},
|
||||
async getVoicemails() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/voicemails", {
|
||||
const response = await window.api.get("/api/v1/telephone/voicemails", {
|
||||
params: { search: this.voicemailSearch },
|
||||
});
|
||||
this.voicemails = response.data.voicemails || [];
|
||||
@@ -3037,7 +3037,7 @@ export default {
|
||||
},
|
||||
async getContacts() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/contacts", {
|
||||
const response = await window.api.get("/api/v1/telephone/contacts", {
|
||||
params: { search: this.contactsSearch },
|
||||
});
|
||||
this.contacts = response.data.contacts || (Array.isArray(response.data) ? response.data : []);
|
||||
@@ -3122,10 +3122,10 @@ export default {
|
||||
if (this.editingContact && this.editingContact.custom_image && !contact.custom_image) {
|
||||
contact.clear_image = true;
|
||||
}
|
||||
await window.axios.patch(`/api/v1/telephone/contacts/${contact.id}`, contact);
|
||||
await window.api.patch(`/api/v1/telephone/contacts/${contact.id}`, contact);
|
||||
ToastUtils.success(this.$t("call.contact_updated"));
|
||||
} else {
|
||||
await window.axios.post("/api/v1/telephone/contacts", contact);
|
||||
await window.api.post("/api/v1/telephone/contacts", contact);
|
||||
ToastUtils.success(this.$t("call.contact_added"));
|
||||
}
|
||||
this.isContactModalOpen = false;
|
||||
@@ -3137,7 +3137,7 @@ export default {
|
||||
async deleteContact(contactId) {
|
||||
if (!confirm("Are you sure you want to delete this contact?")) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/telephone/contacts/${contactId}`);
|
||||
await window.api.delete(`/api/v1/telephone/contacts/${contactId}`);
|
||||
ToastUtils.success(this.$t("call.contact_deleted"));
|
||||
this.getContacts();
|
||||
} catch {
|
||||
@@ -3178,7 +3178,7 @@ export default {
|
||||
async generateGreeting() {
|
||||
this.isGeneratingGreeting = true;
|
||||
try {
|
||||
await window.axios.post("/api/v1/telephone/voicemail/generate-greeting");
|
||||
await window.api.post("/api/v1/telephone/voicemail/generate-greeting");
|
||||
ToastUtils.success(this.$t("call.greeting_generated_successfully"));
|
||||
await this.getVoicemailStatus();
|
||||
} catch (e) {
|
||||
@@ -3196,7 +3196,7 @@ export default {
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
await window.axios.post("/api/v1/telephone/voicemail/greeting/upload", formData, {
|
||||
await window.api.post("/api/v1/telephone/voicemail/greeting/upload", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
@@ -3214,7 +3214,7 @@ export default {
|
||||
if (!confirm("Are you sure you want to delete your custom greeting?")) return;
|
||||
|
||||
try {
|
||||
await window.axios.delete("/api/v1/telephone/voicemail/greeting");
|
||||
await window.api.delete("/api/v1/telephone/voicemail/greeting");
|
||||
ToastUtils.success(this.$t("call.greeting_deleted"));
|
||||
await this.getVoicemailStatus();
|
||||
} catch {
|
||||
@@ -3223,7 +3223,7 @@ export default {
|
||||
},
|
||||
async startRecordingGreetingMic() {
|
||||
try {
|
||||
await window.axios.post("/api/v1/telephone/voicemail/greeting/record/start");
|
||||
await window.api.post("/api/v1/telephone/voicemail/greeting/record/start");
|
||||
await this.getVoicemailStatus();
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_start_recording_greeting"));
|
||||
@@ -3231,7 +3231,7 @@ export default {
|
||||
},
|
||||
async stopRecordingGreetingMic() {
|
||||
try {
|
||||
await window.axios.post("/api/v1/telephone/voicemail/greeting/record/stop");
|
||||
await window.api.post("/api/v1/telephone/voicemail/greeting/record/stop");
|
||||
await this.getVoicemailStatus();
|
||||
ToastUtils.success(this.$t("call.greeting_recorded_from_mic"));
|
||||
} catch {
|
||||
@@ -3277,7 +3277,7 @@ export default {
|
||||
async markVoicemailAsRead(voicemail) {
|
||||
if (!voicemail.is_read) {
|
||||
try {
|
||||
await window.axios.post(`/api/v1/telephone/voicemails/${voicemail.id}/read`);
|
||||
await window.api.post(`/api/v1/telephone/voicemails/${voicemail.id}/read`);
|
||||
voicemail.is_read = 1;
|
||||
this.unreadVoicemailsCount = Math.max(0, this.unreadVoicemailsCount - 1);
|
||||
} catch (e) {
|
||||
@@ -3292,7 +3292,7 @@ export default {
|
||||
},
|
||||
async deleteVoicemail(voicemailId) {
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/telephone/voicemails/${voicemailId}`);
|
||||
await window.api.delete(`/api/v1/telephone/voicemails/${voicemailId}`);
|
||||
this.getVoicemails();
|
||||
ToastUtils.success(this.$t("call.voicemail_deleted"));
|
||||
} catch {
|
||||
@@ -3301,7 +3301,7 @@ export default {
|
||||
},
|
||||
async getRecordings() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/recordings", {
|
||||
const response = await window.api.get("/api/v1/telephone/recordings", {
|
||||
params: { search: this.recordingSearch },
|
||||
});
|
||||
this.recordings = response.data.recordings || [];
|
||||
@@ -3351,7 +3351,7 @@ export default {
|
||||
async deleteRecording(recordingId) {
|
||||
if (!confirm("Are you sure you want to delete this recording?")) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/telephone/recordings/${recordingId}`);
|
||||
await window.api.delete(`/api/v1/telephone/recordings/${recordingId}`);
|
||||
this.getRecordings();
|
||||
ToastUtils.success(this.$t("call.recording_deleted"));
|
||||
} catch {
|
||||
@@ -3410,7 +3410,7 @@ export default {
|
||||
this.wasDeclined = false;
|
||||
|
||||
try {
|
||||
await window.axios.get(`/api/v1/telephone/call/${hashToCall}`);
|
||||
await window.api.get(`/api/v1/telephone/call/${hashToCall}`);
|
||||
} catch (e) {
|
||||
this.initiationStatus = null;
|
||||
ToastUtils.error(e.response?.data?.message || "Failed to initiate call");
|
||||
@@ -3457,7 +3457,7 @@ export default {
|
||||
},
|
||||
async answerCall() {
|
||||
try {
|
||||
await window.axios.get("/api/v1/telephone/answer");
|
||||
await window.api.get("/api/v1/telephone/answer");
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_answer_call"));
|
||||
}
|
||||
@@ -3467,14 +3467,14 @@ export default {
|
||||
if (this.activeCall && this.activeCall.is_incoming && this.activeCall.status === 4) {
|
||||
this.wasDeclined = true;
|
||||
}
|
||||
await window.axios.get("/api/v1/telephone/hangup");
|
||||
await window.api.get("/api/v1/telephone/hangup");
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_hangup_call"));
|
||||
}
|
||||
},
|
||||
async sendToVoicemail() {
|
||||
try {
|
||||
await window.axios.get("/api/v1/telephone/send-to-voicemail");
|
||||
await window.api.get("/api/v1/telephone/send-to-voicemail");
|
||||
ToastUtils.success(this.$t("call.call_sent_to_voicemail"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_send_to_voicemail"));
|
||||
@@ -3482,7 +3482,7 @@ export default {
|
||||
},
|
||||
async switchAudioProfile(audioProfileId) {
|
||||
try {
|
||||
await window.axios.get(`/api/v1/telephone/switch-audio-profile/${audioProfileId}`);
|
||||
await window.api.get(`/api/v1/telephone/switch-audio-profile/${audioProfileId}`);
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("call.failed_to_switch_audio_profile"));
|
||||
}
|
||||
@@ -3501,7 +3501,7 @@ export default {
|
||||
const endpoint = isCurrentlyMuted
|
||||
? "/api/v1/telephone/unmute-transmit"
|
||||
: "/api/v1/telephone/mute-transmit";
|
||||
await window.axios.get(endpoint);
|
||||
await window.api.get(endpoint);
|
||||
|
||||
// clear muting state after a short delay to allow backend to catch up
|
||||
setTimeout(() => {
|
||||
@@ -3528,7 +3528,7 @@ export default {
|
||||
const endpoint = isCurrentlyMuted
|
||||
? "/api/v1/telephone/unmute-receive"
|
||||
: "/api/v1/telephone/mute-receive";
|
||||
await window.axios.get(endpoint);
|
||||
await window.api.get(endpoint);
|
||||
|
||||
// clear muting state after a short delay to allow backend to catch up
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -414,7 +414,7 @@ export default {
|
||||
|
||||
formData.append("file", blob, filename);
|
||||
|
||||
await window.axios.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
await window.api.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ export default {
|
||||
formData.append("file", blob, filename);
|
||||
|
||||
if (this.saveAsNew) {
|
||||
await window.axios.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
await window.api.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
} else {
|
||||
@@ -441,12 +441,12 @@ export default {
|
||||
// but the user might expect replacement.
|
||||
// The backend doesn't seem to support direct replacement via the upload endpoint.
|
||||
// Let's just upload it.
|
||||
await window.axios.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
await window.api.post("/api/v1/telephone/ringtones/upload", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
|
||||
// If not saving as new, maybe delete the old one?
|
||||
// await window.axios.delete(`/api/v1/telephone/ringtones/${this.ringtone.id}`);
|
||||
// await window.api.delete(`/api/v1/telephone/ringtones/${this.ringtone.id}`);
|
||||
}
|
||||
|
||||
ToastUtils.success(this.$t("call.ringtone_saved"));
|
||||
|
||||
@@ -453,7 +453,7 @@ export default {
|
||||
methods: {
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
this.config = response.data.config;
|
||||
this.myIdentityUri = this.buildMyIdentityUri();
|
||||
if (this.myIdentityUri) {
|
||||
@@ -478,7 +478,7 @@ export default {
|
||||
this.contactsOffset = 0;
|
||||
}
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/contacts", {
|
||||
const response = await window.api.get("/api/v1/telephone/contacts", {
|
||||
params: {
|
||||
search: this.contactsSearch || undefined,
|
||||
limit: this.contactsPageSize,
|
||||
@@ -548,7 +548,7 @@ export default {
|
||||
},
|
||||
async importContacts(contacts) {
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/telephone/contacts/import", {
|
||||
const response = await window.api.post("/api/v1/telephone/contacts/import", {
|
||||
contacts,
|
||||
});
|
||||
const added = response.data?.added ?? 0;
|
||||
@@ -561,7 +561,7 @@ export default {
|
||||
},
|
||||
async exportContacts() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/contacts/export");
|
||||
const response = await window.api.get("/api/v1/telephone/contacts/export");
|
||||
const contacts = response.data?.contacts ?? [];
|
||||
const blob = new Blob([JSON.stringify({ contacts }, null, 2)], {
|
||||
type: "application/json",
|
||||
@@ -628,13 +628,13 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = await window.axios.get(`/api/v1/telephone/contacts/check/${destinationHash}`);
|
||||
const existing = await window.api.get(`/api/v1/telephone/contacts/check/${destinationHash}`);
|
||||
if (existing.data?.id) {
|
||||
ToastUtils.info(this.$t("contacts.contact_already_exists"));
|
||||
return;
|
||||
}
|
||||
|
||||
await window.axios.post("/api/v1/telephone/contacts", {
|
||||
await window.api.post("/api/v1/telephone/contacts", {
|
||||
name: this.newContactName?.trim() || `Contact ${destinationHash.slice(0, 8)}`,
|
||||
remote_identity_hash: destinationHash,
|
||||
lxmf_address: destinationHash,
|
||||
@@ -673,7 +673,7 @@ export default {
|
||||
if (!contact?.id) return;
|
||||
if (!window.confirm(this.$t("contacts.remove_contact_confirm"))) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/telephone/contacts/${contact.id}`);
|
||||
await window.api.delete(`/api/v1/telephone/contacts/${contact.id}`);
|
||||
ToastUtils.success(this.$t("contacts.contact_removed"));
|
||||
await this.getContacts();
|
||||
} catch {
|
||||
@@ -707,7 +707,7 @@ export default {
|
||||
const destinationHash = (contact?.lxmf_address || contact?.remote_identity_hash || "").toLowerCase();
|
||||
if (!/^[0-9a-f]{32}$/.test(destinationHash)) return null;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/announces", {
|
||||
const response = await window.api.get("/api/v1/announces", {
|
||||
params: {
|
||||
destination_hash: destinationHash,
|
||||
limit: 1,
|
||||
|
||||
@@ -323,7 +323,7 @@ export default {
|
||||
level: this.level || undefined,
|
||||
is_anomaly: this.is_anomaly ? true : undefined,
|
||||
};
|
||||
const response = await window.axios.get("/api/v1/debug/logs", { params });
|
||||
const response = await window.api.get("/api/v1/debug/logs", { params });
|
||||
this.logs = response.data.logs;
|
||||
this.total = response.data.total;
|
||||
} catch (e) {
|
||||
@@ -342,7 +342,7 @@ export default {
|
||||
search: this.accessSearch || undefined,
|
||||
outcome: this.accessOutcome || undefined,
|
||||
};
|
||||
const response = await window.axios.get("/api/v1/debug/access-attempts", { params });
|
||||
const response = await window.api.get("/api/v1/debug/access-attempts", { params });
|
||||
this.accessAttempts = response.data.attempts;
|
||||
this.accessTotal = response.data.total;
|
||||
} catch (e) {
|
||||
|
||||
@@ -630,7 +630,7 @@ export default {
|
||||
methods: {
|
||||
async fetchStatus() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/docs/status");
|
||||
const response = await window.api.get("/api/v1/docs/status");
|
||||
this.status = response.data;
|
||||
|
||||
// Auto-download Reticulum docs if missing and we're not already doing something
|
||||
@@ -650,7 +650,7 @@ export default {
|
||||
},
|
||||
async fetchMeshChatXDocs() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/meshchatx-docs/list");
|
||||
const response = await window.api.get("/api/v1/meshchatx-docs/list");
|
||||
this.meshchatxDocs = response.data;
|
||||
if (this.meshchatxDocs.length > 0 && !this.selectedDocPath) {
|
||||
this.selectDoc(this.meshchatxDocs[0].path);
|
||||
@@ -662,7 +662,7 @@ export default {
|
||||
async selectDoc(path) {
|
||||
this.selectedDocPath = path;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/meshchatx-docs/content", {
|
||||
const response = await window.api.get("/api/v1/meshchatx-docs/content", {
|
||||
params: { path },
|
||||
});
|
||||
this.selectedDocContent = response.data;
|
||||
@@ -675,7 +675,7 @@ export default {
|
||||
},
|
||||
async updateDocs() {
|
||||
try {
|
||||
await window.axios.post("/api/v1/docs/update");
|
||||
await window.api.post("/api/v1/docs/update");
|
||||
this.fetchStatus();
|
||||
} catch (error) {
|
||||
console.error("Failed to trigger docs update:", error);
|
||||
@@ -685,12 +685,12 @@ export default {
|
||||
if (!this.alternateDocsUrl) return;
|
||||
try {
|
||||
// Get current config
|
||||
const configResponse = await window.axios.get("/api/v1/config");
|
||||
const configResponse = await window.api.get("/api/v1/config");
|
||||
const currentUrls = configResponse.data.config.docs_download_urls || "";
|
||||
const newUrls = currentUrls ? `${currentUrls},${this.alternateDocsUrl}` : this.alternateDocsUrl;
|
||||
|
||||
// Update config
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
docs_download_urls: newUrls,
|
||||
});
|
||||
|
||||
@@ -704,7 +704,7 @@ export default {
|
||||
},
|
||||
async switchVersion(version) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/docs/switch", { version });
|
||||
await window.api.post("/api/v1/docs/switch", { version });
|
||||
this.showVersions = false;
|
||||
this.selectedReticulumPath = null;
|
||||
this.fetchStatus();
|
||||
@@ -725,7 +725,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/docs/version/${encodeURIComponent(version)}`);
|
||||
await window.api.delete(`/api/v1/docs/version/${encodeURIComponent(version)}`);
|
||||
this.fetchStatus();
|
||||
ToastUtils.success(`Version ${version} deleted`);
|
||||
} catch (error) {
|
||||
@@ -744,7 +744,7 @@ export default {
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
await window.axios.post(`/api/v1/docs/upload?version=${encodeURIComponent(version)}`, formData, {
|
||||
await window.api.post(`/api/v1/docs/upload?version=${encodeURIComponent(version)}`, formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
@@ -776,7 +776,7 @@ export default {
|
||||
try {
|
||||
this.showLanguages = false;
|
||||
this.selectedReticulumPath = null;
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
language: langCode,
|
||||
});
|
||||
// The app will update automatically via websocket config sync
|
||||
@@ -798,7 +798,7 @@ export default {
|
||||
if (!this.searchQuery) return;
|
||||
this.isSearching = true;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/docs/search", {
|
||||
const response = await window.api.get("/api/v1/docs/search", {
|
||||
params: {
|
||||
q: this.searchQuery,
|
||||
lang: this.currentLang,
|
||||
|
||||
@@ -1189,7 +1189,7 @@ export default {
|
||||
methods: {
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/config`);
|
||||
const response = await window.api.get(`/api/v1/config`);
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -1197,7 +1197,7 @@ export default {
|
||||
},
|
||||
async updateConfig(config) {
|
||||
try {
|
||||
const response = await window.axios.patch("/api/v1/config", config);
|
||||
const response = await window.api.patch("/api/v1/config", config);
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
ToastUtils.error(this.$t("common.save_failed"));
|
||||
@@ -1212,7 +1212,7 @@ export default {
|
||||
},
|
||||
async loadReticulumDiscoveryConfig() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/reticulum/discovery`);
|
||||
const response = await window.api.get(`/api/v1/reticulum/discovery`);
|
||||
const discovery = response.data?.discovery ?? {};
|
||||
this.reticulumDiscovery.discover_interfaces = this.parseBool(discovery.discover_interfaces);
|
||||
this.reticulumDiscovery.interface_discovery_whitelist = discovery.interface_discovery_whitelist ?? "";
|
||||
@@ -1230,7 +1230,7 @@ export default {
|
||||
interface_discovery_whitelist: this.reticulumDiscovery.interface_discovery_whitelist || null,
|
||||
interface_discovery_blacklist: this.reticulumDiscovery.interface_discovery_blacklist || null,
|
||||
};
|
||||
await window.axios.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
await window.api.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
ToastUtils.success("Discovery listener preferences saved.");
|
||||
} catch (e) {
|
||||
ToastUtils.error("Failed to save discovery preferences.");
|
||||
@@ -1241,7 +1241,7 @@ export default {
|
||||
},
|
||||
async loadComports() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/comports`);
|
||||
const response = await window.api.get(`/api/v1/comports`);
|
||||
this.comports = response.data.comports;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -1249,7 +1249,7 @@ export default {
|
||||
},
|
||||
async loadCommunityInterfaces() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/community-interfaces`);
|
||||
const response = await window.api.get(`/api/v1/community-interfaces`);
|
||||
this.communityInterfaces = response.data.interfaces ?? [];
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -1260,7 +1260,7 @@ export default {
|
||||
},
|
||||
async loadInterfaceToEdit(interfaceName) {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/reticulum/interfaces`);
|
||||
const response = await window.api.get(`/api/v1/reticulum/interfaces`);
|
||||
const interfaces = response.data.interfaces;
|
||||
const iface = interfaces[interfaceName];
|
||||
if (!iface) {
|
||||
@@ -1412,7 +1412,7 @@ export default {
|
||||
? (this.I2PSettings.newInterfacePeers || []).map((p) => String(p).trim()).filter(Boolean)
|
||||
: undefined;
|
||||
|
||||
const response = await window.axios.post(`/api/v1/reticulum/interfaces/add`, {
|
||||
const response = await window.api.post(`/api/v1/reticulum/interfaces/add`, {
|
||||
allow_overwriting_interface: this.isEditingInterface,
|
||||
name: this.newInterfaceName,
|
||||
type: this.newInterfaceType,
|
||||
|
||||
@@ -186,7 +186,7 @@ export default {
|
||||
|
||||
try {
|
||||
// fetch preview of interfaces to import
|
||||
const response = await window.axios.post("/api/v1/reticulum/interfaces/import-preview", {
|
||||
const response = await window.api.post("/api/v1/reticulum/interfaces/import-preview", {
|
||||
config: await file.text(),
|
||||
});
|
||||
|
||||
@@ -249,7 +249,7 @@ export default {
|
||||
|
||||
try {
|
||||
// import interfaces
|
||||
await window.axios.post("/api/v1/reticulum/interfaces/import", {
|
||||
await window.api.post("/api/v1/reticulum/interfaces/import", {
|
||||
config: await this.selectedFile.text(),
|
||||
selected_interface_names: this.selectedInterfaces,
|
||||
});
|
||||
|
||||
@@ -796,11 +796,11 @@ export default {
|
||||
},
|
||||
async loadInterfaces() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/reticulum/interfaces`);
|
||||
const response = await window.api.get(`/api/v1/reticulum/interfaces`);
|
||||
this.interfaces = response.data.interfaces;
|
||||
|
||||
// also check app info for running state
|
||||
const appInfoResponse = await window.axios.get(`/api/v1/app/info`);
|
||||
const appInfoResponse = await window.api.get(`/api/v1/app/info`);
|
||||
this.isReticulumRunning = appInfoResponse.data.app_info.is_reticulum_running;
|
||||
} catch {
|
||||
// do nothing if failed to load interfaces
|
||||
@@ -809,7 +809,7 @@ export default {
|
||||
async updateInterfaceStats() {
|
||||
try {
|
||||
// fetch interface stats
|
||||
const response = await window.axios.get(`/api/v1/interface-stats`);
|
||||
const response = await window.api.get(`/api/v1/interface-stats`);
|
||||
|
||||
// update data
|
||||
const interfaces = response.data.interface_stats?.interfaces ?? [];
|
||||
@@ -823,7 +823,7 @@ export default {
|
||||
async enableInterface(interfaceName) {
|
||||
// enable interface
|
||||
try {
|
||||
await window.axios.post(`/api/v1/reticulum/interfaces/enable`, {
|
||||
await window.api.post(`/api/v1/reticulum/interfaces/enable`, {
|
||||
name: interfaceName,
|
||||
});
|
||||
this.trackInterfaceChange(interfaceName);
|
||||
@@ -838,7 +838,7 @@ export default {
|
||||
async disableInterface(interfaceName) {
|
||||
// disable interface
|
||||
try {
|
||||
await window.axios.post(`/api/v1/reticulum/interfaces/disable`, {
|
||||
await window.api.post(`/api/v1/reticulum/interfaces/disable`, {
|
||||
name: interfaceName,
|
||||
});
|
||||
this.trackInterfaceChange(interfaceName);
|
||||
@@ -866,7 +866,7 @@ export default {
|
||||
|
||||
// delete interface
|
||||
try {
|
||||
await window.axios.post(`/api/v1/reticulum/interfaces/delete`, {
|
||||
await window.api.post(`/api/v1/reticulum/interfaces/delete`, {
|
||||
name: interfaceName,
|
||||
});
|
||||
this.trackInterfaceChange(interfaceName);
|
||||
@@ -881,7 +881,7 @@ export default {
|
||||
async exportInterfaces() {
|
||||
try {
|
||||
// fetch exported interfaces
|
||||
const response = await window.axios.post("/api/v1/reticulum/interfaces/export");
|
||||
const response = await window.api.post("/api/v1/reticulum/interfaces/export");
|
||||
|
||||
// download file to browser
|
||||
DownloadUtils.downloadFile("meshchat_interfaces.txt", new Blob([response.data]));
|
||||
@@ -893,7 +893,7 @@ export default {
|
||||
async exportInterface(interfaceName) {
|
||||
try {
|
||||
// fetch exported interfaces
|
||||
const response = await window.axios.post("/api/v1/reticulum/interfaces/export", {
|
||||
const response = await window.api.post("/api/v1/reticulum/interfaces/export", {
|
||||
selected_interface_names: [interfaceName],
|
||||
});
|
||||
|
||||
@@ -916,7 +916,7 @@ export default {
|
||||
},
|
||||
async loadDiscoveredInterfaces() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/reticulum/discovered-interfaces`);
|
||||
const response = await window.api.get(`/api/v1/reticulum/discovered-interfaces`);
|
||||
const incoming = response.data?.interfaces ?? [];
|
||||
const active = response.data?.active ?? [];
|
||||
|
||||
@@ -1021,7 +1021,7 @@ export default {
|
||||
},
|
||||
async loadDiscoveryConfig() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/reticulum/discovery`);
|
||||
const response = await window.api.get(`/api/v1/reticulum/discovery`);
|
||||
const discovery = response.data?.discovery ?? {};
|
||||
this.discoveryConfig.discover_interfaces = this.parseBool(discovery.discover_interfaces);
|
||||
this.discoveryConfig.interface_discovery_sources = discovery.interface_discovery_sources ?? "";
|
||||
@@ -1066,7 +1066,7 @@ export default {
|
||||
network_identity: this.discoveryConfig.network_identity || null,
|
||||
};
|
||||
|
||||
await window.axios.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
await window.api.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
ToastUtils.success(this.$t("interfaces.discovery_settings_saved"));
|
||||
await this.loadDiscoveryConfig();
|
||||
} catch (e) {
|
||||
@@ -1192,7 +1192,7 @@ export default {
|
||||
interface_discovery_whitelist: nextWhitelist.length ? nextWhitelist.join(",") : null,
|
||||
interface_discovery_blacklist: nextBlacklist.length ? nextBlacklist.join(",") : null,
|
||||
};
|
||||
await window.axios.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
await window.api.patch(`/api/v1/reticulum/discovery`, payload);
|
||||
this.discoveryConfig.interface_discovery_whitelist = payload.interface_discovery_whitelist || "";
|
||||
this.discoveryConfig.interface_discovery_blacklist = payload.interface_discovery_blacklist || "";
|
||||
ToastUtils.success(
|
||||
@@ -1251,7 +1251,7 @@ export default {
|
||||
|
||||
try {
|
||||
this.reloadingRns = true;
|
||||
const response = await window.axios.post("/api/v1/reticulum/reload");
|
||||
const response = await window.api.post("/api/v1/reticulum/reload");
|
||||
ToastUtils.success(response.data.message);
|
||||
GlobalState.hasPendingInterfaceChanges = false;
|
||||
GlobalState.modifiedInterfaceNames.clear();
|
||||
|
||||
@@ -1662,7 +1662,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
this.config = response.data.config;
|
||||
this.offlineEnabled = this.config.map_offline_enabled;
|
||||
this.cachingEnabled =
|
||||
@@ -1680,7 +1680,7 @@ export default {
|
||||
},
|
||||
async loadMBTilesList() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/map/mbtiles");
|
||||
const response = await window.api.get("/api/v1/map/mbtiles");
|
||||
this.mbtilesList = response.data;
|
||||
} catch (e) {
|
||||
console.error("Failed to load MBTiles list", e);
|
||||
@@ -1688,7 +1688,7 @@ export default {
|
||||
},
|
||||
async setActiveMBTiles(filename) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/map/mbtiles/active", { filename });
|
||||
await window.api.post("/api/v1/map/mbtiles/active", { filename });
|
||||
await this.checkOfflineMap();
|
||||
await this.loadMBTilesList();
|
||||
ToastUtils.success(this.$t("map.source_updated"));
|
||||
@@ -1699,7 +1699,7 @@ export default {
|
||||
async deleteMBTiles(filename) {
|
||||
if (!confirm(`Are you sure you want to delete ${filename}?`)) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/map/mbtiles/${filename}`);
|
||||
await window.api.delete(`/api/v1/map/mbtiles/${filename}`);
|
||||
await this.loadMBTilesList();
|
||||
if (this.metadata && this.metadata.path && this.metadata.path.endsWith(filename)) {
|
||||
await this.checkOfflineMap();
|
||||
@@ -1711,7 +1711,7 @@ export default {
|
||||
},
|
||||
async saveMBTilesDir() {
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
map_mbtiles_dir: this.mbtilesDir,
|
||||
});
|
||||
ToastUtils.success(this.$t("map.storage_saved"));
|
||||
@@ -2142,7 +2142,7 @@ export default {
|
||||
},
|
||||
async checkOfflineMap() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/map/offline");
|
||||
const response = await window.api.get("/api/v1/map/offline");
|
||||
if (response.data && response.data.loaded !== false && Object.keys(response.data).length > 0) {
|
||||
this.metadata = response.data;
|
||||
this.hasOfflineMap = true;
|
||||
@@ -2240,7 +2240,7 @@ export default {
|
||||
|
||||
// Persist setting
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
map_offline_enabled: enabled,
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -2252,7 +2252,7 @@ export default {
|
||||
this.tileErrorCount = 0;
|
||||
this.showOfflineHint = false;
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
map_tile_cache_enabled: enabled,
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -2275,7 +2275,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/map/export/${this.exportId}`);
|
||||
await window.api.delete(`/api/v1/map/export/${this.exportId}`);
|
||||
this.exportStatus = null;
|
||||
this.exportId = null;
|
||||
ToastUtils.success(this.$t("map.export_cancelled"));
|
||||
@@ -2287,7 +2287,7 @@ export default {
|
||||
if (!this.selectedBbox) return;
|
||||
this.isExporting = true;
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/map/export", {
|
||||
const response = await window.api.post("/api/v1/map/export", {
|
||||
bbox: this.selectedBbox,
|
||||
min_zoom: this.exportMinZoom,
|
||||
max_zoom: this.exportMaxZoom,
|
||||
@@ -2306,7 +2306,7 @@ export default {
|
||||
if (this.exportInterval) clearInterval(this.exportInterval);
|
||||
this.exportInterval = setInterval(async () => {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/map/export/${this.exportId}`);
|
||||
const response = await window.api.get(`/api/v1/map/export/${this.exportId}`);
|
||||
this.exportStatus = response.data;
|
||||
if (this.exportStatus.status === "completed" || this.exportStatus.status === "failed") {
|
||||
clearInterval(this.exportInterval);
|
||||
@@ -2344,7 +2344,7 @@ export default {
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/map/offline", formData, {
|
||||
const response = await window.api.post("/api/v1/map/offline", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
@@ -2381,7 +2381,7 @@ export default {
|
||||
const zoom = Math.round(view.getZoom());
|
||||
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
map_default_lat: center[1],
|
||||
map_default_lon: center[0],
|
||||
map_default_zoom: zoom,
|
||||
@@ -2401,7 +2401,7 @@ export default {
|
||||
},
|
||||
async saveTileServerUrl() {
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
map_tile_server_url: this.tileServerUrl,
|
||||
});
|
||||
this.updateMapSource();
|
||||
@@ -2427,7 +2427,7 @@ export default {
|
||||
},
|
||||
async saveNominatimApiUrl() {
|
||||
try {
|
||||
await window.axios.patch("/api/v1/config", {
|
||||
await window.api.patch("/api/v1/config", {
|
||||
map_nominatim_api_url: this.nominatimApiUrl,
|
||||
});
|
||||
ToastUtils.success(this.$t("map.nominatim_api_saved"));
|
||||
@@ -2640,9 +2640,9 @@ export default {
|
||||
this.isMobileScreen = window.innerWidth < 640;
|
||||
},
|
||||
async fetchPeers() {
|
||||
if (!window.axios) return;
|
||||
if (!window.api) return;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/lxmf/conversations");
|
||||
const response = await window.api.get("/api/v1/lxmf/conversations");
|
||||
const peers = {};
|
||||
for (const conv of response.data.conversations) {
|
||||
peers[conv.destination_hash] = conv;
|
||||
@@ -3259,7 +3259,7 @@ export default {
|
||||
this.showLoadDrawingModal = true;
|
||||
this.isLoadingDrawings = true;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/map/drawings");
|
||||
const response = await window.api.get("/api/v1/map/drawings");
|
||||
this.savedDrawings = response.data.drawings;
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("map.failed_load_drawings"));
|
||||
@@ -3283,7 +3283,7 @@ export default {
|
||||
});
|
||||
|
||||
try {
|
||||
await window.axios.post("/api/v1/map/drawings", {
|
||||
await window.api.post("/api/v1/map/drawings", {
|
||||
name: this.newDrawingName,
|
||||
data: json,
|
||||
});
|
||||
@@ -3311,7 +3311,7 @@ export default {
|
||||
async deleteDrawing(drawing) {
|
||||
if (!confirm(`Delete drawing "${drawing.name}"?`)) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/map/drawings/${drawing.id}`);
|
||||
await window.api.delete(`/api/v1/map/drawings/${drawing.id}`);
|
||||
this.savedDrawings = this.savedDrawings.filter((d) => d.id !== drawing.id);
|
||||
ToastUtils.success(this.$t("map.deleted"));
|
||||
} catch {
|
||||
@@ -3368,9 +3368,9 @@ export default {
|
||||
}
|
||||
},
|
||||
async fetchTelemetryMarkers() {
|
||||
if (!window.axios) return;
|
||||
if (!window.api) return;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telemetry/peers");
|
||||
const response = await window.api.get("/api/v1/telemetry/peers");
|
||||
this.telemetryList = response.data.telemetry;
|
||||
this.updateMarkers();
|
||||
} catch (e) {
|
||||
@@ -3520,7 +3520,7 @@ export default {
|
||||
async drawTelemetryPath(hash) {
|
||||
this.clearTelemetryPath();
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/telemetry/history/${hash}?limit=50`);
|
||||
const response = await window.api.get(`/api/v1/telemetry/history/${hash}?limit=50`);
|
||||
const history = response.data.telemetry;
|
||||
if (!history || history.length < 2) return;
|
||||
|
||||
@@ -3622,7 +3622,7 @@ export default {
|
||||
},
|
||||
async toggleTracking(hash) {
|
||||
try {
|
||||
const response = await window.axios.post(`/api/v1/telemetry/tracking/${hash}/toggle`, {
|
||||
const response = await window.api.post(`/api/v1/telemetry/tracking/${hash}/toggle`, {
|
||||
is_tracking: this.selectedMarker.telemetry.is_tracking ? false : true,
|
||||
});
|
||||
if (this.selectedMarker && this.selectedMarker.telemetry.destination_hash === hash) {
|
||||
@@ -3640,7 +3640,7 @@ export default {
|
||||
},
|
||||
async mapDiscoveredNodes() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/reticulum/discovered-interfaces");
|
||||
const response = await window.api.get("/api/v1/reticulum/discovered-interfaces");
|
||||
const discovered = response.data?.interfaces ?? [];
|
||||
const nodesWithLoc = discovered.filter((n) => n.latitude != null && n.longitude != null);
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ export default {
|
||||
if (!this.destinationHash) return;
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/lxmf-messages/conversation/${this.destinationHash}?count=20&order=desc`
|
||||
);
|
||||
this.messages = (response.data.lxmf_messages || []).reverse();
|
||||
@@ -148,7 +148,7 @@ export default {
|
||||
if (!this.newMessage.trim() || this.sending) return;
|
||||
this.sending = true;
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/lxmf-messages/send", {
|
||||
const response = await window.api.post("/api/v1/lxmf-messages/send", {
|
||||
lxmf_message: {
|
||||
destination_hash: this.destinationHash,
|
||||
content: this.newMessage,
|
||||
|
||||
@@ -129,9 +129,7 @@ export default {
|
||||
async fetchContact() {
|
||||
if (!this.peer || !this.peer.destination_hash) return;
|
||||
try {
|
||||
const response = await window.axios.get(
|
||||
`/api/v1/telephone/contacts/check/${this.peer.destination_hash}`
|
||||
);
|
||||
const response = await window.api.get(`/api/v1/telephone/contacts/check/${this.peer.destination_hash}`);
|
||||
if (response.data.is_contact) {
|
||||
this.contact = response.data.contact;
|
||||
} else {
|
||||
@@ -146,14 +144,14 @@ export default {
|
||||
try {
|
||||
if (!this.contact) {
|
||||
// create contact first
|
||||
await window.axios.post("/api/v1/telephone/contacts", {
|
||||
await window.api.post("/api/v1/telephone/contacts", {
|
||||
name: this.peer.display_name,
|
||||
remote_identity_hash: this.peer.destination_hash,
|
||||
is_telemetry_trusted: true,
|
||||
});
|
||||
await this.fetchContact();
|
||||
} else {
|
||||
await window.axios.patch(`/api/v1/telephone/contacts/${this.contact.id}`, {
|
||||
await window.api.patch(`/api/v1/telephone/contacts/${this.contact.id}`, {
|
||||
is_telemetry_trusted: newStatus,
|
||||
});
|
||||
this.contact.is_telemetry_trusted = newStatus;
|
||||
@@ -182,7 +180,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
await window.axios.post("/api/v1/blocked-destinations", {
|
||||
await window.api.post("/api/v1/blocked-destinations", {
|
||||
destination_hash: this.peer.destination_hash,
|
||||
});
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
@@ -195,7 +193,7 @@ export default {
|
||||
},
|
||||
async onUnblockDestination() {
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/blocked-destinations/${this.peer.destination_hash}`);
|
||||
await window.api.delete(`/api/v1/blocked-destinations/${this.peer.destination_hash}`);
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
DialogUtils.alert(this.$t("banishment.banishment_lifted"));
|
||||
this.$emit("block-status-changed");
|
||||
@@ -212,7 +210,7 @@ export default {
|
||||
|
||||
// delete all lxmf messages from "us to destination" and from "destination to us"
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/lxmf-messages/conversation/${this.peer.destination_hash}`);
|
||||
await window.api.delete(`/api/v1/lxmf-messages/conversation/${this.peer.destination_hash}`);
|
||||
} catch (e) {
|
||||
DialogUtils.alert(this.$t("messages.failed_delete_history"));
|
||||
console.log(e);
|
||||
@@ -238,7 +236,7 @@ export default {
|
||||
|
||||
try {
|
||||
// ping destination
|
||||
const response = await window.axios.get(`/api/v1/ping/${destinationHash}/lxmf.delivery`, {
|
||||
const response = await window.api.get(`/api/v1/ping/${destinationHash}/lxmf.delivery`, {
|
||||
params: {
|
||||
timeout: 30,
|
||||
},
|
||||
|
||||
@@ -2198,7 +2198,7 @@ export default {
|
||||
},
|
||||
async updatePropagationNodeStatus() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/lxmf/propagation-node/status");
|
||||
const response = await window.api.get("/api/v1/lxmf/propagation-node/status");
|
||||
this.propagationNodeStatus = response.data.propagation_node_status;
|
||||
} catch {
|
||||
// do nothing on error
|
||||
@@ -2226,7 +2226,7 @@ export default {
|
||||
},
|
||||
async fetchContacts() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/contacts");
|
||||
const response = await window.api.get("/api/v1/telephone/contacts");
|
||||
this.contacts = response.data?.contacts ?? (Array.isArray(response.data) ? response.data : []);
|
||||
} catch (e) {
|
||||
console.log("Failed to fetch contacts:", e);
|
||||
@@ -2238,7 +2238,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/translator/languages");
|
||||
const response = await window.api.get("/api/v1/translator/languages");
|
||||
this.translatorLanguages = response.data.languages || [];
|
||||
this.hasTranslator = this.translatorLanguages.length > 0;
|
||||
} catch (e) {
|
||||
@@ -2252,7 +2252,7 @@ export default {
|
||||
try {
|
||||
this.isSendingMessage = true;
|
||||
const targetLang = this.$i18n.locale || "en";
|
||||
const response = await window.axios.post("/api/v1/translator/translate", {
|
||||
const response = await window.api.post("/api/v1/translator/translate", {
|
||||
text: this.newMessageText,
|
||||
source_lang: "auto",
|
||||
target_lang: targetLang,
|
||||
@@ -2303,7 +2303,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/telephone/contacts/check/${this.selectedPeer.destination_hash}`
|
||||
);
|
||||
this.isStrangerPeer = !response.data.is_contact;
|
||||
@@ -2415,7 +2415,7 @@ export default {
|
||||
|
||||
// fetch lxmf messages from "us to destination" and from "destination to us"
|
||||
const pageSize = 30;
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/lxmf-messages/conversation/${this.selectedPeer.destination_hash}`,
|
||||
{
|
||||
params: {
|
||||
@@ -2515,13 +2515,13 @@ export default {
|
||||
async addContact(name, hash, lxmf_address = null, lxst_address = null) {
|
||||
try {
|
||||
// Check if contact already exists
|
||||
const checkResponse = await window.axios.get(`/api/v1/telephone/contacts/check/${hash}`);
|
||||
const checkResponse = await window.api.get(`/api/v1/telephone/contacts/check/${hash}`);
|
||||
if (checkResponse.data?.id) {
|
||||
ToastUtils.info(`${name} is already in your contacts`);
|
||||
return;
|
||||
}
|
||||
|
||||
await window.axios.post("/api/v1/telephone/contacts", {
|
||||
await window.api.post("/api/v1/telephone/contacts", {
|
||||
name: name,
|
||||
remote_identity_hash: hash,
|
||||
lxmf_address: lxmf_address,
|
||||
@@ -2752,7 +2752,7 @@ export default {
|
||||
if (this.selectedPeer) {
|
||||
try {
|
||||
// get path to destination
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/destination/${this.selectedPeer.destination_hash}/path`
|
||||
);
|
||||
|
||||
@@ -2770,7 +2770,7 @@ export default {
|
||||
if (this.selectedPeer) {
|
||||
try {
|
||||
// get lxmf stamp info
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/destination/${this.selectedPeer.destination_hash}/lxmf-stamp-info`
|
||||
);
|
||||
|
||||
@@ -2788,7 +2788,7 @@ export default {
|
||||
if (this.selectedPeer) {
|
||||
try {
|
||||
// get signal metrics
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/destination/${this.selectedPeer.destination_hash}/signal-metrics`
|
||||
);
|
||||
|
||||
@@ -2868,7 +2868,7 @@ export default {
|
||||
if (this.selectedPeer) {
|
||||
try {
|
||||
// get custom display name
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/destination/${this.selectedPeer.destination_hash}/custom-display-name`
|
||||
);
|
||||
|
||||
@@ -2896,7 +2896,7 @@ export default {
|
||||
|
||||
try {
|
||||
// update display name on server
|
||||
await axios.post(
|
||||
await window.api.post(
|
||||
`/api/v1/destination/${this.selectedPeer.destination_hash}/custom-display-name/update`,
|
||||
{
|
||||
display_name: displayName,
|
||||
@@ -2928,7 +2928,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await window.axios.post("/api/v1/blocked-destinations", {
|
||||
await window.api.post("/api/v1/blocked-destinations", {
|
||||
destination_hash: this.selectedPeer.destination_hash,
|
||||
});
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
@@ -2944,7 +2944,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/blocked-destinations/${this.selectedPeer.destination_hash}`);
|
||||
await window.api.delete(`/api/v1/blocked-destinations/${this.selectedPeer.destination_hash}`);
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
DialogUtils.alert(this.$t("banishment.banishment_lifted"));
|
||||
} catch (e) {
|
||||
@@ -3024,7 +3024,7 @@ export default {
|
||||
async showRawMessage(chatItem) {
|
||||
try {
|
||||
// we'll try to get the URI first as it contains the raw signed message
|
||||
const response = await window.axios.get(`/api/v1/lxmf-messages/${chatItem.lxmf_message.hash}/uri`);
|
||||
const response = await window.api.get(`/api/v1/lxmf-messages/${chatItem.lxmf_message.hash}/uri`);
|
||||
this.rawMessageData = {
|
||||
...chatItem.lxmf_message,
|
||||
raw_uri: response.data.uri,
|
||||
@@ -3041,7 +3041,7 @@ export default {
|
||||
this.isDownloadingAudio[chatItem.lxmf_message.hash] = true;
|
||||
try {
|
||||
// fetch audio bytes from api
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/lxmf-messages/attachment/${chatItem.lxmf_message.hash}/audio`,
|
||||
{
|
||||
responseType: "arraybuffer",
|
||||
@@ -3238,7 +3238,7 @@ export default {
|
||||
}
|
||||
|
||||
// delete lxmf message from server
|
||||
await window.axios.delete(`/api/v1/lxmf-messages/${chatItem.lxmf_message.hash}`);
|
||||
await window.api.delete(`/api/v1/lxmf-messages/${chatItem.lxmf_message.hash}`);
|
||||
|
||||
// remove lxmf message from chat items using hash, as other pending items might not have an id yet
|
||||
this.chatItems = this.chatItems.filter((item) => {
|
||||
@@ -3250,7 +3250,7 @@ export default {
|
||||
},
|
||||
async openShareContactModal() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telephone/contacts");
|
||||
const response = await window.api.get("/api/v1/telephone/contacts");
|
||||
this.contacts = response.data?.contacts ?? (Array.isArray(response.data) ? response.data : []);
|
||||
|
||||
if (this.contacts.length === 0) {
|
||||
@@ -3359,7 +3359,7 @@ export default {
|
||||
if (images.length === 0) {
|
||||
const repliedContent =
|
||||
this.replyingTo && this.getRepliedMessage(this.replyingTo.lxmf_message?.hash)?.content;
|
||||
const response = await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
const response = await window.api.post(`/api/v1/lxmf-messages/send`, {
|
||||
delivery_method: this.newMessageDeliveryMethod,
|
||||
lxmf_message: {
|
||||
destination_hash: this.selectedPeer.destination_hash,
|
||||
@@ -3386,7 +3386,7 @@ export default {
|
||||
|
||||
const repliedContent =
|
||||
this.replyingTo && this.getRepliedMessage(this.replyingTo.lxmf_message?.hash)?.content;
|
||||
const response = await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
const response = await window.api.post(`/api/v1/lxmf-messages/send`, {
|
||||
delivery_method: this.newMessageDeliveryMethod,
|
||||
lxmf_message: {
|
||||
destination_hash: this.selectedPeer.destination_hash,
|
||||
@@ -3412,7 +3412,7 @@ export default {
|
||||
};
|
||||
|
||||
try {
|
||||
const subResponse = await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
const subResponse = await window.api.post(`/api/v1/lxmf-messages/send`, {
|
||||
delivery_method: this.newMessageDeliveryMethod,
|
||||
lxmf_message: {
|
||||
destination_hash: this.selectedPeer.destination_hash,
|
||||
@@ -3465,7 +3465,7 @@ export default {
|
||||
|
||||
try {
|
||||
// cancel sending lxmf message
|
||||
const response = await window.axios.post(`/api/v1/lxmf-messages/${lxmfMessageHash}/cancel`);
|
||||
const response = await window.api.post(`/api/v1/lxmf-messages/${lxmfMessageHash}/cancel`);
|
||||
|
||||
// get lxmf message from response
|
||||
const lxmfMessage = response.data.lxmf_message;
|
||||
@@ -3490,7 +3490,7 @@ export default {
|
||||
chatItem.lxmf_message.fields?.reply_quoted_content ||
|
||||
(chatItem.lxmf_message.reply_to_hash &&
|
||||
this.getRepliedMessage(chatItem.lxmf_message.reply_to_hash)?.content);
|
||||
const response = await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
const response = await window.api.post(`/api/v1/lxmf-messages/send`, {
|
||||
lxmf_message: {
|
||||
destination_hash: chatItem.lxmf_message.destination_hash,
|
||||
content: chatItem.lxmf_message.content,
|
||||
@@ -3604,7 +3604,7 @@ export default {
|
||||
if (!this.selectedPeer) return;
|
||||
|
||||
// Send a telemetry request command
|
||||
await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
await window.api.post(`/api/v1/lxmf-messages/send`, {
|
||||
lxmf_message: {
|
||||
destination_hash: this.selectedPeer.destination_hash,
|
||||
content: "",
|
||||
@@ -3643,7 +3643,7 @@ export default {
|
||||
if (!this.selectedPeer) return;
|
||||
const hash = this.selectedPeer.destination_hash;
|
||||
try {
|
||||
const response = await window.axios.post(`/api/v1/telemetry/tracking/${hash}/toggle`, {
|
||||
const response = await window.api.post(`/api/v1/telemetry/tracking/${hash}/toggle`, {
|
||||
is_tracking: !this.selectedPeer.is_tracking,
|
||||
});
|
||||
// Emit event to parent to update peer status
|
||||
@@ -3695,7 +3695,7 @@ export default {
|
||||
},
|
||||
async onStartCall() {
|
||||
try {
|
||||
await window.axios.get(`/api/v1/telephone/call/${this.selectedPeer.destination_hash}`);
|
||||
await window.api.get(`/api/v1/telephone/call/${this.selectedPeer.destination_hash}`);
|
||||
} catch (e) {
|
||||
const message = e.response?.data?.message ?? "Failed to start call";
|
||||
DialogUtils.alert(message);
|
||||
@@ -3986,7 +3986,7 @@ export default {
|
||||
|
||||
// mark conversation as read on server
|
||||
try {
|
||||
await window.axios.get(`/api/v1/lxmf/conversations/${conversation.destination_hash}/mark-as-read`);
|
||||
await window.api.get(`/api/v1/lxmf/conversations/${conversation.destination_hash}/mark-as-read`);
|
||||
} catch (e) {
|
||||
// do nothing if failed to mark as read
|
||||
console.log(e);
|
||||
|
||||
@@ -271,7 +271,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/config`);
|
||||
const response = await window.api.get(`/api/v1/config`);
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
// do nothing if failed to load config
|
||||
@@ -331,7 +331,7 @@ export default {
|
||||
async getLxmfDeliveryAnnounces(append = false) {
|
||||
try {
|
||||
const offset = append ? Object.keys(this.peers).length : 0;
|
||||
const response = await window.axios.get(`/api/v1/announces`, {
|
||||
const response = await window.api.get(`/api/v1/announces`, {
|
||||
params: {
|
||||
aspect: "lxmf.delivery",
|
||||
limit: this.pageSize,
|
||||
@@ -366,7 +366,7 @@ export default {
|
||||
async getLxmfDeliveryAnnounce(destinationHash) {
|
||||
try {
|
||||
// fetch announce for destination hash
|
||||
const response = await window.axios.get(`/api/v1/announces`, {
|
||||
const response = await window.api.get(`/api/v1/announces`, {
|
||||
params: {
|
||||
destination_hash: destinationHash,
|
||||
limit: 1,
|
||||
@@ -392,7 +392,7 @@ export default {
|
||||
}
|
||||
|
||||
const offset = append ? this.conversations.length : 0;
|
||||
const response = await window.axios.get(`/api/v1/lxmf/conversations`, {
|
||||
const response = await window.api.get(`/api/v1/lxmf/conversations`, {
|
||||
params: {
|
||||
...this.buildConversationQueryParams(),
|
||||
limit: this.pageSize,
|
||||
@@ -481,7 +481,7 @@ export default {
|
||||
},
|
||||
async resolvePeerDisplayName(peerHash) {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/lxmf/conversations`, {
|
||||
const response = await window.api.get(`/api/v1/lxmf/conversations`, {
|
||||
params: { search: peerHash, limit: 1 },
|
||||
});
|
||||
const results = response.data.conversations;
|
||||
@@ -514,7 +514,7 @@ export default {
|
||||
},
|
||||
async getFolders() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/lxmf/folders");
|
||||
const response = await window.api.get("/api/v1/lxmf/folders");
|
||||
this.folders = response.data;
|
||||
} catch (e) {
|
||||
console.error("Failed to load folders", e);
|
||||
@@ -522,7 +522,7 @@ export default {
|
||||
},
|
||||
async onCreateFolder(name) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/lxmf/folders", { name });
|
||||
await window.api.post("/api/v1/lxmf/folders", { name });
|
||||
await this.getFolders();
|
||||
ToastUtils.success(this.$t("messages.folder_created"));
|
||||
} catch {
|
||||
@@ -531,7 +531,7 @@ export default {
|
||||
},
|
||||
async onRenameFolder({ id, name }) {
|
||||
try {
|
||||
await window.axios.patch(`/api/v1/lxmf/folders/${id}`, { name });
|
||||
await window.api.patch(`/api/v1/lxmf/folders/${id}`, { name });
|
||||
await this.getFolders();
|
||||
ToastUtils.success(this.$t("messages.folder_renamed"));
|
||||
} catch {
|
||||
@@ -540,7 +540,7 @@ export default {
|
||||
},
|
||||
async onDeleteFolder(id) {
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/lxmf/folders/${id}`);
|
||||
await window.api.delete(`/api/v1/lxmf/folders/${id}`);
|
||||
if (this.selectedFolderId === id) {
|
||||
this.selectedFolderId = null;
|
||||
}
|
||||
@@ -555,7 +555,7 @@ export default {
|
||||
try {
|
||||
// Treat 0 as null (Uncategorized) for the backend
|
||||
const targetFolderId = folder_id === 0 ? null : folder_id;
|
||||
await window.axios.post("/api/v1/lxmf/conversations/move-to-folder", {
|
||||
await window.api.post("/api/v1/lxmf/conversations/move-to-folder", {
|
||||
peer_hashes,
|
||||
folder_id: targetFolderId,
|
||||
});
|
||||
@@ -567,7 +567,7 @@ export default {
|
||||
},
|
||||
async onBulkMarkAsRead(destination_hashes) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/lxmf/conversations/bulk-mark-as-read", {
|
||||
await window.api.post("/api/v1/lxmf/conversations/bulk-mark-as-read", {
|
||||
destination_hashes,
|
||||
});
|
||||
await this.getConversations();
|
||||
@@ -584,7 +584,7 @@ export default {
|
||||
);
|
||||
if (!confirmed) return;
|
||||
|
||||
await window.axios.post("/api/v1/lxmf/conversations/bulk-delete", {
|
||||
await window.api.post("/api/v1/lxmf/conversations/bulk-delete", {
|
||||
destination_hashes,
|
||||
});
|
||||
await this.getConversations();
|
||||
@@ -595,7 +595,7 @@ export default {
|
||||
},
|
||||
async onExportFolders() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/lxmf/folders/export");
|
||||
const response = await window.api.get("/api/v1/lxmf/folders/export");
|
||||
const data = JSON.stringify(response.data, null, 2);
|
||||
const blob = new Blob([data], { type: "application/json" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
@@ -619,7 +619,7 @@ export default {
|
||||
reader.onload = async (re) => {
|
||||
try {
|
||||
const data = JSON.parse(re.target.result);
|
||||
await window.axios.post("/api/v1/lxmf/folders/import", data);
|
||||
await window.api.post("/api/v1/lxmf/folders/import", data);
|
||||
await this.getFolders();
|
||||
await this.getConversations();
|
||||
ToastUtils.success(this.$t("messages.folders_imported"));
|
||||
|
||||
@@ -883,7 +883,7 @@ export default {
|
||||
},
|
||||
async fetchContactForContextMenu(hash) {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/telephone/contacts/check/${hash}`);
|
||||
const response = await window.api.get(`/api/v1/telephone/contacts/check/${hash}`);
|
||||
if (response.data.is_contact) {
|
||||
this.contextMenu.targetContact = response.data.contact;
|
||||
} else {
|
||||
@@ -990,13 +990,13 @@ export default {
|
||||
if (!contact) {
|
||||
// find display name from conversations
|
||||
const conv = this.conversations.find((c) => c.destination_hash === hash);
|
||||
await window.axios.post("/api/v1/telephone/contacts", {
|
||||
await window.api.post("/api/v1/telephone/contacts", {
|
||||
name: conv?.display_name || hash.substring(0, 8),
|
||||
remote_identity_hash: hash,
|
||||
is_telemetry_trusted: true,
|
||||
});
|
||||
} else {
|
||||
await window.axios.patch(`/api/v1/telephone/contacts/${contact.id}`, {
|
||||
await window.api.patch(`/api/v1/telephone/contacts/${contact.id}`, {
|
||||
is_telemetry_trusted: newStatus,
|
||||
});
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/blocked-destinations/${hash}`);
|
||||
await window.api.delete(`/api/v1/blocked-destinations/${hash}`);
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
DialogUtils.alert(this.$t("banishment.banishment_lifted"));
|
||||
} catch (e) {
|
||||
|
||||
@@ -215,7 +215,7 @@ export default {
|
||||
async fetchUri() {
|
||||
try {
|
||||
this.isLoading = true;
|
||||
const response = await window.axios.get(`/api/v1/lxmf-messages/${this.messageHash}/uri`);
|
||||
const response = await window.api.get(`/api/v1/lxmf-messages/${this.messageHash}/uri`);
|
||||
this.uri = response.data.uri;
|
||||
if (this.uri) {
|
||||
this.$nextTick(() => {
|
||||
@@ -302,7 +302,7 @@ export default {
|
||||
}
|
||||
|
||||
// send message
|
||||
const response = await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
const response = await window.api.post(`/api/v1/lxmf-messages/send`, {
|
||||
delivery_method: "opportunistic",
|
||||
lxmf_message: lxmf_message,
|
||||
});
|
||||
|
||||
@@ -789,7 +789,7 @@ ${b}=
|
||||
this.showPublishMenu = !this.showPublishMenu;
|
||||
if (this.showPublishMenu) {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/page-nodes");
|
||||
const response = await window.api.get("/api/v1/page-nodes");
|
||||
this.pageNodes = response.data;
|
||||
} catch {
|
||||
this.pageNodes = [];
|
||||
@@ -800,7 +800,7 @@ ${b}=
|
||||
const tab = this.tabs[this.activeTabIndex];
|
||||
const pageName = tab.name.replace(/\s+/g, "_");
|
||||
try {
|
||||
await window.axios.post(`/api/v1/page-nodes/${node.node_id}/pages`, {
|
||||
await window.api.post(`/api/v1/page-nodes/${node.node_id}/pages`, {
|
||||
name: pageName,
|
||||
content: tab.content,
|
||||
});
|
||||
@@ -827,7 +827,7 @@ ${b}=
|
||||
for (const tab of this.tabs) {
|
||||
const pageName = tab.name.replace(/\s+/g, "_");
|
||||
try {
|
||||
await window.axios.post(`/api/v1/page-nodes/${node.node_id}/pages`, {
|
||||
await window.api.post(`/api/v1/page-nodes/${node.node_id}/pages`, {
|
||||
name: pageName,
|
||||
content: tab.content,
|
||||
});
|
||||
|
||||
@@ -405,24 +405,24 @@ export default {
|
||||
methods: {
|
||||
async getInterfaceStats() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/interface-stats`, {
|
||||
const response = await window.api.get(`/api/v1/interface-stats`, {
|
||||
signal: this.abortController.signal,
|
||||
});
|
||||
this.interfaces = response.data.interface_stats?.interfaces ?? [];
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel(e)) return;
|
||||
if (window.api.isCancel(e)) return;
|
||||
console.error("Failed to fetch interface stats", e);
|
||||
}
|
||||
},
|
||||
async getDiscoveredInterfaces() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/reticulum/discovered-interfaces`, {
|
||||
const response = await window.api.get(`/api/v1/reticulum/discovered-interfaces`, {
|
||||
signal: this.abortController.signal,
|
||||
});
|
||||
this.discoveredInterfaces = response.data?.interfaces ?? [];
|
||||
this.discoveredActive = response.data?.active ?? [];
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel(e)) return;
|
||||
if (window.api.isCancel(e)) return;
|
||||
}
|
||||
},
|
||||
async getPathTableBatch(destinationHashes = null) {
|
||||
@@ -430,7 +430,7 @@ export default {
|
||||
try {
|
||||
this.loadingStatus = "Loading paths...";
|
||||
if (destinationHashes && destinationHashes.length > 0) {
|
||||
const resp = await window.axios.post(
|
||||
const resp = await window.api.post(
|
||||
`/api/v1/path-table`,
|
||||
{ destination_hashes: destinationHashes },
|
||||
{
|
||||
@@ -439,7 +439,7 @@ export default {
|
||||
);
|
||||
this.pathTable.push(...resp.data.path_table);
|
||||
} else {
|
||||
const firstResp = await window.axios.get(`/api/v1/path-table`, {
|
||||
const firstResp = await window.api.get(`/api/v1/path-table`, {
|
||||
params: { limit: this.pageSize, offset: 0 },
|
||||
signal: this.abortController.signal,
|
||||
});
|
||||
@@ -454,7 +454,7 @@ export default {
|
||||
chunk.push(offset + i * this.pageSize);
|
||||
}
|
||||
const promises = chunk.map((o) =>
|
||||
window.axios.get(`/api/v1/path-table`, {
|
||||
window.api.get(`/api/v1/path-table`, {
|
||||
params: { limit: this.pageSize, offset: o },
|
||||
signal: this.abortController.signal,
|
||||
})
|
||||
@@ -468,7 +468,7 @@ export default {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel(e)) return;
|
||||
if (window.api.isCancel(e)) return;
|
||||
console.error("Failed to fetch path table batch", e);
|
||||
}
|
||||
},
|
||||
@@ -482,7 +482,7 @@ export default {
|
||||
let offset = 0;
|
||||
let hasMore = true;
|
||||
while (hasMore) {
|
||||
const resp = await window.axios.get(`/api/v1/announces`, {
|
||||
const resp = await window.api.get(`/api/v1/announces`, {
|
||||
params: { aspect, limit: this.pageSize, offset },
|
||||
signal: this.abortController.signal,
|
||||
});
|
||||
@@ -497,24 +497,24 @@ export default {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel(e)) return;
|
||||
if (window.api.isCancel(e)) return;
|
||||
console.error("Failed to fetch announces batch", e);
|
||||
}
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config", {
|
||||
const response = await window.api.get("/api/v1/config", {
|
||||
signal: this.abortController.signal,
|
||||
});
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel(e)) return;
|
||||
if (window.api.isCancel(e)) return;
|
||||
console.error("Failed to fetch config", e);
|
||||
}
|
||||
},
|
||||
async getConversations() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/lxmf/conversations`, {
|
||||
const response = await window.api.get(`/api/v1/lxmf/conversations`, {
|
||||
signal: this.abortController.signal,
|
||||
});
|
||||
this.conversations = {};
|
||||
@@ -522,7 +522,7 @@ export default {
|
||||
this.conversations[conversation.destination_hash] = conversation;
|
||||
}
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel(e)) return;
|
||||
if (window.api.isCancel(e)) return;
|
||||
console.error("Failed to fetch conversations", e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -753,7 +753,7 @@ export default {
|
||||
},
|
||||
async getFavourites() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/favourites", {
|
||||
const response = await window.api.get("/api/v1/favourites", {
|
||||
params: {
|
||||
aspect: "nomadnetwork.node",
|
||||
},
|
||||
@@ -774,7 +774,7 @@ export default {
|
||||
async addFavourite(node) {
|
||||
// add to favourites
|
||||
try {
|
||||
await window.axios.post("/api/v1/favourites/add", {
|
||||
await window.api.post("/api/v1/favourites/add", {
|
||||
destination_hash: node.destination_hash,
|
||||
display_name: node.display_name,
|
||||
aspect: "nomadnetwork.node",
|
||||
@@ -789,7 +789,7 @@ export default {
|
||||
async removeFavourite(node) {
|
||||
// remove from favourites
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/favourites/${node.destination_hash}`);
|
||||
await window.api.delete(`/api/v1/favourites/${node.destination_hash}`);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
@@ -800,7 +800,7 @@ export default {
|
||||
async getNomadnetworkNodeAnnounces(append = false) {
|
||||
try {
|
||||
const offset = append ? Object.keys(this.nodes).length : 0;
|
||||
const response = await window.axios.get(`/api/v1/announces`, {
|
||||
const response = await window.api.get(`/api/v1/announces`, {
|
||||
params: {
|
||||
aspect: "nomadnetwork.node",
|
||||
limit: this.pageSize,
|
||||
@@ -823,7 +823,7 @@ export default {
|
||||
|
||||
this.hasMoreNodes = nodeAnnounces.length === this.pageSize;
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel?.(e)) return;
|
||||
if (window.api.isCancel?.(e)) return;
|
||||
console.log(e);
|
||||
} finally {
|
||||
this.isLoadingMoreNodes = false;
|
||||
@@ -845,7 +845,7 @@ export default {
|
||||
},
|
||||
async getNomadnetworkNodeAnnounce(destinationHash) {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/announces`, {
|
||||
const response = await window.api.get(`/api/v1/announces`, {
|
||||
params: {
|
||||
destination_hash: destinationHash,
|
||||
limit: 1,
|
||||
@@ -858,7 +858,7 @@ export default {
|
||||
this.updateNodeFromAnnounce(nodeAnnounce);
|
||||
}
|
||||
} catch (e) {
|
||||
if (window.axios.isCancel?.(e)) return;
|
||||
if (window.api.isCancel?.(e)) return;
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
@@ -1399,7 +1399,7 @@ export default {
|
||||
|
||||
try {
|
||||
// rename on server
|
||||
await window.axios.post(`/api/v1/favourites/${favourite.destination_hash}/rename`, {
|
||||
await window.api.post(`/api/v1/favourites/${favourite.destination_hash}/rename`, {
|
||||
display_name: displayName,
|
||||
});
|
||||
|
||||
@@ -1511,7 +1511,7 @@ export default {
|
||||
|
||||
try {
|
||||
// get path to destination
|
||||
const response = await window.axios.get(`/api/v1/destination/${destinationHash}/path`);
|
||||
const response = await window.api.get(`/api/v1/destination/${destinationHash}/path`);
|
||||
|
||||
// update ui
|
||||
this.selectedNodePath = response.data.path;
|
||||
@@ -1527,7 +1527,7 @@ export default {
|
||||
}
|
||||
|
||||
// identify self to nomadnetwork node
|
||||
await window.axios.post(`/api/v1/nomadnetwork/${destinationHash}/identify`);
|
||||
await window.api.post(`/api/v1/nomadnetwork/${destinationHash}/identify`);
|
||||
|
||||
// reload page
|
||||
this.reloadNodePage();
|
||||
|
||||
@@ -723,7 +723,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
await window.axios.post("/api/v1/blocked-destinations", {
|
||||
await window.api.post("/api/v1/blocked-destinations", {
|
||||
destination_hash: node.identity_hash,
|
||||
});
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
@@ -735,7 +735,7 @@ export default {
|
||||
},
|
||||
async onUnblockNode(identityHash) {
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/blocked-destinations/${identityHash}`);
|
||||
await window.api.delete(`/api/v1/blocked-destinations/${identityHash}`);
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
DialogUtils.alert(this.$t("nomadnet.banishment_lifted"));
|
||||
} catch (e) {
|
||||
@@ -942,7 +942,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await window.axios.post("/api/v1/blocked-destinations", {
|
||||
await window.api.post("/api/v1/blocked-destinations", {
|
||||
destination_hash: favourite.destination_hash,
|
||||
});
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
@@ -960,7 +960,7 @@ export default {
|
||||
}
|
||||
this.closeContextMenus();
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/blocked-destinations/${hash}`);
|
||||
await window.api.delete(`/api/v1/blocked-destinations/${hash}`);
|
||||
GlobalEmitter.emit("block-status-changed");
|
||||
DialogUtils.alert(this.$t("nomadnet.banishment_lifted"));
|
||||
} catch (e) {
|
||||
|
||||
@@ -381,7 +381,7 @@ export default {
|
||||
async loadNodes() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/page-nodes");
|
||||
const response = await window.api.get("/api/v1/page-nodes");
|
||||
this.nodes = response.data;
|
||||
if (this.selectedNode) {
|
||||
const updated = this.nodes.find((n) => n.node_id === this.selectedNode.node_id);
|
||||
@@ -405,7 +405,7 @@ export default {
|
||||
async createNode() {
|
||||
if (!this.createNodeName.trim()) return;
|
||||
try {
|
||||
await window.axios.post("/api/v1/page-nodes", { name: this.createNodeName.trim() });
|
||||
await window.api.post("/api/v1/page-nodes", { name: this.createNodeName.trim() });
|
||||
this.createNodeName = "";
|
||||
this.showCreateDialog = false;
|
||||
this.showStatus("Server created", true);
|
||||
@@ -417,7 +417,7 @@ export default {
|
||||
async deleteNode(nodeId) {
|
||||
if (!(await DialogUtils.confirm("Delete this mesh server and all its content?"))) return;
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/page-nodes/${nodeId}`);
|
||||
await window.api.delete(`/api/v1/page-nodes/${nodeId}`);
|
||||
if (this.selectedNode && this.selectedNode.node_id === nodeId) {
|
||||
this.selectedNode = null;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ export default {
|
||||
},
|
||||
async startNode(nodeId) {
|
||||
try {
|
||||
const response = await window.axios.post(`/api/v1/page-nodes/${nodeId}/start`);
|
||||
const response = await window.api.post(`/api/v1/page-nodes/${nodeId}/start`);
|
||||
this.showStatus(`Server started: ${response.data.destination_hash}`, true);
|
||||
await this.loadNodes();
|
||||
} catch (e) {
|
||||
@@ -438,7 +438,7 @@ export default {
|
||||
},
|
||||
async stopNode(nodeId) {
|
||||
try {
|
||||
await window.axios.post(`/api/v1/page-nodes/${nodeId}/stop`);
|
||||
await window.api.post(`/api/v1/page-nodes/${nodeId}/stop`);
|
||||
this.showStatus("Server stopped", true);
|
||||
await this.loadNodes();
|
||||
} catch {
|
||||
@@ -447,7 +447,7 @@ export default {
|
||||
},
|
||||
async announceNode(nodeId) {
|
||||
try {
|
||||
await window.axios.post(`/api/v1/page-nodes/${nodeId}/announce`);
|
||||
await window.api.post(`/api/v1/page-nodes/${nodeId}/announce`);
|
||||
this.showStatus("Announced on mesh", true);
|
||||
} catch {
|
||||
this.showStatus("Failed to announce", false);
|
||||
@@ -456,7 +456,7 @@ export default {
|
||||
async renameNode() {
|
||||
if (!this.renameNodeName.trim() || !this.selectedNode) return;
|
||||
try {
|
||||
await window.axios.put(`/api/v1/page-nodes/${this.selectedNode.node_id}/rename`, {
|
||||
await window.api.put(`/api/v1/page-nodes/${this.selectedNode.node_id}/rename`, {
|
||||
name: this.renameNodeName.trim(),
|
||||
});
|
||||
this.renameNodeName = "";
|
||||
@@ -470,7 +470,7 @@ export default {
|
||||
async addPage() {
|
||||
if (!this.newPageName.trim() || !this.selectedNode) return;
|
||||
try {
|
||||
await window.axios.post(`/api/v1/page-nodes/${this.selectedNode.node_id}/pages`, {
|
||||
await window.api.post(`/api/v1/page-nodes/${this.selectedNode.node_id}/pages`, {
|
||||
name: this.newPageName.trim(),
|
||||
content: "",
|
||||
});
|
||||
@@ -483,7 +483,7 @@ export default {
|
||||
},
|
||||
async editPage(pageName) {
|
||||
try {
|
||||
const response = await window.axios.get(
|
||||
const response = await window.api.get(
|
||||
`/api/v1/page-nodes/${this.selectedNode.node_id}/pages/${encodeURIComponent(pageName)}`
|
||||
);
|
||||
this.editingPage = pageName;
|
||||
@@ -495,7 +495,7 @@ export default {
|
||||
async savePage() {
|
||||
if (!this.editingPage || !this.selectedNode) return;
|
||||
try {
|
||||
await window.axios.post(`/api/v1/page-nodes/${this.selectedNode.node_id}/pages`, {
|
||||
await window.api.post(`/api/v1/page-nodes/${this.selectedNode.node_id}/pages`, {
|
||||
name: this.editingPage,
|
||||
content: this.editingPageContent,
|
||||
});
|
||||
@@ -510,7 +510,7 @@ export default {
|
||||
async deletePage(pageName) {
|
||||
if (!(await DialogUtils.confirm(`Delete page "${pageName}"?`))) return;
|
||||
try {
|
||||
await window.axios.delete(
|
||||
await window.api.delete(
|
||||
`/api/v1/page-nodes/${this.selectedNode.node_id}/pages/${encodeURIComponent(pageName)}`
|
||||
);
|
||||
if (this.editingPage === pageName) {
|
||||
@@ -528,7 +528,7 @@ export default {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
try {
|
||||
await window.axios.post(`/api/v1/page-nodes/${this.selectedNode.node_id}/files`, formData, {
|
||||
await window.api.post(`/api/v1/page-nodes/${this.selectedNode.node_id}/files`, formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
this.showStatus("File uploaded", true);
|
||||
@@ -541,7 +541,7 @@ export default {
|
||||
async deleteFile(fileName) {
|
||||
if (!(await DialogUtils.confirm(`Delete file "${fileName}"?`))) return;
|
||||
try {
|
||||
await window.axios.delete(
|
||||
await window.api.delete(
|
||||
`/api/v1/page-nodes/${this.selectedNode.node_id}/files/${encodeURIComponent(fileName)}`
|
||||
);
|
||||
this.showStatus("File deleted", true);
|
||||
|
||||
@@ -148,7 +148,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { CanceledError } from "axios";
|
||||
import DialogUtils from "../../js/DialogUtils";
|
||||
import MaterialDesignIcon from "../MaterialDesignIcon.vue";
|
||||
|
||||
@@ -230,7 +229,7 @@ export default {
|
||||
this.seq++;
|
||||
|
||||
// ping destination
|
||||
const response = await window.axios.get(`/api/v1/ping/${this.destinationHash}/lxmf.delivery`, {
|
||||
const response = await window.api.get(`/api/v1/ping/${this.destinationHash}/lxmf.delivery`, {
|
||||
signal: this.abortController.signal,
|
||||
params: {
|
||||
timeout: this.timeout,
|
||||
@@ -279,7 +278,7 @@ export default {
|
||||
};
|
||||
} catch (e) {
|
||||
// ignore cancelled error
|
||||
if (e instanceof CanceledError) {
|
||||
if (window.api.isCancel(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -301,7 +300,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await window.axios.post(`/api/v1/destination/${this.destinationHash}/drop-path`);
|
||||
const response = await window.api.post(`/api/v1/destination/${this.destinationHash}/drop-path`);
|
||||
DialogUtils.alert(response.data.message);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
||||
@@ -315,7 +315,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
ToastUtils.error(this.$t("messages.failed_load_config"));
|
||||
@@ -324,7 +324,7 @@ export default {
|
||||
},
|
||||
async updateConfig(config, silent = false) {
|
||||
try {
|
||||
const response = await window.axios.patch("/api/v1/config", config);
|
||||
const response = await window.api.patch("/api/v1/config", config);
|
||||
this.config = response.data.config;
|
||||
GlobalState.config = response.data.config;
|
||||
GlobalEmitter.emit("config-updated", response.data.config);
|
||||
|
||||
@@ -362,7 +362,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
// do nothing if failed to load config
|
||||
@@ -371,7 +371,7 @@ export default {
|
||||
},
|
||||
async updateConfig(config) {
|
||||
try {
|
||||
const response = await window.axios.patch("/api/v1/config", config);
|
||||
const response = await window.api.patch("/api/v1/config", config);
|
||||
this.config = response.data.config;
|
||||
} catch (e) {
|
||||
ToastUtils.error(this.$t("common.save_failed"));
|
||||
@@ -380,7 +380,7 @@ export default {
|
||||
},
|
||||
async loadPropagationNodes() {
|
||||
try {
|
||||
const response = await window.axios.get(`/api/v1/lxmf/propagation-nodes`, {
|
||||
const response = await window.api.get(`/api/v1/lxmf/propagation-nodes`, {
|
||||
params: {
|
||||
limit: 500,
|
||||
},
|
||||
|
||||
@@ -412,7 +412,7 @@ export default {
|
||||
this.sendResult = null;
|
||||
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/rncp/send", {
|
||||
const response = await window.api.post("/api/v1/rncp/send", {
|
||||
destination_hash: this.sendDestinationHash,
|
||||
file_path: this.sendFilePath,
|
||||
timeout: this.sendTimeout,
|
||||
@@ -454,7 +454,7 @@ export default {
|
||||
this.fetchResult = null;
|
||||
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/rncp/fetch", {
|
||||
const response = await window.api.post("/api/v1/rncp/fetch", {
|
||||
destination_hash: this.fetchDestinationHash,
|
||||
file_path: this.fetchFilePath,
|
||||
timeout: this.fetchTimeout,
|
||||
@@ -497,7 +497,7 @@ export default {
|
||||
this.listenResult = null;
|
||||
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/rncp/listen", {
|
||||
const response = await window.api.post("/api/v1/rncp/listen", {
|
||||
allowed_hashes: allowedHashes,
|
||||
fetch_allowed: this.listenFetchAllowed,
|
||||
fetch_jail: this.listenFetchJail || null,
|
||||
|
||||
@@ -199,7 +199,7 @@ export default {
|
||||
this.summary = null;
|
||||
|
||||
try {
|
||||
const response = await window.axios.post(
|
||||
const response = await window.api.post(
|
||||
"/api/v1/rnprobe",
|
||||
{
|
||||
destination_hash: this.destinationHash,
|
||||
@@ -221,7 +221,7 @@ export default {
|
||||
failed: response.data.failed || 0,
|
||||
};
|
||||
} catch (e) {
|
||||
if (e.name !== "CanceledError") {
|
||||
if (!window.api.isCancel(e)) {
|
||||
console.error(e);
|
||||
DialogUtils.alert(e.response?.data?.message || this.$t("rnprobe.failed_to_probe"));
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ export default {
|
||||
if (this.sorting) {
|
||||
params.sorting = this.sorting;
|
||||
}
|
||||
const response = await window.axios.get("/api/v1/rnstatus", { params });
|
||||
const response = await window.api.get("/api/v1/rnstatus", { params });
|
||||
this.interfaces = response.data.interfaces || [];
|
||||
this.linkCount = response.data.link_count;
|
||||
this.blackholeEnabled = response.data.blackhole_enabled;
|
||||
|
||||
@@ -408,7 +408,7 @@ export default {
|
||||
async getIdentities() {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/identities");
|
||||
const response = await window.api.get("/api/v1/identities");
|
||||
this.identities = response.data?.identities ?? [];
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -419,7 +419,7 @@ export default {
|
||||
},
|
||||
async downloadIdentityFile() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/identity/backup/download", {
|
||||
const response = await window.api.get("/api/v1/identity/backup/download", {
|
||||
responseType: "blob",
|
||||
});
|
||||
const blob = new Blob([response.data], { type: "application/octet-stream" });
|
||||
@@ -438,7 +438,7 @@ export default {
|
||||
},
|
||||
async copyIdentityBase32() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/identity/backup/base32");
|
||||
const response = await window.api.get("/api/v1/identity/backup/base32");
|
||||
const base32 = response.data?.identity_base32 ?? "";
|
||||
if (!base32) {
|
||||
ToastUtils.error(this.$t("identities.no_identity_available"));
|
||||
@@ -452,7 +452,7 @@ export default {
|
||||
},
|
||||
async downloadAllIdentities() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/identities/export-all", {
|
||||
const response = await window.api.get("/api/v1/identities/export-all", {
|
||||
responseType: "blob",
|
||||
});
|
||||
const url = window.URL.createObjectURL(new Blob([response.data], { type: "application/zip" }));
|
||||
@@ -487,7 +487,7 @@ export default {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("file", this.identityRestoreFile);
|
||||
const response = await window.axios.post("/api/v1/identity/restore", formData, {
|
||||
const response = await window.api.post("/api/v1/identity/restore", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
this.identityRestoreMessage = response.data?.message ?? this.$t("identities.identity_restored");
|
||||
@@ -505,7 +505,7 @@ export default {
|
||||
this.identityRestoreMessage = "";
|
||||
this.identityRestoreError = "";
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/identity/restore", {
|
||||
const response = await window.api.post("/api/v1/identity/restore", {
|
||||
base32: this.identityRestoreBase32.trim(),
|
||||
});
|
||||
this.identityRestoreMessage = response.data?.message ?? this.$t("identities.identity_restored");
|
||||
@@ -525,7 +525,7 @@ export default {
|
||||
|
||||
this.isCreating = true;
|
||||
try {
|
||||
await window.axios.post("/api/v1/identities/create", {
|
||||
await window.api.post("/api/v1/identities/create", {
|
||||
display_name: this.newIdentityName,
|
||||
});
|
||||
ToastUtils.success(this.$t("identities.created"));
|
||||
@@ -550,7 +550,7 @@ export default {
|
||||
this.isCreating = true;
|
||||
GlobalEmitter.emit("identity-switching-start");
|
||||
|
||||
const response = await window.axios.post("/api/v1/identities/switch", {
|
||||
const response = await window.api.post("/api/v1/identities/switch", {
|
||||
identity_hash: identity.hash,
|
||||
});
|
||||
|
||||
@@ -581,7 +581,7 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
await window.axios.delete(`/api/v1/identities/${identity.hash}`);
|
||||
await window.api.delete(`/api/v1/identities/${identity.hash}`);
|
||||
ToastUtils.success(this.$t("identities.deleted"));
|
||||
await this.getIdentities();
|
||||
} catch (e) {
|
||||
|
||||
@@ -2067,7 +2067,7 @@ export default {
|
||||
methods: {
|
||||
async getTrustedTelemetryPeers() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/telemetry/trusted-peers");
|
||||
const response = await window.api.get("/api/v1/telemetry/trusted-peers");
|
||||
this.trustedTelemetryPeers = response.data.trusted_peers;
|
||||
} catch (e) {
|
||||
console.error("Failed to fetch trusted telemetry peers", e);
|
||||
@@ -2075,7 +2075,7 @@ export default {
|
||||
},
|
||||
async revokeTelemetryTrust(peer) {
|
||||
try {
|
||||
await window.axios.patch(`/api/v1/telephone/contacts/${peer.id}`, {
|
||||
await window.api.patch(`/api/v1/telephone/contacts/${peer.id}`, {
|
||||
is_telemetry_trusted: false,
|
||||
});
|
||||
this.getTrustedTelemetryPeers();
|
||||
@@ -2112,7 +2112,7 @@ export default {
|
||||
},
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
if (response?.data?.config) {
|
||||
this.config = { ...this.config, ...response.data.config };
|
||||
const inbound = Number(this.config.lxmf_inbound_stamp_cost);
|
||||
@@ -2151,7 +2151,7 @@ export default {
|
||||
},
|
||||
async updateConfig(config, label = null) {
|
||||
try {
|
||||
const response = await window.axios.patch("/api/v1/config", config);
|
||||
const response = await window.api.patch("/api/v1/config", config);
|
||||
this.config = response.data.config;
|
||||
if (label) {
|
||||
ToastUtils.success(this.$t("app.setting_auto_saved", { label: this.$t(`app.${label}`) }));
|
||||
@@ -2593,13 +2593,13 @@ export default {
|
||||
async onIsTransportEnabledChange() {
|
||||
if (this.config.is_transport_enabled) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/reticulum/enable-transport");
|
||||
await window.api.post("/api/v1/reticulum/enable-transport");
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("settings.failed_enable_transport"));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await window.axios.post("/api/v1/reticulum/disable-transport");
|
||||
await window.api.post("/api/v1/reticulum/disable-transport");
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("settings.failed_disable_transport"));
|
||||
}
|
||||
@@ -2610,7 +2610,7 @@ export default {
|
||||
|
||||
try {
|
||||
this.reloadingRns = true;
|
||||
const response = await window.axios.post("/api/v1/reticulum/reload");
|
||||
const response = await window.api.post("/api/v1/reticulum/reload");
|
||||
ToastUtils.success(response.data.message);
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("settings.failed_reload_reticulum"));
|
||||
@@ -2621,7 +2621,7 @@ export default {
|
||||
async clearMessages() {
|
||||
if (!(await DialogUtils.confirm(this.$t("maintenance.clear_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete("/api/v1/maintenance/messages");
|
||||
await window.api.delete("/api/v1/maintenance/messages");
|
||||
ToastUtils.success(this.$t("maintenance.messages_cleared"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("common.error"));
|
||||
@@ -2630,7 +2630,7 @@ export default {
|
||||
async clearAnnounces() {
|
||||
if (!(await DialogUtils.confirm(this.$t("maintenance.clear_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete("/api/v1/maintenance/announces");
|
||||
await window.api.delete("/api/v1/maintenance/announces");
|
||||
ToastUtils.success(this.$t("maintenance.announces_cleared"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("common.error"));
|
||||
@@ -2639,7 +2639,7 @@ export default {
|
||||
async clearNomadnetFavorites() {
|
||||
if (!(await DialogUtils.confirm(this.$t("maintenance.clear_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete("/api/v1/maintenance/favourites", {
|
||||
await window.api.delete("/api/v1/maintenance/favourites", {
|
||||
params: { aspect: "nomadnetwork.node" },
|
||||
});
|
||||
ToastUtils.success(this.$t("maintenance.favourites_cleared"));
|
||||
@@ -2650,7 +2650,7 @@ export default {
|
||||
async clearLxmfIcons() {
|
||||
if (!(await DialogUtils.confirm(this.$t("maintenance.clear_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete("/api/v1/maintenance/lxmf-icons");
|
||||
await window.api.delete("/api/v1/maintenance/lxmf-icons");
|
||||
ToastUtils.success(this.$t("maintenance.lxmf_icons_cleared"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("common.error"));
|
||||
@@ -2659,7 +2659,7 @@ export default {
|
||||
async clearArchives() {
|
||||
if (!(await DialogUtils.confirm(this.$t("maintenance.clear_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete("/api/v1/maintenance/archives");
|
||||
await window.api.delete("/api/v1/maintenance/archives");
|
||||
ToastUtils.success(this.$t("maintenance.archives_cleared"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("common.error"));
|
||||
@@ -2668,7 +2668,7 @@ export default {
|
||||
async clearReticulumDocs() {
|
||||
if (!(await DialogUtils.confirm(this.$t("maintenance.clear_confirm")))) return;
|
||||
try {
|
||||
await window.axios.delete("/api/v1/maintenance/docs/reticulum");
|
||||
await window.api.delete("/api/v1/maintenance/docs/reticulum");
|
||||
ToastUtils.success(this.$t("maintenance.docs_cleared"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("common.error"));
|
||||
@@ -2676,7 +2676,7 @@ export default {
|
||||
},
|
||||
async exportMessages() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/maintenance/messages/export");
|
||||
const response = await window.api.get("/api/v1/maintenance/messages/export");
|
||||
const messages = response.data.messages;
|
||||
const dataStr = JSON.stringify({ messages }, null, 2);
|
||||
const dataUri = "data:application/json;charset=utf-8," + encodeURIComponent(dataStr);
|
||||
@@ -2704,7 +2704,7 @@ export default {
|
||||
const data = JSON.parse(e.target.result);
|
||||
if (!data.messages) throw new Error("Invalid file format");
|
||||
|
||||
await window.axios.post("/api/v1/maintenance/messages/import", {
|
||||
await window.api.post("/api/v1/maintenance/messages/import", {
|
||||
messages: data.messages,
|
||||
});
|
||||
ToastUtils.success(this.$t("maintenance.import_success", { count: data.messages.length }));
|
||||
@@ -2718,7 +2718,7 @@ export default {
|
||||
},
|
||||
async exportFolders() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/lxmf/folders/export");
|
||||
const response = await window.api.get("/api/v1/lxmf/folders/export");
|
||||
const dataStr = JSON.stringify(response.data, null, 2);
|
||||
const dataUri = "data:application/json;charset=utf-8," + encodeURIComponent(dataStr);
|
||||
const exportFileDefaultName = `meshchat_folders_${new Date().toISOString().slice(0, 10)}.json`;
|
||||
@@ -2744,7 +2744,7 @@ export default {
|
||||
const data = JSON.parse(e.target.result);
|
||||
if (!data.folders || !data.mappings) throw new Error("Invalid file format");
|
||||
|
||||
await window.axios.post("/api/v1/lxmf/folders/import", data);
|
||||
await window.api.post("/api/v1/lxmf/folders/import", data);
|
||||
ToastUtils.success(this.$t("settings.folders_imported"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("settings.failed_import_folders"));
|
||||
|
||||
@@ -232,7 +232,7 @@ export default {
|
||||
methods: {
|
||||
async getStatus() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/bots/status");
|
||||
const response = await window.api.get("/api/v1/bots/status");
|
||||
this.bots = response.data.status.bots || [];
|
||||
this.runningBots = response.data.status.running_bots;
|
||||
this.templates = response.data.templates;
|
||||
@@ -249,7 +249,7 @@ export default {
|
||||
if (this.isStarting) return;
|
||||
this.isStarting = true;
|
||||
try {
|
||||
await window.axios.post("/api/v1/bots/start", {
|
||||
await window.api.post("/api/v1/bots/start", {
|
||||
template_id: this.selectedTemplate.id,
|
||||
name: this.newBotName,
|
||||
});
|
||||
@@ -265,7 +265,7 @@ export default {
|
||||
},
|
||||
async stopBot(botId) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/bots/stop", { bot_id: botId });
|
||||
await window.api.post("/api/v1/bots/stop", { bot_id: botId });
|
||||
ToastUtils.success(this.$t("bots.bot_stopped"));
|
||||
this.getStatus();
|
||||
} catch (e) {
|
||||
@@ -275,7 +275,7 @@ export default {
|
||||
},
|
||||
async startExisting(bot) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/bots/start", {
|
||||
await window.api.post("/api/v1/bots/start", {
|
||||
bot_id: bot.id,
|
||||
template_id: bot.template_id || bot.template,
|
||||
name: bot.name,
|
||||
@@ -289,7 +289,7 @@ export default {
|
||||
},
|
||||
async restartExisting(bot) {
|
||||
try {
|
||||
await window.axios.post("/api/v1/bots/restart", { bot_id: bot.id });
|
||||
await window.api.post("/api/v1/bots/restart", { bot_id: bot.id });
|
||||
ToastUtils.success(this.$t("bots.bot_started"));
|
||||
this.getStatus();
|
||||
} catch (e) {
|
||||
@@ -300,7 +300,7 @@ export default {
|
||||
async deleteBot(botId) {
|
||||
if (!confirm(this.$t("common.delete_confirm"))) return;
|
||||
try {
|
||||
await window.axios.post("/api/v1/bots/delete", { bot_id: botId });
|
||||
await window.api.post("/api/v1/bots/delete", { bot_id: botId });
|
||||
ToastUtils.success(this.$t("bots.bot_deleted"));
|
||||
this.getStatus();
|
||||
} catch (e) {
|
||||
|
||||
@@ -374,7 +374,7 @@ export default {
|
||||
}
|
||||
|
||||
// send message
|
||||
const response = await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
const response = await window.api.post(`/api/v1/lxmf-messages/send`, {
|
||||
delivery_method: "opportunistic",
|
||||
lxmf_message: lxmf_message,
|
||||
});
|
||||
|
||||
@@ -363,8 +363,8 @@ export default {
|
||||
try {
|
||||
const [pathRes, rateRes, ifaceRes] = await Promise.all([
|
||||
this.fetchPathTable(),
|
||||
window.axios.get("/api/v1/rnpath/rates"),
|
||||
window.axios.get("/api/v1/reticulum/interfaces"),
|
||||
window.api.get("/api/v1/rnpath/rates"),
|
||||
window.api.get("/api/v1/reticulum/interfaces"),
|
||||
]);
|
||||
this.pathTable = pathRes.table;
|
||||
this.totalItems = pathRes.total;
|
||||
@@ -401,7 +401,7 @@ export default {
|
||||
interface: this.filterInterface || undefined,
|
||||
hops: this.filterHops !== null ? this.filterHops : undefined,
|
||||
};
|
||||
const res = await window.axios.get("/api/v1/rnpath/table", { params });
|
||||
const res = await window.api.get("/api/v1/rnpath/table", { params });
|
||||
return res.data;
|
||||
},
|
||||
getStateColor(state) {
|
||||
@@ -419,7 +419,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await window.axios.post("/api/v1/rnpath/drop", { destination_hash: hash });
|
||||
const res = await window.api.post("/api/v1/rnpath/drop", { destination_hash: hash });
|
||||
if (res.data.success) {
|
||||
ToastUtils.success(this.$t("tools.rnpath.path_dropped"));
|
||||
this.refreshAll();
|
||||
@@ -432,7 +432,7 @@ export default {
|
||||
},
|
||||
async requestPath() {
|
||||
try {
|
||||
await window.axios.post("/api/v1/rnpath/request", { destination_hash: this.requestHash });
|
||||
await window.api.post("/api/v1/rnpath/request", { destination_hash: this.requestHash });
|
||||
ToastUtils.success(`Path requested for ${this.requestHash.substring(0, 8)}...`);
|
||||
this.requestHash = "";
|
||||
// Path requests take time, don't refresh immediately
|
||||
@@ -445,7 +445,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await window.axios.post("/api/v1/rnpath/drop-via", {
|
||||
const res = await window.api.post("/api/v1/rnpath/drop-via", {
|
||||
transport_instance_hash: this.dropViaHash,
|
||||
});
|
||||
if (res.data.success) {
|
||||
@@ -462,7 +462,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await window.axios.post("/api/v1/rnpath/drop-queues");
|
||||
await window.api.post("/api/v1/rnpath/drop-queues");
|
||||
ToastUtils.success(this.$t("tools.rnpath.queues_purged"));
|
||||
} catch {
|
||||
ToastUtils.error(this.$t("tools.rnpath.failed_purge"));
|
||||
|
||||
@@ -318,7 +318,7 @@ export default {
|
||||
this.traceResult = null;
|
||||
|
||||
try {
|
||||
const res = await window.axios.get(`/api/v1/rnpath/trace/${this.destinationHash}`);
|
||||
const res = await window.api.get(`/api/v1/rnpath/trace/${this.destinationHash}`);
|
||||
if (res.data.error) {
|
||||
this.error = res.data.error;
|
||||
} else {
|
||||
|
||||
@@ -430,7 +430,7 @@ export default {
|
||||
methods: {
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await window.axios.get("/api/v1/config");
|
||||
const response = await window.api.get("/api/v1/config");
|
||||
this.config = response.data.config;
|
||||
if (this.config.translator_enabled) {
|
||||
this.loadLanguages();
|
||||
@@ -448,7 +448,7 @@ export default {
|
||||
if (this.translationMode === "libretranslate" && this.libretranslateUrl) {
|
||||
params.libretranslate_url = this.libretranslateUrl;
|
||||
}
|
||||
const response = await window.axios.get("/api/v1/translator/languages", { params });
|
||||
const response = await window.api.get("/api/v1/translator/languages", { params });
|
||||
this.languages = response.data.languages || [];
|
||||
this.hasArgos = response.data.has_argos;
|
||||
} catch (e) {
|
||||
@@ -489,7 +489,7 @@ export default {
|
||||
if (this.translationMode === "libretranslate" && this.libretranslateUrl) {
|
||||
payload.libretranslate_url = this.libretranslateUrl;
|
||||
}
|
||||
const response = await window.axios.post("/api/v1/translator/translate", payload);
|
||||
const response = await window.api.post("/api/v1/translator/translate", payload);
|
||||
|
||||
this.translationResult = response.data;
|
||||
if (this.translationResult.source_lang === "auto") {
|
||||
@@ -548,7 +548,7 @@ export default {
|
||||
this.error = null;
|
||||
|
||||
try {
|
||||
const response = await window.axios.post("/api/v1/translator/install-languages", {
|
||||
const response = await window.api.post("/api/v1/translator/install-languages", {
|
||||
package: packageName,
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class WebSocketConnection {
|
||||
async connect() {
|
||||
this.destroyed = false;
|
||||
|
||||
if (typeof window === "undefined" || !window.axios) {
|
||||
if (typeof window === "undefined" || !window.api) {
|
||||
setTimeout(() => this.connect(), 100);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Axios-shaped HTTP helpers backed by fetch (same-origin API calls).
|
||||
*/
|
||||
|
||||
export function isCancel(error) {
|
||||
if (!error) return false;
|
||||
return error.name === "AbortError" || error.name === "CanceledError";
|
||||
}
|
||||
|
||||
function buildUrl(path, params) {
|
||||
if (!params || typeof params !== "object" || Object.keys(params).length === 0) {
|
||||
return path;
|
||||
}
|
||||
const u = new URL(path, window.location.origin);
|
||||
for (const [k, v] of Object.entries(params)) {
|
||||
if (v === undefined || v === null) continue;
|
||||
if (Array.isArray(v)) {
|
||||
for (const item of v) {
|
||||
u.searchParams.append(k, String(item));
|
||||
}
|
||||
} else {
|
||||
u.searchParams.set(k, String(v));
|
||||
}
|
||||
}
|
||||
return `${u.pathname}${u.search}${u.hash}`;
|
||||
}
|
||||
|
||||
async function parseErrorBody(response) {
|
||||
const ct = response.headers.get("content-type") || "";
|
||||
try {
|
||||
if (ct.includes("application/json")) {
|
||||
const text = await response.text();
|
||||
return text ? JSON.parse(text) : null;
|
||||
}
|
||||
const text = await response.text();
|
||||
if (!text) return { message: response.statusText };
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch {
|
||||
return { message: text };
|
||||
}
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function readSuccessBody(response, responseType) {
|
||||
if (response.status === 204 || response.status === 205) {
|
||||
return null;
|
||||
}
|
||||
if (responseType === "blob") {
|
||||
return response.blob();
|
||||
}
|
||||
if (responseType === "arraybuffer") {
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
const ct = response.headers.get("content-type") || "";
|
||||
if (ct.includes("application/json")) {
|
||||
const text = await response.text();
|
||||
return text ? JSON.parse(text) : null;
|
||||
}
|
||||
return response.text();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ onAuthError?: (err: Error & { response?: { status: number, data: unknown } }) => void }} options
|
||||
*/
|
||||
export function createApiClient(options = {}) {
|
||||
const { onAuthError } = options;
|
||||
|
||||
async function request(method, path, config = {}) {
|
||||
const { params, data, signal, headers = {}, responseType } = config;
|
||||
const url = buildUrl(path, params);
|
||||
const hdrs = new Headers(headers);
|
||||
const init = { method, signal, headers: hdrs };
|
||||
|
||||
if (data !== undefined && method !== "GET" && method !== "HEAD") {
|
||||
if (data instanceof FormData) {
|
||||
hdrs.delete("Content-Type");
|
||||
hdrs.delete("content-type");
|
||||
init.body = data;
|
||||
} else if (typeof data === "string" || data instanceof Blob || data instanceof ArrayBuffer) {
|
||||
init.body = data;
|
||||
} else {
|
||||
if (!hdrs.has("Content-Type")) {
|
||||
hdrs.set("Content-Type", "application/json");
|
||||
}
|
||||
init.body = JSON.stringify(data);
|
||||
}
|
||||
}
|
||||
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(url, init);
|
||||
} catch (e) {
|
||||
if (isCancel(e)) throw e;
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const errData = await parseErrorBody(response);
|
||||
const err = Object.assign(new Error(`HTTP ${response.status}`), {
|
||||
name: "HttpError",
|
||||
response: { status: response.status, data: errData },
|
||||
});
|
||||
if (onAuthError && (response.status === 401 || response.status === 403)) {
|
||||
onAuthError(err);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
const dataOut = await readSuccessBody(response, responseType);
|
||||
return { data: dataOut, status: response.status, headers: response.headers };
|
||||
}
|
||||
|
||||
const api = {
|
||||
get(path, config) {
|
||||
return request("GET", path, config || {});
|
||||
},
|
||||
post(path, data, config = {}) {
|
||||
return request("POST", path, { ...config, data });
|
||||
},
|
||||
patch(path, data, config = {}) {
|
||||
return request("PATCH", path, { ...config, data });
|
||||
},
|
||||
put(path, data, config = {}) {
|
||||
return request("PUT", path, { ...config, data });
|
||||
},
|
||||
delete(path, config = {}) {
|
||||
return request("DELETE", path, config || {});
|
||||
},
|
||||
isCancel,
|
||||
};
|
||||
|
||||
return api;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ describe("AboutPage.vue", () => {
|
||||
get: vi.fn().mockImplementation(() => Promise.resolve({ data: {} })),
|
||||
post: vi.fn().mockImplementation(() => Promise.resolve({ data: {} })),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
window.URL.createObjectURL = vi.fn();
|
||||
window.URL.revokeObjectURL = vi.fn();
|
||||
|
||||
@@ -29,7 +29,7 @@ describe("AboutPage.vue", () => {
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
delete window.electron;
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const mockAxios = {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = mockAxios;
|
||||
window.api = mockAxios;
|
||||
|
||||
vi.mock("../../meshchatx/src/frontend/js/DialogUtils", () => ({
|
||||
default: {
|
||||
|
||||
@@ -11,7 +11,7 @@ const axiosMock = {
|
||||
post: vi.fn(),
|
||||
patch: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
const vuetify = createVuetify();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ describe("App propagation sync metrics", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.useFakeTimers();
|
||||
globalThis.axios = axiosMock;
|
||||
globalThis.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -17,7 +17,7 @@ describe("AuthPage.vue", () => {
|
||||
}),
|
||||
post: vi.fn().mockResolvedValue({ data: { success: true } }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
routerMock = {
|
||||
push: vi.fn(),
|
||||
@@ -32,7 +32,7 @@ describe("AuthPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ describe("BlockedPage.vue (Banished UI)", () => {
|
||||
post: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
// Mock localization
|
||||
const t = (key) => {
|
||||
@@ -54,7 +54,7 @@ describe("BlockedPage.vue (Banished UI)", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
const mountBlockedPage = () => {
|
||||
|
||||
@@ -24,7 +24,7 @@ function mountBlockedPage() {
|
||||
describe("BlockedPage UI", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
global.axios.get = vi.fn().mockImplementation((url) => {
|
||||
global.api.get = vi.fn().mockImplementation((url) => {
|
||||
if (url === "/api/v1/blocked-destinations") return Promise.resolve({ data: { blocked_destinations: [] } });
|
||||
if (url === "/api/v1/reticulum/blackhole") return Promise.resolve({ data: { blackholed_identities: {} } });
|
||||
return Promise.resolve({ data: {} });
|
||||
@@ -53,7 +53,7 @@ describe("BlockedPage UI", () => {
|
||||
});
|
||||
|
||||
it("renders blocked items when provided", async () => {
|
||||
global.axios.get = vi.fn().mockImplementation((url, opts) => {
|
||||
global.api.get = vi.fn().mockImplementation((url, opts) => {
|
||||
if (url === "/api/v1/blocked-destinations")
|
||||
return Promise.resolve({ data: { blocked_destinations: ["abc123"] } });
|
||||
if (url === "/api/v1/reticulum/blackhole") return Promise.resolve({ data: { blackholed_identities: {} } });
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("BotsPage.vue", () => {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
axiosMock.get.mockImplementation((url) => {
|
||||
if (url === "/api/v1/bots/status") {
|
||||
@@ -29,7 +29,7 @@ describe("BotsPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@ describe("CallPage.vue", () => {
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
delete: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
const mountCallPage = (routeQuery = {}) => {
|
||||
@@ -144,7 +144,7 @@ describe("CallPage.vue", () => {
|
||||
const callButton = buttons.find((b) => b.text() === "Call");
|
||||
if (callButton) {
|
||||
await callButton.trigger("click");
|
||||
// CallPage.vue uses window.axios.get(`/api/v1/telephone/call/${hashToCall}`)
|
||||
// CallPage.vue uses window.api.get(`/api/v1/telephone/call/${hashToCall}`)
|
||||
expect(axiosMock.get).toHaveBeenCalledWith(
|
||||
expect.stringContaining("/api/v1/telephone/call/test-destination")
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("CallPage.vue - Custom Contact Images", () => {
|
||||
patch: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
// Mock FileReader
|
||||
const mockFileReader = {
|
||||
@@ -44,7 +44,7 @@ describe("CallPage.vue - Custom Contact Images", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.unstubAllGlobals();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ describe("ChangelogModal.vue", () => {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
const mountChangelogModal = (props = {}) => {
|
||||
|
||||
@@ -16,7 +16,7 @@ describe("CommandPalette.vue", () => {
|
||||
},
|
||||
}),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
routerMock = {
|
||||
push: vi.fn(),
|
||||
@@ -27,7 +27,7 @@ describe("CommandPalette.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
GlobalEmitter.off("sync-propagation-node");
|
||||
GlobalEmitter.off("toggle-orbit");
|
||||
vi.clearAllMocks();
|
||||
|
||||
@@ -27,7 +27,7 @@ describe("ContactsPage.vue", () => {
|
||||
post: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
axiosMock.get.mockImplementation((url) => {
|
||||
if (url === "/api/v1/config") {
|
||||
|
||||
@@ -23,7 +23,7 @@ describe("ConversationViewer.vue", () => {
|
||||
}),
|
||||
post: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
// Mock localStorage
|
||||
const localStorageMock = {
|
||||
@@ -52,7 +52,7 @@ describe("ConversationViewer.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.unstubAllGlobals();
|
||||
WebSocketConnection.destroy();
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("ConversationViewer.vue button interactions", () => {
|
||||
post: vi.fn().mockResolvedValue({ data: {} }),
|
||||
delete: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
GlobalState.blockedDestinations = [];
|
||||
GlobalState.config = { banished_effect_enabled: false };
|
||||
@@ -54,7 +54,7 @@ describe("ConversationViewer.vue button interactions", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.unstubAllGlobals();
|
||||
WebSocketConnection.destroy();
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import DebugLogsPage from "@/components/debug/DebugLogsPage.vue";
|
||||
|
||||
// Mock axios
|
||||
window.axios = {
|
||||
window.api = {
|
||||
get: vi.fn(),
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ describe("DebugLogsPage.vue", () => {
|
||||
},
|
||||
];
|
||||
|
||||
window.axios.get.mockResolvedValue({
|
||||
window.api.get.mockResolvedValue({
|
||||
data: {
|
||||
logs: mockLogs,
|
||||
total: 2,
|
||||
@@ -53,7 +53,7 @@ describe("DebugLogsPage.vue", () => {
|
||||
});
|
||||
|
||||
it("handles search input", async () => {
|
||||
window.axios.get.mockResolvedValue({
|
||||
window.api.get.mockResolvedValue({
|
||||
data: { logs: [], total: 0, limit: 100, offset: 0 },
|
||||
});
|
||||
|
||||
@@ -70,7 +70,7 @@ describe("DebugLogsPage.vue", () => {
|
||||
// Wait for debounce (500ms)
|
||||
await new Promise((resolve) => setTimeout(resolve, 600));
|
||||
|
||||
expect(window.axios.get).toHaveBeenCalledWith(
|
||||
expect(window.api.get).toHaveBeenCalledWith(
|
||||
expect.stringContaining("/api/v1/debug/logs"),
|
||||
expect.objectContaining({
|
||||
params: expect.objectContaining({ search: "error" }),
|
||||
@@ -79,7 +79,7 @@ describe("DebugLogsPage.vue", () => {
|
||||
});
|
||||
|
||||
it("handles pagination", async () => {
|
||||
window.axios.get.mockResolvedValue({
|
||||
window.api.get.mockResolvedValue({
|
||||
data: {
|
||||
logs: [],
|
||||
total: 250,
|
||||
@@ -100,7 +100,7 @@ describe("DebugLogsPage.vue", () => {
|
||||
const nextButton = wrapper.findAll("button").find((b) => b.text().includes("Next"));
|
||||
await nextButton.trigger("click");
|
||||
|
||||
expect(window.axios.get).toHaveBeenCalledWith(
|
||||
expect(window.api.get).toHaveBeenCalledWith(
|
||||
expect.stringContaining("/api/v1/debug/logs"),
|
||||
expect.objectContaining({
|
||||
params: expect.objectContaining({ offset: 100 }),
|
||||
@@ -109,7 +109,7 @@ describe("DebugLogsPage.vue", () => {
|
||||
});
|
||||
|
||||
it("loads access attempts when switching to Access attempts tab", async () => {
|
||||
window.axios.get.mockImplementation((url) => {
|
||||
window.api.get.mockImplementation((url) => {
|
||||
if (url.includes("access-attempts")) {
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
@@ -153,7 +153,7 @@ describe("DebugLogsPage.vue", () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
expect(window.axios.get).toHaveBeenCalledWith(
|
||||
expect(window.api.get).toHaveBeenCalledWith(
|
||||
expect.stringContaining("/api/v1/debug/access-attempts"),
|
||||
expect.any(Object)
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ describe("DocsPage.vue", () => {
|
||||
}),
|
||||
post: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
i18nMock = reactive({ locale: "en" });
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ describe("DocsPage.vue", () => {
|
||||
if (wrapper) {
|
||||
wrapper.unmount();
|
||||
}
|
||||
// Do not delete window.axios, as it might be used by async operations
|
||||
// Do not delete window.api, as it might be used by async operations
|
||||
// and it is globally defined in setup.js anyway.
|
||||
});
|
||||
|
||||
|
||||
@@ -57,11 +57,11 @@ describe("IdentitiesPage.vue", () => {
|
||||
post: vi.fn().mockResolvedValue({ data: { hotswapped: true } }),
|
||||
delete: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const mockAxios = {
|
||||
post: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
patch: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
};
|
||||
window.axios = mockAxios;
|
||||
window.api = mockAxios;
|
||||
|
||||
describe("InterfacesPage discovery actions", () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -32,7 +32,7 @@ vi.mock("../../meshchatx/src/frontend/js/ElectronUtils", () => ({
|
||||
}));
|
||||
|
||||
// Mock axios
|
||||
global.axios = {
|
||||
global.api = {
|
||||
get: vi.fn((url) => {
|
||||
if (url.includes("/api/v1/reticulum/interfaces")) {
|
||||
return Promise.resolve({ data: { interfaces: {} } });
|
||||
@@ -53,8 +53,9 @@ global.axios = {
|
||||
}),
|
||||
post: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
patch: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
isCancel: vi.fn().mockReturnValue(false),
|
||||
};
|
||||
window.axios = global.axios;
|
||||
window.api = global.api;
|
||||
|
||||
// Mock MaterialDesignIcon
|
||||
const MaterialDesignIcon = {
|
||||
|
||||
@@ -90,7 +90,11 @@ describe("Load time with prefilled data", () => {
|
||||
}
|
||||
return Promise.resolve({ data: {} });
|
||||
});
|
||||
window.axios = { get: axiosGet, patch: vi.fn(() => Promise.resolve({ data: {} })) };
|
||||
window.api = {
|
||||
get: axiosGet,
|
||||
patch: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
isCancel: vi.fn().mockReturnValue(false),
|
||||
};
|
||||
|
||||
const start = performance.now();
|
||||
const wrapper = mount(PropagationNodesPage, {
|
||||
|
||||
@@ -220,7 +220,7 @@ describe("MapPage.vue - Drawing and Measurement Tools", () => {
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
delete: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
const mountMapPage = () => {
|
||||
|
||||
@@ -206,13 +206,13 @@ describe("MapPage.vue", () => {
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
delete: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
vi.stubGlobal("axios", axiosMock);
|
||||
window.axios = axiosMock;
|
||||
vi.stubGlobal("api", axiosMock);
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal("axios", axiosMock);
|
||||
window.axios = axiosMock;
|
||||
vi.stubGlobal("api", axiosMock);
|
||||
window.api = axiosMock;
|
||||
// Mock localStorage
|
||||
const localStorageMock = {
|
||||
getItem: vi.fn().mockReturnValue(null),
|
||||
@@ -224,7 +224,7 @@ describe("MapPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
const mountMapPage = () => {
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("MessagesPage.vue", () => {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
axiosMock.get.mockImplementation((url) => {
|
||||
if (url === "/api/v1/config")
|
||||
@@ -22,7 +22,7 @@ describe("MessagesPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
const mountMessagesPage = (props = { destinationHash: "" }) => {
|
||||
|
||||
@@ -119,8 +119,9 @@ describe("NetworkVisualiser.vue", () => {
|
||||
}
|
||||
return Promise.resolve({ data: {} });
|
||||
}),
|
||||
isCancel: vi.fn().mockReturnValue(false),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
// Mock URL.createObjectURL and URL.revokeObjectURL
|
||||
global.URL.createObjectURL = vi.fn().mockReturnValue("blob:mock-url");
|
||||
@@ -128,7 +129,7 @@ describe("NetworkVisualiser.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ describe("NomadNetworkPage.vue", () => {
|
||||
post: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
axiosMock.get.mockImplementation((url) => {
|
||||
if (url === "/api/v1/favourites") return Promise.resolve({ data: { favourites: [] } });
|
||||
@@ -22,7 +22,7 @@ describe("NomadNetworkPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
const mountNomadNetworkPage = (props = { destinationHash: "" }) => {
|
||||
|
||||
@@ -33,7 +33,7 @@ describe("NomadNetworkSidebar.vue", () => {
|
||||
post: vi.fn().mockResolvedValue({ data: {} }),
|
||||
delete: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
GlobalState.blockedDestinations = [];
|
||||
GlobalState.config = { banished_effect_enabled: false };
|
||||
@@ -46,7 +46,7 @@ describe("NomadNetworkSidebar.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ describe("NotificationBell UI", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
wsHandlers = {};
|
||||
global.axios.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.axios.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
global.api.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.api.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -84,7 +84,7 @@ describe("NotificationBell UI", () => {
|
||||
});
|
||||
|
||||
it("shows Clear button when dropdown open and notifications exist", async () => {
|
||||
global.axios.get = vi.fn().mockResolvedValue({
|
||||
global.api.get = vi.fn().mockResolvedValue({
|
||||
data: {
|
||||
notifications: [
|
||||
{ destination_hash: "h1", display_name: "A", updated_at: new Date().toISOString(), content: "Hi" },
|
||||
@@ -122,8 +122,8 @@ describe("NotificationBell websocket reliability", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
wsHandlers = {};
|
||||
global.axios.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.axios.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
global.api.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.api.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -134,7 +134,7 @@ describe("NotificationBell websocket reliability", () => {
|
||||
const wrapper = mountBell();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
global.axios.get = vi.fn().mockResolvedValue({
|
||||
global.api.get = vi.fn().mockResolvedValue({
|
||||
data: { notifications: [{ destination_hash: "d1", display_name: "X", content: "msg" }], unread_count: 1 },
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ describe("NotificationBell websocket reliability", () => {
|
||||
const wrapper = mountBell();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
global.axios.get = vi.fn().mockResolvedValue({
|
||||
global.api.get = vi.fn().mockResolvedValue({
|
||||
data: {
|
||||
notifications: [
|
||||
{
|
||||
@@ -173,7 +173,7 @@ describe("NotificationBell websocket reliability", () => {
|
||||
const wrapper = mountBell();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
global.axios.get = vi.fn().mockResolvedValue({
|
||||
global.api.get = vi.fn().mockResolvedValue({
|
||||
data: {
|
||||
notifications: [
|
||||
{
|
||||
@@ -197,27 +197,27 @@ describe("NotificationBell websocket reliability", () => {
|
||||
it("does NOT reload on unrelated websocket events", async () => {
|
||||
const wrapper = mountBell();
|
||||
await wrapper.vm.$nextTick();
|
||||
const callsBefore = global.axios.get.mock.calls.length;
|
||||
const callsBefore = global.api.get.mock.calls.length;
|
||||
|
||||
simulateWsMessage("telephone_ringing");
|
||||
simulateWsMessage("telephone_call_ended");
|
||||
simulateWsMessage("lxmf_message_state_updated");
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
|
||||
expect(global.axios.get.mock.calls.length).toBe(callsBefore);
|
||||
expect(global.api.get.mock.calls.length).toBe(callsBefore);
|
||||
});
|
||||
|
||||
it("rapid sequential websocket events all trigger reloads", async () => {
|
||||
const wrapper = mountBell();
|
||||
await wrapper.vm.$nextTick();
|
||||
const initialCalls = global.axios.get.mock.calls.length;
|
||||
const initialCalls = global.api.get.mock.calls.length;
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
simulateWsMessage("lxmf.delivery");
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
|
||||
expect(global.axios.get.mock.calls.length).toBeGreaterThan(initialCalls);
|
||||
expect(global.api.get.mock.calls.length).toBeGreaterThan(initialCalls);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -225,8 +225,8 @@ describe("NotificationBell badge accuracy", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
wsHandlers = {};
|
||||
global.axios.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.axios.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
global.api.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.api.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -275,7 +275,7 @@ describe("NotificationBell badge accuracy", () => {
|
||||
});
|
||||
|
||||
it("opening dropdown resets unread count to 0", async () => {
|
||||
global.axios.get = vi.fn().mockResolvedValue({
|
||||
global.api.get = vi.fn().mockResolvedValue({
|
||||
data: { notifications: [{ destination_hash: "d1", display_name: "A", content: "m" }], unread_count: 3 },
|
||||
});
|
||||
const wrapper = mountBell({ attachTo: document.body });
|
||||
@@ -290,7 +290,7 @@ describe("NotificationBell badge accuracy", () => {
|
||||
});
|
||||
|
||||
it("API failure does not cause false badge", async () => {
|
||||
global.axios.get = vi.fn().mockRejectedValue(new Error("Network error"));
|
||||
global.api.get = vi.fn().mockRejectedValue(new Error("Network error"));
|
||||
const wrapper = mountBell();
|
||||
await wrapper.vm.$nextTick();
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
@@ -300,7 +300,7 @@ describe("NotificationBell badge accuracy", () => {
|
||||
});
|
||||
|
||||
it("API returning null/empty fields does not cause false badge", async () => {
|
||||
global.axios.get = vi.fn().mockResolvedValue({ data: { notifications: null, unread_count: null } });
|
||||
global.api.get = vi.fn().mockResolvedValue({ data: { notifications: null, unread_count: null } });
|
||||
const wrapper = mountBell();
|
||||
await wrapper.vm.$nextTick();
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
@@ -313,8 +313,8 @@ describe("NotificationBell mark-as-viewed", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
wsHandlers = {};
|
||||
global.axios.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.axios.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
global.api.get = vi.fn().mockResolvedValue({ data: { notifications: [], unread_count: 0 } });
|
||||
global.api.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -322,7 +322,7 @@ describe("NotificationBell mark-as-viewed", () => {
|
||||
});
|
||||
|
||||
it("calls mark-as-viewed API when dropdown is opened", async () => {
|
||||
global.axios.get = vi.fn().mockResolvedValue({
|
||||
global.api.get = vi.fn().mockResolvedValue({
|
||||
data: {
|
||||
notifications: [
|
||||
{ type: "lxmf_message", destination_hash: "abc", display_name: "A", content: "x" },
|
||||
@@ -335,7 +335,7 @@ describe("NotificationBell mark-as-viewed", () => {
|
||||
await wrapper.find("button").trigger("click");
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
|
||||
const postCalls = global.axios.post.mock.calls;
|
||||
const postCalls = global.api.post.mock.calls;
|
||||
const markCall = postCalls.find((c) => c[0] === "/api/v1/notifications/mark-as-viewed");
|
||||
expect(markCall).toBeTruthy();
|
||||
expect(markCall[1].destination_hashes).toContain("abc");
|
||||
@@ -348,7 +348,7 @@ describe("NotificationBell mark-as-viewed", () => {
|
||||
await wrapper.find("button").trigger("click");
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
|
||||
const markCalls = global.axios.post.mock.calls.filter((c) => c[0] === "/api/v1/notifications/mark-as-viewed");
|
||||
const markCalls = global.api.post.mock.calls.filter((c) => c[0] === "/api/v1/notifications/mark-as-viewed");
|
||||
expect(markCalls.length).toBe(0);
|
||||
wrapper.unmount();
|
||||
});
|
||||
@@ -358,7 +358,7 @@ describe("NotificationBell clear all", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
wsHandlers = {};
|
||||
global.axios.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
global.api.post = vi.fn().mockResolvedValue({ data: {} });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -367,7 +367,7 @@ describe("NotificationBell clear all", () => {
|
||||
|
||||
it("clears all notifications and marks conversations as read", async () => {
|
||||
let callCount = 0;
|
||||
global.axios.get = vi.fn().mockImplementation((url) => {
|
||||
global.api.get = vi.fn().mockImplementation((url) => {
|
||||
if (url === "/api/v1/notifications") {
|
||||
callCount++;
|
||||
if (callCount <= 2) {
|
||||
@@ -400,7 +400,7 @@ describe("NotificationBell clear all", () => {
|
||||
await wrapper.vm.clearAllNotifications();
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
|
||||
const readCalls = global.axios.get.mock.calls.filter((c) => c[0]?.includes("/mark-as-read"));
|
||||
const readCalls = global.api.get.mock.calls.filter((c) => c[0]?.includes("/mark-as-read"));
|
||||
expect(readCalls.length).toBe(1);
|
||||
expect(readCalls[0][0]).toContain("conv1");
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ describe("PaperMessagePage.vue", () => {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -50,12 +50,13 @@ vi.mock("../../meshchatx/src/frontend/js/GlobalEmitter", () => ({
|
||||
}));
|
||||
|
||||
// Mock axios
|
||||
global.axios = {
|
||||
global.api = {
|
||||
get: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
post: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
patch: vi.fn(() => Promise.resolve({ data: {} })),
|
||||
isCancel: vi.fn().mockReturnValue(false),
|
||||
};
|
||||
window.axios = global.axios;
|
||||
window.api = global.api;
|
||||
|
||||
// Mock localStorage
|
||||
const localStorageMock = {
|
||||
|
||||
@@ -17,11 +17,11 @@ describe("PingPage.vue", () => {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("RNPathPage.vue", () => {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
axiosMock.get.mockImplementation((url) => {
|
||||
if (url === "/api/v1/rnpath/table") {
|
||||
@@ -48,7 +48,7 @@ describe("RNPathPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
const mountRNPathPage = () => {
|
||||
|
||||
@@ -9,11 +9,11 @@ describe("RNPathTracePage.vue", () => {
|
||||
axiosMock = {
|
||||
get: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -15,12 +15,13 @@ describe("RNProbePage.vue", () => {
|
||||
beforeEach(() => {
|
||||
axiosMock = {
|
||||
post: vi.fn(),
|
||||
isCancel: vi.fn().mockReturnValue(false),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ describe("RNStatusPage.vue", () => {
|
||||
axiosMock = {
|
||||
get: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
axiosMock.get.mockImplementation((url) => {
|
||||
if (url === "/api/v1/rnstatus") {
|
||||
@@ -36,7 +36,7 @@ describe("RNStatusPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("TranslatorPage.vue", () => {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
axiosMock.get.mockImplementation((url) => {
|
||||
if (url === "/api/v1/config") {
|
||||
@@ -34,7 +34,7 @@ describe("TranslatorPage.vue", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ describe("TranslatorPage.vue", () => {
|
||||
});
|
||||
|
||||
it("calls translate API and displays result", async () => {
|
||||
window.axios.post = vi.fn().mockResolvedValue({
|
||||
window.api.post = vi.fn().mockResolvedValue({
|
||||
data: {
|
||||
translated_text: "Hallo Welt",
|
||||
source_lang: "en",
|
||||
@@ -98,7 +98,7 @@ describe("TranslatorPage.vue", () => {
|
||||
// Call directly to verify logic
|
||||
await wrapper.vm.translateText();
|
||||
|
||||
expect(window.axios.post).toHaveBeenCalledWith(
|
||||
expect(window.api.post).toHaveBeenCalledWith(
|
||||
"/api/v1/translator/translate",
|
||||
expect.objectContaining({
|
||||
text: "Hello World",
|
||||
|
||||
@@ -397,7 +397,7 @@ describe("SettingsPage Component", () => {
|
||||
post: vi.fn().mockResolvedValue({ data: { success: true } }),
|
||||
patch: vi.fn().mockResolvedValue({ data: { success: true } }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
websocketMock = {
|
||||
on: vi.fn(),
|
||||
@@ -407,7 +407,7 @@ describe("SettingsPage Component", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -90,12 +90,12 @@ describe("Theme Switching", () => {
|
||||
}),
|
||||
post: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.documentElement.classList.remove("dark");
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
@@ -363,7 +363,7 @@ describe("Visibility Checks", () => {
|
||||
}),
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
const wrapper = mount(SettingsPage, {
|
||||
global: {
|
||||
@@ -390,7 +390,7 @@ describe("Visibility Checks", () => {
|
||||
wrapper.text().includes("app.banished") || wrapper.findAll('input[type="text"]').length > 0;
|
||||
expect(hasBanishedConfig).toBe(true);
|
||||
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
it("SettingsPage shows blackhole integration toggle", async () => {
|
||||
@@ -404,7 +404,7 @@ describe("Visibility Checks", () => {
|
||||
}),
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
const wrapper = mount(SettingsPage, {
|
||||
global: {
|
||||
@@ -426,7 +426,7 @@ describe("Visibility Checks", () => {
|
||||
|
||||
expect(wrapper.text()).toContain("app.blackhole_integration_enabled");
|
||||
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
it("SettingsPage hides banished config when toggle is disabled", async () => {
|
||||
@@ -440,7 +440,7 @@ describe("Visibility Checks", () => {
|
||||
}),
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
const wrapper = mount(SettingsPage, {
|
||||
global: {
|
||||
@@ -466,7 +466,7 @@ describe("Visibility Checks", () => {
|
||||
const colorInputs = wrapper.findAll('input[type="color"]');
|
||||
expect(colorInputs.length).toBe(3);
|
||||
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -594,7 +594,7 @@ describe("Dark Mode Class Application", () => {
|
||||
}),
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
const wrapper = mount(SettingsPage, {
|
||||
global: {
|
||||
@@ -617,7 +617,7 @@ describe("Dark Mode Class Application", () => {
|
||||
const hasDarkClasses = wrapper.html().includes("dark:") || wrapper.html().includes("dark:");
|
||||
expect(hasDarkClasses).toBe(true);
|
||||
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -633,7 +633,7 @@ describe("Theme Persistence", () => {
|
||||
}),
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
const wrapper = mount(SettingsPage, {
|
||||
global: {
|
||||
@@ -660,6 +660,6 @@ describe("Theme Persistence", () => {
|
||||
expect(wrapper.vm.config.theme).toBe("dark");
|
||||
}
|
||||
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ describe("NetworkVisualiser Optimization and Abort", () => {
|
||||
}),
|
||||
isCancel: vi.fn().mockImplementation((e) => e && e.name === "AbortError"),
|
||||
};
|
||||
window.axios = axiosMock;
|
||||
window.api = axiosMock;
|
||||
|
||||
// Mock URL methods
|
||||
global.URL.createObjectURL = vi.fn().mockReturnValue("blob:mock");
|
||||
@@ -69,7 +69,7 @@ describe("NetworkVisualiser Optimization and Abort", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete window.axios;
|
||||
delete window.api;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -27,15 +27,16 @@ global.performance.getEntriesByName = vi.fn(() => []);
|
||||
global.performance.clearMarks = vi.fn();
|
||||
global.performance.clearMeasures = vi.fn();
|
||||
|
||||
// Mock window.axios by default to prevent TypeErrors
|
||||
global.axios = {
|
||||
// Mock window.api by default to prevent TypeErrors
|
||||
global.api = {
|
||||
get: vi.fn().mockResolvedValue({ data: {} }),
|
||||
post: vi.fn().mockResolvedValue({ data: {} }),
|
||||
put: vi.fn().mockResolvedValue({ data: {} }),
|
||||
patch: vi.fn().mockResolvedValue({ data: {} }),
|
||||
delete: vi.fn().mockResolvedValue({ data: {} }),
|
||||
isCancel: vi.fn().mockReturnValue(false),
|
||||
};
|
||||
window.axios = global.axios;
|
||||
window.api = global.api;
|
||||
|
||||
// Stub all Vuetify components to avoid warnings and CSS issues
|
||||
config.global.stubs = {
|
||||
|
||||
Reference in New Issue
Block a user