Skip to content

Commit

Permalink
fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nuraeil committed Dec 14, 2021
2 parents d397288 + 4397a12 commit 484b996
Show file tree
Hide file tree
Showing 77 changed files with 3,627 additions and 4,516 deletions.
105 changes: 105 additions & 0 deletions .env.dusk.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# --------------------------------------------
# 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_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
# --------------------------------------------
APP_LOG=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

50 changes: 7 additions & 43 deletions .env.testing-ci
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
# --------------------------------------------
# REQUIRED: BASIC APP SETTINGS
# --------------------------------------------
APP_ENV=testing-ci
APP_ENV='testing-ci'
APP_DEBUG=false
APP_KEY=ChangeMe
APP_URL=http://localhost:8000
APP_KEY='base64:glJpcM7BYwWiBggp3SQ/+NlRkqsBQMaGEOjemXqJzOU='
APP_URL='http://localhost:8000'
APP_TIMEZONE='US/Pacific'
APP_LOCALE=en
FILESYSTEM_DISK=local

# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql
DB_CONNECTION=sqlite
DB_HOST=localhost
DB_DATABASE=snipeit_unit
DB_DATABASE='sqlite_testing'
DB_USERNAME=root
DB_PASSWORD=null

# --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
# --------------------------------------------
MAIL_DRIVER=log
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=YOURUSERNAME
MAIL_PASSWORD=YOURPASSWORD
MAIL_ENCRYPTION=null
MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME=Snipe-IT


# --------------------------------------------
# REQUIRED: IMAGE LIBRARY
Expand All @@ -37,37 +31,7 @@ MAIL_FROM_NAME=Snipe-IT
IMAGE_LIB=gd


# --------------------------------------------
# OPTIONAL: AWS S3 SETTINGS
# --------------------------------------------
AWS_SECRET_ACCESS_KEY=null
AWS_ACCESS_KEY_ID=null
AWS_DEFAULT_REGION=null
AWS_BUCKET=null
AWS_BUCKET_ROOT=null
AWS_URL=null


# --------------------------------------------
# OPTIONAL: CACHE SETTINGS
# --------------------------------------------
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync


# --------------------------------------------
# OPTIONAL: SESSION SETTINGS
# --------------------------------------------
SESSION_LIFETIME=12000
EXPIRE_ON_CLOSE=false
ENCRYPT=false
COOKIE_NAME=snipeittest_session
COOKIE_DOMAIN=null
SECURE_COOKIES=false


# --------------------------------------------
# OPTIONAL: APP LOG FORMAT
# --------------------------------------------
APP_LOG=single
APP_LOG=single
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public function index(Request $request, $audit = null)
}

$assets = Company::scopeCompanyables(Asset::select('assets.*'), 'company_id', 'assets')
->with('location', 'assetstatus', 'assetlog', 'company', 'defaultLoc','assignedTo',
'model.category', 'model.manufacturer', 'model.fieldset', 'supplier');
->with('location', 'assetstatus', 'company', 'defaultLoc','assignedTo',
'model.category', 'model.manufacturer', 'model.fieldset', 'supplier'); //it's tempting to add assetlogs here, but don't - it blows up update-heavy installations

// These are used by the API to query against specific ID numbers.
// They are also used by the individual searches on detail pages like
Expand Down
43 changes: 25 additions & 18 deletions app/Http/Controllers/Api/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,27 +162,34 @@ public function ldaptestlogin(Request $request, LdapAd $ldap)

public function slacktest(Request $request)
{
$slack = new Client([
'base_url' => e($request->input('slack_endpoint')),
'defaults' => [
'exceptions' => false,
],
]);

$payload = json_encode(
[
'channel' => e($request->input('slack_channel')),
'text' => trans('general.slack_test_msg'),
'username' => e($request->input('slack_botname')),
'icon_emoji' => ':heart:',

// Only attempt the slack request if the validation passes
if ($request->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 = new Client([
'base_url' => e($request->input('slack_endpoint')),
'defaults' => [
'exceptions' => false,
],
]);

try {
$slack->post($request->input('slack_endpoint'), ['body' => $payload]);
$payload = json_encode(
[
'channel' => e($request->input('slack_channel')),
'text' => trans('general.slack_test_msg'),
'username' => e($request->input('slack_botname')),
'icon_emoji' => ':heart:',
]);

return response()->json(['message' => 'Success'], 200);
} catch (\Exception $e) {
return response()->json(['message' => 'Oops! Please check the channel name and webhook endpoint URL. Slack responded with: '.$e->getMessage()], 400);
try {
$slack->post($request->input('slack_endpoint'), ['body' => $payload]);

return response()->json(['message' => 'Success'], 200);
} catch (\Exception $e) {
return response()->json(['message' => 'Oops! Please check the channel name and webhook endpoint URL. Slack responded with: '.$e->getMessage()], 400);
}
}

return response()->json(['message' => 'Something went wrong :( '], 400);
Expand Down
12 changes: 12 additions & 0 deletions app/Http/Controllers/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ public function postCustom(Request $request)
$header[] = trans('general.department');
}

if ($request->filled('title')) {
$header[] = trans('admin/users/table.title');
}

if ($request->filled('status')) {
$header[] = trans('general.status');
}
Expand Down Expand Up @@ -756,6 +760,14 @@ public function postCustom(Request $request)
}
}

if ($request->filled('title')) {
if ($asset->checkedOutToUser()) {
$row[] = ($asset->assignedto) ? $asset->assignedto->jobtitle : '';
} else {
$row[] = ''; // Empty string if unassigned
}
}

if ($request->filled('status')) {
$row[] = ($asset->assetstatus) ? $asset->assetstatus->name.' ('.$asset->present()->statusMeta.')' : '';
}
Expand Down
10 changes: 0 additions & 10 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,6 @@ public function postSlack(Request $request)
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
}

