-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
139 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\ResourceCollection; | ||
|
||
class FloorPricesCollection extends ResourceCollection | ||
{ | ||
public function toArray(Request $request): array | ||
{ | ||
return parent::toArray($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class FloorPricesResource extends JsonResource | ||
{ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
'time' => $this->created_at->getTimeStamp(), | ||
'value' => $this->price_in_sats / 100000000, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// import './bootstrap'; | ||
import './bootstrap'; | ||
|
||
import { codeToHtml } from 'shiki' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { createChart } from 'lightweight-charts'; | ||
|
||
const url = '/api/chart'; | ||
const response = await axios.get(url); | ||
|
||
const chart = createChart( | ||
document.getElementById('trading-view-charts'), | ||
{ | ||
layout: { | ||
background: { color: '#ff5400' }, | ||
textColor: '#fff', | ||
}, | ||
grid: { | ||
vertLines: { color: '#c2410c' }, | ||
horzLines: { color: '#c2410c' }, | ||
}, | ||
handleScroll: { | ||
mouseWheel: false, | ||
pressedMouseMove: false, | ||
horzTouchDrag: false, | ||
vertTouchDrag: false, | ||
}, | ||
handleScale: { | ||
mouseWheel: false, | ||
pinch: false, | ||
}, | ||
} | ||
); | ||
|
||
const priceFormatter = p => p.toFixed(2); | ||
|
||
chart.applyOptions({ | ||
localization: { | ||
priceFormatter: priceFormatter, | ||
}, | ||
}); | ||
|
||
chart.timeScale().fitContent(); | ||
|
||
const areaSeries = chart.addAreaSeries({ | ||
lineColor: '#f97316', topColor: '#fb923c', | ||
bottomColor: 'rgba(67, 20, 7, 0.28)', | ||
}); | ||
|
||
areaSeries.setData(response.data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div id="trading-view-charts" class="w-full h-96"> | ||
|
||
</div> | ||
|
||
<div class="w-full flex mt-4 pr-4 lg:pr-12 justify-end text-gray-600"> | ||
<span class="sr-only">Trading View Charts</span> | ||
<a | ||
href="https://www.tradingview.com" | ||
target="_blank" | ||
rel="noopener" | ||
class="text-white hover:text-gray-200" | ||
> | ||
<x-icon-tradingview class="h-4 lg:h-6" /> | ||
</a> | ||
</div> | ||
|
||
@pushOnce('scripts') | ||
@vite('resources/js/chart.js') | ||
@endPushOnce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
|
||
<x-layout.footer/> | ||
|
||
@vite('resources/js/app.js') | ||
@stack('scripts') | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Tests\TestCase; | ||
|
||
class RetrieveChartDataTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
#[Test] | ||
public function a_request_to_the_homepage_should_return_a_200_status_code(): void | ||
{ | ||
$this->get('/api/chart')->assertOk(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters