-
Notifications
You must be signed in to change notification settings - Fork 15
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
1 parent
5ddfa81
commit 06dbe2b
Showing
20 changed files
with
266 additions
and
26 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
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,3 +1,18 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&display=swap'); | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer components { | ||
.card { | ||
@apply bg-slate-800 rounded-3xl px-6 py-4 shadow-xl; | ||
} | ||
|
||
.card-head { | ||
@apply font-montserrat font-bold text-4xl; | ||
} | ||
|
||
.card-title { | ||
@apply font-montserrat font-semibold text-sm text-slate-400; | ||
} | ||
} |
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,12 @@ | ||
<nav | ||
class="p-1 h-14 rounded-full bg-slate-800 w-full flex items-center justify-center relative shadow-xl" | ||
> | ||
<div class="flex items-center absolute top-1 left-1 h-12"> | ||
<img class="block w-12 mr-4" src="logo.svg" alt="Phala logo" /> | ||
<h1 class="text-xl font-black font-montserrat">Analytics</h1> | ||
</div> | ||
|
||
<ul class="font-montserrat hidden md:block"> | ||
<li>Overview</li> | ||
</ul> | ||
</nav> |
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,125 @@ | ||
<script lang="ts"> | ||
import {compactFormat} from '@phala/lib' | ||
import {gql, request} from 'graphql-request' | ||
import {onMount} from 'svelte' | ||
import {Line} from 'svelte-chartjs' | ||
import { | ||
Chart as ChartJS, | ||
LineElement, | ||
LinearScale, | ||
PointElement, | ||
TimeScale, | ||
Tooltip, | ||
type ChartData, | ||
} from 'chart.js' | ||
import 'chartjs-adapter-date-fns' | ||
ChartJS.register(Tooltip, LineElement, LinearScale, TimeScale, PointElement) | ||
interface Execution { | ||
dt: Date | ||
executionCount: number | ||
userCount: number | ||
} | ||
interface ExecutionData { | ||
dt: string | ||
executionCount: number | ||
userCount: number | ||
} | ||
const document = gql` | ||
{ | ||
phatOfflineExecution(orderBy: {dt: DESC}, limit: 10) { | ||
dt | ||
executionCount | ||
userCount | ||
} | ||
} | ||
` | ||
let executions: Execution[] | ||
let data: ChartData<'line', number[]> | ||
$: current = executions?.[0] | ||
? compactFormat(executions[0].executionCount) | ||
: null | ||
$: if (executions) { | ||
data = { | ||
labels: executions.map((e) => e.dt), | ||
datasets: [ | ||
{ | ||
label: 'Execution', | ||
data: executions.map((e) => e.executionCount), | ||
borderColor: '#C5FF46', | ||
}, | ||
], | ||
} | ||
} | ||
onMount(() => { | ||
request<{phatOfflineExecution: ExecutionData[]}>( | ||
'https://offchain-metrics.phala.network/v1/graphql', | ||
document | ||
).then((res) => { | ||
executions = res.phatOfflineExecution.reverse().map((e) => { | ||
return { | ||
...e, | ||
dt: new Date(e.dt), | ||
} | ||
}) | ||
}) | ||
}) | ||
</script> | ||
|
||
{#if executions != null} | ||
<div class="flex flex-col h-full"> | ||
<div> | ||
<h2 class="card-title">Phat Contract daily execution</h2> | ||
<h1 class="card-head mt-1">{current}</h1> | ||
</div> | ||
|
||
<div class="mt-4 flex-1"> | ||
<Line | ||
{data} | ||
options={{ | ||
scales: { | ||
x: { | ||
type: 'time', | ||
grid: {display: false}, | ||
border: {display: false}, | ||
ticks: {color: '#94a3b8', font: {family: 'Montserrat'}}, | ||
time: {tooltipFormat: 'PP'}, | ||
}, | ||
y: { | ||
// suggestedMin: 1000000, | ||
// min: 0, | ||
grid: {display: false}, | ||
border: {display: false}, | ||
ticks: { | ||
display: false, | ||
// color: '#94a3b8', | ||
// font: {family: 'Montserrat'}, | ||
// callback: (tickValue) => { | ||
// if (typeof tickValue === 'number') { | ||
// return compactFormat(tickValue) | ||
// } | ||
// return tickValue | ||
// }, | ||
}, | ||
}, | ||
}, | ||
elements: {line: {tension: 0.5}, point: {radius: 0}}, | ||
maintainAspectRatio: false, | ||
interaction: {mode: 'index', intersect: false}, | ||
plugins: { | ||
tooltip: { | ||
titleFont: {family: 'Montserrat'}, | ||
bodyFont: {family: 'Montserrat'}, | ||
displayColors: false, | ||
}, | ||
}, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
{/if} |
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,15 +1,20 @@ | ||
<script> | ||
<script lang="ts"> | ||
import Nav from '~/components/Nav.svelte' | ||
import PhatContractChart from '~/components/PhatContractChart.svelte' | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Phala Analytics</title> | ||
</svelte:head> | ||
|
||
<main class="flex flex-col items-center"> | ||
<header class="flex items-center my-6"> | ||
<img class="block w-10 mr-4" src="favicon.png" alt="Phala logo" /> | ||
<h1 class="text-2xl font-medium">Phala Analytics</h1> | ||
</header> | ||
<header class="mx-auto px-4 md:px-6 mt-4 md:mt-6 max-w-6xl"> | ||
<Nav /> | ||
</header> | ||
|
||
<h2>Phat Contract execution count</h2> | ||
<main | ||
class="grid gap-4 grid-cols-1 md:grid-cols-2 max-w-5xl mx-auto mt-6 md:mt-10 px-4 md:px-6" | ||
> | ||
<section class="card h-80"> | ||
<PhatContractChart /> | ||
</section> | ||
</main> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 +1,19 @@ | ||
import adapter from '@sveltejs/adapter-static'; | ||
import {vitePreprocess} from '@sveltejs/kit/vite'; | ||
import adapter from '@sveltejs/adapter-static' | ||
import {vitePreprocess} from '@sveltejs/kit/vite' | ||
import path from 'path' | ||
|
||
/** @type {import('@sveltejs/kit').Config} */ | ||
const config = { | ||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors | ||
// for more information about preprocessors | ||
preprocess: vitePreprocess(), | ||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors | ||
// for more information about preprocessors | ||
preprocess: vitePreprocess(), | ||
|
||
kit: {adapter: adapter()} | ||
}; | ||
kit: { | ||
adapter: adapter(), | ||
alias: { | ||
'~': path.resolve('./src'), | ||
}, | ||
}, | ||
} | ||
|
||
export default config; | ||
export default config |
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
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
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
File renamed without changes.
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,3 +1,4 @@ | ||
export {default as compactFormat} from './compactFormat' | ||
export * from './signAndSend' | ||
export {useConnectPolkadotWallet} from './useConnectPolkadotWallet' | ||
export {useInterval} from './useInterval' |
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
Oops, something went wrong.