Skip to content

Commit ceeca5c

Browse files
committed
First commit
0 parents  commit ceeca5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+27348
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/node_modules
2+
/public/build
3+
/public/hot
4+
/public/storage
5+
/storage/*.key
6+
/vendor
7+
.env
8+
.env.backup
9+
.env.production
10+
.phpunit.result.cache
11+
Homestead.json
12+
Homestead.yaml
13+
auth.json
14+
npm-debug.log
15+
yarn-error.log
16+
/.fleet
17+
/.idea
18+
/.vscode
19+
.DS_Store

README.md

Whitespace-only changes.

app/Console/InstallCommand.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Waterline\Console;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Str;
7+
8+
class InstallCommand extends Command
9+
{
10+
protected $signature = 'waterline:install';
11+
12+
protected $description = 'Install all of Waterline\'s resources';
13+
14+
public function handle()
15+
{
16+
$this->comment('Publishing Waterline Service Provider...');
17+
$this->callSilent('vendor:publish', ['--tag' => 'waterline-provider']);
18+
19+
$this->comment('Publishing Waterline Assets...');
20+
$this->callSilent('vendor:publish', ['--tag' => 'waterline-assets']);
21+
22+
$this->registerWaterlineServiceProvider();
23+
24+
$this->info('Waterline installed successfully.');
25+
}
26+
27+
/**
28+
* Register the Waterline service provider in the application configuration file.
29+
*
30+
* @return void
31+
*/
32+
protected function registerWaterlineServiceProvider()
33+
{
34+
$namespace = Str::replaceLast('\\', '', $this->laravel->getNamespace());
35+
36+
$appConfig = file_get_contents(config_path('app.php'));
37+
38+
if (Str::contains($appConfig, $namespace.'\\Providers\\WaterlineServiceProvider::class')) {
39+
return;
40+
}
41+
42+
file_put_contents(config_path('app.php'), str_replace(
43+
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL,
44+
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." {$namespace}\Providers\WaterlineServiceProvider::class,".PHP_EOL,
45+
$appConfig
46+
));
47+
48+
file_put_contents(app_path('Providers/WaterlineServiceProvider.php'), str_replace(
49+
"namespace App\Providers;",
50+
"namespace {$namespace}\Providers;",
51+
file_get_contents(app_path('Providers/.php'))
52+
));
53+
}
54+
}

app/Console/PublishCommand.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Waterline\Console;
4+
5+
use Illuminate\Console\Command;
6+
7+
class PublishCommand extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'waterline:publish';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Publish all of Waterline\'s resources';
22+
23+
/**
24+
* Execute the console command.
25+
*
26+
* @return void
27+
*/
28+
public function handle()
29+
{
30+
$this->call('vendor:publish', [
31+
'--tag' => 'waterline-assets',
32+
'--force' => true,
33+
]);
34+
}
35+
}

app/Exceptions/Handler.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of exception types with their corresponding custom log levels.
12+
*
13+
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
14+
*/
15+
protected $levels = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the exception types that are not reported.
21+
*
22+
* @var array<int, class-string<\Throwable>>
23+
*/
24+
protected $dontReport = [
25+
//
26+
];
27+
28+
/**
29+
* A list of the inputs that are never flashed to the session on validation exceptions.
30+
*
31+
* @var array<int, string>
32+
*/
33+
protected $dontFlash = [
34+
'current_password',
35+
'password',
36+
'password_confirmation',
37+
];
38+
39+
/**
40+
* Register the exception handling callbacks for the application.
41+
*
42+
* @return void
43+
*/
44+
public function register()
45+
{
46+
$this->reportable(function (Throwable $e) {
47+
//
48+
});
49+
}
50+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Waterline\Http\Controllers;
4+
5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6+
use Illuminate\Foundation\Bus\DispatchesJobs;
7+
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Routing\Controller as BaseController;
9+
use Waterline\Http\Middleware\Authenticate;
10+
11+
class Controller extends BaseController
12+
{
13+
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
14+
15+
public function __construct()
16+
{
17+
$this->middleware(Authenticate::class);
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Waterline\Http\Controllers;
4+
5+
use Illuminate\Support\Facades\App;
6+
7+
class DashboardController extends Controller
8+
{
9+
public function index() {
10+
return view('waterline::layout', [
11+
'assetsAreCurrent' => true,
12+
'cssFile' => true ? 'app-dark.css' : 'app.css',
13+
'waterlineScriptVariables' => [
14+
'path' => config('waterline.path', 'waterline'),
15+
],
16+
'isDownForMaintenance' => App::isDownForMaintenance(),
17+
]);
18+
}
19+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Waterline\Http\Controllers;
4+
5+
use Illuminate\Support\Facades\DB;
6+
use Workflow\Models\StoredWorkflow;
7+
use Workflow\Models\StoredWorkflowException;
8+
9+
class DashboardStatsController extends Controller
10+
{
11+
public function index() {
12+
13+
$flowsPastHour = StoredWorkflow::where('updated_at', '>=', now()->subHour())
14+
->count();
15+
16+
$exceptionsPastHour = StoredWorkflowException::where('created_at', '>=', now()->subHour())
17+
->count();
18+
19+
$failedFlowsPastWeek = StoredWorkflow::where('status', 'failed')
20+
->where('updated_at', '>=', now()->subDays(7))
21+
->count();
22+
23+
$maxWaitTimeWorkflow = StoredWorkflow::where('status', 'pending')
24+
->orderBy('updated_at')
25+
->first();
26+
27+
$maxDurationWorkflow = StoredWorkflow::select('*')
28+
->addSelect(DB::raw('TIMEDIFF(created_at, updated_at) as duration'))
29+
->where('status', '!=', 'pending')
30+
->orderBy('duration')
31+
->first();
32+
33+
$maxExceptionsWorkflow = StoredWorkflow::withCount('exceptions')
34+
->orderByDesc('exceptions_count')
35+
->orderByDesc('updated_at')
36+
->first();
37+
38+
return response()->json([
39+
'flows' => StoredWorkflow::count(),
40+
'flows_per_minute' => $flowsPastHour / 60,
41+
'flows_past_hour' => $flowsPastHour,
42+
'exceptions_past_hour' => $exceptionsPastHour,
43+
'failed_flows_past_week' => $failedFlowsPastWeek,
44+
'max_wait_time_workflow' => $maxWaitTimeWorkflow,
45+
'max_duration_workflow' => $maxDurationWorkflow,
46+
'max_exceptions_workflow' => $maxExceptionsWorkflow,
47+
]);
48+
}
49+
}

0 commit comments

Comments
 (0)