You've already forked isop-mirror
Compare commits
10 Commits
08cae3c9f1
...
c99017623b
| Author | SHA1 | Date | |
|---|---|---|---|
| c99017623b | |||
| b1c26b762a | |||
|
|
d570ca3398 | ||
|
|
bef5a596ba | ||
|
|
c63f973f15 | ||
|
|
ddf6787b76 | ||
|
|
3a9f9c0d58 | ||
|
|
4a26fa82d3 | ||
|
|
1ab02ae489 | ||
|
|
b08311e90b |
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||||||
use App\Models\Internship;
|
use App\Models\Internship;
|
||||||
use App\Models\InternshipStatusData;
|
use App\Models\InternshipStatusData;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Mpdf\Mpdf;
|
use Mpdf\Mpdf;
|
||||||
|
|
||||||
@@ -12,54 +13,7 @@ class InternshipController extends Controller
|
|||||||
{
|
{
|
||||||
public function all(Request $request)
|
public function all(Request $request)
|
||||||
{
|
{
|
||||||
$user = $request->user();
|
$internships = $this->filterSearch($request);
|
||||||
|
|
||||||
$request->validate([
|
|
||||||
'year' => 'nullable|integer',
|
|
||||||
'company' => 'nullable|string|min:3|max:32',
|
|
||||||
'study_programe' => 'nullable|string|min:3|max:32',
|
|
||||||
'student' => 'nullable|string|min:3|max:32',
|
|
||||||
'page' => 'nullable|integer|min:1',
|
|
||||||
'per_page' => 'nullable|integer|min:-1|max:100',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$perPage = $request->input('per_page', 15);
|
|
||||||
|
|
||||||
// Handle "All" items (-1)
|
|
||||||
if ($perPage == -1) {
|
|
||||||
$perPage = Internship::count();
|
|
||||||
}
|
|
||||||
|
|
||||||
$internships = Internship::query()
|
|
||||||
->with(['student.studentData'])
|
|
||||||
->when($request->year, function ($query, $year) {
|
|
||||||
$query->whereYear('start', $year);
|
|
||||||
})
|
|
||||||
->when($request->company, function ($query, $company) {
|
|
||||||
$query->whereHas('company', function ($q) use ($company) {
|
|
||||||
$q->where('name', 'like', "%$company%");
|
|
||||||
});
|
|
||||||
})
|
|
||||||
->when($request->study_programe, function ($query, $studyPrograme) {
|
|
||||||
$query->whereHas('student.studentData', function ($q) use ($studyPrograme) {
|
|
||||||
$q->where('study_field', 'like', "%$studyPrograme%");
|
|
||||||
});
|
|
||||||
})
|
|
||||||
->when($request->student, function ($query, $student) {
|
|
||||||
$query->whereHas('student', function ($q) use ($student) {
|
|
||||||
$q->where('name', 'like', "%$student%");
|
|
||||||
});
|
|
||||||
})
|
|
||||||
->when($user->role === 'STUDENT', function ($query) use ($user) {
|
|
||||||
$query->where('user_id', '=', $user->id);
|
|
||||||
})
|
|
||||||
->when($user->role === 'EMPLOYER', function ($query) use ($user) {
|
|
||||||
$query->whereHas('company', function ($q) use ($user) {
|
|
||||||
$q->where('contact', 'like', $user->id);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
->paginate($perPage);
|
|
||||||
|
|
||||||
return response()->json($internships);
|
return response()->json($internships);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +123,43 @@ class InternshipController extends Controller
|
|||||||
->header('Content-Disposition', 'attachment; filename="report_' . $id . '.pdf"');
|
->header('Content-Disposition', 'attachment; filename="report_' . $id . '.pdf"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
$internships = $this->filterSearch($request, true);
|
||||||
|
|
||||||
|
$csv_header = [
|
||||||
|
'ID',
|
||||||
|
'Student',
|
||||||
|
'Company',
|
||||||
|
'Start',
|
||||||
|
'End',
|
||||||
|
'YearOfStudy',
|
||||||
|
'Semester',
|
||||||
|
'StudyField',
|
||||||
|
'Status'
|
||||||
|
];
|
||||||
|
|
||||||
|
$csv_content = implode(',', $csv_header) . "\n";
|
||||||
|
foreach ($internships as $internship) {
|
||||||
|
$data = [
|
||||||
|
$internship->id,
|
||||||
|
'"' . $internship->student->name . '"',
|
||||||
|
'"' . $internship->company->name . '"',
|
||||||
|
Carbon::parse($internship->start)->format('d.m.Y'),
|
||||||
|
Carbon::parse($internship->end)->format('d.m.Y'),
|
||||||
|
$internship->year_of_study,
|
||||||
|
$internship->semester,
|
||||||
|
$internship->student->studentData->study_field,
|
||||||
|
$internship->status->status->value
|
||||||
|
];
|
||||||
|
$csv_content .= implode(',', $data) . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return response($csv_content, 200)
|
||||||
|
->header('Content-Type', 'application/csv')
|
||||||
|
->header('Content-Disposition', 'attachment; filename="internships.csv"');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
@@ -364,4 +355,61 @@ class InternshipController extends Controller
|
|||||||
], 400));
|
], 400));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function filterSearch(Request $request, bool $ignorePage = false)
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'year' => 'nullable|integer',
|
||||||
|
'company' => 'nullable|string|min:3|max:32',
|
||||||
|
'study_programe' => 'nullable|string|min:3|max:32',
|
||||||
|
'student' => 'nullable|string|min:3|max:32',
|
||||||
|
'page' => 'nullable|integer|min:1',
|
||||||
|
'per_page' => 'nullable|integer|min:-1|max:100',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($ignorePage) {
|
||||||
|
$request->merge(['per_page' => -1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$perPage = $request->input('per_page', 15);
|
||||||
|
|
||||||
|
// Handle "All" items (-1)
|
||||||
|
if ($perPage == -1) {
|
||||||
|
$perPage = Internship::count();
|
||||||
|
}
|
||||||
|
|
||||||
|
$internships = Internship::query()
|
||||||
|
->with(['student.studentData'])
|
||||||
|
->when($request->year, function ($query, $year) {
|
||||||
|
$query->whereYear('start', $year);
|
||||||
|
})
|
||||||
|
->when($request->company, function ($query, $company) {
|
||||||
|
$query->whereHas('company', function ($q) use ($company) {
|
||||||
|
$q->where('name', 'like', "%$company%");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->study_programe, function ($query, $studyPrograme) {
|
||||||
|
$query->whereHas('student.studentData', function ($q) use ($studyPrograme) {
|
||||||
|
$q->where('study_field', 'like', "%$studyPrograme%");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->student, function ($query, $student) {
|
||||||
|
$query->whereHas('student', function ($q) use ($student) {
|
||||||
|
$q->where('name', 'like', "%$student%");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($user->role === 'STUDENT', function ($query) use ($user) {
|
||||||
|
$query->where('user_id', '=', $user->id);
|
||||||
|
})
|
||||||
|
->when($user->role === 'EMPLOYER', function ($query) use ($user) {
|
||||||
|
$query->whereHas('company', function ($q) use ($user) {
|
||||||
|
$q->where('contact', 'like', $user->id);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->paginate($perPage);
|
||||||
|
|
||||||
|
return $internships;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ Route::post('/password-reset', [RegisteredUserController::class, 'reset_password
|
|||||||
|
|
||||||
Route::prefix('/internships')->group(function () {
|
Route::prefix('/internships')->group(function () {
|
||||||
Route::get("/", [InternshipController::class, 'all'])->middleware(['auth:sanctum'])->name("api.internships");
|
Route::get("/", [InternshipController::class, 'all'])->middleware(['auth:sanctum'])->name("api.internships");
|
||||||
|
Route::get("/export", [InternshipController::class, 'export'])->middleware(AdministratorOnly::class)->name("api.internships.export");
|
||||||
|
|
||||||
Route::prefix('/{id}')->middleware("auth:sanctum")->group(function () {
|
Route::prefix('/{id}')->middleware("auth:sanctum")->group(function () {
|
||||||
Route::get("/", [InternshipController::class, 'get'])->name("api.internships.get");
|
Route::get("/", [InternshipController::class, 'get'])->name("api.internships.get");
|
||||||
|
|||||||
1
docker/.gitignore
vendored
Normal file
1
docker/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
mariadb_data/
|
||||||
63
docker/docker-compose.yml
Normal file
63
docker/docker-compose.yml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
services:
|
||||||
|
isop-frontend:
|
||||||
|
container_name: isop-frontend
|
||||||
|
build:
|
||||||
|
context: ../frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
NUXT_HOST: 0.0.0.0
|
||||||
|
NUXT_PORT: 80
|
||||||
|
NUXT_PUBLIC_SANCTUM_BASE_URL: https://localhost
|
||||||
|
NUXT_PUBLIC_SANCTUM_ORIGINAL: http://localhost
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
depends_on:
|
||||||
|
- isop-backend
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost"]
|
||||||
|
start_period: 10s
|
||||||
|
interval: 1m
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
isop-backend:
|
||||||
|
container_name: isop-backend
|
||||||
|
image: dunglas/frankenphp
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- ../backend/.env
|
||||||
|
environment:
|
||||||
|
DB_CONNECTION: mariadb
|
||||||
|
DB_HOST: isop-database
|
||||||
|
DB_PORT: 3306
|
||||||
|
DB_DATABASE: isop
|
||||||
|
DB_USERNAME: root
|
||||||
|
DB_PASSWORD: admin
|
||||||
|
ports:
|
||||||
|
- 443:443
|
||||||
|
- 443:443/udp
|
||||||
|
volumes:
|
||||||
|
- ../backend:/app
|
||||||
|
depends_on:
|
||||||
|
isop-database:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
isop-database:
|
||||||
|
container_name: isop-database
|
||||||
|
image: mariadb:11.8.2-noble
|
||||||
|
restart: unless-stopped
|
||||||
|
cap_add:
|
||||||
|
# Allow memory binding
|
||||||
|
- SYS_NICE
|
||||||
|
environment:
|
||||||
|
MARIADB_DATABASE: "isop"
|
||||||
|
MARIADB_ROOT_PASSWORD: "admin"
|
||||||
|
volumes:
|
||||||
|
- ./mariadb_data:/var/lib/mysql
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
|
||||||
|
start_period: 10s
|
||||||
|
interval: 1m
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
8
frontend/.dockerignore
Normal file
8
frontend/.dockerignore
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.nuxt/
|
||||||
|
.output/
|
||||||
|
.env*
|
||||||
|
node_modules/
|
||||||
|
cypress/
|
||||||
|
cypress.config.ts
|
||||||
|
package-lock.json
|
||||||
|
*.md
|
||||||
37
frontend/Dockerfile
Normal file
37
frontend/Dockerfile
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Build Stage 1
|
||||||
|
|
||||||
|
FROM node:22-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN corepack enable
|
||||||
|
|
||||||
|
# Copy package.json and your lockfile
|
||||||
|
COPY package.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN pnpm i
|
||||||
|
|
||||||
|
# Copy the entire project
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
# Prepare Nuxt (generates .nuxt with type definitions and auto-imports)
|
||||||
|
RUN pnpm run postinstall
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
RUN pnpm run build
|
||||||
|
|
||||||
|
# Build Stage 2
|
||||||
|
|
||||||
|
FROM node:22-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Only `.output` folder is needed from the build stage
|
||||||
|
COPY --from=build /app/.output/ ./
|
||||||
|
|
||||||
|
# Change the port and host
|
||||||
|
ENV PORT=80
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["node", "/app/server/index.mjs"]
|
||||||
@@ -15,7 +15,7 @@ async function requestDownload() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const proof = await client<Blob>(`/api/internships/${props.internship_id}/default-proof`);
|
const proof = await client<Blob>(`/api/internships/${props.internship_id}/default-proof`);
|
||||||
triggerDownload(proof, `default-proof-${props.internship_id}`);
|
triggerDownload(proof, `default-proof-${props.internship_id}`, 'pdf');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof FetchError) {
|
if (e instanceof FetchError) {
|
||||||
alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`);
|
alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`);
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ const client = useSanctumClient();
|
|||||||
|
|
||||||
async function downloadAgreement() {
|
async function downloadAgreement() {
|
||||||
const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`);
|
const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`);
|
||||||
triggerDownload(proof, `proof-${props.internship.id}`);
|
triggerDownload(proof, `proof-${props.internship.id}`, 'pdf');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadReport() {
|
async function downloadReport() {
|
||||||
const report: Blob = await client(`/api/internships/${props.internship.id}/report`);
|
const report: Blob = await client(`/api/internships/${props.internship.id}/report`);
|
||||||
triggerDownload(report, `report-${props.internship.id}`);
|
triggerDownload(report, `report-${props.internship.id}`, 'pdf');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Internship } from '~/types/internships';
|
import type { Internship, InternshipFilter } from '~/types/internships';
|
||||||
import type { Paginated } from '~/types/pagination';
|
import type { Paginated } from '~/types/pagination';
|
||||||
import { prettyInternshipStatus } from '~/types/internship_status';
|
import { prettyInternshipStatus } from '~/types/internship_status';
|
||||||
import { FetchError } from 'ofetch';
|
import { FetchError } from 'ofetch';
|
||||||
@@ -7,8 +7,12 @@ import { FetchError } from 'ofetch';
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
mode: 'admin' | 'company' | 'student';
|
mode: 'admin' | 'company' | 'student';
|
||||||
}>();
|
}>();
|
||||||
|
const emit = defineEmits<{
|
||||||
|
filterApplied: [value: InternshipFilter],
|
||||||
|
itemsAvailable: [value: boolean]
|
||||||
|
}>();
|
||||||
|
|
||||||
const filters = ref({
|
const filters = ref<InternshipFilter>({
|
||||||
year: null,
|
year: null,
|
||||||
company: null,
|
company: null,
|
||||||
study_programe: null,
|
study_programe: null,
|
||||||
@@ -50,10 +54,12 @@ const { data, error, pending, refresh } = await useLazySanctumFetch<Paginated<In
|
|||||||
|
|
||||||
watch(data, (newData) => {
|
watch(data, (newData) => {
|
||||||
totalItems.value = newData?.total ?? 0;
|
totalItems.value = newData?.total ?? 0;
|
||||||
|
emit('itemsAvailable', totalItems.value > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(filters, async () => {
|
watch(filters, async () => {
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
|
emit('filterApplied', filters.value);
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
async function delteInternship(internship: Internship) {
|
async function delteInternship(internship: Internship) {
|
||||||
@@ -137,7 +143,7 @@ async function confirmDeletion(confirm: boolean) {
|
|||||||
<v-dialog v-model="deleteConfirmDialog" max-width="500px">
|
<v-dialog v-model="deleteConfirmDialog" max-width="500px">
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title class="text-h5">
|
<v-card-title class="text-h5">
|
||||||
Nový API kľúč
|
Potvrdiť vymazanie praxe
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { InternshipFilter } from '~/types/internships';
|
||||||
|
import { FetchError } from 'ofetch';
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: ['sanctum:auth', 'admin-only'],
|
middleware: ['sanctum:auth', 'admin-only'],
|
||||||
});
|
});
|
||||||
@@ -20,6 +23,30 @@ const headers = [
|
|||||||
{ title: 'Stav', key: 'status', align: 'middle' },
|
{ title: 'Stav', key: 'status', align: 'middle' },
|
||||||
{ title: 'Operácie', key: 'ops', align: 'middle' },
|
{ title: 'Operácie', key: 'ops', align: 'middle' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const internshipFilters = ref<InternshipFilter | null>(null);
|
||||||
|
const exportPending = ref(false);
|
||||||
|
const exportAvailable = ref(true);
|
||||||
|
|
||||||
|
const client = useSanctumClient();
|
||||||
|
|
||||||
|
async function requestExport() {
|
||||||
|
exportPending.value = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const file = await client<Blob>(`/api/internships/export`, {
|
||||||
|
method: 'GET',
|
||||||
|
query: internshipFilters.value ?? {},
|
||||||
|
});
|
||||||
|
triggerDownload(file, 'internships_export', 'csv');
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof FetchError) {
|
||||||
|
alert(`Chyba pri exportovaní: ${e.statusMessage ?? e.message}`);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
exportPending.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -30,7 +57,16 @@ const headers = [
|
|||||||
<!-- spacer -->
|
<!-- spacer -->
|
||||||
<div style="height: 40px;"></div>
|
<div style="height: 40px;"></div>
|
||||||
|
|
||||||
<InternshipListView mode="admin" />
|
<v-btn prepend-icon="mdi-file-export-outline" color="green" class="mr-2 mb-2" @click="requestExport"
|
||||||
|
:disabled="!exportAvailable" :loading="exportPending">
|
||||||
|
<v-tooltip activator="parent" location="top">
|
||||||
|
Exportovať aktuálne zobrazené výsledky do CSV súboru
|
||||||
|
</v-tooltip>
|
||||||
|
Export výsledkov
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<InternshipListView mode="admin" @filterApplied="(filters) => internshipFilters = filters"
|
||||||
|
@itemsAvailable="(available) => exportAvailable = available" />
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ export interface NewInternship {
|
|||||||
position_description: string;
|
position_description: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface InternshipFilter {
|
||||||
|
year: number | null;
|
||||||
|
company: string | null;
|
||||||
|
study_programe: string | null;
|
||||||
|
student: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
export function convertDate(date: string): Date {
|
export function convertDate(date: string): Date {
|
||||||
const matcher = /^\d\d.\d\d.\d\d\d\d$/;
|
const matcher = /^\d\d.\d\d.\d\d\d\d$/;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
export function triggerDownload(file: Blob, file_name: string) {
|
export function triggerDownload(file: Blob, file_name: string, ext: string) {
|
||||||
const url = window.URL.createObjectURL(file);
|
const url = window.URL.createObjectURL(file);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.download = `${file_name}.pdf`;
|
link.download = `${file_name}.${ext}`;
|
||||||
link.target = "_blank";
|
link.target = "_blank";
|
||||||
link.click();
|
link.click();
|
||||||
window.URL.revokeObjectURL(url);
|
window.URL.revokeObjectURL(url);
|
||||||
|
|||||||
Reference in New Issue
Block a user