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

Fix: websocket connection #255

Merged
merged 30 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2ad9a9b
fix form and responsive
prokawsar Feb 5, 2023
d6bf860
fix loading sections
prokawsar Feb 5, 2023
8467b7e
fix carousela nd table loading
prokawsar Feb 5, 2023
546b36e
Feat: maintenance mode will block login attempts and fixed logout
gagansuie Feb 6, 2023
6372761
Merge branch 'dev' of https://github.com/gagan-suie/mage-website into…
gagansuie Feb 6, 2023
7156634
Merge branch 'dev' of https://github.com/CodeCrowCorp/mage-website in…
gagansuie Feb 6, 2023
e41997f
Fix: removed social icons
gagansuie Feb 6, 2023
5e2e53f
Merge branch 'main' of https://github.com/CodeCrowCorp/mage-website i…
gagansuie Feb 6, 2023
2fd8b55
Merge pull request #245 from gagan-suie/dev
gagansuie Feb 6, 2023
d176b42
Chore: removed unused icons and added local font
gagansuie Feb 6, 2023
a8219ab
Fix: reverted channel button to label to save drawer animation
gagansuie Feb 6, 2023
3db5c7d
Merge pull request #246 from gagan-suie/dev
gagansuie Feb 6, 2023
0dccc1b
swiper installed
prokawsar Feb 6, 2023
38a78cd
Merge branch 'dev' into browse-page-fixes
prokawsar Feb 6, 2023
3d0451e
carousel using swiper
prokawsar Feb 6, 2023
20a5deb
break points
prokawsar Feb 6, 2023
acab438
set width
prokawsar Feb 6, 2023
1673220
make responsive
prokawsar Feb 6, 2023
d1aae69
fix loading state
prokawsar Feb 6, 2023
aeb58ba
temporary data passing
prokawsar Feb 6, 2023
dd6720c
removed unused
prokawsar Feb 6, 2023
c826b4b
Fix: theming and settings page
gagansuie Feb 7, 2023
e90dca3
Merge pull request #249 from gagan-suie/dev
gagansuie Feb 7, 2023
03cfa47
Feat: settings page
gagansuie Feb 7, 2023
8f5cd34
Merge pull request #251 from gagan-suie/dev
gagansuie Feb 7, 2023
ea5a02e
Merge pull request #247 from CodeCrowCorp/browse-page-fixes
gagansuie Feb 7, 2023
e3be791
Fix: fixed websocket connection
da7a90-backup Feb 7, 2023
d9d2587
Merge pull request #253 from da7a90-backup/websocket-cors-fix
gagansuie Feb 7, 2023
e11dc95
Fix: added ondestroy event for sockets
gagansuie Feb 7, 2023
df7ce87
Merge pull request #254 from gagan-suie/dev
gagansuie Feb 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"svelte-preprocess": "^5.0.1",
"svelte-tags-input": "^4.0.0",
"svgo": "^3.0.2",
"swiper": "^9.0.2",
"tailwind-clip-path": "^1.0.0",
"tailwind-scrollbar": "^2.1.0",
"tailwindcss": "^3.2.4",
Expand Down
2 changes: 1 addition & 1 deletion src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
html {
font-family: 'Montserrat', sans-serif;
}
}
}
2 changes: 1 addition & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ declare namespace App {

declare const __VERSION__: string

declare module 'svelte-tags-input'
declare module 'svelte-tags-input'
20 changes: 5 additions & 15 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect, type HandleFetch } from '@sveltejs/kit'
import { redirect, type HandleFetch, type Handle } from '@sveltejs/kit'
import { get as getWritableVal } from 'svelte/store'
import {
isMaintenanceModeEnabled,
Expand All @@ -8,7 +8,6 @@ import {
isFeaturePremiumPageEnabled
} from '$lib/stores/remoteConfigStore'
import { Authenticate } from '$lib/authentication/authentication'
import type { Handle } from '@sveltejs/kit'
import { env } from '$env/dynamic/public'
import { get } from '$lib/api'
import { current_user, user_role } from '$lib/stores/authStore'
Expand Down Expand Up @@ -51,18 +50,9 @@ export const handle: Handle = async ({ event, resolve }) => {

if (!role) {
try {
const headers: any = {
userId: userId
}
if (env.PUBLIC_CROSS_ORIGIN === 'false') {
headers['authorization'] = token
} else {
headers['x-api-key'] = env.PUBLIC_API_KEY
}

const allRoles = await get('roles', headers)
const allRoles = await get('roles', { userId, token })
if (Array.isArray(allRoles)) {
const userRole = await get('roles/role-mapping', headers)
const userRole = await get('roles/role-mapping', { userId, token })
if (userRole && userRole.role) {
const usersRoleName = allRoles.find((item) => {
return item._id == userRole.role
Expand Down Expand Up @@ -136,7 +126,7 @@ export const handleError = ({ error }: { error: any }) => {
}
}

export const handleFetch = (async ({
export const handleFetch = (({
event,
request,
fetch
Expand All @@ -148,7 +138,7 @@ export const handleFetch = (async ({
if (request.url.startsWith(env.PUBLIC_API_URL)) {
request.headers['userId'] = event.locals.user.userId
if (env.PUBLIC_CROSS_ORIGIN === 'false') {
request.headers['authorization'] = event.locals.user.token
request.headers['Authorization'] = event.locals.user.token
} else {
request.headers['x-api-key'] = env.PUBLIC_X_API_KEY
}
Expand Down
8 changes: 6 additions & 2 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function send({

if (env.PUBLIC_CROSS_ORIGIN === 'false') {
if (headers && headers.token) {
opts.headers['authorization'] = headers.token
opts.headers['Authorization'] = headers.token
}
} else {
opts.headers['x-api-key'] = env.PUBLIC_X_API_KEY
Expand All @@ -37,7 +37,7 @@ async function send({
const res = await fetch(`${base}/${path}`, opts)
if (res.ok || res.status === 422) {
const text = await res.text()
if (path === 'wsinit/wsid') return text
if (path === 'wsinit/wsid'|| path.includes('wsinit/channelid')) return text
return text ? JSON.parse(text) : {}
}

Expand All @@ -56,6 +56,10 @@ export function post(path: string, data: any) {
return send({ method: 'POST', path, data })
}

export function patch(path: string, data: any) {
return send({ method: 'PATCH', path, data })
}

export function put(path: string, data: any = {}) {
return send({ method: 'PUT', path, data })
}
62 changes: 61 additions & 1 deletion src/lib/assets/icons/IconMageLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/lib/assets/icons/IconMageText.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/lib/assets/icons/IconMageTextDark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 8 additions & 12 deletions src/lib/components/Browse/CreateChannelDrawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@
</script>

<div class="drawer drawer-end absolute w-full z-20 top-0 right-0">
<input
id="create-channel-drawer"
type="checkbox"
class="drawer-toggle"
bind:checked={showDrawer} />
<input id="create-channel-drawer" type="checkbox" class="drawer-toggle" />
<div class="drawer-side">
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div on:click={() => (showDrawer = false)} class="drawer-overlay" />
Expand All @@ -82,11 +78,11 @@
bind:categoryIcons
bind:categories={newChannel.category} />
{:else}
<div class="bg-base-200 w-80 md:w-[30rem] flex flex-col">
<p class="p-3 text-xl mb-5 pb-2 border-purple-500 font-semibold border-b-2">
Create a new channel
</p>
<form on:submit={() => addChannel()}>
<form on:submit={() => addChannel()}>
<div class="bg-base-200 w-80 md:w-[30rem] h-full flex flex-col">
<p class="p-3 text-xl mb-5 pb-2 border-purple-500 font-semibold border-b-2">
Create a new channel
</p>
<div class="flex flex-col p-3">
<p class="text-xs">
When you create a channel, you may allow viewer's to observe your desktop as you host
Expand Down Expand Up @@ -180,8 +176,8 @@
>Cancel</button>
<button type="submit" class="btn btn-primary grow">Add</button>
</div>
</form>
</div>
</div>
</form>
{/if}
</div>
</div>
Expand Down
18 changes: 12 additions & 6 deletions src/lib/components/Browse/SearchChannel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import CreateChannelDrawer from './CreateChannelDrawer.svelte'
import { current_user } from '$lib/stores/authStore'

export let isDisabled = !current_user

let showDrawer = false
</script>

Expand All @@ -20,12 +22,16 @@
</div>
</div>

<button
class="btn w-[21rem] btn-primary gap-2 drawer-button"
disabled={!$current_user}
on:click={() => (showDrawer = true)}>
<IconCreate />
Create a channel</button>
<div class="form-control">
<!-- svelte-ignore a11y-click-events-have-key-events -->
<label
for="create-channel-drawer"
class="btn w-[21rem] btn-primary gap-2 drawer-button"
on:click={() => (showDrawer = true)}
{...isDisabled ? { disabled: '' } : {}}>
<IconCreate />
Create a channel</label>
</div>

{#if showDrawer}
<CreateChannelDrawer bind:showDrawer />
Expand Down
Loading