From 90c20fd76c5155746ad4cdbf2c1b587725ed6763 Mon Sep 17 00:00:00 2001 From: mathias Date: Tue, 19 Dec 2023 00:10:31 +0100 Subject: [PATCH 1/5] update lang display --- frontend-vue/src/components/HintsDisplay.vue | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/frontend-vue/src/components/HintsDisplay.vue b/frontend-vue/src/components/HintsDisplay.vue index d0756a3..7817d63 100644 --- a/frontend-vue/src/components/HintsDisplay.vue +++ b/frontend-vue/src/components/HintsDisplay.vue @@ -18,23 +18,24 @@ @@ -57,6 +58,15 @@ export default { DirectionalArrow, }, methods: { + formatLanguages(langues) { + if (Array.isArray(langues) && langues.length > 0) { + const languageNames = langues.map(langue => langue.name); + + return languageNames.join('/'); + } + + return ''; + } }, computed: { guesses() { @@ -79,14 +89,14 @@ export default { display: flex; } -.hint > div { +.hint>div { flex: 1; border: 1px solid black; padding: 10px 5px; margin: 10px 5px; } -.hint-titles > div { +.hint-titles>div { flex: 1; padding: 10px 5px; } @@ -101,7 +111,7 @@ export default { background-color: #FD9696; } -.hint.good-guess > div { +.hint.good-guess>div { background-color: #83D881; } @@ -110,7 +120,8 @@ export default { margin: 0; } -.distance, .population { +.distance, +.population { display: flex; justify-content: center; } @@ -131,7 +142,7 @@ export default { background-color: #FAE46E; } -.hint-grey{ +.hint-grey { background-color: #D9D9D9; } \ No newline at end of file From d2a7e9b930db79360cefbda47bb2dd2f108aad1f Mon Sep 17 00:00:00 2001 From: Thombrix Date: Tue, 19 Dec 2023 00:49:46 +0100 Subject: [PATCH 2/5] finally generate swagger doc --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e8cc55d..9024ee6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,4 +26,4 @@ jobs: chmod 600 ~/.ssh/pkey eval "$(ssh-agent -s)" ssh-add ~/.ssh/pkey - ssh ${{ secrets.SECRET_USER }}@${{ secrets.SECRET_HOST }} -p ${{ secrets.SECRET_PORT }} "cd ./project/Swissdle && git pull origin main && cd backend-laravel && php artisan db:wipe --force && php artisan migrate --force && php artisan db:seed --force && composer install && php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" && cd ../frontend-vue && npm install && npm run build && (crontab -l && crontab -r) || echo '* * * * * cd /home/laravel/project/Swissdle/backend-laravel && /usr/local/bin/php artisan schedule:run >> /home/laravel/project/Swissdle/cron.log' | crontab" \ No newline at end of file + ssh ${{ secrets.SECRET_USER }}@${{ secrets.SECRET_HOST }} -p ${{ secrets.SECRET_PORT }} "cd ./project/Swissdle && git pull origin main && cd backend-laravel && php artisan db:wipe --force && php artisan migrate --force && php artisan db:seed --force && composer install && php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" && php artisan l5-swagger:generate && cd ../frontend-vue && npm install && npm run build && (crontab -l && crontab -r) || echo '* * * * * cd /home/laravel/project/Swissdle/backend-laravel && /usr/local/bin/php artisan schedule:run >> /home/laravel/project/Swissdle/cron.log' | crontab" \ No newline at end of file From 711080507b4f81d2550f988cd0d21eea7227254d Mon Sep 17 00:00:00 2001 From: Thombrix Date: Tue, 19 Dec 2023 00:53:36 +0100 Subject: [PATCH 3/5] changes city every 5 minutes --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9024ee6..581bb49 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,4 +26,4 @@ jobs: chmod 600 ~/.ssh/pkey eval "$(ssh-agent -s)" ssh-add ~/.ssh/pkey - ssh ${{ secrets.SECRET_USER }}@${{ secrets.SECRET_HOST }} -p ${{ secrets.SECRET_PORT }} "cd ./project/Swissdle && git pull origin main && cd backend-laravel && php artisan db:wipe --force && php artisan migrate --force && php artisan db:seed --force && composer install && php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" && php artisan l5-swagger:generate && cd ../frontend-vue && npm install && npm run build && (crontab -l && crontab -r) || echo '* * * * * cd /home/laravel/project/Swissdle/backend-laravel && /usr/local/bin/php artisan schedule:run >> /home/laravel/project/Swissdle/cron.log' | crontab" \ No newline at end of file + ssh ${{ secrets.SECRET_USER }}@${{ secrets.SECRET_HOST }} -p ${{ secrets.SECRET_PORT }} "cd ./project/Swissdle && git pull origin main && cd backend-laravel && php artisan db:wipe --force && php artisan migrate --force && php artisan db:seed --force && composer install && php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider" && php artisan l5-swagger:generate && cd ../frontend-vue && npm install && npm run build && (crontab -l && crontab -r) || echo '*/5 * * * * cd /home/laravel/project/Swissdle/backend-laravel && /usr/local/bin/php artisan schedule:run >> /home/laravel/project/Swissdle/cron.log' | crontab" \ No newline at end of file From 6c4447353e26a2e039986a6912ed46eef75a6e46 Mon Sep 17 00:00:00 2001 From: "loic.santschi" Date: Tue, 19 Dec 2023 01:11:24 +0100 Subject: [PATCH 4/5] updated the swagger doc --- .../app/Http/Controllers/VilleController.php | 64 ++++++++++++++ .../storage/api-docs/api-docs.json | 85 +++++++++++++++++++ 2 files changed, 149 insertions(+) diff --git a/backend-laravel/app/Http/Controllers/VilleController.php b/backend-laravel/app/Http/Controllers/VilleController.php index 254768c..14032b8 100644 --- a/backend-laravel/app/Http/Controllers/VilleController.php +++ b/backend-laravel/app/Http/Controllers/VilleController.php @@ -44,6 +44,44 @@ public function today() return $ville; } + /** + * Make a guess + * + * @OA\Get( + * path="/api/ville/guess/{id}", + * summary="Get a guess for a city based on the provided ID.", + * description="Retrieve information about the guessed city.", + * operationId="getGuess", + * tags={"Ville"}, + * @OA\Parameter( + * name="id", + * in="path", + * required=true, + * description="The ID of the guessed city.", + * @OA\Schema(type="integer") + * ), + * + * @OA\Response( + * response=200, + * description="Successful response", + * @OA\JsonContent( + * type="object", + * @OA\Property(property="ville", ref="#/components/schemas/Ville"), + * @OA\Property(property="canton_diff", type="boolean", description="Whether the guessed city's canton matches the current city's canton"), + * @OA\Property(property="pop_diff", type="integer", description="Population comparison result"), + * @OA\Property(property="lang_diff", type="string", description="Language comparison result"), + * @OA\Property(property="position_diff", type="string", description="Position comparison result"), + * ) + * ), + * + * @OA\Response( + * response=404, + * description="Ville not found" + * ) + * ) + * + * @return App\Utility\CityComparator::compareToToday + */ public function guess($id) { // TODO: clean id @@ -51,6 +89,32 @@ public function guess($id) return $a->compareToToday($id); } + /** + * Get all Villes. + * + * @OA\Get( + * path="/api/villes", + * summary="Get all cities", + * description="Retrieve information about all cities.", + * operationId="getAll", + * tags={"Ville"}, + * @OA\Response( + * response=200, + * description="Successful response", + * @OA\JsonContent( + * type="array", + * @OA\Items(ref="#/components/schemas/Ville") + * ) + * ), + * + * @OA\Response( + * response=404, + * description="Ville not found" + * ) + * ) + * + * @return \Illuminate\Http\JsonResponse + */ public function all() { $villes = Ville::all(); diff --git a/backend-laravel/storage/api-docs/api-docs.json b/backend-laravel/storage/api-docs/api-docs.json index 34db0b1..dbbf9d4 100644 --- a/backend-laravel/storage/api-docs/api-docs.json +++ b/backend-laravel/storage/api-docs/api-docs.json @@ -33,6 +33,91 @@ } } } + }, + "/api/ville/guess/{id}": { + "get": { + "tags": [ + "Ville" + ], + "summary": "Get a guess for a city based on the provided ID.", + "description": "Retrieve information about the guessed city.", + "operationId": "getGuess", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The ID of the guessed city.", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "properties": { + "ville": { + "$ref": "#/components/schemas/Ville" + }, + "canton_diff": { + "description": "Whether the guessed city's canton matches the current city's canton", + "type": "boolean" + }, + "pop_diff": { + "description": "Population comparison result", + "type": "integer" + }, + "lang_diff": { + "description": "Language comparison result", + "type": "string" + }, + "position_diff": { + "description": "Position comparison result", + "type": "string" + } + }, + "type": "object" + } + } + } + }, + "404": { + "description": "Ville not found" + } + } + } + }, + "/api/villes": { + "get": { + "tags": [ + "Ville" + ], + "summary": "Get all cities", + "description": "Retrieve information about all cities.", + "operationId": "getAll", + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Ville" + } + } + } + } + }, + "404": { + "description": "Ville not found" + } + } + } } }, "components": { From 9886323368f6d8cd3b2522fc41206275100ebcae Mon Sep 17 00:00:00 2001 From: mathias Date: Tue, 19 Dec 2023 01:19:44 +0100 Subject: [PATCH 5/5] changed img size + hints final display --- frontend-vue/src/components/DailyCity.vue | 4 ++-- frontend-vue/src/components/HintsDisplay.vue | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend-vue/src/components/DailyCity.vue b/frontend-vue/src/components/DailyCity.vue index c332aad..681a60c 100644 --- a/frontend-vue/src/components/DailyCity.vue +++ b/frontend-vue/src/components/DailyCity.vue @@ -18,8 +18,8 @@ export default {