Merge pull request #261 from henrywhitaker3/alpha

Minor updates
This commit is contained in:
Henry Whitaker
2020-08-15 16:49:57 +01:00
committed by GitHub
24 changed files with 568 additions and 69 deletions

View File

@@ -3,8 +3,6 @@ name: Dev
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
jobs:
laravel-tests:
@@ -17,19 +15,28 @@ jobs:
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Generate JWT key
run: php artisan jwt:secret
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Generate key
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan key:generate
- name: Generate JWT key
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan jwt:secret
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Download Speedtest binary
run: wget https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
- name: Accept EULA
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan speedtest:eula
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:

45
.github/workflows/laravel-pr.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: PR
on:
pull_request:
branches: [ master, dev, alpha ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Generate key
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan key:generate
- name: Generate JWT key
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan jwt:secret
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Download Speedtest binary
run: wget https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
- name: Accept EULA
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan speedtest:eula
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit

View File

@@ -3,8 +3,6 @@ name: Stable
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
laravel-tests:
@@ -17,19 +15,28 @@ jobs:
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Generate JWT key
run: php artisan jwt:secret
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Generate key
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan key:generate
- name: Generate JWT key
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan jwt:secret
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Download Speedtest binary
run: wget https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
- name: Accept EULA
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan speedtest:eula
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:

View File

@@ -1,6 +1,6 @@
# Speedtest Tracker
[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.8.0-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE)
[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.8.1-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE)
This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses the [Ookla's speedtest cli](https://www.speedtest.net/apps/cli) package to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results.

View File

@@ -28,7 +28,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->job(new SpeedtestJob)->cron(SettingsHelper::get('schedule')['value']);
$schedule->job(new SpeedtestJob(true, config('integrations')))->cron(SettingsHelper::get('schedule')['value']);
$schedule->command('speedtest:overview')->cron('0 ' . SettingsHelper::get('speedtest_overview_time')->value . ' * * *');
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class HealthchecksFacade extends Facade
{
protected static function getFacadeAccessor()
{
return 'healthcheck';
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Http\Controllers;
use App\Helpers\SettingsHelper;
use Exception;
use Healthcheck;
use Henrywhitaker3\Healthchecks\Exceptions\HealthchecksUuidNotFoundException;
use Henrywhitaker3\Healthchecks\Healthchecks;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Ramsey\Uuid\Exception\InvalidUuidStringException;
class IntegrationsController extends Controller
{
/**
* Test the healthchecks config
*
* @return JsonResponse
*/
public function testHealthchecks(String $method)
{
$methodResp = 'test healthchecks \'' . $method . '\' endpoint';
try {
$hc = new Healthchecks(config('integrations.healthchecks_uuid'));
if($method == 'success') {
$hc->success();
}
if($method == 'fail') {
$hc->fail();
}
if($method == 'start') {
$hc->start();
}
return response()->json([
'method' => $methodResp,
'success' => true
], 200);
} catch(InvalidUuidStringException $e) {
return response()->json([
'method' => $methodResp,
'success' => false,
'error' => 'Invalid UUID'
], 422);
} catch(HealthchecksUuidNotFoundException $e) {
return response()->json([
'method' => $methodResp,
'success' => false,
'error' => 'UUID not found'
], 404);
} catch(Exception $e) {
return response()->json([
'method' => $methodResp,
'success' => false,
'error' => $e->getMessage()
], 422);
}
}
/**
* Trigger a test of all notification agents
*
* @return JsonResponse
*/
public function testNotification()
{
SettingsHelper::testNotification();
return response()->json([
'method' => 'test notificaiton agents'
], 200);
}
}

View File

@@ -135,19 +135,4 @@ class SettingsController extends Controller
{
return SettingsHelper::getConfig();
}
/**
* Trigger a test of all notification agents
*
* @return JsonResponse
*/
public function testNotification()
{
SettingsHelper::testNotification();
return response()->json([
'method' => 'test notificaiton agents'
], 200);
}
}

View File

@@ -136,7 +136,7 @@ class SpeedtestController extends Controller
public function run()
{
try {
$data = SpeedtestJob::dispatch(false);
$data = SpeedtestJob::dispatch(false, config('integrations'));
return response()->json([
'method' => 'run speedtest',
'data' => 'a new speedtest has been added to the queue'

View File

@@ -7,6 +7,7 @@ use App\Events\SpeedtestFailedEvent;
use App\Helpers\SettingsHelper;
use App\Helpers\SpeedtestHelper;
use Exception;
use Healthcheck;
use Henrywhitaker3\Healthchecks\Healthchecks;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -19,16 +20,29 @@ class SpeedtestJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Scheduled bool
*
* @var bool
*/
private $scheduled;
/**
* Integrations config array
*
* @var array
*/
private $config;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($scheduled = true)
public function __construct($scheduled = true, $config = [])
{
$this->scheduled = $scheduled;
$this->config = $config;
}
/**
@@ -38,38 +52,49 @@ class SpeedtestJob implements ShouldQueue
*/
public function handle()
{
$healthchecksEnabled = (bool)SettingsHelper::get('healthchecks_enabled')->value;
$healthchecksUuid = SettingsHelper::get('healthchecks_uuid')->value;
if($healthchecksEnabled === true) {
try {
$hc = new Healthchecks($healthchecksUuid);
$hc->start();
} catch(Exception $e) {
Log::error($e->getMessage());
}
if($this->config['healthchecks_enabled'] === true) {
$this->healthcheck('start');
}
$output = SpeedtestHelper::output();
$speedtest = SpeedtestHelper::runSpeedtest($output, $this->scheduled);
if($speedtest == false) {
if(isset($hc)) {
try {
$hc->fail();
} catch(Exception $e) {
//
}
if($this->config['healthchecks_enabled'] === true) {
$this->healthcheck('fail');
}
event(new SpeedtestFailedEvent());
} else {
if(isset($hc)) {
try {
$hc->success();
} catch(Exception $e) {
//
}
if($this->config['healthchecks_enabled'] === true) {
$this->healthcheck('success');
}
event(new SpeedtestCompleteEvent($speedtest));
}
return $speedtest;
}
/**
* Wrapper to reduce duplication of try/catch for hc
*
* @param String $method
* @return void
*/
private function healthcheck(String $method)
{
try {
if($method === 'start') {
Healthcheck::start();
}
if($method === 'success') {
Healthcheck::success();
}
if($method === 'fail') {
Healthcheck::fail();
}
} catch(Exception $e) {
Log::error($e->getMessage());
}
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Providers;
use App\Helpers\SettingsHelper;
use Exception;
use Henrywhitaker3\Healthchecks\Healthchecks;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
use Ramsey\Uuid\Exception\InvalidUuidStringException;
use Schema;
/**
* This class updates the integrations.php config with the relevant values
* from the databse.
*/
class IntegrationsServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
if(Schema::hasTable('settings')) {
$settings = [
'healthchecks_enabled' => (bool)SettingsHelper::get('healthchecks_enabled')->value,
'healthchecks_uuid' => SettingsHelper::get('healthchecks_uuid')->value,
'slack_webhook' => SettingsHelper::get('slack_webhook')->value,
'telegram_bot_token' => SettingsHelper::get('telegram_bot_token')->value,
'telegram_chat_id' => SettingsHelper::get('telegram_chat_id')->value,
];
foreach($settings as $key => $value) {
$key = 'integrations.' . $key;
if($value === "") {
$value = null;
}
config()->set([ $key => $value ]);
}
if($settings['healthchecks_enabled']) {
try {
App::bind('healthcheck', function() use ($settings) {
return new Healthchecks($settings['healthchecks_uuid']);
});
} catch(InvalidUuidStringException $e) {
Log::error('Invalid healthchecks UUID');
} catch(Exception $e) {
Log::error($e->getMessage());
}
}
}
}
}

View File

@@ -1,4 +1,18 @@
{
"1.8.1": [
{
"description": "Added healthchecks.io test buttons.",
"link": ""
},
{
"description": "Added close buttons to modals.",
"link": ""
},
{
"description": "Back-end config handling changes.",
"link": ""
}
],
"1.8.0": [
{
"description": "Added healthchecks.io integration.",

View File

@@ -23,6 +23,7 @@
"tymon/jwt-auth": "^1.0"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.8",
"facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",

131
composer.lock generated
View File

@@ -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": "837c814b9f3c208c35d3e28d611623fa",
"content-hash": "94fffe1900e25fd9ab781c8dd9ebab35",
"packages": [
{
"name": "asm89/stack-cors",
@@ -5375,6 +5375,135 @@
}
],
"packages-dev": [
{
"name": "barryvdh/laravel-ide-helper",
"version": "v2.8.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-ide-helper.git",
"reference": "ba95d18ef55c91295250ae8b7bfa73d8fb866b9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/ba95d18ef55c91295250ae8b7bfa73d8fb866b9b",
"reference": "ba95d18ef55c91295250ae8b7bfa73d8fb866b9b",
"shasum": ""
},
"require": {
"barryvdh/reflection-docblock": "^2.0.6",
"composer/composer": "^1.6 || ^2.0@dev",
"doctrine/dbal": "~2.3",
"illuminate/console": "^5.5 || ^6 || ^7",
"illuminate/filesystem": "^5.5 || ^6 || ^7",
"illuminate/support": "^5.5 || ^6 || ^7",
"php": ">=7.2",
"phpdocumentor/type-resolver": "^1.1.0"
},
"require-dev": {
"illuminate/config": "^5.5 || ^6 || ^7",
"illuminate/view": "^5.5 || ^6 || ^7",
"mockery/mockery": "^1.3",
"orchestra/testbench": "^3.5 || ^4 || ^5",
"phpro/grumphp": "^0.19.0",
"spatie/phpunit-snapshot-assertions": "^1.4 || ^2.2 || ^3",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^3.12"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
},
"laravel": {
"providers": [
"Barryvdh\\LaravelIdeHelper\\IdeHelperServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Barryvdh\\LaravelIdeHelper\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.",
"keywords": [
"autocomplete",
"codeintel",
"helper",
"ide",
"laravel",
"netbeans",
"phpdoc",
"phpstorm",
"sublime"
],
"funding": [
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2020-08-10T08:22:48+00:00"
},
{
"name": "barryvdh/reflection-docblock",
"version": "v2.0.6",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/ReflectionDocBlock.git",
"reference": "6b69015d83d3daf9004a71a89f26e27d27ef6a16"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/ReflectionDocBlock/zipball/6b69015d83d3daf9004a71a89f26e27d27ef6a16",
"reference": "6b69015d83d3daf9004a71a89f26e27d27ef6a16",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0,<4.5"
},
"suggest": {
"dflydev/markdown": "~1.0",
"erusev/parsedown": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Barryvdh": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "mike.vanriel@naenius.com"
}
],
"time": "2018-12-13T10:34:14+00:00"
},
{
"name": "composer/ca-bundle",
"version": "1.2.7",

View File

@@ -178,6 +178,11 @@ return [
App\Providers\RouteServiceProvider::class,
App\Providers\UpdaterServiceProvider::class,
/*
* Custom providers...
*/
App\Providers\IntegrationsServiceProvider::class,
],
/*
@@ -230,6 +235,7 @@ return [
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Updater' => App\Facades\UpdaterFacade::class,
'Healthcheck' => App\Facades\HealthchecksFacade::class,
],
];

59
config/integrations.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Healthchecks enabled
|--------------------------------------------------------------------------
|
| This option defines whether healthchecks integrations are enabled
|
*/
'healthchecks_enabled' => false,
/*
|--------------------------------------------------------------------------
| Healthchecks UUID
|--------------------------------------------------------------------------
|
| This option defines the UUID for healthchecks
|
*/
'healthchecks_uuid' => null,
/*
|--------------------------------------------------------------------------
| Slack webhook
|--------------------------------------------------------------------------
|
| This option defines the slack webhook url
|
*/
'slack_webhook' => null,
/*
|--------------------------------------------------------------------------
| Telegram bot token
|--------------------------------------------------------------------------
|
| This option defines the telegram bot token
|
*/
'telegram_bot_token' => null,
/*
|--------------------------------------------------------------------------
| Telegram chat id
|--------------------------------------------------------------------------
|
| This option defines the telegram chat id
|
*/
'telegram_chat_id' => null,
];

View File

@@ -7,7 +7,7 @@ return [
|--------------------------------------------------------------------------
*/
'version' => '1.8.0',
'version' => '1.8.1',
/*
|--------------------------------------------------------------------------

6
package-lock.json generated
View File

@@ -6357,9 +6357,9 @@
}
},
"lodash": {
"version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ=="
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
},
"lodash-es": {
"version": "4.17.15",

View File

@@ -16,7 +16,7 @@
"cross-env": "^7.0",
"jquery": "^3.5",
"laravel-mix": "^5.0.1",
"lodash": "^4.17.19",
"lodash": "^4.17.20",
"popper.js": "^1.12",
"react": "^16.2.0",
"react-dom": "^16.2.0",

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -62,7 +62,7 @@ export default class TableRow extends Component {
<td>
<span onClick={this.toggleShow} className="ti-arrow-top-right mouse"></span>
<Modal show={show} onHide={this.toggleShow}>
<Modal.Header>
<Modal.Header closeButton>
<Modal.Title>More info</Modal.Title>
</Modal.Header>
<Modal.Body className="text-center">

View File

@@ -101,7 +101,7 @@ export default class SettingWithModal extends Component {
<>
<SettingsModalCard title={title} description={description} toggleShow={this.toggleShow} />
<Modal show={show} onHide={this.toggleShow}>
<Modal.Header>
<Modal.Header closeButton>
<Modal.Title>{title}</Modal.Title>
</Modal.Header>
<Modal.Body>
@@ -248,6 +248,35 @@ export default class SettingWithModal extends Component {
}
</Row>
)
} else if(e.type == 'group') {
return (
<div key={e.obj.id}>
<Row>
<Col md={md} sm={sm}>
<p className="mb-0">{name}</p>
</Col>
{e.description == null &&
<Col md={md} sm={sm}>
<p>{e.obj.description}</p>
</Col>
}
</Row>
<Row>
<Col sm={{ span: 12 }}>
{e.children.map((ee,ii) => {
if(ee.type == 'button-get') {
return (
<Button key={ii} variant={ee.btnType} className={'mr-2 mb-3'} onClick={() => { Axios.get(ee.url)
.then((resp) => { toast.success('Healthcheck sent') })
.catch((resp) => { resp = resp.response; toast.error(resp.data.error) })
}} >{ee.text}</Button>
)
}
})}
</Col>
</Row>
</div>
)
}
})}
<Button variant="primary" type="submit" onClick={this.update} >Save</Button>

View File

@@ -159,7 +159,7 @@ export default class Settings extends Component {
]} />
</Col>
<Col lg={{ span: 4 }} md={{ span: 6 }} sm={{ span: 12 }}>
<SettingWithModal title="healthchecks.io settings" description="Control settings for healthchecks.io" autoClose={true} settings={[
<SettingWithModal title="healthchecks.io settings" description="Control settings for healthchecks.io" autoClose={false} settings={[
{
obj: e.healthchecks_uuid,
type: 'text'
@@ -167,7 +167,38 @@ export default class Settings extends Component {
{
obj: e.healthchecks_enabled,
type: 'checkbox'
}
},
{
obj: {
id: (Math.floor(Math.random() * 10000) + 1),
name: "Test healthchecks (after saving)",
description: ""
},
type: 'group',
children: [
{
type: 'button-get',
url: 'api/settings/test-healthchecks/start',
btnType: 'outline-success',
text: 'Start',
inline: true,
},
{
type: 'button-get',
url: 'api/settings/test-healthchecks/success',
btnType: 'success',
text: 'Success',
inline: true,
},
{
type: 'button-get',
url: 'api/settings/test-healthchecks/fail',
btnType: 'danger',
text: 'Fail',
inline: true,
},
]
},
]} />
</Col>
<Col lg={{ span: 4 }} md={{ span: 6 }} sm={{ span: 12 }}>

View File

@@ -70,7 +70,9 @@ Route::group([
], function () {
Route::get('/config', 'SettingsController@config')
->name('settings.config');
Route::get('/test-notification', 'SettingsController@testNotification')
Route::get('/test-notification', 'IntegrationsController@testNotification')
->name('settings.test_notification');
Route::get('/test-healthchecks/{method}', 'IntegrationsController@testHealthchecks')
->name('settings.test_notification');
Route::get('/', 'SettingsController@index')
->name('settings.index');