mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-13 01:22:26 -06:00
Update strings and view for telemetry (inactive)
This commit is contained in:
parent
367f225f38
commit
5e323b958f
@ -21,7 +21,10 @@
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Jobs\SubmitTelemetryData;
|
||||
use FireflyIII\Repositories\Telemetry\TelemetryRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\View\View;
|
||||
|
||||
@ -30,14 +33,18 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class TelemetryController extends Controller
|
||||
{
|
||||
/** @var TelemetryRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->middleware(
|
||||
static function ($request, $next) {
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
$this->repository = app(TelemetryRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@ -47,15 +54,43 @@ class TelemetryController extends Controller
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function delete()
|
||||
public function deleteSubmitted()
|
||||
{
|
||||
session()->flash('info', 'No telemetry to delete. Does not work yet.');
|
||||
$this->repository->deleteSubmitted();
|
||||
|
||||
return redirect(route('admin.telemetry.index'));
|
||||
session()->flash('success', trans('firefly.telemetry_submitted_deleted'));
|
||||
|
||||
return redirect(url()->previous(route('admin.telemetry.index')));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
$this->repository->deleteAll();
|
||||
|
||||
session()->flash('success', trans('firefly.telemetry_all_deleted'));
|
||||
|
||||
return redirect(url()->previous(route('admin.telemetry.index')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run job to submit telemetry.
|
||||
*/
|
||||
public function submit()
|
||||
{
|
||||
$job = app(SubmitTelemetryData::class);
|
||||
$job->setDate(new Carbon);
|
||||
$job->setForce(true);
|
||||
$job->handle();
|
||||
session()->flash('info', trans('firefly.telemetry_submission_executed'));
|
||||
|
||||
return redirect(url()->previous(route('admin.telemetry.index')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Index
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -63,16 +98,22 @@ class TelemetryController extends Controller
|
||||
app('view')->share('subTitle', (string) trans('firefly.telemetry_admin_index'));
|
||||
$version = config('firefly.version');
|
||||
$enabled = config('firefly.telemetry', false);
|
||||
$count = 1;
|
||||
$count = $this->repository->count();
|
||||
|
||||
return view('admin.telemetry.index', compact('version', 'enabled', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* View telemetry. Paginated because you never know how much will be collected.
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function view()
|
||||
{
|
||||
return view('admin.telemetry.view');
|
||||
$format = trans('config.date_time');
|
||||
$size = 100;
|
||||
$records = $this->repository->paginated($size);
|
||||
|
||||
return view('admin.telemetry.view', compact('records', 'format'));
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ use FireflyIII\Helpers\Report\PopupReport;
|
||||
use FireflyIII\Helpers\Report\PopupReportInterface;
|
||||
use FireflyIII\Helpers\Report\ReportHelper;
|
||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
use FireflyIII\Repositories\Telemetry\TelemetryRepository;
|
||||
use FireflyIII\Repositories\Telemetry\TelemetryRepositoryInterface;
|
||||
use FireflyIII\Repositories\TransactionType\TransactionTypeRepository;
|
||||
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepository;
|
||||
@ -178,6 +180,7 @@ class FireflyServiceProvider extends ServiceProvider
|
||||
$this->app->bind(ReportHelperInterface::class, ReportHelper::class);
|
||||
$this->app->bind(FiscalHelperInterface::class, FiscalHelper::class);
|
||||
$this->app->bind(UpdateRequestInterface::class, UpdateRequest::class);
|
||||
$this->app->bind(TelemetryRepositoryInterface::class, TelemetryRepository::class);
|
||||
|
||||
$class = (string)config(sprintf('firefly.cer_providers.%s', (string)config('firefly.cer_provider')));
|
||||
if ('' === $class) {
|
||||
|
67
app/Repositories/Telemetry/TelemetryRepository.php
Normal file
67
app/Repositories/Telemetry/TelemetryRepository.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TelemetryRepository.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Repositories\Telemetry;
|
||||
|
||||
use FireflyIII\Models\Telemetry;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Class TelemetryRepository
|
||||
*/
|
||||
class TelemetryRepository implements TelemetryRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Telemetry::count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteAll(): void
|
||||
{
|
||||
// created_at is never NULL.
|
||||
Telemetry::whereNotNull('created_at')->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function paginated(int $pageSize): LengthAwarePaginator
|
||||
{
|
||||
return Telemetry::orderBy('created_at', 'DESC')->paginate($pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteSubmitted(): void
|
||||
{
|
||||
// created_at is never NULL.
|
||||
Telemetry::whereNotNull('submitted')->delete();
|
||||
}
|
||||
}
|
59
app/Repositories/Telemetry/TelemetryRepositoryInterface.php
Normal file
59
app/Repositories/Telemetry/TelemetryRepositoryInterface.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TelemetryRepositoryInterface.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Repositories\Telemetry;
|
||||
|
||||
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Interface TelemetryRepositoryInterface
|
||||
*/
|
||||
interface TelemetryRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return the number of stored telemetry records.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int;
|
||||
|
||||
/**
|
||||
* Return paginated result of telemetry records.
|
||||
*
|
||||
* @param int $pageSize
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function paginated( int $pageSize): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Delete all records.
|
||||
*/
|
||||
public function deleteAll(): void;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function deleteSubmitted(): void;
|
||||
|
||||
}
|
@ -1589,7 +1589,7 @@ return [
|
||||
// telemetry
|
||||
'telemetry_admin_index' => 'Telemetry',
|
||||
'telemetry_intro' => 'Firefly III supports the collection and sending of usage telemetry. This means that Firefly III will try to collect info on how you use Firefly III, and send it to the developer of Firefly III. This is always opt-in, and is disabled by default. Firefly III will never collect or send financial information. Firefly III will also never collect or send financial meta-information, like sums or calculations. The collected data will never be made publicly accessible.',
|
||||
'telemetry_what_collected' => 'What Firefly III collects and sends exactly is different for each version. You are running version :version. What Firefly III collects in version :version is something you can read in the help pages. Click the (?)-icon in the top-right corner <a href="https://github.com/firefly-iii/help/blob/master/en_US/admin.telemetry.index.md">or visit the help page directly on GitHub</a>.',
|
||||
'telemetry_what_collected' => 'What Firefly III collects and sends exactly is different for each version. You are running version :version. What Firefly III collects in version :version is something you can read in the help pages. Click the (?)-icon in the top-right corner <a href="https://docs.firefly-iii.org/support/telemetry">or visit the documentation page</a>.',
|
||||
'telemetry_is_enabled_yes_no' => 'Is Firefly III telemetry enabled?',
|
||||
'telemetry_disabled_no' => 'Telemetry is NOT enabled',
|
||||
'telemetry_disabled_yes' => 'Telemetry is enabled',
|
||||
@ -1599,7 +1599,14 @@ return [
|
||||
'no_telemetry_present' => 'Firefly III has collected zero telemetry records.',
|
||||
'records_telemetry_present' => 'Firefly III has collected :count telemetry record(s).',
|
||||
'telemetry_button_view' => 'View telemetry',
|
||||
'telemetry_button_delete' => 'Delete telemetry',
|
||||
'telemetry_button_delete' => 'Delete all telemetry',
|
||||
'telemetry_admin_overview' => 'Telemetry overview',
|
||||
'telemetry_back_to_index' => 'Back to telemetry'
|
||||
'telemetry_back_to_index' => 'Back to telemetry index',
|
||||
'not_yet_submitted' => 'Not yet submitted',
|
||||
'telemetry_type_feature' => 'Feature flag',
|
||||
'telemetry_submit_all' => 'Submit records',
|
||||
'telemetry_delete_submitted_records' => 'Delete submitted records',
|
||||
'telemetry_submission_executed' => 'Records have been submitted. Check your log files for more info.',
|
||||
'telemetry_all_deleted' => 'All telemetry records have been deleted.',
|
||||
'telemetry_submitted_deleted' => 'All submitted telemetry records have been deleted.'
|
||||
];
|
||||
|
@ -265,5 +265,10 @@ return [
|
||||
'auto_budget_amount' => 'Auto-budget amount',
|
||||
'auto_budget_period' => 'Auto-budget period',
|
||||
|
||||
'collected' => 'Collected',
|
||||
'submitted' => 'Submitted',
|
||||
'key' => 'Key',
|
||||
'value' => 'Content of record'
|
||||
|
||||
|
||||
];
|
||||
|
@ -11,17 +11,91 @@
|
||||
<h3 class="box-title">{{ 'telemetry_admin_overview'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p>
|
||||
<em>(this version does not yet support telemetry)</em>
|
||||
</p>
|
||||
<div class="btn-group" style="margin-bottom: 1em;">
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.index') }}"><i class="fa fa-fw fa-arrow-left"></i> {{ 'telemetry_back_to_index'|_ }}</a>
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.submit') }}"><i class="fa fa-fw fa-upload"></i> {{ 'telemetry_submit_all'|_ }}</a>
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.delete') }}"><i class="fa fa-fw fa-trash"></i> {{ 'telemetry_button_delete'|_ }}</a>
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.delete-submitted') }}"><i class="fa fa-fw fa-trash"></i> {{ 'telemetry_delete_submitted_records'|_ }}</a>
|
||||
</div>
|
||||
<div>
|
||||
{{ records.links | raw }}
|
||||
</div>
|
||||
<table class="table table-striped table-condensed">
|
||||
<tr>
|
||||
<th>{{ trans('form.collected') }}</th>
|
||||
<th>{{ trans('form.submitted') }}</th>
|
||||
<th>{{ trans('form.type') }}</th>
|
||||
<th>{{ trans('form.key') }}</th>
|
||||
<th>{{ trans('form.value') }}</th>
|
||||
</tr>
|
||||
{% for record in records %}
|
||||
<tr>
|
||||
<td style="width:15%;">
|
||||
<small>{{ record.created_at.formatLocalized(format) }}</small>
|
||||
</td>
|
||||
<td style="width:15%;">
|
||||
<small>
|
||||
{% if record.submitted %}
|
||||
{{ record.submitted.formatLocalized(format) }}
|
||||
{% else %}
|
||||
<em>{{ 'not_yet_submitted'|_ }}</em>
|
||||
{% endif %}
|
||||
</small>
|
||||
</td>
|
||||
<td style="width:15%;">
|
||||
{{ trans('firefly.telemetry_type_'~record.type) }}
|
||||
</td>
|
||||
<td style="width:15%;">
|
||||
<code>{{ record.key }}</code>
|
||||
</td>
|
||||
<td style="width:40%;">
|
||||
{% if record.value|json_encode|length > 100 %}
|
||||
<code data-state="partial" data-partial="{{ record.value|json_encode|slice(0, 30)|escape }}..."
|
||||
data-full="{{ record.value|json_encode }}|escape" class="expando">
|
||||
{{ record.value|json_encode|slice(0, 30) }}...
|
||||
</code>
|
||||
{% else %}
|
||||
<code>{{ record.value|json_encode }}</code>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div>
|
||||
{{ records.links | raw }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.index') }}">{{ 'telemetry_back_to_index'|_ }}</a>
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.index') }}"><i class="fa fa-fw fa-arrow-left"></i> {{ 'telemetry_back_to_index'|_ }}</a>
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.submit') }}"><i class="fa fa-fw fa-upload"></i> {{ 'telemetry_submit_all'|_ }}</a>
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.delete') }}"><i class="fa fa-fw fa-trash"></i> {{ 'telemetry_button_delete'|_ }}</a>
|
||||
<a class="btn btn-default" href="{{ route('admin.telemetry.delete-submitted') }}"><i class="fa fa-fw fa-trash"></i> {{ 'telemetry_delete_submitted_records'|_ }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
{% block styles %}
|
||||
<style type="text/css">
|
||||
.expando {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" nonce="{{ JS_NONCE }}">
|
||||
$('.expando').click(function (e) {
|
||||
var codeBlock = $(e.currentTarget);
|
||||
if ('partial' === codeBlock.data('state')) {
|
||||
codeBlock.text(codeBlock.data('full'));
|
||||
codeBlock.data('state', 'full');
|
||||
} else {
|
||||
codeBlock.text(codeBlock.data('partial'));
|
||||
codeBlock.data('state', 'partial');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -1137,7 +1137,9 @@ Route::group(
|
||||
// telemetry manager:
|
||||
Route::get('telemetry', ['uses' => 'TelemetryController@index', 'as' => 'telemetry.index']);
|
||||
Route::get('telemetry/view', ['uses' => 'TelemetryController@view', 'as' => 'telemetry.view']);
|
||||
Route::get('telemetry/delete', ['uses' => 'TelemetryController@delete', 'as' => 'telemetry.delete']);
|
||||
Route::get('telemetry/delete', ['uses' => 'TelemetryController@deleteAll', 'as' => 'telemetry.delete']);
|
||||
Route::get('telemetry/delete-submitted', ['uses' => 'TelemetryController@deleteSubmitted', 'as' => 'telemetry.delete-submitted']);
|
||||
Route::get('telemetry/submit', ['uses' => 'TelemetryController@submit', 'as' => 'telemetry.submit']);
|
||||
|
||||
// journal links manager
|
||||
Route::get('links', ['uses' => 'LinkController@index', 'as' => 'links.index']);
|
||||
|
Loading…
Reference in New Issue
Block a user