Skip to content
12 changes: 10 additions & 2 deletions Modules/Front/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ public function docs()
return response()->redirectTo('https://docs.abrouter.com')->send();
}

public function stats()
public function stats(Request $request)
{
if ($request->hasValidSignature()){
return view('front::dashboard/stats');
}

$this->enforceAuth();
return view('front::dashboard/stats');
}

public function experimentStats()
public function experimentStats(Request $request)
{
if ($request->hasValidSignature()) {
return view('front::dashboard/experiment-stats');
}

$this->enforceAuth();
return view('front::dashboard/experiment-stats');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
$(document).ready(function () {
$.ajax({
'method': "GET",
'url': "/api/v1/user-events",
'url': "/api/v1/display-user-events",
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json',
Expand Down Expand Up @@ -140,7 +140,7 @@

$.ajax({
'method': 'POST',
'url': "/api/v1/user-events",
'url': "/api/v1/display-user-events",
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json',
Expand Down Expand Up @@ -230,7 +230,7 @@

$.ajax({
'method': 'PATCH',
'url': "/api/v1/user-events/" + dataId,
'url': "/api/v1/display-user-events/" + dataId,
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json',
Expand Down Expand Up @@ -290,7 +290,7 @@

$.ajax({
'method': "DELETE",
'url': "/api/v1/user-events/" + id,
'url': "/api/v1/display-user-events/" + id,
'headers': {
'Authorization': window.token,
},
Expand Down
34 changes: 27 additions & 7 deletions Modules/Front/Resources/views/dashboard/experiment-stats.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
use Modules\Front\Internal\User;
use Modules\Front\Assets\Puller;
use Illuminate\Support\Facades\URL;
?>
@extends('front::layouts.settings')

Expand Down Expand Up @@ -105,12 +105,17 @@ class="date__input date-range"
Add a tag
</button>
</form>
<a href="/en/stats/customization-event" class="track__add">
Add events
<svg class="track__add-icon">
<use href="/img/icons/icons.svg#arrow-blue"></use>
</svg>
</a>
@if(\Modules\Front\Internal\User::isAuthorized())
<button class="track__add" id="share_page">
Share page
</button>
<a href="/en/stats/customization-event" class="track__add">
Add events
<svg class="track__add-icon">
<use href="/img/icons/icons.svg#arrow-blue"></use>
</svg>
</a>
@endif
</div>
<div class="track__tags">

Expand Down Expand Up @@ -218,6 +223,21 @@ class="date__input date-range"
window.token='Bearer <?=request()->cookie('token')?>';
window.onload = $('.loader').show();
window.mode = 'experiment_stats';
<?php if (User::isAuthorized()):?>
window.url = getShareUrl();

function getShareUrl() {
return '<?=URL::temporarySignedRoute(
'experiment-stats', now()->addMinutes(30),
[
'userId' => User::me()['data']['id'],
'experimentId' => request()->get('experimentId'),
'dateFrom' => request()->get('dateFrom'),
'dateTo' => request()->get('dateTo')
])
?>';
}
<?php endif;?>
</script>
<script src="/js/Stats.js"></script>
@endsection
33 changes: 28 additions & 5 deletions Modules/Front/Resources/views/dashboard/stats.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<?php
use Illuminate\Support\Facades\URL;
use Modules\Front\Internal\User;
?>
@extends('front::layouts.settings')

@section('settings')
Expand Down Expand Up @@ -31,11 +35,16 @@ class="date__input date-range"
>
</div>
</form>
<a href="/en/stats/customization-event" class="track__add">
Add events <svg class="track__add-icon">
<use href="/img/icons/icons.svg#arrow-blue"></use>
</svg>
</a>
@if(\Modules\Front\Internal\User::isAuthorized())
<button class="track__add" id="share_page">
Share page
</button>
<a href="/en/stats/customization-event" class="track__add">
Add events <svg class="track__add-icon">
<use href="/img/icons/icons.svg#arrow-blue"></use>
</svg>
</a>
@endif
</div>

<table class="table table_info" id="stats_info">
Expand Down Expand Up @@ -116,6 +125,20 @@ class="date__input date-range"
window.token='Bearer <?=request()->cookie('token')?>';
window.onload = $('.loader').show();
window.mode = 'stats';
<?php if (User::isAuthorized()):?>
window.url = getShareUrl();

function getShareUrl() {
return '<?=URL::temporarySignedRoute(
'stats', now()->addMinutes(30),
[
'userId' => User::me()['data']['id'],
'dateFrom' => request()->get('dateFrom'),
'dateTo' => request()->get('dateTo')
])
?>';
}
<?php endif;?>
</script>
<script src="/js/Stats.js"></script>
@endsection
2 changes: 2 additions & 0 deletions Modules/Front/Resources/views/layouts/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<a href="/" class="header-profile__logo">
<picture><source srcset="/img/logo.svg" type="image/webp"><img src="/img/logo.svg" alt="Logo"></picture>
</a>
@if(\Modules\Front\Internal\User::isAuthorized())
<button type="button" class="menu__icon icon-menu"><span></span></button>
<div class="header-profile__menu">
<div class="header-profile__token token-header">
Expand Down Expand Up @@ -64,6 +65,7 @@
</div>
</div>
</div>
@endif
</div>
</header>
@endsection
Expand Down
6 changes: 4 additions & 2 deletions Modules/Front/Routes/web.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Routing\Router;

Expand Down Expand Up @@ -29,9 +30,10 @@
$router->get('/en/feature-toggle', 'DashboardController@featureToggle');
$router->get('/en/feature-toggle/run-feature-flag', 'DashboardController@runFeatureFlag');
$router->get('/en/docs', 'DashboardController@docs');
$router->get('/en/stats', 'DashboardController@stats');
$router->get('/en/stats', 'DashboardController@stats')->name('stats');
$router->get('/en/stats/customization-event', 'CustomizationEventController@index');
$router->get('/en/board/experiment-stats', 'DashboardController@experimentStats');
$router->get('/en/board/experiment-stats', 'DashboardController@experimentStats')
->name('experiment-stats');
$router->get('/en/board/run-experiment', 'DashboardController@runExperiment');
$router->get('/en/user-page', 'DashboardController@userPage');

Expand Down
Loading