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

+18
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

+11
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

+19
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

+54
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

+35
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

+50
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+
}

app/Http/Controllers/Controller.php

+19
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+
}
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+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Waterline\Http\Controllers;
4+
5+
use SplFileObject;
6+
use Workflow\Models\StoredWorkflow;
7+
8+
class WorkflowsController extends Controller
9+
{
10+
public function completed() {
11+
return StoredWorkflow::whereStatus('completed')
12+
->paginate(50);
13+
}
14+
15+
public function failed() {
16+
return StoredWorkflow::whereStatus('failed')
17+
->paginate(50);
18+
}
19+
20+
public function running() {
21+
return StoredWorkflow::whereIn('status', [
22+
'created',
23+
'pending',
24+
'running',
25+
'waiting',
26+
])
27+
->paginate(50);
28+
}
29+
30+
public function show($id) {
31+
$flow = StoredWorkflow::whereId($id)->with(['exceptions', 'logs'])->first();
32+
33+
$flow->exceptions = $flow->exceptions->map(function ($exception) {
34+
$unserialized = unserialize($exception->exception);
35+
$file = new SplFileObject($unserialized->getFile());
36+
$file->seek($unserialized->getLine() - 4);
37+
for ($line = 0; $line < 7; ++$line) {
38+
$exception->code .= $file->current();
39+
$file->next();
40+
if ($file->eof()) break;
41+
}
42+
$exception->code = rtrim($exception->code);
43+
return $exception;
44+
});
45+
46+
return $flow;
47+
}
48+
}

app/Http/Kernel.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Waterline\Http;
4+
5+
use Illuminate\Foundation\Http\Kernel as HttpKernel;
6+
7+
class Kernel extends HttpKernel
8+
{
9+
/**
10+
* The application's global HTTP middleware stack.
11+
*
12+
* These middleware are run during every request to your application.
13+
*
14+
* @var array<int, class-string|string>
15+
*/
16+
protected $middleware = [
17+
// \App\Http\Middleware\TrustHosts::class,
18+
\App\Http\Middleware\TrustProxies::class,
19+
\Illuminate\Http\Middleware\HandleCors::class,
20+
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
21+
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
22+
\App\Http\Middleware\TrimStrings::class,
23+
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
24+
];
25+
26+
/**
27+
* The application's route middleware groups.
28+
*
29+
* @var array<string, array<int, class-string|string>>
30+
*/
31+
protected $middlewareGroups = [
32+
'web' => [
33+
\App\Http\Middleware\EncryptCookies::class,
34+
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
35+
\Illuminate\Session\Middleware\StartSession::class,
36+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
37+
\App\Http\Middleware\VerifyCsrfToken::class,
38+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
39+
],
40+
41+
'api' => [
42+
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
43+
'throttle:api',
44+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
45+
],
46+
];
47+
48+
/**
49+
* The application's route middleware.
50+
*
51+
* These middleware may be assigned to groups or used individually.
52+
*
53+
* @var array<string, class-string|string>
54+
*/
55+
protected $routeMiddleware = [
56+
'auth' => \App\Http\Middleware\Authenticate::class,
57+
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
58+
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
59+
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
60+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
61+
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
62+
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
63+
'signed' => \App\Http\Middleware\ValidateSignature::class,
64+
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
65+
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
66+
];
67+
}

0 commit comments

Comments
 (0)