$validatedData = $request->validate([
'slack_channel' => 'regex:/(?<!\w)#\w+/|required_with:slack_endpoint|nullable',
]);

if ($validatedData) {
$setting->slack_endpoint = $request->input('slack_endpoint');
$setting->slack_channel = $request->input('slack_channel');
$setting->slack_botname = $request->input('slack_botname');
}

if ($setting->save()) {
return redirect()->route('settings.index')
->with('success', trans('admin/settings/message.update.success'));
Expand Down
2 changes: 1 addition & 1 deletion app/Listeners/CheckoutableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private function getNotifiables($event)
/**
* Notify Admin users if the settings is activated
*/
if (Setting::getSettings()->admin_cc_email != '') {
if ((Setting::getSettings()) && (Setting::getSettings()->admin_cc_email != '')) {
$notifiables->push(new AdminRecipient());
}

Expand Down
1 change: 1 addition & 0 deletions app/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function declinedCheckout(User $declinedBy, $signature)
'purchase_cost' => 'numeric|nullable',
'next_audit_date' => 'date|nullable',
'last_audit_date' => 'date|nullable',
'supplier_id' => 'exists:suppliers,id|nullable',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Models/AssetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AssetModel extends SnipeModel
'name' => 'required|min:1|max:255',
'model_number' => 'max:255|nullable',
'category_id' => 'required|integer|exists:categories,id',
'manufacturer_id' => 'required|integer|exists:manufacturers,id',
'manufacturer_id' => 'integer|exists:manufacturers,id|nullable',
'eol' => 'integer:min:0|max:240|nullable',
];

Expand Down
4 changes: 2 additions & 2 deletions app/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class Setting extends Model
'admin_cc_email' => 'email|nullable',
'default_currency' => 'required',
'locale' => 'required',
'slack_endpoint' => 'url|required_with:slack_channel|nullable',
'slack_endpoint' => 'url|required_with:slack_channel|nullable|starts_with:https://hooks.slack.com',
'labels_per_page' => 'numeric',
'slack_channel' => 'regex:/^[\#\@]?\w+/|required_with:slack_endpoint|nullable',
'slack_channel' => 'required_with:slack_endpoint|starts_with:#|nullable',
'slack_botname' => 'string|nullable',
'labels_width' => 'numeric',
'labels_height' => 'numeric',
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/CheckoutAssetNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function via()
{
$notifyBy = [];

if (Setting::getSettings()->slack_endpoint != '') {
if ((Setting::getSettings()) && (Setting::getSettings()->slack_endpoint != '')) {
\Log::debug('use slack');
$notifyBy[] = 'slack';
}
Expand Down
2 changes: 1 addition & 1 deletion app/Presenters/AccessoryPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function dataTableLayout()
'searchable' => true,
'sortable' => true,
'title' => trans('general.purchase_cost'),
'footerFormatter' => 'sumFormatter',
'footerFormatter' => 'sumFormatterQuantity',
'class' => 'text-right',
], [
'field' => 'order_number',
Expand Down
2 changes: 1 addition & 1 deletion app/Presenters/ComponentPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function dataTableLayout()
'sortable' => true,
'title' => trans('general.purchase_cost'),
'visible' => true,
'footerFormatter' => 'sumFormatter',
'footerFormatter' => 'sumFormatterQuantity',
'class' => 'text-right',
],
];
Expand Down
2 changes: 1 addition & 1 deletion app/Presenters/ConsumablePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static function dataTableLayout()
'sortable' => true,
'title' => trans('general.purchase_cost'),
'visible' => true,
'footerFormatter' => 'sumFormatter',
'footerFormatter' => 'sumFormatterQuantity',
'class' => 'text-right',
], [
'field' => 'change',
Expand Down
2 changes: 1 addition & 1 deletion app/Presenters/LicensePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function dataTableLayout()
'sortable' => true,
'visible' => false,
'title' => trans('general.purchase_cost'),
'footerFormatter' => 'sumFormatter',
'footerFormatter' => 'sumFormatterQuantity',
'class' => 'text-right',
], [
'field' => 'purchase_order',
Expand Down
9 changes: 8 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ public function boot(UrlGenerator $url)
*/
public function register()
{
// Only load rollbar if there is a rollbar key and the app is in production
if (($this->app->environment('production')) && (config('logging.channels.rollbar.access_token'))) {
$this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class);
}
}

// Only load dusk's service provider if the app is in local or develop mode
if ($this->app->environment(['local', 'develop'])) {
$this->app->register(\Laravel\Dusk\DuskServiceProvider::class);
}

}
}
Loading

0 comments on commit 484b996

Please sign in to comment.