Skip to content

Commit 7809af3

Browse files
authored
Add toggle for source's passive mining (#2622)
* add SERVER_ENDPOINT env to edge functions * add toggle for source's passive mining
1 parent 4cf7247 commit 7809af3

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

frontend/src/pages/sources.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@
9292
<span>{{
9393
source.passive_mining ? t('enabled') : t('disabled')
9494
}}</span>
95+
<ToggleSwitch
96+
v-model="source.passive_mining"
97+
@update:model-value="
98+
(val: boolean) =>
99+
togglePassiveMining(source.email, source.type, val)
100+
"
101+
/>
95102
</div>
96103
</div>
97104

@@ -292,6 +299,14 @@ async function confirmStopMining() {
292299
}
293300
}
294301
302+
async function togglePassiveMining(
303+
email: string,
304+
type: string,
305+
value: boolean,
306+
) {
307+
await updatePassiveMining(email, type, value);
308+
}
309+
295310
onMounted(async () => {
296311
await $leadminer.fetchMiningSources();
297312
await $leadminer.getCurrentRunningMining();

frontend/src/utils/sources.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export async function getMiningSources(): Promise<MiningSource[]> {
3131
}
3232

3333
const { data: miningSources, error } = await supabase
34+
// @ts-expect-error: Issue with nuxt/supabase
3435
.schema('private')
3536
.from('mining_sources')
3637
.select('*');
@@ -41,6 +42,7 @@ export async function getMiningSources(): Promise<MiningSource[]> {
4142
}
4243

4344
const { data: overviewData, error: overviewError } = await supabase
45+
// @ts-expect-error: Issue with nuxt/supabase
4446
.schema('private')
4547
.rpc('get_mining_source_overview', { user_id: user.value.sub });
4648

@@ -72,3 +74,22 @@ export async function getMiningSources(): Promise<MiningSource[]> {
7274

7375
return sourcesWithStats;
7476
}
77+
78+
export async function updatePassiveMining(
79+
email: string,
80+
type: string,
81+
value: boolean,
82+
): Promise<void> {
83+
const { error } = await useSupabaseClient()
84+
// @ts-expect-error: Issue with nuxt/supabase
85+
.schema('private')
86+
.from('mining_sources')
87+
.update({ passive_mining: value })
88+
.eq('email', email)
89+
.eq('type', type);
90+
91+
if (error) {
92+
console.error('Error updating passive mining status:', error.message);
93+
throw error;
94+
}
95+
}

supabase/functions/.env.dev

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ SMTP_USER=your-secret-smtp-username
1010
SMTP_PASS=your-secret-smtp-password
1111

1212
LOGO_URL="https://db.leadminer.io/storage/v1/object/public/templates/LogoWithIcon.png"
13-
FRONTEND_HOST="http://localhost:8082"
13+
FRONTEND_HOST="http://localhost:8082"
14+
SERVER_ENDPOINT = http://localhost:8081 # ( REQUIRED ) URL of the Backend server.

supabase/functions/.env.prod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ SMTP_USER=
99
SMTP_PASS=
1010

1111
LOGO_URL="https://db.leadminer.io/storage/v1/object/public/templates/LogoWithIcon.png"
12-
FRONTEND_HOST="https://app.leadminer.io"
12+
FRONTEND_HOST="https://app.leadminer.io"
13+
SERVER_ENDPOINT = http://localhost:8081 # ( REQUIRED ) URL of the Backend server.

0 commit comments

Comments
 (0)