You've already forked isop-mirror
Compare commits
49 Commits
08cae3c9f1
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
| 885ad069d3 | |||
| cd2afee8fc | |||
| af5dbc2767 | |||
| 430100f62d | |||
| 1224d2057b | |||
| 77e099a16e | |||
| 0da6157255 | |||
| f0ac4e0cdf | |||
| 679b6ab913 | |||
| a93c8d236a | |||
| 92782bfff3 | |||
| d052e464b2 | |||
| 962ae2d0d3 | |||
| 72bca8876e | |||
| 380cf51b77 | |||
| a6164cdcf0 | |||
| 43b056f412 | |||
| cbfd4f1b68 | |||
| be284c061e | |||
| e62fe4c443 | |||
|
|
b9be4a2e6c | ||
|
|
06e6e59a18 | ||
|
|
a9ac8a2735 | ||
|
|
01aae85efc | ||
|
|
b95cdb070d | ||
|
|
e64b6c2eca | ||
|
|
4a5a4f990c | ||
|
|
2b31c1d2ad | ||
|
|
b612c0f873 | ||
|
|
9de30a7df1 | ||
|
|
1d2016c011 | ||
|
|
687018e0fe | ||
|
|
6902eadef5 | ||
| 187b56b464 | |||
| c99017623b | |||
| b1c26b762a | |||
|
|
d570ca3398 | ||
|
|
bef5a596ba | ||
|
|
c63f973f15 | ||
|
|
ddf6787b76 | ||
|
|
3a9f9c0d58 | ||
|
|
4a26fa82d3 | ||
|
|
1ab02ae489 | ||
|
|
b08311e90b | ||
| 77c4164dcb | |||
| 550f07df79 | |||
| 4714cc7892 | |||
| 042cdcdb3a | |||
| 79a8c4f229 |
9
backend/.dockerignore
Normal file
9
backend/.dockerignore
Normal file
@@ -0,0 +1,9 @@
|
||||
.git
|
||||
.env
|
||||
storage/logs/*
|
||||
storage/framework/cache/*
|
||||
storage/framework/sessions/*
|
||||
storage/framework/views/*
|
||||
bootstrap/cache/*
|
||||
.phpunit.result.cache
|
||||
vendor/*
|
||||
18
backend/Dockerfile
Normal file
18
backend/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM dunglas/frankenphp:1.10-php8.4-bookworm
|
||||
|
||||
RUN install-php-extensions \
|
||||
pdo_mysql \
|
||||
gd \
|
||||
intl \
|
||||
zip \
|
||||
opcache
|
||||
|
||||
COPY . /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
RUN composer install --no-dev --optimize-autoloader
|
||||
|
||||
ENV SERVER_NAME=:80
|
||||
61
backend/app/Console/Commands/CreateAdmin.php
Normal file
61
backend/app/Console/Commands/CreateAdmin.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use Hash;
|
||||
|
||||
class CreateAdmin extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:create-admin';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new admin user';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('=== Create Admin ===');
|
||||
|
||||
// Načítanie údajov interaktívne
|
||||
$firstName = $this->ask('First name');
|
||||
$lastName = $this->ask('Last name');
|
||||
$email = $this->ask('E-mail');
|
||||
|
||||
// Kontrola duplicity emailu
|
||||
if (User::where('email', $email)->exists()) {
|
||||
$this->error('A user with the same email already exists.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$password = $this->secret('Enter password');
|
||||
$phone = $this->ask('Enter phone number');
|
||||
|
||||
// Vytvorenie používateľa
|
||||
$user = User::create([
|
||||
'name' => $firstName . ' ' . $lastName,
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'email' => $email,
|
||||
'password' => Hash::make($password),
|
||||
'active' => true,
|
||||
'role' => 'ADMIN',
|
||||
'phone' => $phone,
|
||||
]);
|
||||
|
||||
$this->info("\n Admin {$user->first_name} {$user->last_name} created.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CreateGarant extends Command
|
||||
{
|
||||
/**
|
||||
* Názov CLI príkazu.
|
||||
*/
|
||||
protected $signature = 'user:create-garant';
|
||||
|
||||
/**
|
||||
* Popis príkazu.
|
||||
*/
|
||||
protected $description = 'Interaktívne vytvorí nového používateľa s rolou admin (garant)';
|
||||
|
||||
/**
|
||||
* Spustenie príkazu.
|
||||
* php artisan user:create-garant
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('=== Vytvorenie garanta (admin) ===');
|
||||
|
||||
// Načítanie údajov interaktívne
|
||||
$firstName = $this->ask('Zadaj krstné meno');
|
||||
$lastName = $this->ask('Zadaj priezvisko');
|
||||
$email = $this->ask('Zadaj email');
|
||||
|
||||
// Kontrola duplicity emailu
|
||||
if (User::where('email', $email)->exists()) {
|
||||
$this->error('Používateľ s týmto emailom už existuje.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$password = $this->secret('Zadaj heslo (nebude sa zobrazovať)');
|
||||
$phone = $this->ask('Zadaj telefón ');
|
||||
|
||||
// Vytvorenie používateľa
|
||||
$user = User::create([
|
||||
'name' => $firstName . ' ' . $lastName,
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'email' => $email,
|
||||
'phone' => $phone,
|
||||
'role' => 'ADMIN',
|
||||
'password' => Hash::make($password),
|
||||
]);
|
||||
|
||||
$this->info("\n Garant {$user->first_name} {$user->last_name} bol úspešne vytvorený s rolou ADMIN.");
|
||||
$this->info("Email: {$user->email}");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Internship;
|
||||
use App\Models\InternshipStatusData;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
@@ -12,54 +13,7 @@ class InternshipController extends Controller
|
||||
{
|
||||
public function all(Request $request)
|
||||
{
|
||||
$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',
|
||||
]);
|
||||
|
||||
$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);
|
||||
|
||||
$internships = $this->filterSearch($request);
|
||||
return response()->json($internships);
|
||||
}
|
||||
|
||||
@@ -169,6 +123,43 @@ class InternshipController extends Controller
|
||||
->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.
|
||||
*/
|
||||
@@ -364,4 +355,61 @@ class InternshipController extends Controller
|
||||
], 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,17 +123,30 @@ class InternshipStatusDataController extends Controller
|
||||
'modified_by' => $user->id
|
||||
]);
|
||||
|
||||
// mail študentovi
|
||||
Mail::to($internship->student)
|
||||
->sendNow(new InternshipStatusUpdated(
|
||||
$internship,
|
||||
$user->name,
|
||||
$internship->student->name,
|
||||
$internship->company->name,
|
||||
$internshipStatus->status,
|
||||
$request->enum('status', InternshipStatus::class),
|
||||
$request->note
|
||||
$newStatus->status,
|
||||
$request->note,
|
||||
$user,
|
||||
recipiantIsStudent: true,
|
||||
));
|
||||
|
||||
// ak zmenu nevykonala firma, posleme mail aj firme
|
||||
if ($user->id !== $internship->company->contactPerson->id) {
|
||||
Mail::to($internship->company->contactPerson->email)
|
||||
->sendNow(new InternshipStatusUpdated(
|
||||
$internship,
|
||||
$internshipStatus->status,
|
||||
$newStatus->status,
|
||||
$request->note,
|
||||
$user,
|
||||
recipiantIsStudent: false,
|
||||
));
|
||||
}
|
||||
|
||||
$newStatus->save();
|
||||
return response()->noContent();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Mail;
|
||||
|
||||
use App\Enums\InternshipStatus;
|
||||
use App\Models\Internship;
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -15,25 +16,23 @@ class InternshipStatusUpdated extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private Internship $internship;
|
||||
private string $changedByName;
|
||||
private string $studentName;
|
||||
private string $companyName;
|
||||
private InternshipStatus $oldStatus;
|
||||
private InternshipStatus $newStatus;
|
||||
private string $note;
|
||||
private User $changedBy;
|
||||
private bool $recipiantIsStudent;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct(Internship $internship, string $changedByName, string $studentName, string $companyName, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note)
|
||||
public function __construct(Internship $internship, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note, User $changedBy, bool $recipiantIsStudent)
|
||||
{
|
||||
$this->internship = $internship;
|
||||
$this->changedByName = $changedByName;
|
||||
$this->studentName = $studentName;
|
||||
$this->companyName = $companyName;
|
||||
$this->oldStatus = $oldStatus;
|
||||
$this->newStatus = $newStatus;
|
||||
$this->note = $note;
|
||||
$this->changedBy = $changedBy;
|
||||
$this->recipiantIsStudent = $recipiantIsStudent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,12 +54,11 @@ class InternshipStatusUpdated extends Mailable
|
||||
view: 'mail.internship.status_updated',
|
||||
with: [
|
||||
"internship" => $this->internship,
|
||||
"changedByName" => $this->changedByName,
|
||||
"studentName" => $this->studentName,
|
||||
"companyName" => $this->companyName,
|
||||
"oldStatus" => $this->prettyStatus($this->oldStatus->value),
|
||||
"newStatus" => $this->prettyStatus($this->newStatus->value),
|
||||
"note" => $this->note,
|
||||
"recipiantIsStudent" => $this->recipiantIsStudent,
|
||||
"changedBy" => $this->changedBy,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Company extends Model
|
||||
/**
|
||||
* Get the contact person (user) for the company.
|
||||
*/
|
||||
public function contact()
|
||||
public function contactPerson()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'contact');
|
||||
}
|
||||
|
||||
@@ -107,6 +107,10 @@ class Internship extends Model
|
||||
$current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && !$report_confirmed
|
||||
=> ['DENIED_BY_ADMIN', 'CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY'],
|
||||
|
||||
// prax bola zamietnutá garantom a ide ju meniť garant
|
||||
$current_status === InternshipStatus::DENIED_BY_ADMIN && $userRole === "ADMIN"
|
||||
=> ['CONFIRMED_BY_COMPANY', 'CONFIRMED_BY_ADMIN', 'DENIED_BY_COMPANY'],
|
||||
|
||||
// prax bola obhájená a ide ju meniť admin
|
||||
$current_status === InternshipStatus::DEFENDED && $userRole === "ADMIN"
|
||||
=> ['NOT_DEFENDED'],
|
||||
|
||||
@@ -6,12 +6,14 @@ use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
web: __DIR__ . '/../routes/web.php',
|
||||
api: __DIR__ . '/../routes/api.php',
|
||||
commands: __DIR__ . '/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->trustProxies('*');
|
||||
|
||||
$middleware->api(prepend: [
|
||||
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
]);
|
||||
|
||||
@@ -18,7 +18,7 @@ class CompanyFactory extends Factory
|
||||
{
|
||||
return [
|
||||
'name' => fake()->company(),
|
||||
'address' => fake()->address(),
|
||||
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
|
||||
'ico' => fake()->numberBetween(111111, 999999),
|
||||
'contact' => 0,
|
||||
'hiring' => fake()->boolean(),
|
||||
|
||||
@@ -18,7 +18,7 @@ class StudentDataFactory extends Factory
|
||||
{
|
||||
return [
|
||||
'user_id' => 0,
|
||||
'address' => fake()->address(),
|
||||
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
|
||||
'personal_email' => fake()->safeEmail(),
|
||||
'study_field' => fake()->randomElement(["AI22m", "AI22b"]),
|
||||
];
|
||||
|
||||
14
backend/docker/entrypoint.sh
Normal file
14
backend/docker/entrypoint.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
function exit_container_SIGTERM(){
|
||||
echo "Caught SIGTERM"
|
||||
exit 0
|
||||
}
|
||||
trap exit_container_SIGTERM SIGTERM
|
||||
|
||||
echo "Setting /app/public ownership..."
|
||||
chgrp -R 33 /app
|
||||
chown -hR 33:33 /app
|
||||
|
||||
echo "Starting PHP-FPM..."
|
||||
php-fpm -F & wait
|
||||
@@ -1,14 +1,21 @@
|
||||
@include("parts.header")
|
||||
<p>Vážená/ý {{ $studentName }},</p>
|
||||
<p>stav vašej praxe vo firme {{ $companyName }} bola aktualizovaná zo stavu "{{ $oldStatus }}" na
|
||||
"{{ $newStatus }}".</p>
|
||||
<p>Zmenu vykonal <em>{{ $changedByName }}</em>.</p>
|
||||
<br />
|
||||
|
||||
@if($recipiantIsStudent)
|
||||
<p>Vážená/ý {{ $internship->student->name }},</p>
|
||||
@else
|
||||
<p>Vážená/ý {{ $internship->company->contactPerson->name }},</p>
|
||||
@endif
|
||||
|
||||
<p>oznamujeme Vás o zmene praxe:</p>
|
||||
@if(!$recipiantIsStudent)
|
||||
<p>Študent: <em>{{ $internship->student->name }} ({{ $internship->student->email }},
|
||||
{{ $internship->student->phone }})</em></p>
|
||||
@endif
|
||||
<p>Stav: <em>{{ $oldStatus }}</em> <strong>-></strong> <em>{{ $newStatus }}</em></p>
|
||||
<p>Poznámka: <em>{{ $note }}</em>.</p>
|
||||
|
||||
<p>Zmenu vykonal <em>{{ $changedBy->name }}</em>.</p>
|
||||
<br />
|
||||
|
||||
<p>s pozdravom</p>
|
||||
<p>S pozdravom.</p>
|
||||
<p>Systém ISOP UKF</p>
|
||||
@include("parts.footer")
|
||||
@@ -43,6 +43,7 @@ Route::post('/password-reset', [RegisteredUserController::class, 'reset_password
|
||||
|
||||
Route::prefix('/internships')->group(function () {
|
||||
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::get("/", [InternshipController::class, 'get'])->name("api.internships.get");
|
||||
|
||||
6
docker/.env.example
Normal file
6
docker/.env.example
Normal file
@@ -0,0 +1,6 @@
|
||||
BACKEND_URL=https://backend.example.com
|
||||
FRONTEND_URL=https://example.com
|
||||
BACKEND_DOMAIN=backend.example.com
|
||||
FRONTEND_DOMAIN=example.com
|
||||
SESSION_DOMAIN=.example.com
|
||||
APP_KEY=SOME-KEY
|
||||
2
docker/.gitignore
vendored
Normal file
2
docker/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
mariadb_data/
|
||||
.env
|
||||
199
docker/README.md
Normal file
199
docker/README.md
Normal file
@@ -0,0 +1,199 @@
|
||||
# Docker
|
||||
|
||||
Hostovanie s Dockerom je možné použitím `docker-compose.yml`. Definuje 3 služby:
|
||||
- Frontend
|
||||
- `node:22-alpine`
|
||||
- Build aplikácie prebieha cez [pnpm](https://pnpm.io/).
|
||||
- Backend
|
||||
- `dunglas/frankenphp:1.10-php8.4-bookworm`
|
||||
- PHP verzia `8.4`
|
||||
- Extensions:
|
||||
- `pdo_mysql`
|
||||
- `gd`
|
||||
- `intl`
|
||||
- `zip`
|
||||
- `opcache`
|
||||
- Aplikácia je servovaná pomocou [Caddy](https://caddyserver.com/)
|
||||
- Databáza
|
||||
- `mariadb:11.8.2-noble`
|
||||
|
||||
Každá služba má `healthcheck` a `depends_on` na zabezpečenie vhodného spustenia a kontroly funkčnosti.
|
||||
|
||||
> ⚠️ Tento setup je určený pre produkčné nasadenie a vyžaduje manuálne nastavenie reverzných proxy na zabezpečenie pomocou HTTPS. Pre lokálne testovanie (neodporúčané) je nutné ručne nastaviť DNS záznamy (napr. cez `/etc/hosts`).
|
||||
|
||||
## Prerekvizity
|
||||
|
||||
### Softvérové požiadavky
|
||||
|
||||
Je vyžadovaný iba Docker s Docker Compose. V novších verzách Dockeru je už Compose zabudovaný.
|
||||
|
||||
Testované s:
|
||||
| **Verzia** | **OS** |
|
||||
|-------------------|--------------------|
|
||||
| 28.5.2/ecc694264d | linux/arch-cachyos |
|
||||
| 29.1.1/0aedba5 | linux/debian-lxc |
|
||||
|
||||
Ako reverzné proxy môžete použiť napríklad [Caddy](https://caddyserver.com/), [Traefik](https://traefik.io/), [Nginx](https://nginx.org/) alebo [Cloudflare Tunely](https://www.cloudflare.com/products/tunnel/). Odporúčame však Caddy kvôli jednoduchej konfigurácii a automatickému získavaniu SSL certifikátov cez Let's Encrypt, prípadne Cloudflare Tunely pre jednoduché nastavenie bez potreby spravovať DNS záznamy a certifikáty.
|
||||
|
||||
### Hardvérové požiadavky (pre build)
|
||||
| | Minimálne | Odporúčané |
|
||||
|-----|-----------|------------|
|
||||
| RAM | 2GB | 4GB |
|
||||
| CPU | 2 | 4 |
|
||||
|
||||
Ak máte iba 2GB RAM, odporúčame nastaviť min 2GB swap pamäte, aby build prebehol úspešne. Prípadne môžete obmedziť počet paralelných buildov.
|
||||
|
||||
## Základná inštalácia a nastavenie
|
||||
|
||||
### Stiahnutie projektu a buildovanie
|
||||
|
||||
Projekt si najprv stiahnite do vami zvoleného priečinka:
|
||||
```sh
|
||||
git clone https://github.com/isop-ukf/isop-app.git
|
||||
```
|
||||
|
||||
Podľa potreby prejdite na požadovanú branchu:
|
||||
```sh
|
||||
cd isop-app
|
||||
git checkout [branch]
|
||||
```
|
||||
|
||||
Prejdite do adresára `docker`:
|
||||
```sh
|
||||
cd docker
|
||||
```
|
||||
|
||||
Spustite build nasledovným príkazom:
|
||||
```sh
|
||||
docker compose build
|
||||
```
|
||||
> Počet paralelných buildov môžete obmedziť pomocou `--parallel N` (pred `build`), kde N je počet súčasne bežiacich buildov.
|
||||
|
||||
> ⏱️ Build trvá približne 2 min.
|
||||
|
||||
|
||||
> ⚠️ Kvôli kompilácii PHP modulov počas buildu dôjde k zvýšenému využitiu CPU a RAM.
|
||||
|
||||
### Nastavenie prostredia
|
||||
Pred prvým spustením je potrebné vytvoriť súbor `.env` na základe šablóny `.env.example`:
|
||||
```sh
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
- `BACKEND_URL`: URL adresa backendu **vrátane** protokolu (a prípade portu)
|
||||
- `FRONTEND_URL`: URL adresa frontendu **vrátane** protokolu (a prípade portu)
|
||||
- `BACKEND_DOMAIN`: Doména pre backend **bez** protokolu a portu
|
||||
- `FRONTEND_DOMAIN`: Doména pre frontend **bez** protokolu a portu
|
||||
- `SESSION_DOMAIN`: Doména pre session cookies, prípadne aj s bodkou na začiatku pre zdieľanie medzi subdoménami
|
||||
- `APP_KEY`: Aplikačný kľúč pre šifrovanie (postup nižšie)
|
||||
|
||||
Príklad `.env` súboru:
|
||||
```env
|
||||
BACKEND_URL=https://backend.myapp.com
|
||||
FRONTEND_URL=https://myapp.com
|
||||
BACKEND_DOMAIN=backend.myapp.com
|
||||
FRONTEND_DOMAIN=myapp.com
|
||||
SESSION_DOMAIN=.myapp.com
|
||||
APP_KEY=base64:Xxx00XX+X/ABC+AABBCCDDEEFFGGHHXYZ0+00000000=
|
||||
```
|
||||
|
||||
### Vygenerovanie aplikačného kľúča
|
||||
Aplikačný kľúč môžete vygenerovať pomocou nasledujúceho príkazu:
|
||||
```sh
|
||||
docker compose run --rm --no-deps isop-backend php artisan key:generate --show
|
||||
```
|
||||
|
||||
> ⚠️ Odporúčame zmazať vytvorený kontajner po vygenerovaní kľúča.
|
||||
> ```sh
|
||||
> docker compose down
|
||||
> ```
|
||||
|
||||
### Spustenie migrácií
|
||||
Pred prvým spustením aplikácie je potrebné spustiť databázové migrácie príkazmi:
|
||||
```sh
|
||||
docker compose up -d isop-backend isop-database
|
||||
docker compose exec isop-backend php artisan migrate:fresh
|
||||
docker compose down
|
||||
```
|
||||
|
||||
## Spustenie aplikácie
|
||||
Aplikáciu spustíte príkazom:
|
||||
```sh
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Logy môžete sledovať pomocou:
|
||||
```sh
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
## Zastavenie aplikácie
|
||||
Aplikáciu zastavíte príkazom:
|
||||
```sh
|
||||
docker compose down
|
||||
```
|
||||
|
||||
## Aktualizácia aplikácie
|
||||
Pre aktualizáciu aplikácie postupujte nasledovne:
|
||||
1. Stiahnite najnovšie zmeny z repozitára:
|
||||
```sh
|
||||
git pull
|
||||
```
|
||||
2. Zastavte bežiacu aplikáciu:
|
||||
```sh
|
||||
docker compose down
|
||||
```
|
||||
3. Znovu postavte kontajnery:
|
||||
```sh
|
||||
docker compose build
|
||||
```
|
||||
4. Spustite aplikáciu:
|
||||
```sh
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
## Záloha a obnova dát
|
||||
Dáta aplikácie sú uložené v databáze, ktorú je možné zálohovať a obnoviť pomocou štandardných nástrojov pre MariaDB/MySQL, ako je `mysqldump` a `mysql`, alebo pomcou archivácie dátového adresára databázy.
|
||||
|
||||
Príklad na zálohovanie databázy:
|
||||
```sh
|
||||
tar czvf db-backup.tar.gz mariadb-data/
|
||||
```
|
||||
|
||||
> ⚠️ Odporúčame použiť `tar` na archiváciu dátového adresára, aby ste zachovali správne oprávnenia.
|
||||
|
||||
## Zabezpečenie
|
||||
|
||||
## Cloudflare Tunnel
|
||||
Inštaláciu a základné nastavenie nájdete v [dokumentácii Cloudflare](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/). Je potrebné vytvoriť 2 tunely - jeden pre frontend a druhý pre backend.
|
||||
|
||||
Na spustenie tunela môžete vytvoriť samostatný Docker Compose súbor, napríklad:
|
||||
```yaml
|
||||
services:
|
||||
tunnel:
|
||||
image: cloudflare/cloudflared:2025.11.1
|
||||
container_name: cloudflared-tunnel
|
||||
restart: unless-stopped
|
||||
network_mode: "host"
|
||||
command: tunnel run
|
||||
environment:
|
||||
- TUNNEL_TOKEN=TOKEN-XYZ
|
||||
```
|
||||
|
||||
Následne nastavne DNS záznamy vo vašom Cloudflare účte, aby smerovali na tunely, napríklad:
|
||||
- `myapp.com` -> `localhost:80`
|
||||
- `backend.myapp.com` -> `localhost:8111`
|
||||
|
||||
## Caddy
|
||||
Inštaláciu a základné nastavenie nájdete v [dokumentácii Caddy](https://caddyserver.com/docs/).
|
||||
|
||||
Príklad konfigurácie:
|
||||
```
|
||||
backend.myapp.com {
|
||||
reverse_proxy localhost:8111
|
||||
}
|
||||
|
||||
myapp.com {
|
||||
reverse_proxy localhost:80
|
||||
}
|
||||
```
|
||||
83
docker/docker-compose.yml
Normal file
83
docker/docker-compose.yml
Normal file
@@ -0,0 +1,83 @@
|
||||
services:
|
||||
isop-frontend:
|
||||
container_name: isop-frontend
|
||||
build:
|
||||
context: ../frontend
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NUXT_PUBLIC_SANCTUM_BASE_URL: ${BACKEND_URL:-https://backend.example.com}
|
||||
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
|
||||
build:
|
||||
context: ../backend
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
APP_NAME: ISOP
|
||||
APP_ENV: production
|
||||
APP_KEY: ${APP_KEY:-SOME-KEY}
|
||||
APP_DEBUG: false
|
||||
APP_URL: ${BACKEND_URL:-https://example.com}
|
||||
FRONTEND_URL: ${FRONTEND_URL:-https://example.com}
|
||||
SANCTUM_STATEFUL_DOMAINS: ${BACKEND_DOMAIN:-https://backend.example.com},${FRONTEND_DOMAIN:-https://example.com}
|
||||
SESSION_DOMAIN: ${SESSION_DOMAIN:-.example.com} # Note the first dot
|
||||
|
||||
APP_LOCALE: sk
|
||||
APP_FALLBACK_LOCALE: en_US
|
||||
|
||||
MAIL_MAILER: smtp
|
||||
MAIL_HOST: smtp.example.com
|
||||
MAIL_PORT: 2525
|
||||
MAIL_USERNAME: username
|
||||
MAIL_PASSWORD: password
|
||||
MAIL_FROM_ADDRESS: "noreply@example.com"
|
||||
MAIL_FROM_NAME: "ISOP"
|
||||
|
||||
DB_CONNECTION: mariadb
|
||||
DB_HOST: isop-database
|
||||
DB_PORT: 3306
|
||||
DB_DATABASE: isop
|
||||
DB_USERNAME: root
|
||||
DB_PASSWORD: admin
|
||||
ports:
|
||||
- 8111:80
|
||||
depends_on:
|
||||
isop-database:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/api"]
|
||||
start_period: 10s
|
||||
interval: 1m
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
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 {
|
||||
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) {
|
||||
if (e instanceof FetchError) {
|
||||
alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`);
|
||||
|
||||
@@ -9,12 +9,12 @@ const client = useSanctumClient();
|
||||
|
||||
async function downloadAgreement() {
|
||||
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() {
|
||||
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>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { Internship } from '~/types/internships';
|
||||
import type { Internship, InternshipFilter } from '~/types/internships';
|
||||
import type { Paginated } from '~/types/pagination';
|
||||
import { prettyInternshipStatus } from '~/types/internship_status';
|
||||
import { FetchError } from 'ofetch';
|
||||
@@ -7,8 +7,12 @@ import { FetchError } from 'ofetch';
|
||||
const props = defineProps<{
|
||||
mode: 'admin' | 'company' | 'student';
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
filterApplied: [value: InternshipFilter],
|
||||
itemsAvailable: [value: boolean]
|
||||
}>();
|
||||
|
||||
const filters = ref({
|
||||
const filters = ref<InternshipFilter>({
|
||||
year: null,
|
||||
company: null,
|
||||
study_programe: null,
|
||||
@@ -21,6 +25,11 @@ const totalItems = ref(0);
|
||||
const deleteConfirmDialog = ref(false);
|
||||
const internshipToDelete = ref<Internship | null>(null);
|
||||
|
||||
const rules = {
|
||||
minFilterLen: (v: string) => (v.length >= 3) || 'Min. 3 znaky',
|
||||
minYear: (v: number | null) => (v === null ? true : v >= 1000) || 'Min. 4-ciferné číslo'
|
||||
};
|
||||
|
||||
const allHeaders = [
|
||||
{ title: "Študent", key: "student.name", sortable: false },
|
||||
{ title: "Firma", key: "company.name", sortable: false },
|
||||
@@ -50,10 +59,12 @@ const { data, error, pending, refresh } = await useLazySanctumFetch<Paginated<In
|
||||
|
||||
watch(data, (newData) => {
|
||||
totalItems.value = newData?.total ?? 0;
|
||||
emit('itemsAvailable', totalItems.value > 0);
|
||||
});
|
||||
|
||||
watch(filters, async () => {
|
||||
page.value = 1;
|
||||
emit('filterApplied', filters.value);
|
||||
}, { deep: true });
|
||||
|
||||
async function delteInternship(internship: Internship) {
|
||||
@@ -93,16 +104,20 @@ async function confirmDeletion(confirm: boolean) {
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12" md="3">
|
||||
<v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact" />
|
||||
<v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact"
|
||||
:rules="[rules.minYear]" />
|
||||
</v-col>
|
||||
<v-col cols="12" md="3" v-if="mode !== 'company'">
|
||||
<v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact" />
|
||||
<v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact"
|
||||
:rules="[rules.minFilterLen]" />
|
||||
</v-col>
|
||||
<v-col cols="12" md="3" v-if="mode !== 'student'">
|
||||
<v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact" />
|
||||
<v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact"
|
||||
:rules="[rules.minFilterLen]" />
|
||||
</v-col>
|
||||
<v-col cols="12" md="3" v-if="mode !== 'student'">
|
||||
<v-text-field v-model="filters.student" label="Študent" clearable density="compact" />
|
||||
<v-text-field v-model="filters.student" label="Študent" clearable density="compact"
|
||||
:rules="[rules.minFilterLen]" />
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
@@ -121,13 +136,13 @@ async function confirmDeletion(confirm: boolean) {
|
||||
<v-tooltip text="Editovať">
|
||||
<template #activator="{ props }">
|
||||
<v-btn icon="mdi-pencil" size="small" variant="text"
|
||||
:to="`/dashboard/${mode}/internships/edit/${item.id}`" />
|
||||
:to="`/dashboard/${mode}/internships/edit/${item.id}`" class="internship-edit-btn" />
|
||||
</template>
|
||||
</v-tooltip>
|
||||
<v-tooltip text="Vymazať" v-if="mode === 'admin'">
|
||||
<template #activator="{ props }">
|
||||
<v-btn icon="mdi-delete" size="small" variant="text" color="error"
|
||||
@click="() => openDeleteDialog(item)" />
|
||||
@click="() => openDeleteDialog(item)" class="internship-delete-btn" />
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</template>
|
||||
@@ -137,7 +152,7 @@ async function confirmDeletion(confirm: boolean) {
|
||||
<v-dialog v-model="deleteConfirmDialog" max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title class="text-h5">
|
||||
Nový API kľúč
|
||||
Potvrdiť vymazanie praxe
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { InternshipFilter } from '~/types/internships';
|
||||
import { FetchError } from 'ofetch';
|
||||
|
||||
definePageMeta({
|
||||
middleware: ['sanctum:auth', 'admin-only'],
|
||||
});
|
||||
@@ -20,6 +23,30 @@ const headers = [
|
||||
{ title: 'Stav', key: 'status', 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>
|
||||
|
||||
<template>
|
||||
@@ -30,7 +57,16 @@ const headers = [
|
||||
<!-- spacer -->
|
||||
<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-container>
|
||||
</template>
|
||||
|
||||
@@ -19,7 +19,8 @@ useSeoMeta({
|
||||
const rules = {
|
||||
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
|
||||
email: (v: string) => /.+@.+\..+/.test(v) || 'Zadajte platný email',
|
||||
phone: (v: string) => (!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo',
|
||||
phone: (v: string) =>
|
||||
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
|
||||
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
|
||||
};
|
||||
|
||||
@@ -101,8 +102,8 @@ async function handleRegistration() {
|
||||
density="comfortable" />
|
||||
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
|
||||
variant="outlined" density="comfortable" />
|
||||
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón:" variant="outlined"
|
||||
density="comfortable" />
|
||||
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón (s predvoľbou):"
|
||||
variant="outlined" density="comfortable" />
|
||||
|
||||
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
|
||||
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />
|
||||
|
||||
@@ -23,11 +23,14 @@ const rules = {
|
||||
personal_email: (v: string) =>
|
||||
/.+@.+\..+/.test(v) || 'Zadajte platný osobný email',
|
||||
phone: (v: string) =>
|
||||
(!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo',
|
||||
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
|
||||
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
|
||||
};
|
||||
const programs = [
|
||||
'Aplikovaná informatika',
|
||||
{ title: 'Aplikovaná informatika, Bc. (AI22b)', value: 'AI22b' },
|
||||
{ title: 'Aplikovaná informatika, Bc. (AI15b)', value: 'AI15b' },
|
||||
{ title: 'Aplikovaná informatika, Mgr. (AI22m)', value: 'AI22m' },
|
||||
{ title: 'Aplikovaná informatika, Mgr. (AI15m)', value: 'AI15m' },
|
||||
];
|
||||
|
||||
const isValid = ref(false);
|
||||
@@ -38,10 +41,11 @@ const form = ref({
|
||||
studentEmail: '',
|
||||
personalEmail: '',
|
||||
phone: '',
|
||||
studyProgram: programs[0] as string,
|
||||
studyProgram: programs[0]!.value,
|
||||
year_of_study: 1,
|
||||
consent: false,
|
||||
});
|
||||
const maxYearOfStudy = ref(0);
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref(null as null | string);
|
||||
@@ -80,6 +84,10 @@ async function handleRegistration() {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(form, (newForm) => {
|
||||
maxYearOfStudy.value = newForm.studyProgram.slice(-1) === 'b' ? 3 : 2;
|
||||
}, { deep: true, immediate: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -109,14 +117,14 @@ async function handleRegistration() {
|
||||
<v-text-field v-model="form.personalEmail" :rules="[rules.required, rules.personal_email]"
|
||||
label="Alternatívny email:" variant="outlined" density="comfortable" />
|
||||
|
||||
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]" label="Telefón:"
|
||||
variant="outlined" density="comfortable" />
|
||||
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]"
|
||||
label="Telefón (s predvoľbou):" variant="outlined" density="comfortable" />
|
||||
|
||||
<v-select v-model="form.studyProgram" :items="programs" :rules="[rules.required]"
|
||||
label="Študijný odbor:" variant="outlined" density="comfortable" />
|
||||
|
||||
<v-number-input control-variant="split" v-model="form.year_of_study" :rules="[rules.required]"
|
||||
label="Ročník:" :min="1" :max="5"></v-number-input>
|
||||
label="Ročník:" :min="1" :max="maxYearOfStudy"></v-number-input>
|
||||
|
||||
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
|
||||
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />
|
||||
|
||||
@@ -27,6 +27,13 @@ export interface NewInternship {
|
||||
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 {
|
||||
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 link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `${file_name}.pdf`;
|
||||
link.download = `${file_name}.${ext}`;
|
||||
link.target = "_blank";
|
||||
link.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
@@ -12,6 +12,7 @@ describe('Admin Student Document Downloads', () => {
|
||||
|
||||
cy.contains("Praxe").click()
|
||||
cy.url().should('include', '/dashboard/admin/internships')
|
||||
cy.wait(2000)
|
||||
})
|
||||
|
||||
it('should be able to generate and download the default proof', () => {
|
||||
@@ -24,13 +25,12 @@ describe('Admin Student Document Downloads', () => {
|
||||
})
|
||||
|
||||
cy.get('@randomRow').within(() => {
|
||||
cy.get('td').contains('Editovať').click()
|
||||
cy.get('td').get('.internship-edit-btn').click()
|
||||
})
|
||||
})
|
||||
|
||||
cy.url().should('include', '/dashboard/admin/internships/edit/')
|
||||
|
||||
const downloadsFolder = Cypress.config("downloadsFolder");
|
||||
cy.contains('Stiahnuť originálnu zmluvu').click()
|
||||
cy.wait(2000)
|
||||
})
|
||||
|
||||
@@ -12,6 +12,7 @@ describe('Admin Internship CRUD', () => {
|
||||
|
||||
cy.contains("Praxe").click()
|
||||
cy.url().should('include', '/dashboard/admin/internships')
|
||||
cy.wait(2000)
|
||||
})
|
||||
|
||||
it('should load the list of internships in a proper format', () => {
|
||||
@@ -64,28 +65,15 @@ describe('Admin Internship CRUD', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// Ešte nie je implementované mazanie
|
||||
/*it('should be able to delete an internship', () => {
|
||||
let initialRowCount = 0
|
||||
|
||||
cy.get('table tbody tr').its('length').then((count) => {
|
||||
initialRowCount = count
|
||||
})
|
||||
|
||||
it('should be able to delete an internship', () => {
|
||||
cy.get('table tbody tr').first().within(() => {
|
||||
cy.contains('Vymazať').click()
|
||||
cy.get('.internship-delete-btn').click()
|
||||
})
|
||||
|
||||
cy.contains("Potvrdiť vymazanie").parent().should('be.visible')
|
||||
cy.contains("Potvrdiť vymazanie").parent().contains("Vymazať").click()
|
||||
cy.contains("Potvrdiť vymazanie").parent().contains("Áno").click()
|
||||
cy.contains("Potvrdiť vymazanie").should('not.exist')
|
||||
|
||||
cy.wait(1000)
|
||||
|
||||
cy.get('table tbody tr').its('length').then((count) => {
|
||||
expect(count).to.be.eq(initialRowCount - 1)
|
||||
})
|
||||
})*/
|
||||
|
||||
// TODO: Edit praxe
|
||||
})
|
||||
})
|
||||
@@ -22,8 +22,6 @@ export default defineNuxtConfig({
|
||||
},
|
||||
|
||||
sanctum: {
|
||||
baseUrl: 'http://localhost:8000',
|
||||
origin: 'http://localhost:3000',
|
||||
redirect: {
|
||||
onLogin: '/dashboard',
|
||||
onLogout: "/",
|
||||
|
||||
Reference in New Issue
Block a user