From 2aa50859b325ea0d31a0ab1e64da1acd34b1c937 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:01:03 -0800
Subject: [PATCH 001/159] Bump Dusk version to fix broken macOS chrome driver
link
---
composer.json | 2 +-
composer.lock | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/composer.json b/composer.json
index 07dbf20639..06d8563039 100644
--- a/composer.json
+++ b/composer.json
@@ -73,7 +73,7 @@
},
"require-dev": {
"fakerphp/faker": "^1.16",
- "laravel/dusk": "^6.19",
+ "laravel/dusk": "^6.25",
"mockery/mockery": "^1.4",
"phpunit/php-token-stream": "^3.1",
"phpunit/phpunit": "^9.0",
diff --git a/composer.lock b/composer.lock
index bf8cb1f758..7c8b7030ba 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "0c1f3848f8c9ede2b5f1513e4feaa7d7",
+ "content-hash": "4fed0ab76a34ef85a44568e470abab48",
"packages": [
{
"name": "alek13/slack",
@@ -11847,16 +11847,16 @@
},
{
"name": "laravel/dusk",
- "version": "v6.25.0",
+ "version": "v6.25.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/dusk.git",
- "reference": "b4632b7493a187d31afc5c9ddec437c81b16421a"
+ "reference": "25a595ac3dc82089a91af10dd23b0d58fd3f6d0b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/dusk/zipball/b4632b7493a187d31afc5c9ddec437c81b16421a",
- "reference": "b4632b7493a187d31afc5c9ddec437c81b16421a",
+ "url": "https://api.github.com/repos/laravel/dusk/zipball/25a595ac3dc82089a91af10dd23b0d58fd3f6d0b",
+ "reference": "25a595ac3dc82089a91af10dd23b0d58fd3f6d0b",
"shasum": ""
},
"require": {
@@ -11914,9 +11914,9 @@
],
"support": {
"issues": "https://github.com/laravel/dusk/issues",
- "source": "https://github.com/laravel/dusk/tree/v6.25.0"
+ "source": "https://github.com/laravel/dusk/tree/v6.25.2"
},
- "time": "2022-07-11T11:38:43+00:00"
+ "time": "2022-09-29T09:37:07+00:00"
},
{
"name": "mockery/mockery",
From 581655f7562199c61267e15e8ba05f1b3fd32b52 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:02:11 -0800
Subject: [PATCH 002/159] Run database migrations for all Dusk tests
---
tests/DuskTestCase.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php
index ac750d9efc..e591a7c771 100644
--- a/tests/DuskTestCase.php
+++ b/tests/DuskTestCase.php
@@ -5,11 +5,13 @@ namespace Tests;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
+use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
+ use DatabaseMigrations;
/**
* Prepare for Dusk test execution.
From bc0f666906d81eaedc0d9273ed54fb1cc8a6e496 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:03:09 -0800
Subject: [PATCH 003/159] Create Setting in test to avoid being redirected to
the setup screen
---
tests/Browser/LoginTest.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/Browser/LoginTest.php b/tests/Browser/LoginTest.php
index 5ed055cda9..18f5172f15 100644
--- a/tests/Browser/LoginTest.php
+++ b/tests/Browser/LoginTest.php
@@ -2,8 +2,8 @@
namespace Tests\Browser;
+use App\Models\Setting;
use App\Models\User;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
@@ -26,6 +26,9 @@ class LoginTest extends DuskTestCase
$user->permissions = '{"superuser": 1}';
$user->save();
+
+ Setting::factory()->create();
+
$this->browse(function (Browser $browser) {
$browser->visitRoute('login')
->assertSee(trans('auth/general.login_prompt'));
@@ -37,10 +40,7 @@ class LoginTest extends DuskTestCase
->type('password', 'password')
->press(trans('auth/general.login'))
->assertPathIs('/');
- $browser->screenshot('dashboard');
+ $browser->screenshot('dashboard');
});
-
- // Delete the user afterwards
- $user->delete();
}
}
From b8b2543b0dca61c29e90eac45a44d6852b6d4491 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:04:21 -0800
Subject: [PATCH 004/159] Reference the correct table in migration down method
---
.../migrations/2017_03_10_210807_add_fields_to_manufacturer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/database/migrations/2017_03_10_210807_add_fields_to_manufacturer.php b/database/migrations/2017_03_10_210807_add_fields_to_manufacturer.php
index 0d05a680c1..05af7c8316 100644
--- a/database/migrations/2017_03_10_210807_add_fields_to_manufacturer.php
+++ b/database/migrations/2017_03_10_210807_add_fields_to_manufacturer.php
@@ -28,7 +28,7 @@ class AddFieldsToManufacturer extends Migration
*/
public function down()
{
- Schema::table('settings', function ($table) {
+ Schema::table('manufacturers', function ($table) {
$table->dropColumn('url');
$table->dropColumn('support_url');
$table->dropColumn('support_phone');
From e5cb68cc5ebc73fda5266b783440117550f72f6c Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:06:16 -0800
Subject: [PATCH 005/159] Move drop column command to correct migration
---
.../2016_08_23_145619_add_show_in_nav_to_status_labels.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/database/migrations/2016_08_23_145619_add_show_in_nav_to_status_labels.php b/database/migrations/2016_08_23_145619_add_show_in_nav_to_status_labels.php
index c4e1a18177..5ea26bf4c1 100644
--- a/database/migrations/2016_08_23_145619_add_show_in_nav_to_status_labels.php
+++ b/database/migrations/2016_08_23_145619_add_show_in_nav_to_status_labels.php
@@ -25,7 +25,7 @@ class AddShowInNavToStatusLabels extends Migration
public function down()
{
Schema::table('status_labels', function (Blueprint $table) {
- $table->dropColumn('show_in_nav', 'field_encrypted');
+ $table->dropColumn('show_in_nav');
});
}
}
From 39ab545cf5b08d3a79d6d4a84d96874db11519ba Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:08:28 -0800
Subject: [PATCH 006/159] Update alter statement to use correct suffix for
column
This is brittle...
---
database/migrations/2015_09_22_003413_migrate_mac_address.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/database/migrations/2015_09_22_003413_migrate_mac_address.php b/database/migrations/2015_09_22_003413_migrate_mac_address.php
index 516b5c2ec7..8167e28adf 100644
--- a/database/migrations/2015_09_22_003413_migrate_mac_address.php
+++ b/database/migrations/2015_09_22_003413_migrate_mac_address.php
@@ -55,6 +55,6 @@ class MigrateMacAddress extends Migration
Schema::table('models', function (Blueprint $table) {
$table->renameColumn('deprecated_mac_address', 'show_mac_address');
});
- DB::statement('ALTER TABLE assets CHANGE _snipeit_mac_address mac_address varchar(255)');
+ DB::statement('ALTER TABLE assets CHANGE _snipeit_mac_address_1 mac_address varchar(255)');
}
}
From 4ee3cbf60e5b6f17ecae9e6fc2025795f26008bd Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:20:20 -0800
Subject: [PATCH 007/159] Comment out migration's down method to match its up
method
---
...015_07_29_230054_add_thread_id_to_asset_logs_table.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php b/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php
index eefc283e3f..f14dc078cc 100644
--- a/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php
+++ b/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php
@@ -105,10 +105,10 @@
*/
public function down()
{
- Schema::table('asset_logs', function (Blueprint $table) {
- $table->dropIndex('thread_id');
- $table->dropColumn('thread_id');
- });
+ // Schema::table('asset_logs', function (Blueprint $table) {
+ // $table->dropIndex('thread_id');
+ // $table->dropColumn('thread_id');
+ // });
}
/**
From c5b09ed95584b01e649c670f9d8b8e2a8778e041 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:21:46 -0800
Subject: [PATCH 008/159] Fix column name typo
---
.../migrations/2013_12_10_084038_add_eol_on_models_table.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/database/migrations/2013_12_10_084038_add_eol_on_models_table.php b/database/migrations/2013_12_10_084038_add_eol_on_models_table.php
index d8d222deec..97e7b266e6 100755
--- a/database/migrations/2013_12_10_084038_add_eol_on_models_table.php
+++ b/database/migrations/2013_12_10_084038_add_eol_on_models_table.php
@@ -24,7 +24,7 @@ class AddEolOnModelsTable extends Migration
public function down()
{
Schema::table('models', function ($table) {
- $table->dropColumn('old');
+ $table->dropColumn('eol');
});
}
}
From 296c9a723d25ec46190273ec39426d489cbe25c3 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:22:29 -0800
Subject: [PATCH 009/159] Reverse column rename in migration's down method
---
.../2013_11_25_104343_alter_warranty_column_on_assets.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/database/migrations/2013_11_25_104343_alter_warranty_column_on_assets.php b/database/migrations/2013_11_25_104343_alter_warranty_column_on_assets.php
index be62374dce..d63a6ad9b4 100755
--- a/database/migrations/2013_11_25_104343_alter_warranty_column_on_assets.php
+++ b/database/migrations/2013_11_25_104343_alter_warranty_column_on_assets.php
@@ -23,6 +23,8 @@ class AlterWarrantyColumnOnAssets extends Migration
*/
public function down()
{
- //
+ Schema::table('assets', function ($table) {
+ $table->renameColumn('warranty_months', 'warrantee_months');
+ });
}
}
From 03938d0f32fd6f1b6891d5aa75e83edc7f8eccc1 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:24:38 -0800
Subject: [PATCH 010/159] Conditionally drop table
---
.../migrations/2013_11_25_013244_recreate_licenses_table.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/database/migrations/2013_11_25_013244_recreate_licenses_table.php b/database/migrations/2013_11_25_013244_recreate_licenses_table.php
index fb18452794..a22349dcd6 100755
--- a/database/migrations/2013_11_25_013244_recreate_licenses_table.php
+++ b/database/migrations/2013_11_25_013244_recreate_licenses_table.php
@@ -37,7 +37,7 @@ class ReCreateLicensesTable extends Migration
*/
public function down()
{
- //
- Schema::drop('licenses');
+ // This was most likely handled in 2013_11_17_054359_drop_licenses_table.php
+ Schema::dropIfExists('licenses');
}
}
From aec64fa64ac2a7b59e953972af55c349de7864d7 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:25:25 -0800
Subject: [PATCH 011/159] Comment out migration's down method to match its up
method
---
.../migrations/2013_11_17_054526_add_physical_to_assets.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/database/migrations/2013_11_17_054526_add_physical_to_assets.php b/database/migrations/2013_11_17_054526_add_physical_to_assets.php
index 2ccc7c43dc..28d1117201 100755
--- a/database/migrations/2013_11_17_054526_add_physical_to_assets.php
+++ b/database/migrations/2013_11_17_054526_add_physical_to_assets.php
@@ -26,6 +26,6 @@ class AddPhysicalToAssets extends Migration
*/
public function down()
{
- $table->dropColumn('physical');
+ // $table->dropColumn('physical');
}
}
From b5ea8b8a4fd17bc27ddffb05881a748fec4526b2 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Tue, 10 Jan 2023 17:29:38 -0800
Subject: [PATCH 012/159] Conditionally drop table
---
..._12_06_225929_migration_cartalyst_sentry_install_groups.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php b/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
index cd45847bc7..49242f2e30 100644
--- a/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
+++ b/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
@@ -44,6 +44,7 @@ class MigrationCartalystSentryInstallGroups extends Migration
*/
public function down()
{
- Schema::drop('permission_groups');
+ // See 2014_11_04_231416_update_group_field_for_reporting.php and 2019_06_12_184327_rename_groups_table.php
+ Schema::dropIfExists('permission_groups');
}
}
From e8c2b84d24b7fcfbd0bcced9bee09e0e701b5bed Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Wed, 11 Jan 2023 12:51:15 -0800
Subject: [PATCH 013/159] Add example dusk environment file
---
.env.dusk.example | 106 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 106 insertions(+)
create mode 100644 .env.dusk.example
diff --git a/.env.dusk.example b/.env.dusk.example
new file mode 100644
index 0000000000..074f6fc3d7
--- /dev/null
+++ b/.env.dusk.example
@@ -0,0 +1,106 @@
+# --------------------------------------------
+# REQUIRED: BASIC APP SETTINGS
+# --------------------------------------------
+APP_ENV=local
+APP_DEBUG=false
+APP_KEY=base64:hTUIUh9CP6dQx+6EjSlfWTgbaMaaRvlpEwk45vp+xmk=
+APP_URL=http://127.0.0.1:8000
+APP_TIMEZONE='US/Eastern'
+APP_LOCALE=en
+APP_LOCKED=false
+MAX_RESULTS=200
+
+# --------------------------------------------
+# REQUIRED: UPLOADED FILE STORAGE SETTINGS
+# --------------------------------------------
+PRIVATE_FILESYSTEM_DISK=local
+PUBLIC_FILESYSTEM_DISK=local_public
+
+# --------------------------------------------
+# REQUIRED: DATABASE SETTINGS
+# --------------------------------------------
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=null
+DB_USERNAME=null
+DB_PASSWORD=null
+DB_PREFIX=null
+#DB_DUMP_PATH=
+
+# --------------------------------------------
+# OPTIONAL: SSL DATABASE SETTINGS
+# --------------------------------------------
+DB_SSL=false
+DB_SSL_KEY_PATH=null
+DB_SSL_CERT_PATH=null
+DB_SSL_CA_PATH=null
+DB_SSL_CIPHER=null
+
+# --------------------------------------------
+# REQUIRED: OUTGOING MAIL SERVER SETTINGS
+# --------------------------------------------
+MAIL_DRIVER="log"
+
+
+# --------------------------------------------
+# REQUIRED: IMAGE LIBRARY
+# This should be gd or imagick
+# --------------------------------------------
+IMAGE_LIB=gd
+
+
+# --------------------------------------------
+# OPTIONAL: SESSION SETTINGS
+# --------------------------------------------
+SESSION_LIFETIME=12000
+EXPIRE_ON_CLOSE=false
+ENCRYPT=true
+COOKIE_NAME=snipeit_v5_local
+SECURE_COOKIES=true
+
+# --------------------------------------------
+# OPTIONAL: SECURITY HEADER SETTINGS
+# --------------------------------------------
+REFERRER_POLICY=same-origin
+ENABLE_CSP=true
+CORS_ALLOWED_ORIGINS="*"
+
+# --------------------------------------------
+# OPTIONAL: CACHE SETTINGS
+# --------------------------------------------
+CACHE_DRIVER=file
+SESSION_DRIVER=file
+QUEUE_DRIVER=sync
+
+# --------------------------------------------
+# OPTIONAL: LOGIN THROTTLING
+# --------------------------------------------
+LOGIN_MAX_ATTEMPTS=50000
+LOGIN_LOCKOUT_DURATION=1000
+RESET_PASSWORD_LINK_EXPIRES=15
+
+# --------------------------------------------
+# OPTIONAL: API
+# --------------------------------------------
+API_MAX_REQUESTS_PER_HOUR=200
+
+# --------------------------------------------
+# OPTIONAL: SAML SETTINGS
+# --------------------------------------------
+DISABLE_NOSAML_LOCAL_LOGIN=true
+
+
+# --------------------------------------------
+# OPTIONAL: MISC
+# --------------------------------------------
+LOG_CHANNEL=single
+LOG_LEVEL=debug
+LOG_CHANNEL=stack
+LOG_SLACK_WEBHOOK_URL=null
+APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
+ALLOW_IFRAMING=true
+ENABLE_HSTS=false
+WARN_DEBUG=false
+APP_CIPHER=AES-256-CBC
+
From 9a3a796e176ad593619d8633b73db77fe1d81ed7 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Wed, 11 Jan 2023 12:57:05 -0800
Subject: [PATCH 014/159] Add dusk environment files to gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 37e9d3f68c..cc67e5c40d 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
.couscous
.DS_Store
.env
+.env.dusk.*
.idea
/bin/
/bootstrap/compiled.php
From 49383ddbe0fd3c6a37a5a22a7cfeaa67c0c49926 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Wed, 11 Jan 2023 12:58:57 -0800
Subject: [PATCH 015/159] Delete old dusk local configuration
---
.env.dusk.local | 106 ------------------------------------------------
1 file changed, 106 deletions(-)
delete mode 100644 .env.dusk.local
diff --git a/.env.dusk.local b/.env.dusk.local
deleted file mode 100644
index 33343ffc51..0000000000
--- a/.env.dusk.local
+++ /dev/null
@@ -1,106 +0,0 @@
-# --------------------------------------------
-# REQUIRED: BASIC APP SETTINGS
-# --------------------------------------------
-APP_ENV=local
-APP_DEBUG=false
-APP_KEY=base64:hTUIUh9CP6dQx+6EjSlfWTgbaMaaRvlpEwk45vp+xmk=
-APP_URL=http://127.0.0.1:8000
-APP_TIMEZONE='US/Eastern'
-APP_LOCALE=en
-APP_LOCKED=false
-MAX_RESULTS=200
-
-# --------------------------------------------
-# REQUIRED: UPLOADED FILE STORAGE SETTINGS
-# --------------------------------------------
-PRIVATE_FILESYSTEM_DISK=local
-PUBLIC_FILESYSTEM_DISK=local_public
-
-# --------------------------------------------
-# REQUIRED: DATABASE SETTINGS
-# --------------------------------------------
-DB_CONNECTION=mysql
-DB_HOST=localhost
-DB_PORT=3306
-DB_DATABASE=snipeit-local
-DB_USERNAME=snipeit-local
-DB_PASSWORD=snipeit-local
-DB_PREFIX=null
-DB_DUMP_PATH='/Applications/MAMP/Library/bin'
-
-# --------------------------------------------
-# OPTIONAL: SSL DATABASE SETTINGS
-# --------------------------------------------
-DB_SSL=false
-DB_SSL_KEY_PATH=null
-DB_SSL_CERT_PATH=null
-DB_SSL_CA_PATH=null
-DB_SSL_CIPHER=null
-
-# --------------------------------------------
-# REQUIRED: OUTGOING MAIL SERVER SETTINGS
-# --------------------------------------------
-MAIL_DRIVER="log"
-
-
-# --------------------------------------------
-# REQUIRED: IMAGE LIBRARY
-# This should be gd or imagick
-# --------------------------------------------
-IMAGE_LIB=gd
-
-
-# --------------------------------------------
-# OPTIONAL: SESSION SETTINGS
-# --------------------------------------------
-SESSION_LIFETIME=12000
-EXPIRE_ON_CLOSE=false
-ENCRYPT=true
-COOKIE_NAME=snipeit_v5_local
-SECURE_COOKIES=true
-
-# --------------------------------------------
-# OPTIONAL: SECURITY HEADER SETTINGS
-# --------------------------------------------
-REFERRER_POLICY=same-origin
-ENABLE_CSP=true
-CORS_ALLOWED_ORIGINS="*"
-
-# --------------------------------------------
-# OPTIONAL: CACHE SETTINGS
-# --------------------------------------------
-CACHE_DRIVER=file
-SESSION_DRIVER=file
-QUEUE_DRIVER=sync
-
-# --------------------------------------------
-# OPTIONAL: LOGIN THROTTLING
-# --------------------------------------------
-LOGIN_MAX_ATTEMPTS=50000
-LOGIN_LOCKOUT_DURATION=1000
-RESET_PASSWORD_LINK_EXPIRES=15
-
-# --------------------------------------------
-# OPTIONAL: API
-# --------------------------------------------
-API_MAX_REQUESTS_PER_HOUR=200
-
-# --------------------------------------------
-# OPTIONAL: SAML SETTINGS
-# --------------------------------------------
-DISABLE_NOSAML_LOCAL_LOGIN=true
-
-
-# --------------------------------------------
-# OPTIONAL: MISC
-# --------------------------------------------
-LOG_CHANNEL=single
-LOG_LEVEL=debug
-LOG_CHANNEL=stack
-LOG_SLACK_WEBHOOK_URL=null
-APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
-ALLOW_IFRAMING=true
-ENABLE_HSTS=false
-WARN_DEBUG=false
-APP_CIPHER=AES-256-CBC
-
From bc80f672ee1f88e8d4bc66facee410f439bcdedd Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Wed, 11 Jan 2023 13:00:34 -0800
Subject: [PATCH 016/159] Keep the example dusk environment file
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index cc67e5c40d..078a7e4b8a 100755
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
.DS_Store
.env
.env.dusk.*
+!.env.dusk.example
.idea
/bin/
/bootstrap/compiled.php
From 49f2573f36602370666808494d9d738cd96ee436 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Wed, 11 Jan 2023 13:51:01 -0800
Subject: [PATCH 017/159] Update testing readme
---
TESTING.md | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/TESTING.md b/TESTING.md
index 6624289758..f7034895a3 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -43,23 +43,25 @@ you want to run.
## Browser Tests
-The browser tests use [Dusk](https://laravel.com/docs/8.x/dusk) to run them.
-When troubleshooting any problems, make sure that your `.env` file is configured
-correctly to run the existing application.
+Browser tests are run via [Laravel Dusk](https://laravel.com/docs/8.x/dusk) and require Google Chrome to be installed.
+
+Before attempting to run Dusk tests copy the example environment file for Dusk and update the values to match your environment:
+
+`cp .env.dusk.example .env.dusk.local`
+> `local` refers to the value of `APP_ENV` in your `.env` so if you have it set to `dev` then the file should be named `.env.dusk.dev`.
### Test Setup
-Your application needs to be configued and up and running in order for the browser
+Your application needs to be configured and up and running in order for the browser
tests to actually run. When running the tests locally, you can start the application
using the following command:
`php artisan serve`
-
-To run the test suite use the following command from another terminal tab or window:
+Now you are ready to run the test suite. Use the following command from another terminal tab or window:
`php artisan dusk`
-To run individual test files, you can pass the path to the test that you want to run.
+To run individual test files, you can pass the path to the test that you want to run:
`php artisan dusk tests/Browser/LoginTest.php`
From 0dd7cc9967941a821fe9d45864ab0c6844c8be4d Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Wed, 11 Jan 2023 13:54:28 -0800
Subject: [PATCH 018/159] Add note about installing ChromeDriver to testing
readme
---
TESTING.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/TESTING.md b/TESTING.md
index f7034895a3..a1706177a9 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -65,3 +65,9 @@ Now you are ready to run the test suite. Use the following command from another
To run individual test files, you can pass the path to the test that you want to run:
`php artisan dusk tests/Browser/LoginTest.php`
+
+If you get an error when attempting to run Dusk tests that says `Couldn't connect to server` run:
+
+`php artisan dusk:chrome-driver --detect`
+
+This command will install the specific ChromeDriver Dusk needs for your operating system and Chrome version.
From 51da747809ff039d5d294f493f13cd726cd4fbc3 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Wed, 11 Jan 2023 18:05:07 -0800
Subject: [PATCH 019/159] Add note about database requirements when running
Dusk tests
---
TESTING.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/TESTING.md b/TESTING.md
index a1706177a9..8a430d498e 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -50,6 +50,8 @@ Before attempting to run Dusk tests copy the example environment file for Dusk a
`cp .env.dusk.example .env.dusk.local`
> `local` refers to the value of `APP_ENV` in your `.env` so if you have it set to `dev` then the file should be named `.env.dusk.dev`.
+**Important**: Dusk tests cannot be run using an in-memory SQLite database. Additionally, the Dusk test suite uses the `DatabaseMigrations` trait which will leave the database in a fresh state after running. Therefore, it is recommended that you create a test database and point `DB_DATABASE` in `.env.dusk.local` to it.
+
### Test Setup
Your application needs to be configured and up and running in order for the browser
From fd73bee8505b766d102cb2003ae6bb6e0437dc92 Mon Sep 17 00:00:00 2001
From: snipe
Date: Sat, 21 Jan 2023 14:38:05 -0800
Subject: [PATCH 020/159] Fixed hardcoded string and added new checkout count
to accessory view
Signed-off-by: snipe
---
resources/views/accessories/view.blade.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/resources/views/accessories/view.blade.php b/resources/views/accessories/view.blade.php
index 82d7c8201a..59ff1b9c80 100644
--- a/resources/views/accessories/view.blade.php
+++ b/resources/views/accessories/view.blade.php
@@ -327,13 +327,22 @@
- Number remaining
+ {{ trans('admin/accessories/general.remaining') }}
{{ $accessory->numRemaining() }}
+
+
+ {{ trans('general.checked_out') }}
+
+
+ {{ $accessory->users_count }}
+
+
+
@can('checkout', \App\Models\Accessory::class)
From 56090bc64534f73d9e2cab10ff4f70e4d97d65ef Mon Sep 17 00:00:00 2001
From: snipe
Date: Sat, 21 Jan 2023 14:38:35 -0800
Subject: [PATCH 021/159] Re-ordered notes to be more consistent, fixed missing
iCheck class
Signed-off-by: snipe
---
resources/views/accessories/edit.blade.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/resources/views/accessories/edit.blade.php b/resources/views/accessories/edit.blade.php
index d6233d4e5a..c16e57cb22 100755
--- a/resources/views/accessories/edit.blade.php
+++ b/resources/views/accessories/edit.blade.php
@@ -21,22 +21,24 @@
@include ('partials.forms.edit.purchase_cost')
@include ('partials.forms.edit.quantity')
@include ('partials.forms.edit.minimum_quantity')
-
+@include ('partials.forms.edit.notes')
@if ($item->image)
@endif
-@include ('partials.forms.edit.notes')
-
@include ('partials.forms.edit.image-upload')
@stop
From 46e3e8a3dd9b80e1c33b0a3af951ec547f8b638c Mon Sep 17 00:00:00 2001
From: snipe
Date: Sat, 21 Jan 2023 14:39:53 -0800
Subject: [PATCH 022/159] Added new users_count field to API
Signed-off-by: snipe
---
app/Presenters/AccessoryPresenter.php | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/app/Presenters/AccessoryPresenter.php b/app/Presenters/AccessoryPresenter.php
index 7d77acc8d7..cc4f9badfc 100644
--- a/app/Presenters/AccessoryPresenter.php
+++ b/app/Presenters/AccessoryPresenter.php
@@ -80,19 +80,25 @@ class AccessoryPresenter extends Presenter
], [
'field' => 'qty',
'searchable' => false,
- 'sortable' => false,
- 'title' => trans('admin/accessories/general.total'),
- ], [
- 'field' => 'min_qty',
- 'searchable' => false,
'sortable' => true,
- 'title' => trans('general.min_amt'),
+ 'title' => trans('admin/accessories/general.total'),
], [
'field' => 'remaining_qty',
'searchable' => false,
'sortable' => false,
'visible' => false,
'title' => trans('admin/accessories/general.remaining'),
+ ],[
+ 'field' => 'users_count',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'visible' => true,
+ 'title' => trans('general.checked_out'),
+ ], [
+ 'field' => 'min_qty',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'title' => trans('general.min_amt'),
], [
'field' => 'purchase_date',
'searchable' => true,
From dceb77d4d4a70df6a1ab0b4a70b1bf0ad500e64a Mon Sep 17 00:00:00 2001
From: snipe
Date: Sat, 21 Jan 2023 14:40:20 -0800
Subject: [PATCH 023/159] Refactored numRemaining, removed unnecessary
numCheckout
Signed-off-by: snipe
---
app/Models/Accessory.php | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index 3f2004b047..d39d653382 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -327,20 +327,6 @@ class Accessory extends SnipeModel
return null;
}
- /**
- * Check how many items within an accessory are checked out
- *
- * @author [A. Gianotto] []
- * @since [v5.0]
- * @return int
- */
- public function numCheckedOut()
- {
- $checkedout = 0;
- $checkedout = $this->users->count();
-
- return $checkedout;
- }
/**
* Check how many items of an accessory remain
@@ -351,11 +337,11 @@ class Accessory extends SnipeModel
*/
public function numRemaining()
{
- $checkedout = $this->users->count();
+ $checkedout = $this->users_count;
$total = $this->qty;
$remaining = $total - $checkedout;
- return $remaining;
+ return (int) $remaining;
}
/**
From 90c16318201b45fa233e07ca19f0e4f8a38c7c54 Mon Sep 17 00:00:00 2001
From: snipe
Date: Sat, 21 Jan 2023 14:40:35 -0800
Subject: [PATCH 024/159] Added users_count to transformer for API
Signed-off-by: snipe
---
app/Http/Transformers/AccessoriesTransformer.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/Http/Transformers/AccessoriesTransformer.php b/app/Http/Transformers/AccessoriesTransformer.php
index 6f254b3b87..00c30f9ea2 100644
--- a/app/Http/Transformers/AccessoriesTransformer.php
+++ b/app/Http/Transformers/AccessoriesTransformer.php
@@ -38,7 +38,8 @@ class AccessoriesTransformer
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
- 'remaining_qty' => $accessory->numRemaining(),
+ 'remaining_qty' => (int) $accessory->numRemaining(),
+ 'users_count' => $accessory->users_count,
'created_at' => Helper::getFormattedDateObject($accessory->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($accessory->updated_at, 'datetime'),
From 60eab08735187044240c3f180867411c9b772813 Mon Sep 17 00:00:00 2001
From: snipe
Date: Sat, 21 Jan 2023 14:41:07 -0800
Subject: [PATCH 025/159] =?UTF-8?q?Added=20`->with(=E2=80=98users=20as=20u?=
=?UTF-8?q?sers=5Fcount=E2=80=99)`=20in=20Accessory=20query?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: snipe
---
.../Accessories/AccessoriesController.php | 74 +++++++++----------
.../Controllers/Api/AccessoriesController.php | 5 +-
2 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/app/Http/Controllers/Accessories/AccessoriesController.php b/app/Http/Controllers/Accessories/AccessoriesController.php
index d1af79adf1..96f83d7665 100755
--- a/app/Http/Controllers/Accessories/AccessoriesController.php
+++ b/app/Http/Controllers/Accessories/AccessoriesController.php
@@ -127,45 +127,45 @@ class AccessoriesController extends Controller
*/
public function update(ImageUploadRequest $request, $accessoryId = null)
{
- if (is_null($accessory = Accessory::find($accessoryId))) {
+ if ($accessory = Accessory::withCount('users as users_count')->find($accessoryId)) {
+
+ $validator = Validator::make($request->all(), [
+ "qty" => "required|numeric|min:$accessory->users_count"
+ ]);
+
+ if ($validator->fails()) {
+ return redirect()->back()
+ ->withErrors($validator)
+ ->withInput();
+ }
+
+ $this->authorize($accessory);
+
+ // Update the accessory data
+ $accessory->name = request('name');
+ $accessory->location_id = request('location_id');
+ $accessory->min_amt = request('min_amt');
+ $accessory->category_id = request('category_id');
+ $accessory->company_id = Company::getIdForCurrentUser(request('company_id'));
+ $accessory->manufacturer_id = request('manufacturer_id');
+ $accessory->order_number = request('order_number');
+ $accessory->model_number = request('model_number');
+ $accessory->purchase_date = request('purchase_date');
+ $accessory->purchase_cost = Helper::ParseCurrency(request('purchase_cost'));
+ $accessory->qty = request('qty');
+ $accessory->supplier_id = request('supplier_id');
+ $accessory->notes = request('notes');
+
+ $accessory = $request->handleImages($accessory);
+
+ // Was the accessory updated?
+ if ($accessory->save()) {
+ return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.update.success'));
+ }
+ } else {
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
}
- $min = $accessory->numCheckedOut();
- $validator = Validator::make($request->all(), [
- "qty" => "required|numeric|min:$min"
- ]);
-
- if ($validator->fails()) {
- return redirect()->back()
- ->withErrors($validator)
- ->withInput();
- }
-
- $this->authorize($accessory);
-
- // Update the accessory data
- $accessory->name = request('name');
- $accessory->location_id = request('location_id');
- $accessory->min_amt = request('min_amt');
- $accessory->category_id = request('category_id');
- $accessory->company_id = Company::getIdForCurrentUser(request('company_id'));
- $accessory->manufacturer_id = request('manufacturer_id');
- $accessory->order_number = request('order_number');
- $accessory->model_number = request('model_number');
- $accessory->purchase_date = request('purchase_date');
- $accessory->purchase_cost = Helper::ParseCurrency(request('purchase_cost'));
- $accessory->qty = request('qty');
- $accessory->supplier_id = request('supplier_id');
- $accessory->notes = request('notes');
-
- $accessory = $request->handleImages($accessory);
-
- // Was the accessory updated?
- if ($accessory->save()) {
- return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.update.success'));
- }
-
return redirect()->back()->withInput()->withErrors($accessory->getErrors());
}
@@ -217,7 +217,7 @@ class AccessoriesController extends Controller
*/
public function show($accessoryID = null)
{
- $accessory = Accessory::find($accessoryID);
+ $accessory = Accessory::withCount('users as users_count')->find($accessoryID);
$this->authorize('view', $accessory);
if (isset($accessory->id)) {
return view('accessories/view', compact('accessory'));
diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.php
index a894dc3760..fd21ebaf3a 100644
--- a/app/Http/Controllers/Api/AccessoriesController.php
+++ b/app/Http/Controllers/Api/AccessoriesController.php
@@ -41,10 +41,13 @@ class AccessoriesController extends Controller
'min_amt',
'company_id',
'notes',
+ 'users_count',
+ 'qty',
];
- $accessories = Accessory::select('accessories.*')->with('category', 'company', 'manufacturer', 'users', 'location', 'supplier');
+ $accessories = Accessory::select('accessories.*')->with('category', 'company', 'manufacturer', 'users', 'location', 'supplier')
+ ->withCount('users as users_count');
if ($request->filled('search')) {
$accessories = $accessories->TextSearch($request->input('search'));
From 2bdf3d3f44cc460c26f68949891ea16c5f0025c8 Mon Sep 17 00:00:00 2001
From: snipe
Date: Sat, 21 Jan 2023 14:44:10 -0800
Subject: [PATCH 026/159] Missed a few strong HTML tags
Signed-off-by: snipe
---
resources/views/accessories/view.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/accessories/view.blade.php b/resources/views/accessories/view.blade.php
index 59ff1b9c80..fd31722204 100644
--- a/resources/views/accessories/view.blade.php
+++ b/resources/views/accessories/view.blade.php
@@ -290,7 +290,7 @@
@if ($accessory->company)
- {{ trans('general.company')}}
+ {{ trans('general.company')}}
{{ $accessory->company->name }}
@@ -302,7 +302,7 @@
@if ($accessory->category)
- {{ trans('general.category')}}
+ {{ trans('general.category')}}
{{ $accessory->category->name }}
From e6dc61d2cffe712f9f0a77b78eed83f84ed7f5f1 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Mon, 23 Jan 2023 15:42:05 -0800
Subject: [PATCH 027/159] Revert column names to legacy versions in down method
---
...357_fix_utf8_custom_field_column_names.php | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/database/migrations/2017_01_25_063357_fix_utf8_custom_field_column_names.php b/database/migrations/2017_01_25_063357_fix_utf8_custom_field_column_names.php
index 72e85698e0..4725cccfe1 100644
--- a/database/migrations/2017_01_25_063357_fix_utf8_custom_field_column_names.php
+++ b/database/migrations/2017_01_25_063357_fix_utf8_custom_field_column_names.php
@@ -4,6 +4,7 @@ use App\Models\CustomField;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Str;
/**
* Fixes issue #2551 where columns got donked if the field name in non-ascii
@@ -71,6 +72,25 @@ class FixUtf8CustomFieldColumnNames extends Migration
*/
public function down()
{
+ // In the up method above, updateLegacyColumnName is called and custom fields in the assets table are prefixed
+ // with "_snipe_it_", suffixed with "_{id of the CustomField}", and stored in custom_fields.db_column.
+ // The following reverses those changes.
+ foreach (CustomField::all() as $field) {
+ $currentColumnName = $field->db_column;
+
+ // "_snipeit_imei_1" becomes "_snipeit_imei"
+ $legacyColumnName = (string) Str::of($currentColumnName)->replaceMatches('/_(\d)+$/', '');
+
+ if (Schema::hasColumn(CustomField::$table_name, $currentColumnName)) {
+ Schema::table(CustomField::$table_name, function (Blueprint $table) use ($currentColumnName, $legacyColumnName) {
+ $table->renameColumn(
+ $currentColumnName,
+ $legacyColumnName
+ );
+ });
+ }
+ }
+
Schema::table('custom_fields', function ($table) {
$table->dropColumn('db_column');
$table->dropColumn('help_text');
From 760844de6fb252bd7f979d8eaa6fa3a92283caf2 Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Mon, 23 Jan 2023 15:42:33 -0800
Subject: [PATCH 028/159] Add conditionals
---
.../2015_09_22_003413_migrate_mac_address.php | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/database/migrations/2015_09_22_003413_migrate_mac_address.php b/database/migrations/2015_09_22_003413_migrate_mac_address.php
index 8167e28adf..3c4bf93e15 100644
--- a/database/migrations/2015_09_22_003413_migrate_mac_address.php
+++ b/database/migrations/2015_09_22_003413_migrate_mac_address.php
@@ -48,13 +48,19 @@ class MigrateMacAddress extends Migration
*/
public function down()
{
- //
$f = \App\Models\CustomFieldset::where(['name' => 'Asset with MAC Address'])->first();
- $f->fields()->delete();
- $f->delete();
+
+ if ($f) {
+ $f->fields()->delete();
+ $f->delete();
+ }
+
Schema::table('models', function (Blueprint $table) {
$table->renameColumn('deprecated_mac_address', 'show_mac_address');
});
- DB::statement('ALTER TABLE assets CHANGE _snipeit_mac_address_1 mac_address varchar(255)');
+
+ if (Schema::hasColumn('assets', '_snipeit_mac_address')) {
+ DB::statement('ALTER TABLE assets CHANGE _snipeit_mac_address mac_address varchar(255)');
+ }
}
}
From cd582be851b6dff9d1c3135ff3c0a7d79519ecae Mon Sep 17 00:00:00 2001
From: Marcus Moore
Date: Mon, 23 Jan 2023 15:42:45 -0800
Subject: [PATCH 029/159] Drop tables that may exist in down methods
---
...2_12_06_225929_migration_cartalyst_sentry_install_groups.php | 1 +
.../migrations/2013_11_25_031458_create_license_seats_table.php | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php b/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
index 49242f2e30..55d7318736 100644
--- a/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
+++ b/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
@@ -46,5 +46,6 @@ class MigrationCartalystSentryInstallGroups extends Migration
{
// See 2014_11_04_231416_update_group_field_for_reporting.php and 2019_06_12_184327_rename_groups_table.php
Schema::dropIfExists('permission_groups');
+ Schema::dropIfExists('groups');
}
}
diff --git a/database/migrations/2013_11_25_031458_create_license_seats_table.php b/database/migrations/2013_11_25_031458_create_license_seats_table.php
index 466ef00870..d023b8ebec 100755
--- a/database/migrations/2013_11_25_031458_create_license_seats_table.php
+++ b/database/migrations/2013_11_25_031458_create_license_seats_table.php
@@ -31,6 +31,6 @@ class CreateLicenseSeatsTable extends Migration
*/
public function down()
{
- //
+ Schema::dropIfExists('license_seats');
}
}
From dc155846ca11d404aed416bf7bc0bc64f2252b1b Mon Sep 17 00:00:00 2001
From: snipe
Date: Mon, 23 Jan 2023 21:49:17 -0800
Subject: [PATCH 030/159] =?UTF-8?q?Hoist=20the=20autorization=20higher=20i?=
=?UTF-8?q?n=20the=20stack=20so=20we=E2=80=99re=20not=20doing=20logic=20or?=
=?UTF-8?q?=20math=20when=20the=20user=20isn=E2=80=99t=20authorized=20to?=
=?UTF-8?q?=20touch=20this?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: snipe
---
app/Http/Controllers/Accessories/AccessoriesController.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/Http/Controllers/Accessories/AccessoriesController.php b/app/Http/Controllers/Accessories/AccessoriesController.php
index 96f83d7665..f0b54a9498 100755
--- a/app/Http/Controllers/Accessories/AccessoriesController.php
+++ b/app/Http/Controllers/Accessories/AccessoriesController.php
@@ -63,6 +63,7 @@ class AccessoriesController extends Controller
public function store(ImageUploadRequest $request)
{
$this->authorize(Accessory::class);
+
// create a new model instance
$accessory = new Accessory();
@@ -82,7 +83,6 @@ class AccessoriesController extends Controller
$accessory->supplier_id = request('supplier_id');
$accessory->notes = request('notes');
-
$accessory = $request->handleImages($accessory);
// Was the accessory created?
@@ -129,6 +129,8 @@ class AccessoriesController extends Controller
{
if ($accessory = Accessory::withCount('users as users_count')->find($accessoryId)) {
+ $this->authorize($accessory);
+
$validator = Validator::make($request->all(), [
"qty" => "required|numeric|min:$accessory->users_count"
]);
@@ -139,7 +141,7 @@ class AccessoriesController extends Controller
->withInput();
}
- $this->authorize($accessory);
+
// Update the accessory data
$accessory->name = request('name');
From 0f8ee220534b89fe5ef3b7a8f652ce306d3c0752 Mon Sep 17 00:00:00 2001
From: Godfrey M
Date: Tue, 24 Jan 2023 09:25:05 -0800
Subject: [PATCH 031/159] Creates Slack Setting Form
---
app/Http/Livewire/SlackSettingsForm.php | 21 +++++++++++++++++++
.../livewire/slack-settings-form.blade.php | 3 +++
2 files changed, 24 insertions(+)
create mode 100644 app/Http/Livewire/SlackSettingsForm.php
create mode 100644 resources/views/livewire/slack-settings-form.blade.php
diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php
new file mode 100644
index 0000000000..c796ee53cc
--- /dev/null
+++ b/app/Http/Livewire/SlackSettingsForm.php
@@ -0,0 +1,21 @@
+
+ {{-- In work, do what you enjoy. --}}
+
From cafe8f3074276c33aba4cf7537c008de14f12351 Mon Sep 17 00:00:00 2001
From: akemidx
Date: Tue, 24 Jan 2023 16:20:20 -0500
Subject: [PATCH 032/159] notification for slack message
---
resources/views/consumables/checkout.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/consumables/checkout.blade.php b/resources/views/consumables/checkout.blade.php
index f768f78484..85cec320e2 100644
--- a/resources/views/consumables/checkout.blade.php
+++ b/resources/views/consumables/checkout.blade.php
@@ -60,7 +60,7 @@
@if ($snipeSettings->slack_endpoint!='')
- A slack message will be sent
+ {{ trans('general.slack_msg_note') }}
@endif
From 3c4f254583d8454a70c50f95538b7f61f4c7ba10 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 24 Jan 2023 13:38:53 -0800
Subject: [PATCH 033/159] Enforce Y-m-d as date format for date fields
Signed-off-by: snipe
---
app/Models/Accessory.php | 1 +
app/Models/Asset.php | 9 +++++----
app/Models/Component.php | 2 +-
app/Models/Consumable.php | 1 +
app/Models/License.php | 3 +++
app/Models/User.php | 4 ++--
6 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index 3f2004b047..9569917ab3 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -63,6 +63,7 @@ class Accessory extends SnipeModel
'company_id' => 'integer|nullable',
'min_amt' => 'integer|min:0|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
+ 'purchase_date' => 'date_format:Y-m-d|nullable',
];
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index f8e0cab314..75e1f38e45 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -105,16 +105,17 @@ class Asset extends Depreciable
'company_id' => 'integer|nullable',
'warranty_months' => 'numeric|nullable|digits_between:0,240',
'physical' => 'numeric|max:1|nullable',
- 'checkout_date' => 'date|max:10|min:10|nullable',
- 'checkin_date' => 'date|max:10|min:10|nullable',
+ 'checkout_date' => 'date_format:Y-m-d|max:10|min:10|nullable',
+ 'checkin_date' => 'date_format:Y-m-d|max:10|min:10|nullable',
'location_id' => 'exists:locations,id|nullable',
'rtd_location_id' => 'exists:locations,id|nullable',
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
'status' => 'integer',
+ 'purchase_date' => 'date_format:Y-m-d|nullable',
'serial' => 'unique_serial|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
- 'next_audit_date' => 'date|nullable',
- 'last_audit_date' => 'date|nullable',
+ 'next_audit_date' => 'date_format:Y-m-d|nullable',
+ 'last_audit_date' => 'date_format:Y-m-d|nullable',
'supplier_id' => 'exists:suppliers,id|nullable',
];
diff --git a/app/Models/Component.php b/app/Models/Component.php
index dc353d288c..98230132be 100644
--- a/app/Models/Component.php
+++ b/app/Models/Component.php
@@ -35,7 +35,7 @@ class Component extends SnipeModel
'category_id' => 'required|integer|exists:categories,id',
'company_id' => 'integer|nullable',
'min_amt' => 'integer|min:0|nullable',
- 'purchase_date' => 'date|nullable',
+ 'purchase_date' => 'date_format:Y-m-d|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
];
diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php
index c04c9b53d5..ea4ac6086b 100644
--- a/app/Models/Consumable.php
+++ b/app/Models/Consumable.php
@@ -41,6 +41,7 @@ class Consumable extends SnipeModel
'company_id' => 'integer|nullable',
'min_amt' => 'integer|min:0|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
+ 'purchase_date' => 'date_format:Y-m-d|nullable',
];
/**
diff --git a/app/Models/License.php b/app/Models/License.php
index b59387a42e..d3c4d8a1c3 100755
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@ -50,6 +50,9 @@ class License extends Depreciable
'category_id' => 'required|exists:categories,id',
'company_id' => 'integer|nullable',
'purchase_cost'=> 'numeric|nullable|gte:0',
+ 'purchase_date' => 'date_format:Y-m-d|nullable',
+ 'expiration_date' => 'date_format:Y-m-d|nullable',
+ 'termination_date' => 'date_format:Y-m-d|nullable',
];
/**
diff --git a/app/Models/User.php b/app/Models/User.php
index 34c0af6b2e..4d430af741 100755
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -98,8 +98,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
'website' => 'url|nullable|max:191',
'manager_id' => 'nullable|exists:users,id|cant_manage_self',
'location_id' => 'exists:locations,id|nullable',
- 'start_date' => 'nullable|date',
- 'end_date' => 'nullable|date|after_or_equal:start_date',
+ 'start_date' => 'nullable|date_format:Y-m-d',
+ 'end_date' => 'nullable|date_format:Y-m-d|after_or_equal:start_date',
];
/**
From 3ba79600fb6e163c9afec105a345cfabeef07c56 Mon Sep 17 00:00:00 2001
From: akemidx
Date: Tue, 24 Jan 2023 18:17:49 -0500
Subject: [PATCH 034/159] checkin limit for the components checkin
---
resources/lang/en/admin/components/general.php | 1 +
resources/views/components/checkin.blade.php | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/resources/lang/en/admin/components/general.php b/resources/lang/en/admin/components/general.php
index f7689a7ad1..5d93036054 100644
--- a/resources/lang/en/admin/components/general.php
+++ b/resources/lang/en/admin/components/general.php
@@ -12,4 +12,5 @@ return array(
'remaining' => 'Remaining',
'total' => 'Total',
'update' => 'Update Component',
+ 'checkin_limit' => 'Amount checked in must be equal to or less than this amount'
);
diff --git a/resources/views/components/checkin.blade.php b/resources/views/components/checkin.blade.php
index 8dca260443..55822fb9cf 100644
--- a/resources/views/components/checkin.blade.php
+++ b/resources/views/components/checkin.blade.php
@@ -42,7 +42,7 @@
-
Must be {{ $component_assets->assigned_qty }} or less.
+
{{ trans(admin/components/general.checkin_limit) }}: {{ $component_assets->assigned_qty }}
{!! $errors->first('checkin_qty', '
:message') !!}
From 91394f72624a501fde291c5631044e4bbb4fa261 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 24 Jan 2023 17:23:06 -0800
Subject: [PATCH 035/159] Removed duplicate comment section
Signed-off-by: snipe
---
resources/lang/en/validation.php | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php
index 04f8d65303..18387310f8 100644
--- a/resources/lang/en/validation.php
+++ b/resources/lang/en/validation.php
@@ -103,17 +103,6 @@ return [
],
- /*
- |--------------------------------------------------------------------------
- | Custom Validation Language Lines
- |--------------------------------------------------------------------------
- |
- | Here you may specify custom validation messages for attributes using the
- | convention "attribute.rule" to name the lines. This makes it quick to
- | specify a specific custom language line for a given attribute rule.
- |
- */
-
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
From a61ccbb9658da024185575fe017fe81b86b64776 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 24 Jan 2023 17:33:49 -0800
Subject: [PATCH 036/159] Added very clunky but better error messages on that
validation for date_format
Signed-off-by: snipe
---
resources/lang/en/validation.php | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php
index 18387310f8..31c9dcd85d 100644
--- a/resources/lang/en/validation.php
+++ b/resources/lang/en/validation.php
@@ -120,6 +120,18 @@ return [
'hashed_pass' => 'Your current password is incorrect',
'dumbpwd' => 'That password is too common.',
'statuslabel_type' => 'You must select a valid status label type',
+
+ // date_format validation with slightly less stupid messages. It duplicates a lot, but it gets the job done :(
+ // We use this because the default error message for date_format is reflects php Y-m-d, which non-PHP
+ // people won't know how to format.
+ 'purchase_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
+ 'last_audit_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD hh:mm:ss format',
+ 'expiration_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
+ 'termination_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
+ 'expected_checkin.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
+ 'start_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
+ 'end_date.date_format' => 'The :attribute must be a valid date in YYYY-MM-DD format',
+
],
/*
From fd2a057d384d9a57b6717fd92020e2f44c4f460f Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 24 Jan 2023 17:36:58 -0800
Subject: [PATCH 037/159] Make audit dates fillable
Signed-off-by: snipe
---
app/Models/Asset.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index 75e1f38e45..e3e2e96b0c 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -146,6 +146,9 @@ class Asset extends Depreciable
'last_checkout',
'expected_checkin',
'byod',
+ 'last_audit_date',
+ 'next_audit_date',
+
];
use Searchable;
From 9c79fc19cb6eab3f31d587120b1c9c9534a34dd9 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 24 Jan 2023 17:37:15 -0800
Subject: [PATCH 038/159] =?UTF-8?q?Tightened=20up=20and=20removed=20some?=
=?UTF-8?q?=20validation=20that=20wasn=E2=80=99t=20needed?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: snipe
---
app/Models/Asset.php | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index e3e2e96b0c..3c1bc9beca 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -84,11 +84,11 @@ class Asset extends Depreciable
protected $casts = [
- 'purchase_date' => 'datetime',
+ 'purchase_date' => 'date',
'last_checkout' => 'datetime',
- 'expected_checkin' => 'datetime',
+ 'expected_checkin' => 'date',
'last_audit_date' => 'datetime',
- 'next_audit_date' => 'datetime',
+ 'next_audit_date' => 'date',
'model_id' => 'integer',
'status_id' => 'integer',
'company_id' => 'integer',
@@ -105,17 +105,14 @@ class Asset extends Depreciable
'company_id' => 'integer|nullable',
'warranty_months' => 'numeric|nullable|digits_between:0,240',
'physical' => 'numeric|max:1|nullable',
- 'checkout_date' => 'date_format:Y-m-d|max:10|min:10|nullable',
- 'checkin_date' => 'date_format:Y-m-d|max:10|min:10|nullable',
+ 'last_checkout' => 'date|date_format:Y-m-d H:i:s|nullable',
+ 'expected_checkin' => 'date|date_format:Y-m-d|nullable',
'location_id' => 'exists:locations,id|nullable',
'rtd_location_id' => 'exists:locations,id|nullable',
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
- 'status' => 'integer',
- 'purchase_date' => 'date_format:Y-m-d|nullable',
+ 'purchase_date' => 'date|date_format:Y-m-d|nullable',
'serial' => 'unique_serial|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
- 'next_audit_date' => 'date_format:Y-m-d|nullable',
- 'last_audit_date' => 'date_format:Y-m-d|nullable',
'supplier_id' => 'exists:suppliers,id|nullable',
];
From 2e22eeade548c18228a9852e63a0472051bad29e Mon Sep 17 00:00:00 2001
From: Godfrey M
Date: Wed, 25 Jan 2023 14:29:20 -0800
Subject: [PATCH 039/159] adds one input
---
app/Http/Livewire/SlackSettingsForm.php | 5 +++++
.../livewire/slack-settings-form.blade.php | 19 ++++++++++++++++++-
resources/views/settings/slack.blade.php | 17 +----------------
3 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php
index c796ee53cc..0193aa7daf 100644
--- a/app/Http/Livewire/SlackSettingsForm.php
+++ b/app/Http/Livewire/SlackSettingsForm.php
@@ -11,6 +11,11 @@ class SlackSettingsForm extends Component
{
public Setting $setting;
+ protected $rules = [
+ 'setting.slack_endpoint' => 'url|required_with:slack_channel|starts_with:https://hooks.slack.com/|nullable',
+ 'setting.slack_channel' => 'required_with:slack_endpoint|starts_with:#|nullable',
+ 'setting.slack_botname' => 'string|nullable',
+ ];
public function render()
diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php
index cdda2ce1ff..4846aa95fb 100644
--- a/resources/views/livewire/slack-settings-form.blade.php
+++ b/resources/views/livewire/slack-settings-form.blade.php
@@ -1,3 +1,20 @@
- {{-- In work, do what you enjoy. --}}
+
diff --git a/resources/views/settings/slack.blade.php b/resources/views/settings/slack.blade.php
index 705510ab8e..f5f21c5aa9 100644
--- a/resources/views/settings/slack.blade.php
+++ b/resources/views/settings/slack.blade.php
@@ -50,22 +50,7 @@
-
-
+ @livewire('slack-settings-form', ['setting' => $setting])
+
+
+
+
+
+
diff --git a/resources/views/settings/slack.blade.php b/resources/views/settings/slack.blade.php
index f5f21c5aa9..6bbd321662 100644
--- a/resources/views/settings/slack.blade.php
+++ b/resources/views/settings/slack.blade.php
@@ -50,41 +50,9 @@
- @livewire('slack-settings-form', ['setting' => $setting])
+ @livewire('slack-settings-form')
-
-
-
-
-
-
+
diff --git a/resources/views/hardware/quickscan-checkin.blade.php b/resources/views/hardware/quickscan-checkin.blade.php
index b2075c51d0..8884821809 100644
--- a/resources/views/hardware/quickscan-checkin.blade.php
+++ b/resources/views/hardware/quickscan-checkin.blade.php
@@ -73,7 +73,7 @@
@@ -86,7 +86,7 @@
- Processing...
+ {{ trans(general.processing') }}...
diff --git a/resources/views/hardware/quickscan.blade.php b/resources/views/hardware/quickscan.blade.php
index dbcae0fa26..fdc30e2772 100644
--- a/resources/views/hardware/quickscan.blade.php
+++ b/resources/views/hardware/quickscan.blade.php
@@ -99,7 +99,7 @@
diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php
index 336283b6ba..a710bc815a 100755
--- a/resources/views/hardware/view.blade.php
+++ b/resources/views/hardware/view.blade.php
@@ -75,8 +75,8 @@
@if (!$asset->model)
-
NO MODEL ASSOCIATED
-
This will break things in weird and horrible ways. Edit this asset now to assign it a model.
+
{{ trans('admin/models/message.no_association') }}
+
{{ trans('admin/models/message.no_association_fix') }}
@endif
@@ -85,9 +85,8 @@
- WARNING:
- This asset has been deleted.
- You must restore it before you can assign it to someone.
+ {{ trans('general.'notification_warning') }}
+ {{ trans('general.asset_deleted_warning') }}
@endif
From a63ea560ae8b0fb3f0d7134458ae49d10979b512 Mon Sep 17 00:00:00 2001
From: Godfrey M
Date: Thu, 26 Jan 2023 15:17:08 -0800
Subject: [PATCH 049/159] adds submit button, getting setAttribute error
---
app/Http/Livewire/SlackSettingsForm.php | 1 +
.../livewire/slack-settings-form.blade.php | 11 +-
resources/views/settings/slack.blade.php | 208 +++++++++---------
3 files changed, 111 insertions(+), 109 deletions(-)
diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php
index 9e7670d218..63b9383a93 100644
--- a/app/Http/Livewire/SlackSettingsForm.php
+++ b/app/Http/Livewire/SlackSettingsForm.php
@@ -41,6 +41,7 @@ class SlackSettingsForm extends Component
public function submit()
{
+ dd("we here now");
$this->validate();
diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php
index cd7978f08e..a42a99fd7f 100644
--- a/resources/views/livewire/slack-settings-form.blade.php
+++ b/resources/views/livewire/slack-settings-form.blade.php
@@ -1,5 +1,5 @@
diff --git a/resources/views/settings/slack.blade.php b/resources/views/settings/slack.blade.php
index 6bbd321662..67a3550536 100644
--- a/resources/views/settings/slack.blade.php
+++ b/resources/views/settings/slack.blade.php
@@ -71,15 +71,7 @@
-
@@ -88,129 +80,129 @@
@stop
-@push('js')
-
+{{-- --}}
-@endpush
+{{--@endpush--}}
From 37f5cfa8ce0844edc65cc4e329d8a70a8fc6f845 Mon Sep 17 00:00:00 2001
From: snipe
Date: Thu, 26 Jan 2023 17:02:53 -0800
Subject: [PATCH 050/159] Added edit button for fieldsets
Signed-off-by: snipe
---
resources/views/custom_fields/index.blade.php | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/resources/views/custom_fields/index.blade.php b/resources/views/custom_fields/index.blade.php
index 08c43cdd7b..d2435d7db5 100644
--- a/resources/views/custom_fields/index.blade.php
+++ b/resources/views/custom_fields/index.blade.php
@@ -69,8 +69,18 @@
@endforeach
+
+
+
+ @can('update', $fieldset)
+
+
+ {{ trans('button.edit') }}
+
+ @endcan
+
@can('delete', $fieldset)
- {{ Form::open(['route' => array('fieldsets.destroy', $fieldset->id), 'method' => 'delete']) }}
+ {{ Form::open(['route' => array('fieldsets.destroy', $fieldset->id), 'method' => 'delete','style' => 'display:inline-block']) }}
@if($fieldset->models->count() > 0)
@else
@@ -78,6 +88,7 @@
@endif
{{ Form::close() }}
@endcan
+
@endforeach
From a16604285c5d8460f559af3c5eadbffa433c06cd Mon Sep 17 00:00:00 2001
From: snipe
Date: Thu, 26 Jan 2023 17:03:07 -0800
Subject: [PATCH 051/159] Normalize the fieldset form
Signed-off-by: snipe
---
.../custom_fields/fieldsets/edit.blade.php | 58 ++++---------------
1 file changed, 11 insertions(+), 47 deletions(-)
diff --git a/resources/views/custom_fields/fieldsets/edit.blade.php b/resources/views/custom_fields/fieldsets/edit.blade.php
index 04885891ec..a43769255d 100644
--- a/resources/views/custom_fields/fieldsets/edit.blade.php
+++ b/resources/views/custom_fields/fieldsets/edit.blade.php
@@ -1,49 +1,13 @@
-@extends('layouts.default')
+@extends('layouts/edit-form', [
+ 'createText' => trans('admin/custom_fields/general.create_fieldset') ,
+ 'updateText' => trans('admin/custom_fields/general.update_fieldset'),
+ 'formAction' => (isset($item->id)) ? route('fieldsets.update', ['fieldset' => $item->id]) : route('fieldsets.store'),
+])
+
+@section('inputFields')
+
+ @include ('partials.forms.edit.name', ['translated_name' => trans('general.name')])
+
+
-{{-- Page title --}}
-@section('title')
- {{ trans('admin/custom_fields/general.create_fieldset') }}
-@parent
-@stop
-
-@section('header_right')
-
- {{ trans('general.back') }}
-@stop
-
-
-{{-- Page content --}}
-@section('content')
-
-
-
- {{ Form::open(['route' => 'fieldsets.store', 'class'=>'form-horizontal']) }}
-
-
- {{ Form::close() }}
-
-
-
{{ trans('admin/custom_fields/general.about_fieldsets_title') }}
- {{ trans('admin/custom_fields/general.about_fieldsets_text') }}
-
-
@stop
From 583a0412fedba46f36598c5ddc65eb461d55ccc8 Mon Sep 17 00:00:00 2001
From: snipe
Date: Thu, 26 Jan 2023 17:03:23 -0800
Subject: [PATCH 052/159] Added edit fieldsets translations
Signed-off-by: snipe
---
.../Controllers/CustomFieldsetsController.php | 61 +++++++++++++------
.../lang/en/admin/custom_fields/general.php | 3 +
2 files changed, 44 insertions(+), 20 deletions(-)
diff --git a/app/Http/Controllers/CustomFieldsetsController.php b/app/Http/Controllers/CustomFieldsetsController.php
index c7c00a7bd2..bee0f38e27 100644
--- a/app/Http/Controllers/CustomFieldsetsController.php
+++ b/app/Http/Controllers/CustomFieldsetsController.php
@@ -75,9 +75,9 @@ class CustomFieldsetsController extends Controller
*/
public function create()
{
- $this->authorize('create', CustomFieldset::class);
+ $this->authorize('create', CustomField::class);
- return view('custom_fields.fieldsets.edit');
+ return view('custom_fields.fieldsets.edit')->with('item', new CustomFieldset());
}
/**
@@ -91,7 +91,7 @@ class CustomFieldsetsController extends Controller
*/
public function store(Request $request)
{
- $this->authorize('create', CustomFieldset::class);
+ $this->authorize('create', CustomField::class);
$cfset = new CustomFieldset([
'name' => e($request->get('name')),
@@ -110,31 +110,52 @@ class CustomFieldsetsController extends Controller
}
/**
- * What the actual fuck, Brady?
+ * Presents edit form for fieldset
*
- * @todo Uhh, build this?
- * @author [Brady Wetherington] []
+ * @author [A. Gianotto] []
* @param int $id
- * @since [v1.8]
- * @return Fuckall
+ * @since [v6.0.14]
+ * @return Redirect
+ * @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function edit($id)
{
- //
+ $this->authorize('create', CustomField::class);
+
+ if ($fieldset = CustomFieldset::find($id)) {
+ return view('custom_fields.fieldsets.edit')->with('item', $fieldset);
+ }
+
+ return redirect()->route('fields.index')->with('error', trans('admin/custom_fields/general.fieldset_does_not_exist', ['id' => $id]));
+
}
/**
- * GET IN THE SEA BRADY.
+ * Saves updated fieldset data
*
- * @todo Uhh, build this too?
- * @author [Brady Wetherington] []
+ * @author [A. Gianotto] []
* @param int $id
- * @since [v1.8]
- * @return Fuckall
+ * @since [v6.0.14]
+ * @return Redirect
+ * @throws \Illuminate\Auth\Access\AuthorizationException
*/
- public function update($id)
+ public function update(Request $request, $id)
{
- //
+ $this->authorize('create', CustomField::class);
+
+ if ($fieldset = CustomFieldset::find($id)) {
+
+ $fieldset->name = $request->input('name');
+
+ if ($fieldset->save()) {
+ return redirect()->route('fields.index')->with('success', trans('admin/custom_fields/general.fieldset_updated'));
+ }
+
+ return redirect()->back()->withInput()->withErrors($fieldset->getErrors());
+
+ }
+
+ return redirect()->route('fields.index')->with('error', trans('admin/custom_fields/general.fieldset_does_not_exist', ['id' => $id]));
}
/**
@@ -148,7 +169,7 @@ class CustomFieldsetsController extends Controller
*/
public function destroy($id)
{
- $fieldset = CustomFieldset::find($id);
+ $fieldset = CustomField::find($id);
$this->authorize('delete', $fieldset);
@@ -175,7 +196,7 @@ class CustomFieldsetsController extends Controller
*/
public function associate(Request $request, $id)
{
- $set = CustomFieldset::find($id);
+ $set = CustomField::find($id);
$this->authorize('update', $set);
@@ -202,7 +223,7 @@ class CustomFieldsetsController extends Controller
*/
public function makeFieldRequired($fieldset_id, $field_id)
{
- $this->authorize('update', CustomFieldset::class);
+ $this->authorize('update', CustomField::class);
$field = CustomField::findOrFail($field_id);
$fieldset = CustomFieldset::findOrFail($fieldset_id);
$fields[$field->id] = ['required' => 1];
@@ -220,7 +241,7 @@ class CustomFieldsetsController extends Controller
*/
public function makeFieldOptional($fieldset_id, $field_id)
{
- $this->authorize('update', CustomFieldset::class);
+ $this->authorize('update', CustomField::class);
$field = CustomField::findOrFail($field_id);
$fieldset = CustomFieldset::findOrFail($fieldset_id);
$fields[$field->id] = ['required' => 0];
diff --git a/resources/lang/en/admin/custom_fields/general.php b/resources/lang/en/admin/custom_fields/general.php
index 92bf240a76..9dae380aa5 100644
--- a/resources/lang/en/admin/custom_fields/general.php
+++ b/resources/lang/en/admin/custom_fields/general.php
@@ -27,6 +27,9 @@ return [
'used_by_models' => 'Used By Models',
'order' => 'Order',
'create_fieldset' => 'New Fieldset',
+ 'update_fieldset' => 'Update Fieldset',
+ 'fieldset_does_not_exist' => 'Fieldset :id does not exist',
+ 'fieldset_updated' => 'Fieldset updated',
'create_fieldset_title' => 'Create a new fieldset',
'create_field' => 'New Custom Field',
'create_field_title' => 'Create a new custom field',
From 22b0b9b090b0fc85fa1209cd6fa3a978666383d4 Mon Sep 17 00:00:00 2001
From: snipe
Date: Thu, 26 Jan 2023 17:05:41 -0800
Subject: [PATCH 053/159] Fixed gates on fieldsets
Signed-off-by: snipe
---
.../Controllers/Api/CustomFieldsetsController.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/Http/Controllers/Api/CustomFieldsetsController.php b/app/Http/Controllers/Api/CustomFieldsetsController.php
index 18da1b67c2..27da7733cd 100644
--- a/app/Http/Controllers/Api/CustomFieldsetsController.php
+++ b/app/Http/Controllers/Api/CustomFieldsetsController.php
@@ -33,7 +33,7 @@ class CustomFieldsetsController extends Controller
*/
public function index()
{
- $this->authorize('index', CustomFieldset::class);
+ $this->authorize('index', CustomField::class);
$fieldsets = CustomFieldset::withCount('fields as fields_count', 'models as models_count')->get();
return (new CustomFieldsetsTransformer)->transformCustomFieldsets($fieldsets, $fieldsets->count());
@@ -49,7 +49,7 @@ class CustomFieldsetsController extends Controller
*/
public function show($id)
{
- $this->authorize('view', CustomFieldset::class);
+ $this->authorize('view', CustomField::class);
if ($fieldset = CustomFieldset::find($id)) {
return (new CustomFieldsetsTransformer)->transformCustomFieldset($fieldset);
}
@@ -68,7 +68,7 @@ class CustomFieldsetsController extends Controller
*/
public function update(Request $request, $id)
{
- $this->authorize('update', CustomFieldset::class);
+ $this->authorize('update', CustomField::class);
$fieldset = CustomFieldset::findOrFail($id);
$fieldset->fill($request->all());
@@ -89,7 +89,7 @@ class CustomFieldsetsController extends Controller
*/
public function store(Request $request)
{
- $this->authorize('create', CustomFieldset::class);
+ $this->authorize('create', CustomField::class);
$fieldset = new CustomFieldset;
$fieldset->fill($request->all());
@@ -109,7 +109,7 @@ class CustomFieldsetsController extends Controller
*/
public function destroy($id)
{
- $this->authorize('delete', CustomFieldset::class);
+ $this->authorize('delete', CustomField::class);
$fieldset = CustomFieldset::findOrFail($id);
$modelsCount = $fieldset->models->count();
@@ -136,7 +136,7 @@ class CustomFieldsetsController extends Controller
*/
public function fields($id)
{
- $this->authorize('view', CustomFieldset::class);
+ $this->authorize('view', CustomField::class);
$set = CustomFieldset::findOrFail($id);
$fields = $set->fields;
@@ -153,7 +153,7 @@ class CustomFieldsetsController extends Controller
*/
public function fieldsWithDefaultValues($fieldsetId, $modelId)
{
- $this->authorize('view', CustomFieldset::class);
+ $this->authorize('view', CustomField::class);
$set = CustomFieldset::findOrFail($fieldsetId);
From c2854f1bcb79a9f0fbe8342a4993e9c375b16f57 Mon Sep 17 00:00:00 2001
From: Ben Periton <104396+benperiton@users.noreply.github.com>
Date: Tue, 18 Oct 2022 08:00:36 +0100
Subject: [PATCH 054/159] Update database.php
Although Postgres is not officially supported, it does seem to work ok, but to help a little bit with the Docker image, this is non-breaking change but allows the env file to specify the pgsql connection port
---
config/database.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/config/database.php b/config/database.php
index 9d94454db2..36440b2127 100755
--- a/config/database.php
+++ b/config/database.php
@@ -102,6 +102,7 @@ return [
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
+ 'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
From ccc7b78f623678ada9ef37a5ec34c45f76521b3c Mon Sep 17 00:00:00 2001
From: Ivan Nieto Vivanco
Date: Mon, 30 Jan 2023 15:11:41 -0600
Subject: [PATCH 055/159] Store the acceptance dates with format YYY-mm-dd
---
app/Http/Controllers/Account/AcceptanceController.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php
index 59c8f88430..726e164ba8 100644
--- a/app/Http/Controllers/Account/AcceptanceController.php
+++ b/app/Http/Controllers/Account/AcceptanceController.php
@@ -222,8 +222,8 @@ class AcceptanceController extends Controller
'item_model' => $display_model,
'item_serial' => $item->serial,
'eula' => $item->getEula(),
- 'check_out_date' => Carbon::parse($acceptance->created_at)->format($branding_settings->date_display_format),
- 'accepted_date' => Carbon::parse($acceptance->accepted_at)->format($branding_settings->date_display_format),
+ 'check_out_date' => Carbon::parse($acceptance->created_at)->format('Y-m-d'),
+ 'accepted_date' => Carbon::parse($acceptance->accepted_at)->format('Y-m-d'),
'assigned_to' => $assigned_to,
'company_name' => $branding_settings->site_name,
'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null,
@@ -273,7 +273,7 @@ class AcceptanceController extends Controller
'item_tag' => $item->asset_tag,
'item_model' => $display_model,
'item_serial' => $item->serial,
- 'declined_date' => Carbon::parse($acceptance->accepted_at)->format($branding_settings->date_display_format),
+ 'declined_date' => Carbon::parse($acceptance->declined_at)->format('Y-m-d'),
'assigned_to' => $assigned_to,
'company_name' => $branding_settings->site_name,
'date_settings' => $branding_settings->date_display_format,
From 214a1af61a804ccda8f490e7fa53cf3efadceeee Mon Sep 17 00:00:00 2001
From: akemidx
Date: Mon, 30 Jan 2023 16:54:23 -0500
Subject: [PATCH 056/159] apostrophe updates
---
resources/views/hardware/checkin.blade.php | 2 +-
resources/views/hardware/checkout.blade.php | 2 +-
resources/views/hardware/quickscan-checkin.blade.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php
index 7f9087ae3d..f7fe067c8a 100755
--- a/resources/views/hardware/checkin.blade.php
+++ b/resources/views/hardware/checkin.blade.php
@@ -47,7 +47,7 @@
@else
{{ trans('admin/hardware/general.model_invalid')}}
- {{ trans(admin/hardware/general.model_invalid_fix')}}
+ {{ trans('admin/hardware/general.model_invalid_fix')}}
@endif
diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php
index bdb03d3147..31dff70eaa 100755
--- a/resources/views/hardware/checkout.blade.php
+++ b/resources/views/hardware/checkout.blade.php
@@ -37,7 +37,7 @@
@else
{{ trans('admin/hardware/general.model_invalid')}}
- {{ trans(admin/hardware/general.model_invalid_fix')}}
+ {{ trans('admin/hardware/general.model_invalid_fix')}}
@endif
diff --git a/resources/views/hardware/quickscan-checkin.blade.php b/resources/views/hardware/quickscan-checkin.blade.php
index 8884821809..677e0c0f15 100644
--- a/resources/views/hardware/quickscan-checkin.blade.php
+++ b/resources/views/hardware/quickscan-checkin.blade.php
@@ -86,7 +86,7 @@
- {{ trans(general.processing') }}...
+ {{ trans('general.processing') }}...
From fc044528b89249efc4852fb8ec992bfa702b7f1c Mon Sep 17 00:00:00 2001
From: Godfrey M
Date: Mon, 30 Jan 2023 16:10:02 -0800
Subject: [PATCH 057/159] validation is working, success message appears,
database is not updating
---
app/Http/Livewire/SlackSettingsForm.php | 11 +-
app/Models/Setting.php | 3 +
.../livewire/slack-settings-form.blade.php | 138 ++++++++------
resources/views/settings/slack.blade.php | 175 +-----------------
4 files changed, 95 insertions(+), 232 deletions(-)
diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php
index 63b9383a93..ddc38f36b3 100644
--- a/app/Http/Livewire/SlackSettingsForm.php
+++ b/app/Http/Livewire/SlackSettingsForm.php
@@ -10,6 +10,7 @@ class SlackSettingsForm extends Component
public $slack_endpoint;
public $slack_channel;
public $slack_botname;
+ public $successMessage;
public Setting $setting;
@@ -41,13 +42,17 @@ class SlackSettingsForm extends Component
public function submit()
{
- dd("we here now");
-
- $this->validate();
+ $this->validate([
+ 'slack_endpoint' => 'url|required_with:slack_channel|starts_with:https://hooks.slack.com/|nullable',
+ 'slack_channel' => 'required_with:slack_endpoint|starts_with:#|nullable',
+ 'slack_botname' => 'string|nullable',
+ ]);
$this->setting->slack_endpoint = $this->slack_endpoint;
$this->setting->slack_channel = $this->slack_channel;
$this->setting->slack_botname = $this->slack_botname;
+ $this->successMessage= trans('admin/settings/message.update.success');
+
}
}
diff --git a/app/Models/Setting.php b/app/Models/Setting.php
index f2a4184178..8289260647 100755
--- a/app/Models/Setting.php
+++ b/app/Models/Setting.php
@@ -83,6 +83,9 @@ class Setting extends Model
'email_domain',
'email_format',
'username_format',
+ 'slack_endpoint',
+ 'slack_channel',
+ 'slack_botname',
];
/**
diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php
index a42a99fd7f..5d41ff2a6f 100644
--- a/resources/views/livewire/slack-settings-form.blade.php
+++ b/resources/views/livewire/slack-settings-form.blade.php
@@ -1,65 +1,85 @@