Skip to content

Commit

Permalink
First version still WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
schmeits committed Jun 18, 2024
1 parent 0729ef7 commit 6d005c0
Show file tree
Hide file tree
Showing 47 changed files with 1,294 additions and 304 deletions.
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"pest_2.34.8","defects":[],"times":{"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.003,"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.188}}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ return [
## Usage

```php
$filamentUmamiWidgets = new Schmeits\FilamentUmamiWidgets();
echo $filamentUmamiWidgets->echoPhrase('Hello, Schmeits!');
$filamentUmami = new Schmeits\FilamentUmami();
echo $filamentUmami->echoPhrase('Hello, Schmeits!');
```

## Testing
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.1|^8.2|^8.3",
"filament/filament": "^3.0",
"malzariey/filament-daterangepicker-filter": "^2.6",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
Expand All @@ -39,13 +40,13 @@
},
"autoload": {
"psr-4": {
"Schmeits\\FilamentUmamiWidgets\\": "src/",
"Schmeits\\FilamentUmamiWidgets\\Database\\Factories\\": "database/factories/"
"Schmeits\\FilamentUmami\\": "src/",
"Schmeits\\FilamentUmami\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
"psr-4": {
"Schmeits\\FilamentUmamiWidgets\\Tests\\": "tests/"
"Schmeits\\FilamentUmami\\Tests\\": "tests/"
}
},
"scripts": {
Expand All @@ -65,13 +66,13 @@
"extra": {
"laravel": {
"providers": [
"Schmeits\\FilamentUmamiWidgets\\FilamentUmamiWidgetsServiceProvider"
"Schmeits\\FilamentUmami\\FilamentUmamiServiceProvider"
],
"aliases": {
"FilamentUmamiWidgets": "Schmeits\\FilamentUmamiWidgets\\Facades\\FilamentUmamiWidgets"
"FilamentUmami": "Schmeits\\FilamentUmami\\Facades\\FilamentUmami"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
91 changes: 91 additions & 0 deletions config/filament-umami-widgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Umami type
|--------------------------------------------------------------------------
|
| Which version of Umami are you using?
| Option 1: self_hosted (https://umami.is/docs)
| Option 2: cloud (https://umami.is/docs/cloud)
|
*/
'type' => env('UMAMI_TYPE', 'self-hosted'),

/*
|--------------------------------------------------------------------------
| Umami API Endpoint URL
|--------------------------------------------------------------------------
|
| For the self hosted version you should provide the API
| endpoint e.g. https://your_url.com/api
|
| If you are using the Cloud type your values should be something
| like: https://api.umami.is/v1
|
*/
'api_endpoint_url' => env('UMAMI_API_ENDPOINT', 'https://api.umami.is/v1'),

/*
|--------------------------------------------------------------------------
| Umami Website ID
|--------------------------------------------------------------------------
|
| This is the ID of the website stats you want to show om the website
|
| In Umami Cloud you can find the ID by going to Websites
| Click edit and use the Website ID provided
|
| In the self-hosted version navigate to Settings and edit the website
| use the Website ID provided
|
*/
'website_id' => env('UMAMI_WEBSITE_ID', null),

/*
|--------------------------------------------------------------------------
| Umami Http options
|--------------------------------------------------------------------------
|
| The timeout options defines the default timeout for the API requests
| in seconds
|
*/
'timeout' => env('UMAMI_TIMEOUT', 5),

/*
|--------------------------------------------------------------------------
| Self Hosted Options
|--------------------------------------------------------------------------
|
| Add a user to your Umami installation
| https://umami.is/docs/add-a-user
|
*/
'username' => env('UMAMI_USERNAME', null),
'password' => env('UMAMI_PASSWORD', null),

/*
|--------------------------------------------------------------------------
| Cloud Options
|--------------------------------------------------------------------------
|
| Check the website how to obtain an API key
| https://umami.is/docs/cloud/api-key
|
*/
'cloud_api_key' => env('UMAMI_API_KEY', null),

/*
|--------------------------------------------------------------------------
| Caching options
|--------------------------------------------------------------------------
|
| You can set the options for the caching here
| cache_time is the time the values will be cached in seconds
|
*/
'cache_time' => 300,

];
6 changes: 0 additions & 6 deletions config/umami-widgets.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/migrations/create_umami_widgets_table.php.stub

This file was deleted.

7 changes: 3 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ includes:
- phpstan-baseline.neon

parameters:
level: 4
level: 5
paths:
- src
- config
- database
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false

ignoreErrors:
- '#Call to an undefined static method#'
1 change: 0 additions & 1 deletion resources/css/index.css

This file was deleted.

Empty file removed resources/js/index.js
Empty file.
56 changes: 56 additions & 0 deletions resources/lang/en/translations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

return [
'filter' => [
'title' => 'Date Filter for Umami',
'description' => 'The set filters are used for the analytics shown below.',
'select_range' => 'Choose Filter Range',
'date_format' => 'DD-MM-YYYY',
],
'widget' => [
'global' => [
'time_range_days' => ' (:value day)| (:value days)',
],
'live_visitors' => [
'label' => 'Live Visitors',
'description' => 'Live visitors on the page',
],
'pageviews' => [
'label' => 'Pageviews',
'description' => 'Page hits in the selected range',
],
'visitors' => [
'label' => 'Unique visitors',
'description' => 'Number of unique visitors in the selected range',
],
'visits' => [
'label' => 'Visits',
'description' => 'Number of sessions in the selected range',
],
'bounces' => [
'label' => 'Bounces',
'description' => 'Number of visitors who only visit a single page in the selected range',
],
'total_time' => [
'label' => 'Time spent on the website',
'description' => 'Time spent on the website in the selected range',
],
'metrics_referrer' => [
'heading' => '',
'headers' => [
'metric' => 'Referrers',
'count' => 'Count',
],
'description' => 'Referrers in the selected range',
'empty_referrer' => 'unknown',
],
'metrics_url' => [
'heading' => '',
'headers' => [
'metric' => 'Visited URL\'s',
'count' => 'Count',
],
'description' => 'Visited URL\'s in the selected range',
],
],
];
6 changes: 0 additions & 6 deletions resources/lang/en/umami-widgets.php

This file was deleted.

78 changes: 78 additions & 0 deletions resources/views/table-widget.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@php
$tableHeading = $this->getTableHeading();
$headers = $this->getHeaders();
$data = $this->getData();
$description = $this->getDescription();
@endphp
<x-filament-widgets::widget class="fi-wi-stats-overview">
<div
@if ($pollingInterval = $this->getPollingInterval())
wire:poll.{{ $pollingInterval }}
@endif
>
<div
class="fi-ta-ctn divide-y divide-gray-200 overflow-hidden rounded-xl bg-white shadow-sm ring-1 ring-gray-950/5 dark:divide-white/10 dark:bg-gray-900 dark:ring-white/10">
@if ($tableHeading)
<div class="fi-ta-header-ctn divide-y divide-gray-200 dark:divide-white/10">
<div class="fi-ta-header flex flex-col gap-3 p-4 sm:px-6 sm:flex-row sm:items-center">
<div class="grid gap-y-1">
<h3 class="fi-ta-header-heading text-base font-semibold leading-6 text-gray-950 dark:text-white">
{{ $this->getTableHeading() }}
</h3>
</div>
</div>
</div>
@endif

<div class="fi-ta-content relative divide-y divide-gray-200 overflow-x-auto dark:divide-white/10 dark:border-t-white/10">
<table class="fi-ta-table w-full table-auto divide-y divide-gray-200 text-start dark:divide-white/5">
<thead class="divide-y divide-gray-200 dark:divide-white/5">
<tr class="bg-gray-50 dark:bg-white/5">
@foreach ($headers as $header)
<th class="fi-ta-header-cell px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6 fi-table-header-cell-title" style="width:{{ $header['width'] }}">
<span class="group flex w-full items-center gap-x-1 whitespace-nowrap justify-start">
<span class="fi-ta-header-cell-label text-sm font-semibold text-gray-950 dark:text-white">
{{ $header['label'] }}
</span>
</span>
</th>
@endforeach
</tr>
</thead>
<tbody class="divide-y divide-gray-200 whitespace-nowrap dark:divide-white/5">
@foreach ($data as $row)
<tr class="fi-ta-row [@media(hover:hover)]:transition [@media(hover:hover)]:duration-75">
@foreach ($headers as $header)
<td class="fi-ta-cell p-0 first-of-type:ps-1 last-of-type:pe-1 sm:first-of-type:ps-3 sm:last-of-type:pe-3 fi-table-cell-title">
<div class="fi-ta-col-wrp">
<div class="flex w-full disabled:pointer-events-none justify-start text-start">
<div class="fi-ta-text grid w-full gap-y-1 px-3 py-4">
<div class="flex">
<div class="flex max-w-max" style="">
<div class="fi-ta-text-item inline-flex items-center gap-1.5">
<span class="fi-ta-text-item-label text-sm leading-6 text-gray-950 dark:text-white" style="">
{{ $row[$header['name']] ?? '' }}
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
@if ($description)
<div class="flex items-center gap-x-1 px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6">
<span class="fi-wi-stats-overview-stat-description text-sm text-gray-500 dark:text-gray-400 fi-color-gray">
{{ $description }}
</span>
</div>
@endif
</div>
</div>
</div>
</x-filament-widgets::widget>
19 changes: 0 additions & 19 deletions src/Commands/FilamentUmamiWidgetsCommand.php

This file was deleted.

Loading

0 comments on commit 6d005c0

Please sign in to comment.