Skip to content

Commit

Permalink
add localization table
Browse files Browse the repository at this point in the history
add http resource Reports
  • Loading branch information
agoalofalife committed Mar 6, 2018
1 parent dee8f1f commit a2c1236
Show file tree
Hide file tree
Showing 15 changed files with 155 additions and 32 deletions.
3 changes: 2 additions & 1 deletion config/reports.php
Expand Up @@ -3,5 +3,6 @@
return [
'reports' => [

]
],
'middleware' => '',
];
6 changes: 3 additions & 3 deletions public/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
@@ -1,3 +1,3 @@
{
"/js/app.js": "/js/app.js?id=7118357fbe29c87424cb"
"/js/app.js": "/js/app.js?id=be2441ad52c7c15d2749"
}
30 changes: 25 additions & 5 deletions resources/assets/js/pages/Table-Reports.vue
Expand Up @@ -23,29 +23,30 @@
<i class="fa fa-bell" aria-hidden="true"></i>
</el-badge>
<el-table
:data="tableData"
v-loading="!states.isReadyReports"
:data="reports"
style="width: 100%"
height="650"
>
<el-table-column
fixed
prop="name"
label="Name"
:label="columnsName.name"
width="150">
</el-table-column>
<el-table-column
prop="description"
label="Description"
:label="columnsName.description"
width="250">
</el-table-column>
<el-table-column
prop="date"
label="Date last update"
:label="columnsName.dateLastUpdate"
width="250">
</el-table-column>
<el-table-column
fixed="right"
label="Operations"
:label="columnsName.operations"
width="120">
<template slot-scope="scope">
<i class="fa fa-arrow-circle-down"
Expand Down Expand Up @@ -81,7 +82,15 @@
process:false,
error:false,
emptyNotification:false,
isReadyReports:false,
},
columnsName:{
name:'',
description:'',
dateLastUpdate:'',
operations:'Operations'
},
reports:[],
tableData: [{
name: 'Report Seller',
description: 'Report for sale seller',
Expand All @@ -99,6 +108,17 @@
handleClose(key, keyPath) {
console.log(key, keyPath);
}
},
created(){
this.$http.get('/reports/api/dashboard.table.column')
.then(response => {
this.columnsName = response.data;
});
this.$http.get('/reports/api/dashboard.reports')
.then(response => {
this.reports = response.data.data;
this.states.isReadyReports = true;
});
}
}
</script>
Expand Down
7 changes: 7 additions & 0 deletions resources/lang/en/dashboard.php
@@ -0,0 +1,7 @@
<?php
return [
'name' => 'Name',
'description' => 'Description',
'dateLastUpdate' => 'Date last update',
'operations' => 'Operations',
];
7 changes: 7 additions & 0 deletions resources/lang/ru/dashboard.php
@@ -0,0 +1,7 @@
<?php
return [
'name' => 'Название',
'description' => 'Описание отчета',
'dateLastUpdate' => 'Последнее обновление',
'operations' => 'Операции',
];
9 changes: 1 addition & 8 deletions routes/web.php
Expand Up @@ -4,14 +4,7 @@

Route::prefix('api')->group(function () {
Route::get('dashboard.table.column', 'DashboardController@tableColumn');
Route::get('dashboard.table.formColumn', 'DashboardController@formColumn');
Route::get('dashboard.table.tasks', 'DashboardController@index');
Route::get('dashboard.table.users', 'DashboardController@users');
Route::get('dashboard.table.statuses', 'DashboardController@statuses');
Route::get('dashboard.table.listMode', 'DashboardController@listMode');
Route::post('dashboard.table.tasks.create', 'DashboardController@createTask');
Route::put('dashboard.table.tasks.update', 'DashboardController@updateTask');
Route::delete('dashboard.table.tasks.remove/{id}', 'DashboardController@remove');
Route::get('dashboard.reports', 'DashboardController@getReports');
});

Route::get('/{view?}', 'HomeController@index')->where('view', '(.*)');
11 changes: 11 additions & 0 deletions src/Console/ReportMakeCommand.php
Expand Up @@ -38,4 +38,15 @@ protected function getStub()
{
return __DIR__.'/stubs/report.stub';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Reports';
}
}
9 changes: 4 additions & 5 deletions src/Console/stubs/report.stub
@@ -1,8 +1,7 @@
<?php

declare(strict_types=1);
namespace DummyNamespace;

use Illuminate\Database\Eloquent\Model;
use agoalofalife\Reports\Report;

