Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use API v2 in web client #1153

Merged
merged 24 commits into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add scan local on lookup button
  • Loading branch information
RomainMaillot committed Oct 23, 2022
commit eea97400b038ac2ede8168ecc206fe00ad964cfa
4 changes: 2 additions & 2 deletions web/client/src/components/Scanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<b-row align-h="between" align-v="center">
<h3>{{ name }}</h3>
<b-button
v-if="!error && !loading"
v-if="!error && !loading && !data"
@click="runScan"
variant="outline-primary"
size="lg"
Expand Down Expand Up @@ -40,7 +40,7 @@ import config from "@/config";
},
})
export default class Scanner extends Vue {
data = {};
data = null;
loading = false;
error = null;
computed = {
Expand Down
61 changes: 53 additions & 8 deletions web/client/src/views/Scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class="m-1"
>
<b-icon-play-fill></b-icon-play-fill>
Run scan
Lookup
</b-button>

<b-button
Expand All @@ -40,7 +40,17 @@

<hr />

<b-container class="border p-4">
<b-container v-if="isLookup" class="border p-4 mb-3">
<h3 class="text-center">Local</h3>
<b-container>
<b-row v-for="(value, name) in localData" :key="name" align-v="center">
<h5 class="text-capitalize m-0 mr-4">{{ name }}:</h5>
<p class="m-0">{{ value }}</p>
</b-row>
</b-container>
</b-container>

<b-container v-if="isLookup" class="border p-4">
<h3 class="text-center">Scanners</h3>
<Scanner name="GoogleSearch" scanId="googlesearch" />
<Scanner name="Numverify Scan" scanId="numverify" />
Expand All @@ -63,12 +73,22 @@ import Scanner from "../components/Scanner.vue";
// import NumverifyScan from "../components/NumverifyScan.vue";
// import GoogleSearch from "../components/GoogleSearch.vue";
// import OVHScan from "../components/OVHScan.vue";
import { AxiosResponse } from "axios";
import axios, { AxiosResponse } from "axios";
import config from "@/config";

interface Data {
loading: boolean;
isLookup: boolean;
inputNumber: string;
scanEvent: Vue;
localData: {
raw_local: string;
local: string;
e164: string;
international: string;
country_code: string;
country: string;
};
}

export type ScanResponse<T> = AxiosResponse<{
Expand All @@ -86,13 +106,23 @@ export default Vue.extend({
data(): Data {
return {
loading: false,
isLookup: false,
inputNumber: "",
scanEvent: new Vue(),
localData: {
raw_local: "",
local: "",
e164: "",
international: "",
country_code: "",
country: "",
},
};
},
methods: {
clearData() {
this.scanEvent.$emit("clear");
// this.scanEvent.$emit("clear");
sundowndev marked this conversation as resolved.
Show resolved Hide resolved
this.isLookup = false;
this.$store.commit("resetState");
},
async runScans(): Promise<void> {
Expand All @@ -105,11 +135,26 @@ export default Vue.extend({

this.$store.commit("setNumber", formatNumber(this.inputNumber));

this.scanEvent.$emit("scan");
try {
const res = await axios.get(
`${config.apiUrl}/numbers/${this.$store.state.number}/scan/local`,
{
validateStatus: () => true,
}
);

this.localData = res.data.result;
} catch (error) {
this.$store.commit("pushError", { message: error });
}

this.isLookup = true;
this.loading = false;
// this.scanEvent.$emit("scan");

this.scanEvent.$on("finished", () => {
this.loading = false;
});
// this.scanEvent.$on("finished", () => {
// this.loading = false;
// });
},
onSubmit(evt: Event) {
evt.preventDefault();
Expand Down