feat: move api url to env (#23)
This commit is contained in:
+4
-1
@@ -21,4 +21,7 @@ VITE_SENTRY_ORG_NAME=the-next-greats
|
|||||||
VITE_SENTRY_PROJECT_NAME=classroomio
|
VITE_SENTRY_PROJECT_NAME=classroomio
|
||||||
|
|
||||||
# OpenAI setup - Optional if you want to use OpenAI
|
# OpenAI setup - Optional if you want to use OpenAI
|
||||||
OPENAI_API_KEY=
|
OPENAI_API_KEY=
|
||||||
|
|
||||||
|
# Sever URL - Optional if you want to use video upload and pdf downloads
|
||||||
|
PUBLIC_SERVER_URL=
|
||||||
+3
-1
@@ -1,4 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { PUBLIC_SERVER_URL } from '$env/static/public';
|
||||||
import { course } from '$lib/components/Course/store';
|
import { course } from '$lib/components/Course/store';
|
||||||
import { currentOrg } from '$lib/utils/store/org';
|
import { currentOrg } from '$lib/utils/store/org';
|
||||||
import { profile } from '$lib/utils/store/user';
|
import { profile } from '$lib/utils/store/user';
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
|
|
||||||
const downLoadCertificate = async () => {
|
const downLoadCertificate = async () => {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const response = await fetch('https://classroomio-server.fly.dev/downloadCertificate', {
|
const response = await fetch(PUBLIC_SERVER_URL + '/downloadCertificate', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
label="DownLoad Certificate"
|
label="DownLoad Certificate"
|
||||||
className="rounded-md"
|
className="rounded-md"
|
||||||
onClick={downLoadCertificate}
|
onClick={downLoadCertificate}
|
||||||
|
isDisabled={!PUBLIC_SERVER_URL}
|
||||||
{isLoading}
|
{isLoading}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { PUBLIC_SERVER_URL } from '$env/static/public';
|
||||||
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
||||||
import {
|
import {
|
||||||
lesson,
|
lesson,
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
try {
|
try {
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: 'https://classroomio-server.fly.dev/uploadVideo?lessonId=' + lessonId,
|
url: PUBLIC_SERVER_URL + '/uploadVideo?lessonId=' + lessonId,
|
||||||
data: formData,
|
data: formData,
|
||||||
maxContentLength: Infinity,
|
maxContentLength: Infinity,
|
||||||
maxBodyLength: Infinity,
|
maxBodyLength: Infinity,
|
||||||
@@ -112,7 +113,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
on:click={() => (fileInput && !isLoading ? fileInput.click() : null)}
|
on:click={() => (fileInput && !isLoading ? fileInput.click() : null)}
|
||||||
class="w-full h-full"
|
class="w-full h-full"
|
||||||
disabled={isLoading}
|
disabled={isLoading || !PUBLIC_SERVER_URL}
|
||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
class="h-full w-full flex flex-col items-center justify-center border border-primary-300 border-dashed rounded-xl"
|
class="h-full w-full flex flex-col items-center justify-center border border-primary-300 border-dashed rounded-xl"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { CodeSnippet, Grid, Row, Column, Toggle } from 'carbon-components-svelte';
|
import { CodeSnippet, Grid, Row, Column, Toggle } from 'carbon-components-svelte';
|
||||||
|
import { PUBLIC_SERVER_URL } from '$env/static/public';
|
||||||
|
|
||||||
import SectionTitle from '$lib/components/Org/SectionTitle.svelte';
|
import SectionTitle from '$lib/components/Org/SectionTitle.svelte';
|
||||||
import TextField from '$lib/components/Form/TextField.svelte';
|
import TextField from '$lib/components/Form/TextField.svelte';
|
||||||
@@ -53,7 +54,7 @@
|
|||||||
slideUrl: lesson.slide_url || '',
|
slideUrl: lesson.slide_url || '',
|
||||||
video: lesson.videos || ''
|
video: lesson.videos || ''
|
||||||
}));
|
}));
|
||||||
const response = await fetch('https://classroomio-server.fly.dev/downloadCourse', {
|
const response = await fetch(PUBLIC_SERVER_URL + '/downloadCourse', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
@@ -291,7 +292,7 @@
|
|||||||
variant={VARIANTS.OUTLINED}
|
variant={VARIANTS.OUTLINED}
|
||||||
label="Download"
|
label="Download"
|
||||||
onClick={downloadCourse}
|
onClick={downloadCourse}
|
||||||
isDisabled={isLoading}
|
isDisabled={isLoading || !PUBLIC_SERVER_URL}
|
||||||
{isLoading}
|
{isLoading}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import CourseContainer from '$lib/components/CourseContainer/index.svelte';
|
import CourseContainer from '$lib/components/CourseContainer/index.svelte';
|
||||||
import { fetchCourse, fetchLesson, updateLessonCompletion } from '$lib/utils/services/courses';
|
import { PUBLIC_SERVER_URL } from '$env/static/public';
|
||||||
|
import { fetchLesson, updateLessonCompletion } from '$lib/utils/services/courses';
|
||||||
import CheckmarkOutlineIcon from 'carbon-icons-svelte/lib/CheckmarkOutline.svelte';
|
import CheckmarkOutlineIcon from 'carbon-icons-svelte/lib/CheckmarkOutline.svelte';
|
||||||
import CheckmarkFilledIcon from 'carbon-icons-svelte/lib/CheckmarkFilled.svelte';
|
import CheckmarkFilledIcon from 'carbon-icons-svelte/lib/CheckmarkFilled.svelte';
|
||||||
import ListChecked from 'carbon-icons-svelte/lib/ListChecked.svelte';
|
import ListChecked from 'carbon-icons-svelte/lib/ListChecked.svelte';
|
||||||
@@ -126,7 +127,7 @@
|
|||||||
const lessonNumber = getLessonOrder(currentLesson.id);
|
const lessonNumber = getLessonOrder(currentLesson.id);
|
||||||
const slideUrl = $lesson.materials.slide_url || '';
|
const slideUrl = $lesson.materials.slide_url || '';
|
||||||
|
|
||||||
const response = await fetch('https://classroomio-server.fly.dev/downloadLesson', {
|
const response = await fetch(PUBLIC_SERVER_URL + '/downloadLesson', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
@@ -253,7 +254,7 @@
|
|||||||
: 'hidden'
|
: 'hidden'
|
||||||
} lg:flex items-center`}
|
} lg:flex items-center`}
|
||||||
>
|
>
|
||||||
{#if $course.metadata.lessonDownload}
|
{#if $course.metadata.lessonDownload && !!PUBLIC_SERVER_URL}
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
className="mb-2 lg:mb-0 mr-2"
|
className="mb-2 lg:mb-0 mr-2"
|
||||||
variant={VARIANTS.OUTLINED}
|
variant={VARIANTS.OUTLINED}
|
||||||
|
|||||||
Reference in New Issue
Block a user