diff --git a/assets/css/app.scss b/assets/css/app.scss index f955fad8f..b4a73bdb7 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -1,3 +1,4 @@ +$body-bg: #ff622b; // customize some Bootstrap variables $primary: darken(#428bca, 20%); diff --git a/assets/js/app.js b/assets/js/app.js index f0bafb1df..8a678918b 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -12,7 +12,7 @@ require('../css/app.scss'); const $ = require('jquery'); require('bootstrap'); -$(document).ready(function() { +$(document).ready(function () { $('[data-toggle="popover"]').popover(); }); @@ -26,4 +26,4 @@ if (typeof usingVersionedFileJs !== "undefined") { .catch(function (error) { versionedFileElement.innerText = 'Error: '.error; }); -} +} \ No newline at end of file diff --git a/assets/js/validation.js b/assets/js/validation.js index 1881c8a67..9bb870c7c 100644 --- a/assets/js/validation.js +++ b/assets/js/validation.js @@ -1,21 +1,51 @@ const axios = require('axios'); let name = document.getElementById('name'); -let validationResult = document.getElementById('validation-result'); + +let validationResultName = document.getElementById('validation-result-name'); + const validateName = function () { - validationResult.innerText = '...'; - axios.post(validationResult.dataset.path, {input: name.value}) - .then(function(response) { + validationResultName.innerText = '...'; + axios.post(validationResultName.dataset.path, {input: name.value}) + .then(function (response) { if (response.data.valid) { - validationResult.innerHTML = ":)"; + validationResultName.innerHTML = ":)"; } else { - validationResult.innerHTML = ":("; + validationResultName.innerHTML = ":("; } }) .catch(function (error) { - validationResult.innerText = 'Error: ' + error; + validationResultName.innerText = 'Error: ' + error; + }); +}; + + +let team = document.getElementById('team'); +let validateResultTeam = document.getElementById('validation-result-team'); +const validateTeam = function () { + validateResultTeam.innerText = '...'; + axios.post(validateResultTeam.dataset.path, { input: team.value}) + .then(function (response) { + if (response.data.valid) { + validateResultTeam.innerHTML = ":)"; + } else { + validateResultTeam.innerHTML = ":("; + } + }) + .catch(function (error) { + validateResultTeam.innerText = 'Error: ' + error; }); }; name.onkeyup = validateName; name.onchange = validateName; +team.onkeyup = validateTeam; +team.onchange = validateTeam; + + + + + + + + diff --git a/public/students.json b/public/students.json new file mode 100644 index 000000000..c06cff4d5 --- /dev/null +++ b/public/students.json @@ -0,0 +1,181 @@ +{ + "team1": { + "name": "Team1", + "mentors": [ + "Mantas" + ], + "students": [ + "Tadas", + "Gytis", + "Ričardas" + ] + }, + "baltichalatai": { + "name": "BaltiChalatai", + "mentors": [ + "Lukas" + ], + "students": [ + "Vytas", + "Lukas", + "Diana" + ] + }, + "nnizer": { + "name": "ePacientas", + "mentors": [ + "Tadas" + ], + "students": [ + "Kornelijus", + "Dominykas", + "Miglė" + ] + }, + "activegen": { + "name": "ActiveGen", + "mentors": [ + "Arnoldas" + ], + "students": [ + "Andrius", + "Nojus", + "Martynas", + "Edvinas" + ] + }, + "mms": { + "name": "Membership-management-system", + "mentors": [ + "Mindaugas" + ], + "students": [ + "Erika", + "Rokas", + "Valentinas", + "Eligijus" + ] + }, + "pamainos": { + "name": "NFQ pamainu sistema", + "mentors": [ + "Paulius" + ], + "students": [ + "Liudas", + "Justina", + "Andrius" + ] + }, + "receptai": { + "name": "Receptai", + "mentors": [ + "Mantas" + ], + "students": [ + "Arnoldas", + "Arentas", + "Tautvydas" + ] + }, + "pulse": { + "name": "NFQ pulse", + "mentors": [ + "Lorenas" + ], + "students": [ + "Arvydas", + "Titas", + "Kristijonas", + "Andrius" + ] + }, + "lita": { + "name": "NFQ Petro atrankos problema akademijai", + "mentors": [ + "Paulius" + ], + "students": [ + "Kristina", + "Indrė", + "Dmitri" + ] + }, + "myfleet": { + "name": "MyFleet", + "mentors": [ + "Laurynas" + ], + "students": [ + "Artūras", + "Ignas", + "Jonas" + ] + }, + "career": { + "name": "NFQ Career Criteria Assessment", + "mentors": [ + "Erikas" + ], + "students": [ + "Matas", + "Andrius", + "Ainis" + ] + }, + "carparking": { + "name": "NFQ Car parking", + "mentors": [ + "Andrejus" + ], + "students": [ + "Kęstas", + "Lukas", + "Lukas" + ] + }, + "podcast": { + "name": "Krepšinio podcastai", + "mentors": [ + "Eligijus" + ], + "students": [ + "Edvardas", + "Nerijus", + "Kazimieras" + ] + }, + "Barakas": { + "name": "barakas", + "mentors": [ + "Armandas" + ], + "students": [ + "Raimondas", + "Mantas", + "Tomas" + ] + }, + "devcollab": { + "name": "Education sharing platform", + "mentors": [ + "Viktoras" + ], + "students": [ + "Karolis", + "Arnas", + "Evaldas", + "Algirdas" + ] + }, + "hacker'is po .mySubdomain &project=123": { + "name": "' OR 1 -- DROP DATABASE", + "mentors": [ + "Ponas Programišius" + ], + "students": [ + "Aurelijus", + "Ir jo \"geras\" draug'as" + ] + } +} \ No newline at end of file diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 90484f11f..3ae4b419e 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -3,17 +3,35 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Annotation\Route; class HomeController extends AbstractController { /** * @Route("/", name="home") + * @param KernelInterface $kernel + * @return \Symfony\Component\HttpFoundation\Response */ - public function index() + public function index(KernelInterface $kernel) { + $projects = json_decode(file_get_contents($kernel->getProjectDir() . '/public/students.json'), true); + + $students = $this->groupByStudents($projects); return $this->render('home/index.html.twig', [ - 'someVariable' => 'NFQ Akademija', + 'someVariable' => $students, + 'projects' => $projects ]); } + + private function groupByStudents(array $projects) + { + $result = []; + foreach ($projects as $projectName => $project) { + foreach ($project['students'] as $student) { + $result[] = ['student' => $student, 'project' => $projectName, 'mentor' => $project['mentors'][0]]; + } + } + return $result; + } } diff --git a/src/Controller/PeopleController.php b/src/Controller/PeopleController.php index bb86b5f8e..8d78ca20c 100644 --- a/src/Controller/PeopleController.php +++ b/src/Controller/PeopleController.php @@ -4,8 +4,8 @@ use Exception; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -27,6 +27,9 @@ public function index() * name="validatePerson", * methods={"POST"} * ) + * @param Request $request + * @param string $element + * @return JsonResponse */ public function validate(Request $request, string $element) { @@ -37,18 +40,20 @@ public function validate(Request $request, string $element) } $students = $this->getStudents(); + $teams = $this->getTeams(); switch ($element) { case 'name': return new JsonResponse(['valid' => in_array(strtolower($input), $students)]); + case 'team': + return new JsonResponse(['valid' => in_array(strtolower($input), $teams)]); } return new JsonResponse(['error' => 'Invalid arguments'], Response::HTTP_BAD_REQUEST); } - private function getStorage() { return /** @lang json */ - '{ + '{ "team1": { "name": "Team1", "mentors": [ @@ -230,7 +235,6 @@ private function getStorage() } }'; } - private function getStudents(): array { $students = []; @@ -242,4 +246,14 @@ private function getStudents(): array } return $students; } + private function getTeams(): array + { + $teams = []; + $storage = json_decode($this->getStorage(), true); + $storage = array_keys($storage); + foreach ($storage as $teamData) { + $teams[] = strtolower($teamData); + } + return $teams; + } } diff --git a/src/Controller/StudentController.php b/src/Controller/StudentController.php new file mode 100644 index 000000000..148dd4f93 --- /dev/null +++ b/src/Controller/StudentController.php @@ -0,0 +1,27 @@ +get('name'); + $project = $request->get('project'); + + return $this->render('student/index.html.twig', [ + 'name' => $name, + 'project' => $project, + ]); + } +} diff --git a/templates/base.html.twig b/templates/base.html.twig index cfd34354b..5d6a6dc54 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -10,18 +10,18 @@ {% endblock %}
- + {% block body %}{% endblock %} {% block javascripts %} {{ encore_entry_script_tags('app') }} diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig index b1bd0115c..1be8b4aca 100644 --- a/templates/home/index.html.twig +++ b/templates/home/index.html.twig @@ -1,7 +1,59 @@ {% extends 'base.html.twig' %} -{% block title %}{{ someVariable }}{% endblock %} +{% block title %}Student{% endblock %} + + {% block body %} +ssh {{ nameUrl|escape }}@deploy.nfqakademija.lt -p 2222
+ | Projektas | +Studentas | +
|---|---|
| {{ project|escape }} | +{{ name|escape }} | +