Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Create and publish container
on:
release:
types: [published]
workflow_dispatch:
jobs:
build_container:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out Git repository
uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
- name: Build image
run: docker buildx build . --tag ghcr.io/studyphoenix/frontend --build-arg GIT_REF="$( git rev-parse HEAD )"
- name: Login to registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Publish to GitHub Container Registry
run: |
docker push ghcr.io/studyphoenix/frontend
22 changes: 22 additions & 0 deletions .github/workflows/update-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Update data types
on:
workflow_dispatch:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
run_eslint:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out Git repository
uses: actions/checkout@v6
with:
ref: ${{ env.BRANCH_NAME }}
persist-credentials: true
- name: Generate types
run: ./generate-types.yml ci
- name: Push changes back to repository
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "chore: updated data types for API [skip ci]"
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:25-alpine3.21 AS build

ARG GIT_REF="studyphoenix"

# Frontend Build stage
WORKDIR /usr/src/build

ENV VITE_GIT_REF="${GIT_REF}"

COPY . /usr/src/build

RUN npm i
RUN npm run build

# Build final image
FROM nginx AS prod
COPY --from=build /usr/src/build/dist /usr/share/nginx/html
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
5 changes: 5 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ services:
restart: on-failure
ports:
- 8080:8080
environment:
DATA_DIR: /data
BACKEND_URL: http://localhost:8080
FRONTEND_URL: http://localhost:8081
DEFAULT_REDIRECT: http://localhost:8081
volumes:
- ./backend-data:/data
6 changes: 5 additions & 1 deletion generate-types.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

if [[ $1 != "" ]]; then
set -e

if [[ $1 == "ci" ]]; then
npx --yes swagger-typescript-api@13.13.0 generate --path https://raw.githubusercontent.com/studyphoenix/backend/refs/heads/main/docs/swagger.json -o ./src/ts/types -n api.d.ts --no-client
elif [[ $1 != "" ]]; then
npx swagger-typescript-api@13.13.0 generate --path http://$1:8080/swagger/doc.json -o ./src/ts/types -n api.d.ts --no-client
else
npx swagger-typescript-api@13.13.0 generate --path https://raw.githubusercontent.com/studyphoenix/backend/refs/heads/main/docs/swagger.json -o ./src/ts/types -n api.d.ts --no-client
Expand Down
5 changes: 5 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e
docker compose pull
docker compose down && docker compose up -d
16 changes: 16 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 3000;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html;
}

error_page 404 /index.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@fontsource/roboto": "^5.2.10",
"@janishutz/oidc-login-sdk-browser": "^1.5.3",
"@janishutz/oidc-login-sdk-browser": "^1.7.0",
"@mdi/font": "7.4.47",
"pinia": "^3.0.4",
"vue": "^3.5.30",
Expand Down
13 changes: 9 additions & 4 deletions run-lint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash

docker run -v .:/mnt -e VITE_BACKENDLESS=true --name linter ghcr.io/janishutz/vue-dev-runner
docker exec linter bash -c "npm run type-check && npm run lint-fix"
docker stop linter
docker rm linter
if [[ $1 == "local" ]]; then
npm run lint-fix
npm run type-check
else
docker run -v .:/mnt -e VITE_BACKENDLESS=true --name linter ghcr.io/janishutz/vue-dev-runner
docker exec linter bash -c "npm run lint-fix && npm run type-check"
docker stop linter
docker rm linter
fi
27 changes: 17 additions & 10 deletions src/components/SideBar.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<script setup lang="ts">
import {
useAuthStore
} from '@/stores/authstore';
import {
useTheme
} from 'vuetify';

const theme = useTheme();
const toggleTheme = theme.toggle;
const store = useAuthStore();
const username = store.username;
const email = store.email;
</script>

<template>
Expand All @@ -15,10 +22,10 @@
<v-list nav>
<v-list-item
prepend-avatar="https://randomuser.me/api/portraits/women/84.jpg"
subtitle="jane.doe@example.ccom"
title="Jane Doe"
:subtitle="email"
:title="username"
link
href="/profile"
href="/account"
/>
</v-list>

Expand All @@ -33,18 +40,18 @@
href="/"
/>
<v-list-item
prepend-icon="mdi-flag"
prepend-icon="mdi-chat"
title="Chats"
value="chats"
link
href="/flags"
href="/chat"
/>
<v-list-item
prepend-icon="mdi-ab-testing"
title="A/B Testing"
value="ab-testing"
prepend-icon="mdi-school"
title="Subjects"
value="subjects"
link
href="/ab-testing"
href="/subjects"
/>
</v-list>
<template #append>
Expand All @@ -59,7 +66,7 @@
<v-list-item
prepend-icon="mdi-theme-light-dark"
title="Theme"
@click="theme.toggle()"
@click="toggleTheme()"
/>
</v-list>
</template>
Expand Down
1 change: 1 addition & 0 deletions src/components/authz/LoginProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
const profile: ControllerUserProfileResponse = await ( await sdk.request.get( '/user/profile' ) ).json();

store.username = profile.username;
store.email = profile.email;

router.push( '/app' );
};
Expand Down
32 changes: 31 additions & 1 deletion src/components/authz/LogoutProvider.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
<script setup lang="ts">
import * as sdk from '@janishutz/oidc-login-sdk-browser';
import {
ref
} from 'vue';
import {
useAuthStore
} from '@/stores/authstore';

const dialog = ref( false );

const logout = () => {
const store = useAuthStore();

store.isAuth = false;

sdk.auth.logout();
dialog.value = false;
};
</script>

<template>
<v-btn @click="logout">
<v-btn @click="dialog = true">
Log Out
</v-btn>
<v-dialog
v-model="dialog"
width="auto"
>
<v-card
max-width="400"
prepend-icon="mdi-logout"
text="You are about to be logged out"
title="Logout"
>
<template #actions>
<v-btn
class=""
text="Cancel"
@click="dialog = false"
/>
<v-btn
class="text-weight-bold"
text="Log Out"
@click="logout"
/>
</template>
</v-card>
</v-dialog>
</template>
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ router.afterEach( to => {
'top': 0,
'behavior': 'smooth'
} );
document.title = to.meta.title ? to.meta.title + ' - MusicPlayer' : 'MusicPlayer';
document.title = to.meta.title ? to.meta.title + ' - StudyPhoenix' : 'StudyPhoenix';
// NProgress.done();
} );

Expand Down
4 changes: 3 additions & 1 deletion src/stores/authstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
export const useAuthStore = defineStore( 'authstore', () => {
const isAuth = ref( import.meta.env.PROD ? false : ( import.meta.env.VITE_BACKENDLESS == 'true' ? true : false ) );
const username = ref( '' );
const email = ref( '' );

return {
isAuth,
username
username,
email
};
} );
Loading
Loading