Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

feat(web): port all components (Toast, LoadingDashboard, LoadingButton, BackButton, CopyButton, FixedHeader, BlogAuthorBio, BlogInfo, NuxtLogo, FirebaseAuth, MessageThread, MessageThreadHeader)

Acho Arnold018b531d14a6
diff --git a/web/app/components/BackButton.vue b/web/app/components/BackButton.vue
new file mode 100644
index 00000000..67994ff9
--- /dev/null
+++ b/web/app/components/BackButton.vue
@@ -0,0 +1,42 @@
+<script setup lang="ts">
+import { useDisplay } from "vuetify";
+import { mdiArrowLeft } from "@mdi/js";
+import type { RouteLocationRaw } from "vue-router";
+
+const props = withDefaults(
+ defineProps<{
+ route?: RouteLocationRaw;
+ block?: boolean;
+ }>(),
+ {
+ block: false,
+ },
+);
+
+const router = useRouter();
+const { smAndDown } = useDisplay();
+
+function goBack() {
+ if (props.route) {
+ router.push(props.route);
+ return;
+ }
+ if (window.history.length > 1) {
+ router.back();
+ return;
+ }
+ router.push({ name: "index" });
+}
+</script>
+
+<template>
+ <v-btn
+ color="default"
+ :size="smAndDown ? 'small' : 'default'"
+ :block="block"
+ @click="goBack"
+ >
+ <v-icon :icon="mdiArrowLeft" />
+ Go Back
+ </v-btn>
+</template>
diff --git a/web/app/components/BlogAuthorBio.vue b/web/app/components/BlogAuthorBio.vue
new file mode 100644
index 00000000..69cc93ea
--- /dev/null
+++ b/web/app/components/BlogAuthorBio.vue
@@ -0,0 +1,24 @@
+<script setup lang="ts">
+import { mdiTwitter, mdiGithub } from "@mdi/js";
+</script>
+
+<template>
+ <div class="d-flex mb-6 mt-8">
+ <v-avatar image="/img/arnold.png" />
+ <div class="ml-2">
+ <p class="text-subtitle-1 mb-n1">Acho Arnold</p>
+ <a
+ class="mb-n4 text-decoration-none text-on-surface"
+ href="https://twitter.com/acho_arnold"
+ >
+ <v-icon color="#1DA1F2" :icon="mdiTwitter" />
+ </a>
+ <a
+ class="ml-2 text-decoration-none text-on-surface"
+ href="https://github.com/AchoArnold"
+ >
+ <v-icon color="#FFFFFF" :icon="mdiGithub" />
+ </a>
+ </div>
+ </div>
+</template>
diff --git a/web/app/components/BlogInfo.vue b/web/app/components/BlogInfo.vue
new file mode 100644
index 00000000..067261bb
--- /dev/null
+++ b/web/app/components/BlogInfo.vue
@@ -0,0 +1,28 @@
+<script setup lang="ts">
+import { mdiBookOpenVariant } from "@mdi/js";
+
+const appStore = useAppStore();
+</script>
+
+<template>
+ <div>
+ <NuxtLink to="/" class="text-decoration-none d-flex">
+ <v-avatar :image="'/img/logo.svg'" :size="33" class="mt-1" />
+ <h3 class="text-h4 text-on-surface ml-1">httpSMS</h3>
+ </NuxtLink>
+ <p>
+ httpSMS is an
+ <a
+ class="text-decoration-none"
+ href="https://github.com/NdoleStudio/httpsms"
+ >open source</a
+ >
+ application that converts your android phone into an SMS gateway so you
+ can send and receive SMS messages using a simple HTTP API.
+ </p>
+ <v-btn :href="appStore.appData.documentationUrl">
+ <v-icon start :icon="mdiBookOpenVariant" />
+ Documentation
+ </v-btn>
+ </div>
+</template>
diff --git a/web/app/components/CopyButton.vue b/web/app/components/CopyButton.vue
new file mode 100644
index 00000000..3c626c00
--- /dev/null
+++ b/web/app/components/CopyButton.vue
@@ -0,0 +1,51 @@
+<script setup lang="ts">
+import { useDisplay } from "vuetify";
+import { mdiContentCopy } from "@mdi/js";
+
+const props = withDefaults(
+ defineProps<{
+ value: string;
+ color?: string;
+ block?: boolean;
+ large?: boolean;
+ copyText?: string;
+ notificationText?: string;
+ }>(),
+ {
+ color: "default",
+ block: false,
+ large: false,
+ copyText: "Copy",
+ notificationText: "Copied",
+ },
+);
+
+const { smAndDown } = useDisplay();
+const notificationsStore = useNotificationsStore();
+const disabled = ref(false);
+
+async function copy() {
+ disabled.value = true;
+ await navigator.clipboard.writeText(props.value);
+ notificationsStore.addNotification({
+ message: props.notificationText,
+ type: "success",
+ });
+ setTimeout(() => {
+ disabled.value = false;
+ }, 5000);
+}
+</script>
+
+<template>
+ <v-btn
+ :disabled="disabled"
+ :color="color"
+ :size="smAndDown ? 'small' : large ? 'large' : 'default'"
+ :block="block"
+ @click="copy"
+ >
+ <v-icon start :icon="mdiContentCopy" />
+ {{ copyText }}
+ </v-btn>
+</template>
diff --git a/web/app/components/FirebaseAuth.vue b/web/app/components/FirebaseAuth.vue
new file mode 100644
index 00000000..6701d45b
--- /dev/null
+++ b/web/app/components/FirebaseAuth.vue
@@ -0,0 +1,87 @@
+<script setup lang="ts">
+import {
+ getAuth,
+ GoogleAuthProvider,
+ GithubAuthProvider,
+ EmailAuthProvider,
+} from "firebase/auth";
+
+const props = withDefaults(
+ defineProps<{
+ to?: string;
+ }>(),
+ { to: "/" },
+);
+
+const router = useRouter();
+const authStore = useAuthStore();
+const notificationsStore = useNotificationsStore();
+const appStore = useAppStore();
+const authContainer = ref<HTMLElement | null>(null);
+const firebaseUIInitialized = ref(false);
+let ui: any = null;
+
+onMounted(async () => {
+ if (!import.meta.client) return;
+
+ const firebaseui = await import("firebaseui");
+ await import("firebaseui/dist/firebaseui.css");
+
+ const auth = getAuth();
+ ui = new firebaseui.auth.AuthUI(auth);
+ ui.start("#firebaseui-auth-container", {
+ callbacks: {
+ signInSuccessWithAuthResult: (authResult: any) => {
+ notificationsStore.addNotification({
+ message: "Login successful!",
+ type: "success",
+ });
+ authStore.onAuthStateChanged(authResult.user);
+ router.push({ path: props.to });
+ return false;
+ },
+ uiShown: () => {
+ firebaseUIInitialized.value = true;
+ if (authContainer.value) {
+ Array.from(
+ authContainer.value.getElementsByClassName(
+ "firebaseui-idp-text-long",
+ ),
+ ).forEach((item: Element) => {
+ item.textContent =
+ item.textContent?.replace("Sign in with", "Continue with") ||
+ null;
+ });
+ }
+ },
+ },
+ signInFlow: "popup",
+ signInSuccessUrl: window.location.href,
+ signInOptions: [
+ GoogleAuthProvider.PROVIDER_ID,
+ GithubAuthProvider.PROVIDER_ID,
+ EmailAuthProvider.PROVIDER_ID,
+ ],
+ tosUrl: appStore.appData.url + "/terms-and-conditions",
+ privacyPolicyUrl: appStore.appData.url + "/privacy-policy",
+ });
+});
+
+onBeforeUnmount(() => {
+ if (ui) ui.delete();
+});
+</script>
+
+<template>
+ <div>
+ <div id="firebaseui-auth-container" ref="authContainer" />
+ <v-progress-circular
+ v-if="!firebaseUIInitialized"
+ class="mx-auto d-block my-16"
+ :size="80"
+ :width="5"
+ color="primary"
+ indeterminate
+ />
+ </div>
+</template>
diff --git a/web/app/components/FixedHeader.vue b/web/app/components/FixedHeader.vue
new file mode 100644
index 00000000..9d3d4115
--- /dev/null
+++ b/web/app/components/FixedHeader.vue
@@ -0,0 +1,34 @@
+<script setup lang="ts">
+import { useDisplay } from "vuetify";
+
+const { lgAndUp, mdAndDown } = useDisplay();
+</script>
+
+<template>
+ <v-app-bar elevation="0" color="#121212" height="70">
+ <v-container>
+ <v-row>
+ <v-col class="w-full d-flex">
+ <NuxtLink
+ :to="{ name: 'index' }"
+ class="text-on-surface text-h4 text-decoration-none"
+ :class="{ 'mt-5': mdAndDown, 'mt-4': !mdAndDown }"
+ >
+ <v-avatar v-if="lgAndUp" :image="'/img/logo.svg'" :size="30" />
+ HTTP SMS
+ </NuxtLink>
+ <v-spacer />
+ <v-btn
+ color="primary"
+ class="mt-5 mb-5"
+ :size="lgAndUp ? 'large' : 'default'"
+ :to="{ name: 'login' }"
+ >
+ Get Started
+ <span v-if="lgAndUp">&nbsp;For Free</span>
+ </v-btn>
+ </v-col>
+ </v-row>
+ </v-container>
+ </v-app-bar>
+</template>
diff --git a/web/app/components/LoadingButton.vue b/web/app/components/LoadingButton.vue
new file mode 100644
index 00000000..baf55e62
--- /dev/null
+++ b/web/app/components/LoadingButton.vue
@@ -0,0 +1,77 @@
+<script setup lang="ts">
+const props = withDefaults(
+ defineProps<{
+ type?: string;
+ block?: boolean;
+ large?: boolean;
+ xLarge?: boolean;
+ tile?: boolean;
+ text?: boolean;
+ small?: boolean;
+ color?: string;
+ icon?: string | null;
+ loading: boolean;
+ }>(),
+ {
+ type: "submit",
+ block: false,
+ large: false,
+ xLarge: false,
+ tile: false,
+ text: false,
+ small: false,
+ color: "primary",
+ icon: null,
+ },
+);
+
+const emit = defineEmits<{
+ click: [];
+ "update:loading": [value: boolean];
+}>();
+
+const isClicked = ref(false);
+
+watch(
+ () => props.loading,
+ (submitting) => {
+ if (!submitting && isClicked.value) {
+ isClicked.value = false;
+ }
+ },
+);
+
+function onClick() {
+ isClicked.value = true;
+ emit("click");
+}
+
+const size = computed(() => {
+ if (props.xLarge) return "x-large";
+ if (props.large) return "large";
+ if (props.small) return "small";
+ return "default";
+});
+</script>
+
+<template>
+ <v-btn
+ :block="block"
+ :type="type"
+ :size="size"
+ :color="color"
+ :variant="text ? 'text' : 'elevated'"
+ :disabled="loading"
+ @click.prevent="onClick"
+ >
+ <v-progress-circular
+ v-if="isClicked"
+ :size="small ? 20 : 25"
+ color="grey"
+ class="mr-2"
+ indeterminate
+ />
+ <v-icon v-if="icon && !loading" start :icon="icon" />
+ <slot />
+ </v-btn>
+</template>
diff --git a/web/app/components/LoadingDashboard.vue b/web/app/components/LoadingDashboard.vue
new file mode 100644
index 00000000..51ecf7d5
--- /dev/null
+++ b/web/app/components/LoadingDashboard.vue
@@ -0,0 +1,36 @@
+<script setup lang="ts">
+import { useDisplay } from "vuetify";
+const { mdAndDown } = useDisplay();
+</script>
+
+<template>
+ <v-main>
+ <v-container fluid class="fill-height">
+ <v-row align="center" justify="center">
+ <v-col
+ cols="12"
+ md="5"
+ xl="3"
+ class="text-center mt-16"
+ :class="{ 'px-6': mdAndDown, 'px-16': !mdAndDown }"
+ >
+ <h2 class="text-h4 text-medium-emphasis mt-16 mb-4">
+ <img
+ class="mx-auto d-inline-block"
+ src="/img/logo.svg"
+ style="max-width: 32px"
+ alt="httpSMS Logo"
+ />
+ Loading the httpSMS dashboard
+ </h2>
+ <v-progress-circular
+ indeterminate
+ size="160"
+ class="mt-8"
+ color="primary"
+ />
+ </v-col>
+ </v-row>
+ </v-container>
+ </v-main>
+</template>
diff --git a/web/app/components/MessageThread.vue b/web/app/components/MessageThread.vue
new file mode 100644
index 00000000..10c598a8
--- /dev/null
+++ b/web/app/components/MessageThread.vue
@@ -0,0 +1,84 @@
+<script setup lang="ts">
+import { useDisplay } from "vuetify";
+import { mdiPlus } from "@mdi/js";
+import { formatPhoneNumber } from "~/utils/filters";
+import type { MessageThread } from "~~/shared/types/message-thread";
+
+const { mdAndDown } = useDisplay();
+const threadsStore = useThreadsStore();
+const phonesStore = usePhonesStore();
+
+function getInitials(contact: string): string {
+ const formatted = formatPhoneNumber(contact);
+ return formatted.substring(0, 2);
+}
+</script>
+
+<template>
+ <div>
+ <v-progress-linear
+ v-if="threadsStore.loadingThreads"
+ color="primary"
+ indeterminate
+ />
+ <div
+ v-if="!threadsStore.loadingThreads && threadsStore.archivedThreads"
+ class="bg-warning py-1 text-center text-uppercase text-subtitle-1"
+ >
+ Archived Messages
+ </div>
+ <v-sheet
+ v-if="
+ !threadsStore.loadingThreads &&
+ threadsStore.threads.length === 0 &&
+ !threadsStore.archivedThreads
+ "
+ class="text-center mt-8 mx-3"
+ :color="mdAndDown ? '#121212' : '#363636'"
+ >
+ <div v-if="mdAndDown">
+ <v-img
+ class="mx-auto mb-4"
+ max-width="80%"
+ src="/img/person-texting.svg"
+ />
+ <p v-if="phonesStore.owner" class="text-medium-emphasis">
+ Start sending messages
+ </p>
+ </div>
+ <v-btn
+ v-if="phonesStore.owner && phonesStore.phones.length !== 0"
+ color="primary"
+ :to="{ name: 'messages' }"
+ >
+ <v-icon :icon="mdiPlus" />
+ New Message
+ </v-btn>
+ </v-sheet>
+ <v-list
+ v-if="!threadsStore.loadingThreads && threadsStore.threads.length > 0"
+ class="pa-0"
+ >
+ <v-list-item
+ v-for="thread in threadsStore.threads"
+ :key="thread.id"
+ :to="{ name: 'threads-id', params: { id: thread.id } }"
+ :active="threadsStore.threadId === thread.id"
+ >
+ <template #prepend>
+ <v-avatar :color="thread.color" size="40">
+ <span class="text-white text-body-2">{{
+ getInitials(thread.contact)
+ }}</span>
+ </v-avatar>
+ </template>
+ <v-list-item-title>{{
+ formatPhoneNumber(thread.contact)
+ }}</v-list-item-title>
+ <v-list-item-subtitle class="text-truncate" style="max-width: 250px">
+ {{ thread.last_message_content }}
+ </v-list-item-subtitle>
+ </v-list-item>
+ </v-list>
+ </div>
+</template>
diff --git a/web/app/components/MessageThreadHeader.vue b/web/app/components/MessageThreadHeader.vue
new file mode 100644
index 00000000..c62dcccc
--- /dev/null
+++ b/web/app/components/MessageThreadHeader.vue
@@ -0,0 +1,204 @@
+<script setup lang="ts">
+import { useDisplay } from "vuetify";
+import { getAuth, signOut } from "firebase/auth";
+import {
+ mdiPlus,
+ mdiAccountCog,
+ mdiLogout,
+ mdiCellphoneKey,
+ mdiDownload,
+ mdiFinance,
+ mdiBatteryChargingHigh,
+ mdiPackageUp,
+ mdiPackageDown,
+ mdiDotsVertical,
+ mdiMagnify,
+ mdiCommentTextMultipleOutline,
+ mdiCircle,
+} from "@mdi/js";
+import { formatPhoneNumber, phoneCountry, humanizeTime } from "~/utils/filters";
+import type { EntitiesPhone } from "~~/shared/types/api";
+
+const router = useRouter();
+const route = useRoute();
+const { mdAndDown, mdAndUp, lgAndUp } = useDisplay();
+const authStore = useAuthStore();
+const phonesStore = usePhonesStore();
+const threadsStore = useThreadsStore();
+const appStore = useAppStore();
+const notificationsStore = useNotificationsStore();
+
+const selectedMenuItem = ref(-1);
+
+interface SelectItem {
+ title: string;
+ value: string;
+}
+
+const owners = computed<SelectItem[]>(() => {
+ return phonesStore.phones.map((phone: EntitiesPhone) => ({
+ title: formatPhoneNumber(phone.phone_number),
+ value: phone.phone_number,
+ }));
+});
+
+async function onOwnerChanged(owner: string) {
+ await authStore.updateUser({ owner });
+ if (route.name !== "threads") {
+ threadsStore.setThreadId(null);
+ await router.push({ name: "threads" });
+ return;
+ }
+ await threadsStore.loadThreads();
+}
+
+async function toggleArchive() {
+ threadsStore.toggleArchive();
+ setTimeout(() => {
+ selectedMenuItem.value = -1;
+ }, 1000);
+ if (route.name !== "threads") {
+ threadsStore.setThreadId(null);
+ await router.push({ name: "threads" });
+ return;
+ }
+ await threadsStore.loadThreads();
+}
+
+async function logout() {
+ const auth = getAuth();
+ await signOut(auth);
+ authStore.resetState();
+ phonesStore.resetState();
+ threadsStore.resetState();
+ notificationsStore.addNotification({
+ type: "info",
+ message: "You have successfully logged out",
+ });
+ router.push({ name: "index" });
+}
+</script>
+
+<template>
+ <v-sheet
+ class="pa-4 d-flex"
+ :elevation="lgAndUp ? 0 : 2"
+ :color="lgAndUp ? 'grey-darken-4' : 'black'"
+ >
+ <div :class="{ 'px-2': mdAndDown }">
+ <v-toolbar-title>
+ <div class="d-flex pt-2" style="width: 245px">
+ <v-select
+ variant="outlined"
+ density="compact"
+ :disabled="owners.length === 0"
+ placeholder="Phone Numbers"
+ :class="{ 'mb-n6': !phonesStore.owner }"
+ :items="owners"
+ :model-value="phonesStore.owner"
+ @update:model-value="onOwnerChanged"
+ />
+ <div style="width: 50px">
+ <v-progress-circular
+ v-if="appStore.polling"
+ indeterminate
+ :size="20"
+ :width="1"
+ class="mt-3 ml-2"
+ color="success"
+ />
+ </div>
+ </div>
+ </v-toolbar-title>
+ <div v-if="phonesStore.owner" class="d-flex mt-n4">
+ <p class="text-medium-emphasis mb-n1">
+ {{ phoneCountry(phonesStore.owner) }}
+ </p>
+ <v-tooltip v-if="phonesStore.heartbeat" location="end">
+ <template #activator="{ props: tooltipProps }">
+ <v-btn
+ v-bind="tooltipProps"
+ size="x-small"
+ :to="{
+ name: 'heartbeats-id',
+ params: { id: phonesStore.owner },
+ }"
+ color="success"
+ class="ml-2 mt-1 mb-n1"
+ icon
+ >
+ <v-icon
+ v-if="phonesStore.heartbeat.charging"
+ size="small"
+ class="mt-n1"
+ :icon="mdiBatteryChargingHigh"
+ />
+ <v-icon v-else size="x-small" :icon="mdiCircle" />
+ </v-btn>
+ </template>
+ <h4>Last Heartbeat</h4>
+ {{ humanizeTime(phonesStore.heartbeat.timestamp) }} ago
+ </v-tooltip>
+ </div>
+ </div>
+ <v-spacer />
+ <v-menu>
+ <template #activator="{ props: menuProps }">
+ <v-btn v-bind="menuProps" icon variant="text" class="mt-2">
+ <v-icon :icon="mdiDotsVertical" />
+ </v-btn>
+ </template>
+ <v-list class="px-2" nav :density="mdAndDown ? 'compact' : 'default'">
+ <v-list-item @click.prevent="toggleArchive">
+ <template #prepend>
+ <v-icon
+ v-if="!threadsStore.archivedThreads"
+ :icon="mdiPackageDown"
+ />
+ <v-icon v-else :icon="mdiPackageUp" />
+ </template>
+ <v-list-item-title>
+ {{ threadsStore.archivedThreads ? "Unarchived" : "Archived" }}
+ </v-list-item-title>
+ </v-list-item>
+ <v-list-item v-if="phonesStore.owner" :to="{ name: 'messages' }">
+ <template #prepend><v-icon :icon="mdiPlus" /></template>
+ <v-list-item-title>New Message</v-list-item-title>
+ </v-list-item>
+ <v-list-item v-if="phonesStore.owner" :to="{ name: 'bulk-messages' }">
+ <template #prepend
+ ><v-icon :icon="mdiCommentTextMultipleOutline"
+ /></template>
+ <v-list-item-title>Bulk Messages</v-list-item-title>
+ </v-list-item>
+ <v-list-item v-if="phonesStore.owner" :to="{ name: 'search-messages' }">
+ <template #prepend><v-icon :icon="mdiMagnify" /></template>
+ <v-list-item-title>Search Messages</v-list-item-title>
+ </v-list-item>
+ <v-list-item :to="{ name: 'settings' }">
+ <template #prepend><v-icon :icon="mdiAccountCog" /></template>
+ <v-list-item-title>Settings</v-list-item-title>
+ </v-list-item>
+ <v-list-item :to="{ name: 'phone-api-keys' }">
+ <template #prepend><v-icon :icon="mdiCellphoneKey" /></template>
+ <v-list-item-title>Phone API Keys</v-list-item-title>
+ </v-list-item>
+ <v-list-item
+ v-if="phonesStore.owner"
+ :href="appStore.appData.appDownloadUrl"
+ >
+ <template #prepend><v-icon :icon="mdiDownload" /></template>
+ <v-list-item-title>Install App</v-list-item-title>
+ </v-list-item>
+ <v-list-item :to="{ name: 'billing' }">
+ <template #prepend><v-icon :icon="mdiFinance" /></template>
+ <v-list-item-title>Usage & Billing</v-list-item-title>
+ </v-list-item>
+ <v-list-item @click.prevent="logout">
+ <template #prepend><v-icon :icon="mdiLogout" /></template>
+ <v-list-item-title>Logout</v-list-item-title>
+ </v-list-item>
+ </v-list>
+ </v-menu>
+ </v-sheet>
+</template>
diff --git a/web/app/components/NuxtLogo.vue b/web/app/components/NuxtLogo.vue
new file mode 100644
index 00000000..66daa93f
--- /dev/null
+++ b/web/app/components/NuxtLogo.vue
@@ -0,0 +1,3 @@
+<template>
+ <img src="/img/logo.svg" alt="httpSMS Logo" style="max-width: 100px" />
+</template>
diff --git a/web/app/components/Toast.vue b/web/app/components/Toast.vue
new file mode 100644
index 00000000..c79d33f7
--- /dev/null
+++ b/web/app/components/Toast.vue
@@ -0,0 +1,42 @@
+<script setup lang="ts">
+import { useDisplay } from "vuetify";
+import { mdiCheck, mdiInformation } from "@mdi/js";
+
+const { lgAndUp } = useDisplay();
+const notificationsStore = useNotificationsStore();
+
+const notificationActive = computed({
+ get: () => notificationsStore.notification.active,
+ set: () => notificationsStore.disableNotification(),
+});
+</script>
+
+<template>
+ <v-snackbar
+ v-model="notificationActive"
+ :color="notificationsStore.notification.type"
+ :timeout="notificationsStore.notification.timeout"
+ >
+ <v-icon
+ v-if="notificationsStore.notification.type === 'success'"
+ :color="notificationsStore.notification.type"
+ :icon="mdiCheck"
+ />
+ <v-icon
+ v-if="notificationsStore.notification.type === 'info'"
+ :color="notificationsStore.notification.type"
+ :icon="mdiInformation"
+ />
+ {{ notificationsStore.notification.message }}
+ <template #actions>
+ <v-btn
+ v-if="lgAndUp"
+ :color="notificationsStore.notification.type"
+ variant="text"
+ @click="notificationsStore.disableNotification()"
+ >
+ <span class="font-weight-bold">Close</span>
+ </v-btn>
+ </template>
+ </v-snackbar>
+</template>