class DummyClass extends Report
Expand All @@ -11,7 +10,7 @@ class DummyClass extends Report
* Get file name
* @return string
*/
function getFilename() : string
public function getFilename() : string
{
return '';
}
Expand All @@ -20,7 +19,7 @@ class DummyClass extends Report
* Get title report
* @return string
*/
function getTitle() : string
public function getTitle() : string
{
return '';
}
Expand All @@ -29,7 +28,7 @@ class DummyClass extends Report
* Get description report
* @return string
*/
function getDescription() : string
public function getDescription() : string
{
return '';
}
Expand Down
9 changes: 9 additions & 0 deletions src/Contracts/ResourceCollectionReport.php
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);

namespace agoalofalife\Reports\Contracts;

interface ResourceCollectionReport
{
public function toArray() : array;
}
30 changes: 30 additions & 0 deletions src/Http/Controllers/DashboardController.php
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);

namespace agoalofalife\Reports\Http\Controllers;

use agoalofalife\Reports\Http\Resources\ReportsCollection;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;

class DashboardController extends Controller
{
/**
* Get table columns
* @return \Illuminate\Http\JsonResponse
*/
public function tableColumn() : JsonResponse
{
return response()->json(trans("reports::dashboard"));
}

public function getReports()
{
$reports = collect(config('reports.reports'))->map(function ($classReport) {
return new $classReport;
});
return (new ReportsCollection($reports))->response();
// dd($reports);
// return response()->json($reports);
}
}
3 changes: 2 additions & 1 deletion src/Http/Controllers/HomeController.php
Expand Up @@ -4,8 +4,9 @@
namespace agoalofalife\Reports\Http\Controllers;

use Illuminate\View\View;
use Illuminate\Routing\Controller;

class HomeController
class HomeController extends Controller
{
public function __construct()
{
Expand Down
24 changes: 24 additions & 0 deletions src/Http/Resources/ReportsCollection.php
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace agoalofalife\Reports\Http\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;

/**
* Class ReportsCollection
* @package agoalofalife\Reports\Http\Resources
*/
class ReportsCollection extends ResourceCollection
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
// TODO add reports merge with database info
return parent::toArray($request);
}
}
28 changes: 24 additions & 4 deletions src/Report.php
Expand Up @@ -3,8 +3,9 @@

namespace agoalofalife\Reports;

use agoalofalife\Reports\Contracts\ResourceCollectionReport;

abstract class Report
abstract class Report implements ResourceCollectionReport
{
/**
* Disk for filesystem
Expand All @@ -16,18 +17,37 @@ abstract class Report
* Get file name
* @return string
*/
abstract function getFilename() : string;
abstract public function getFilename() : string;

/**
* Get title report
* @return string
*/
abstract function getTitle() : string;
abstract public function getTitle() : string;

/**
* Get description report
* @return string
*/
abstract function getDescription() : string;
abstract public function getDescription() : string;

/**
* @return array
*/
public function toArray() : array
{
return [
'name' => $this->getTitle(),
'description' => $this->getDescription(),
'class' => $this->getNameClass()
];
}
/**
* Get full class name
* @return string
*/
private function getNameClass() : string
{
return get_class($this);
}
}
9 changes: 5 additions & 4 deletions src/ReportsServiceProvider.php
Expand Up @@ -11,6 +11,7 @@ class ReportsServiceProvider extends ServiceProvider
public function boot()
{
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'reports');
$this->registerRoutes();
$this->commands([
Console\InstallCommand::class,
Expand Down Expand Up @@ -38,9 +39,9 @@ protected function toPublish()
$this->publishes([
__DIR__.'/../config/reports.php' => config_path('reports.php'),
], 'reports-migration');
// $this->publishes([
// __DIR__.'/../resources/lang' => resource_path('lang/vendor/reports'),
// ], 'reports-migration');
$this->publishes([
__DIR__.'/../resources/lang' => resource_path('lang/vendor/reports'),
], 'reports-migration');
// $this->publishes([
// REPORTS_PATH.'/public' => public_path('vendor/reports'),
// ], 'reports-assets');
Expand All @@ -56,7 +57,7 @@ protected function registerRoutes() : void
{
Route::group([
'prefix' => 'reports',
'namespace' => 'agoalofalife\reports\Http\Controllers',
'namespace' => 'agoalofalife\Reports\Http\Controllers',
'middleware' => 'web',
], function () {
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
Expand Down

0 comments on commit a2c1236

Please sign in to comment.