Compare commits
11 Commits
9bd45bb5e8
...
af9d8a9eff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af9d8a9eff | ||
|
|
549b09f4e1 | ||
|
|
a0edc63e10 | ||
|
|
c253961c2f | ||
|
|
86a81d367e | ||
|
|
b5afb216de | ||
|
|
54e851fbb9 | ||
|
|
243622af7f | ||
|
|
107aea309f | ||
|
|
fdd99dda83 | ||
|
|
61789b2723 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,3 +18,4 @@ package-lock.json
|
||||
.idea/
|
||||
config/web-tinker.php
|
||||
public/vendor/web-tinker
|
||||
public/js/app.js.LICENSE.txt
|
||||
|
||||
125
.gitlab-ci.yml
125
.gitlab-ci.yml
@@ -1,72 +1,63 @@
|
||||
# Official framework image. Look for the different tagged releases at:
|
||||
# https://hub.docker.com/r/library/php
|
||||
image: php:latest
|
||||
image: lorisleiva/laravel-docker:latest
|
||||
|
||||
# Pick zero or more services to be used on all builds.
|
||||
# Only needed when using a docker container to run your tests in.
|
||||
# Check out: http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
|
||||
services:
|
||||
- mysql:latest
|
||||
# https://lorisleiva.com/laravel-deployment-using-gitlab-pipelines/
|
||||
|
||||
variables:
|
||||
MYSQL_DATABASE: project_name
|
||||
MYSQL_ROOT_PASSWORD: secret
|
||||
# Replace the last line with the following lines if you'd rather
|
||||
# leave StrictHostKeyChecking enabled (replace yourdomain.com):
|
||||
#
|
||||
# ssh-keyscan yourdomain.com >> ~/.ssh/known_hosts
|
||||
# chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
# This folder is cached between builds
|
||||
# http://docs.gitlab.com/ee/ci/yaml/README.html#cache
|
||||
cache:
|
||||
paths:
|
||||
- vendor/
|
||||
- node_modules/
|
||||
.change_file_permissions: &change_file_permissions |
|
||||
find . -type f -not -path "./vendor/*" -exec chmod 664 {} \;
|
||||
find . -type d -not -path "./vendor/*" -exec chmod 775 {} \;
|
||||
|
||||
# This is a basic example for a gem or script which doesn't use
|
||||
# services such as redis or postgres
|
||||
before_script:
|
||||
# Update packages
|
||||
- apt-get update -yqq
|
||||
# Prep for Node
|
||||
- apt-get install gnupg -yqq
|
||||
# Upgrade to Node 8
|
||||
- curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
||||
# Install dependencies
|
||||
- apt-get install git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
|
||||
# Install php extensions
|
||||
- docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache
|
||||
# Install & enable Xdebug for code coverage reports
|
||||
- pecl install xdebug
|
||||
- docker-php-ext-enable xdebug
|
||||
# Install Composer and project dependencies.
|
||||
- curl -sS https://getcomposer.org/installer | php
|
||||
- php composer.phar install
|
||||
# Install Node dependencies.
|
||||
# comment this out if you don't have a node dependency
|
||||
- npm install
|
||||
# Copy over testing configuration.
|
||||
# Don't forget to set the database config in .env.testing correctly
|
||||
# DB_HOST=mysql
|
||||
# DB_DATABASE=project_name
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=secret
|
||||
- cp .env.testing .env
|
||||
# Run npm build
|
||||
# comment this out if you don't have a frontend build
|
||||
# you can change this to to your frontend building script like
|
||||
# npm run build
|
||||
- npm run dev
|
||||
# Generate an application key. Re-cache.
|
||||
- php artisan key:generate
|
||||
- php artisan config:cache
|
||||
# Run database migrations.
|
||||
- php artisan migrate
|
||||
# Run database seed
|
||||
- php artisan db:seed
|
||||
|
||||
test:
|
||||
composer:
|
||||
stage: build
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}-composer
|
||||
paths:
|
||||
- vendor/
|
||||
script:
|
||||
# run laravel tests
|
||||
- php vendor/bin/phpunit --coverage-text --colors=never
|
||||
# run frontend tests
|
||||
# if you have any task for testing frontend
|
||||
# set it in your package.json script
|
||||
# comment this out if you don't have a frontend test
|
||||
- npm test
|
||||
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
artifacts:
|
||||
expire_in: 1 month
|
||||
paths:
|
||||
- vendor/
|
||||
- .env
|
||||
|
||||
npm:
|
||||
stage: build
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}-npm
|
||||
paths:
|
||||
- node_modules/
|
||||
script:
|
||||
- npm install
|
||||
- npm run production
|
||||
artifacts:
|
||||
expire_in: 1 month
|
||||
paths:
|
||||
- node_modules/
|
||||
- public/css/
|
||||
- public/js/
|
||||
|
||||
|
||||
codestyle:
|
||||
stage: test
|
||||
dependencies: []
|
||||
script:
|
||||
- phpcs --standard=PSR2 --extensions=php --ignore=app/Support/helpers.php app
|
||||
|
||||
phpunit:
|
||||
stage: test
|
||||
dependencies:
|
||||
- composer
|
||||
script:
|
||||
- phpunit --coverage-text --colors=never
|
||||
artifacts:
|
||||
paths:
|
||||
- storage/
|
||||
|
||||
|
||||
3
.idea/php.xml
generated
3
.idea/php.xml
generated
@@ -149,9 +149,10 @@
|
||||
<path value="$PROJECT_DIR$/vendor/spatie/temporary-directory" />
|
||||
<path value="$PROJECT_DIR$/vendor/spatie/db-dumper" />
|
||||
<path value="$PROJECT_DIR$/vendor/paragonie/constant_time_encoding" />
|
||||
<path value="$PROJECT_DIR$/vendor/talvbansal/laravel-gitlab-ci-config-generator" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.4" />
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />
|
||||
<component name="PhpUnit">
|
||||
<phpunit_settings>
|
||||
<PhpUnitSettings configuration_file_path="$PROJECT_DIR$/phpunit.xml" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
|
||||
|
||||
1
.idea/portal.iml
generated
1
.idea/portal.iml
generated
@@ -148,6 +148,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/spatie/temporary-directory" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/spatie/db-dumper" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/constant_time_encoding" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/talvbansal/laravel-gitlab-ci-config-generator" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
||||
@@ -55,12 +55,12 @@
|
||||
cd {{ $config->prod_path }}
|
||||
php artisan down
|
||||
php artisan backup:run
|
||||
rsync -avz storage/app/Portal/ raspiwork:/media/pi/RaspiWorkData/Sav/Portal
|
||||
rsync -avz storage/app/Portal/ /home/pi/Sav/Portal
|
||||
git reset --hard HEAD
|
||||
git pull origin {{ $config->prod_branch }}
|
||||
php composer.phar install --no-dev
|
||||
npm install --only=dependencies
|
||||
npm run production --only=dependencies
|
||||
composer install --no-dev
|
||||
npm install
|
||||
npm run production
|
||||
php artisan migrate --force
|
||||
php artisan optimize
|
||||
php artisan up
|
||||
|
||||
@@ -7,6 +7,8 @@ use App\Models\Event;
|
||||
use App\Http\Resources\Event as EventResource;
|
||||
use App\Models\EventGuestsNonUsers;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EventController extends Controller
|
||||
@@ -14,91 +16,82 @@ class EventController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response|object
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$events = Event::all();
|
||||
|
||||
return (EventResource::collection($events))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(EventResource::collection($events));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param EventRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function store(EventRequest $request)
|
||||
public function store(EventRequest $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
$event = $request->user()->events()->create($validated);
|
||||
$event->save();
|
||||
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(201);
|
||||
return response()->json(new EventResource($event), 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Event $event
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @param Event $event
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function show(Event $event)
|
||||
public function show(Event $event): JsonResponse
|
||||
{
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(new EventResource($event));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Event $event
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @param EventRequest $request
|
||||
* @param Event $event
|
||||
* @return JsonResponse
|
||||
* @throws AuthorizationException
|
||||
*/
|
||||
public function update(EventRequest $request, Event $event)
|
||||
public function update(EventRequest $request, Event $event): JsonResponse
|
||||
{
|
||||
$this->authorize('update', $event);
|
||||
|
||||
$event->update($request->all());
|
||||
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(new EventResource($event));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Event $event
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param Event $event
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function destroy(Event $event)
|
||||
public function destroy(Event $event): JsonResponse
|
||||
{
|
||||
$this->authorize('delete', $event);
|
||||
|
||||
$event->delete();
|
||||
|
||||
return response([], 204);
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
public function inviteUser(Event $event, User $user)
|
||||
public function inviteUser(Event $event, User $user): JsonResponse
|
||||
{
|
||||
|
||||
$this->authorize('update', $event);
|
||||
|
||||
$event->guests()->attach($user);
|
||||
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(new EventResource($event));
|
||||
}
|
||||
|
||||
public function removeInviteUser(Event $event, User $user)
|
||||
@@ -113,27 +106,23 @@ class EventController extends Controller
|
||||
->setStatusCode(204);
|
||||
}
|
||||
|
||||
public function addGuestToStaffEvent(Event $event, User $user)
|
||||
public function addGuestToStaffEvent(Event $event, User $user): JsonResponse
|
||||
{
|
||||
|
||||
$this->authorize('delete', $event);
|
||||
|
||||
$event->guests()->updateExistingPivot($user, ['is_staff' => true], false);
|
||||
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(new EventResource($event));
|
||||
}
|
||||
|
||||
public function deleteGuestToStaffEvent(Event $event, User $user)
|
||||
public function deleteGuestToStaffEvent(Event $event, User $user): JsonResponse
|
||||
{
|
||||
$this->authorize('delete', $event);
|
||||
|
||||
$event->guests()->updateExistingPivot($user, ['is_staff' => false], false);
|
||||
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(new EventResource($event));
|
||||
}
|
||||
|
||||
public function userConfirmParticipation(Event $event)
|
||||
@@ -156,38 +145,32 @@ class EventController extends Controller
|
||||
return response([], 204);
|
||||
}
|
||||
|
||||
public function addGuestWithEmail(Event $event)
|
||||
public function addGuestWithEmail(Request $request, Event $event)
|
||||
{
|
||||
$data = request()->validate([
|
||||
$data = $request->validate([
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
|
||||
$event->emailedGuests()->save(new EventGuestsNonUsers(['email' => $data['email']]));
|
||||
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(201);
|
||||
return response()->json(new EventResource($event), 201);
|
||||
}
|
||||
|
||||
public function guestCanReadEvent(Event $event)
|
||||
public function guestCanReadEvent(Request $request, Event $event)
|
||||
{
|
||||
$guest = request()->guest;
|
||||
$guest = $request->guest;
|
||||
|
||||
if (!$guest->read_at) {
|
||||
$guest->update(['read_at' => now()->toDateTimeString()]);
|
||||
}
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(new EventResource($event));
|
||||
}
|
||||
|
||||
public function guestCanConfirmEvent(Event $event)
|
||||
public function guestCanConfirmEvent(Request $request, Event $event)
|
||||
{
|
||||
$guest = request()->guest;
|
||||
$guest = $request->guest;
|
||||
$guest->update(['validated_at' => now()->toDateTimeString()]);
|
||||
|
||||
return (new EventResource($event))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
return response()->json(new EventResource($event));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EventGuestWithoutEmail extends JsonResource
|
||||
|
||||
@@ -13,7 +13,7 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function viewAny(User $user)
|
||||
@@ -24,8 +24,8 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\Event $event
|
||||
* @param User $user
|
||||
* @param Event $event
|
||||
* @return mixed
|
||||
*/
|
||||
public function view(User $user, Event $event)
|
||||
@@ -36,7 +36,7 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(User $user)
|
||||
@@ -47,8 +47,8 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\Event $event
|
||||
* @param User $user
|
||||
* @param Event $event
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(User $user, Event $event)
|
||||
@@ -58,9 +58,9 @@ class EventPolicy
|
||||
} else {
|
||||
$testedUser = $event->guests()->where('users.id', $user->id)->first();
|
||||
if ($testedUser !== null) {
|
||||
if($testedUser->pivot->is_staff) {
|
||||
if ($testedUser->pivot->is_staff) {
|
||||
return $testedUser->pivot->is_staff;
|
||||
} else if (!$event->private) {
|
||||
} elseif (!$event->private) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -71,8 +71,8 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\Event $event
|
||||
* @param User $user
|
||||
* @param Event $event
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(User $user, Event $event)
|
||||
@@ -83,8 +83,8 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\Event $event
|
||||
* @param User $user
|
||||
* @param Event $event
|
||||
* @return mixed
|
||||
*/
|
||||
public function restore(User $user, Event $event)
|
||||
@@ -95,8 +95,8 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\Event $event
|
||||
* @param User $user
|
||||
* @param Event $event
|
||||
* @return mixed
|
||||
*/
|
||||
public function forceDelete(User $user, Event $event)
|
||||
@@ -107,8 +107,8 @@ class EventPolicy
|
||||
/**
|
||||
* Determine whether the guest can permanently delete invitation.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\Event $event
|
||||
* @param User $user
|
||||
* @param Event $event
|
||||
* @return mixed
|
||||
*/
|
||||
public function participation(User $user, Event $event)
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.4.0",
|
||||
"php": "^7.3|^8.0",
|
||||
"fideloper/proxy": "^4.2",
|
||||
"fruitcake/laravel-cors": "^1.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"intervention/image": "^2.5",
|
||||
"laravel/framework": "^8.0",
|
||||
"laravel/framework": "^8.12",
|
||||
"laravel/legacy-factories": "^1.0",
|
||||
"laravel/passport": "^10.0",
|
||||
"laravel/slack-notification-channel": "^2.2",
|
||||
"laravel/tinker": "^2.0",
|
||||
"laravel/ui": "^2.0",
|
||||
"laravel/ui": "^3.2",
|
||||
"predis/predis": "^1.1",
|
||||
"sentry/sentry-laravel": "^2.0",
|
||||
"spatie/laravel-backup": "^6.15",
|
||||
@@ -32,7 +32,8 @@
|
||||
"mockery/mockery": "^1.3.1",
|
||||
"nunomaduro/collision": "^5.0",
|
||||
"phpunit/phpunit": "^8.5",
|
||||
"spatie/laravel-web-tinker": "^1.7"
|
||||
"spatie/laravel-web-tinker": "^1.7",
|
||||
"talvbansal/laravel-gitlab-ci-config-generator": "dev-master"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
|
||||
1668
composer.lock
generated
1668
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,12 @@
|
||||
/*!
|
||||
* Vue.js v2.6.12
|
||||
* (c) 2014-2020 Evan You
|
||||
* Vue.js v2.6.14
|
||||
* (c) 2014-2021 Evan You
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* vuex v3.6.0
|
||||
* (c) 2020 Evan You
|
||||
* vuex v3.6.2
|
||||
* (c) 2021 Evan You
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
|
||||
@@ -18,18 +18,15 @@ export default {
|
||||
return {
|
||||
links: [
|
||||
{ name: 'Gitea', link: 'https://git.rodev.fr/'},
|
||||
{ name: 'Home Assistant', link: 'http://192.168.1.27:8123/lovelace/default_view'},
|
||||
{ name: 'Météo', link: 'http://192.168.1.32/meteo/meteo'},
|
||||
{ name: 'MotionEye', link: 'http://192.168.1.32:8765'},
|
||||
{ name: 'MotionEye', link: 'http://192.168.3.19:8765'},
|
||||
{ name: 'TT-RSS', link: 'https://tt-rss.bricooli.fr'},
|
||||
{ name: 'Datus', link: 'https://192.168.1.24:5001'},
|
||||
{ name: 'Pi-Hole', link: 'http://192.168.1.27:8089/admin/index.php'},
|
||||
{ name: 'Grafana', link: 'http://192.168.1.27:3000'},
|
||||
{ name: 'Gladys', link: 'http://192.168.1.32/dashboard'},
|
||||
{ name: 'Kodi', link: 'http://192.168.1.19:8080/'},
|
||||
{ name: 'RaspiWork Adminer', link: 'http://192.168.1.27:9080/'},
|
||||
{ name: 'RaspiWeb Adminer', link: 'http://192.168.1.32/adminer.php'},
|
||||
{ name: 'RaspiGate Adminer', link: 'http://192.168.1.29/adminer.php'},
|
||||
{ name: 'Datus', link: 'https://192.168.3.24:5001'},
|
||||
{ name: 'Pi-Hole', link: 'http://192.168.3.19:8089/admin/index.php'},
|
||||
{ name: 'Grafana', link: 'http://192.168.3.19:3000'},
|
||||
{ name: 'Gladys', link: 'http://192.168.3.21/dashboard'},
|
||||
{ name: 'Kodi', link: 'http://192.168.3.12:8080/'},
|
||||
{ name: 'RaspiWork Adminer', link: 'http://192.168.3.19:9080/'},
|
||||
{ name: 'RaspiGate Adminer', link: 'http://192.168.3.29/adminer.php'},
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -627,7 +627,7 @@ class EventsTest extends TestCase
|
||||
'data' => [
|
||||
'user_id' => $userTwo->id,
|
||||
'attributes' => [
|
||||
'validated_at' => now()->toDateTimeString(),
|
||||
'validated_at' => now()->format('Y'),
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user