Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions CashPilot/CashPilot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\SupportedApps\CashPilot;

class CashPilot extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;

public function test()
{
$test = parent::appTest($this->url('api/earnings/summary'), $this->attrs());
echo $test->status;
}

public function livestats()
{
$status = 'inactive';
$data = [];

$res = parent::execute($this->url('api/earnings/summary'), $this->attrs());
$details = json_decode($res->getBody());

if ($details) {
$status = 'active';

// CashPilot separates "nothing has been read yet" from "read, and it
// is zero". has_readings is false on a fresh install and on one whose
// collection has stopped, so a figure there would state a
// measurement that was never taken.
$data['earnings'] = (isset($details->has_readings) && $details->has_readings)
? '$' . number_format((float) ($details->total_adjusted ?? 0), 2)
: '—';

// active_services is null when the count could not be taken. Showing
// 0 would read as "nothing is running" while containers are running.
$data['running'] = (isset($details->active_services) && $details->active_services !== null)
? $details->active_services
: '—';
}

return parent::getLiveStats($status, $data);
}

public function url($endpoint)
{
return parent::normaliseurl($this->config->url) . $endpoint;
}

public function attrs()
{
return [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $this->config->access_token,
],
];
}
}
10 changes: 10 additions & 0 deletions CashPilot/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"appid": "5b7c085bf60518c8e7261473688a98200e60847b",
"name": "CashPilot",
"website": "https://github.com/GeiserX/CashPilot",
"license": "GNU General Public License v3.0 only",
"description": "Self-hosted passive income orchestrator. Deploy, manage and monitor bandwidth-sharing, DePIN, storage and GPU compute containers from a single web dashboard, with earnings tracked across 49 services.",
"enhanced": true,
"tile_background": "dark",
"icon": "cashpilot.svg"
}
50 changes: 50 additions & 0 deletions CashPilot/cashpilot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions CashPilot/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }} (API Key)</label>
{!! Form::text('config[access_token]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'access_token', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>
10 changes: 10 additions & 0 deletions CashPilot/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="livestats">
<li>
<span class="title">Earnings</span>
<strong>{!! $earnings !!}</strong>
</li>
<li>
<span class="title">Running</span>
<strong>{!! $running !!}</strong>
</li>
</ul>