Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #19 from RedRoundRobin/feature/frontend
Browse files Browse the repository at this point in the history
Feature/frontend
  • Loading branch information
BroHPotato committed Apr 4, 2020
2 parents 7841e0e + fd9b951 commit 49800d5
Show file tree
Hide file tree
Showing 55 changed files with 1,965 additions and 1,072 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ APP_KEY=base64:Kx0bZ0S6BUK05v9vam8ty+7Zsigqlp/Wqf+cbLCyOEM=
APP_DEBUG=true
APP_URL=http://localhost

API_URL=http://core.redroundrobin.site:9999
API_URL=http://core.host.redroundrobin.site:9999

LOG_CHANNEL=stack

Expand Down
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
],
"rules": {
"prettier/prettier": "error",
"no-invalid-this": "warn"
"no-invalid-this": "warn",
"no-unused-vars": "warn",
"no-var": "warn"
}
}
8 changes: 5 additions & 3 deletions __tests__/ChartManagement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import ChartManagement from "../resources/js/components/ChartManagement.vue";

describe("ChartManagement", () => {
test("is a Vue instance", () => {
const deviceId = 1;
const sensorId = 1;
const sensor2 =
'{"type":"stick","realSensorId":1,"device":1,"sensorId":1}';
const sensor1 =
'{"type":"stick","realSensorId":1,"device":1,"sensorId":1}';
const chart = mount(ChartManagement, {
propsData: { deviceId, sensorId },
propsData: { sensor2, sensor1 },
});
expect(chart.isVueInstance()).toBeTruthy();
});
Expand Down
60 changes: 32 additions & 28 deletions app/Http/Controllers/DeviceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

use App\Models\Device;
use App\Providers\DeviceServiceProvider;
use App\Providers\GatewayServiceProvider;
use App\Providers\SensorServiceProvider;
use Illuminate\Contracts\View\Factory;
use Illuminate\View\View;

class DeviceController extends Controller
{
private $provider;
private $gatewayProvider;
private $deviceProvider;
private $sensorProvider;

/**
* Create a new controller instance.
Expand All @@ -19,19 +23,23 @@ class DeviceController extends Controller
public function __construct()
{
$this->middleware('auth');
$this->provider = new DeviceServiceProvider();
$this->gatewayProvider = new GatewayServiceProvider();
$this->deviceProvider = new DeviceServiceProvider();
$this->sensorProvider = new SensorServiceProvider();
}

public function create()
{
$entities = $this->provider->findAll();
return view('devices.create', compact(['entities']));
$entities = $this->deviceProvider->findAll();
return view('devices.create', compact('entities'));
}

public function edit($device)
{
$device = $this->provider->retrieveById($device);
return view('devices.edit', compact('user'));
$device = $this->deviceProvider->find($device);
$sensors = $this->sensorProvider->findAllFromDevice($device->deviceId);

return view('devices.edit', compact('device', 'sensors'));
}

/**
Expand All @@ -41,17 +49,20 @@ public function edit($device)
*/
public function index()
{
//$devices = $this->provider->findAll();
///FAKER
$user = new Device();
$arr = array_combine(
array('deviceId', 'name', 'frequency', 'gatewayId'),
array("1", "dev1", 123, 1)
);
$user->fill($arr);
$devices[] = $user;
//TODO remove
return view('devices.index', compact('devices'));
$gateways = $this->gatewayProvider->findAll();
$devicesOnGateways = [];
foreach ($gateways as $g) {
$sensors = [];
$devices = $this->deviceProvider->findAll();//todo sostituire con findAllFromGateway($g->gatewayId);
foreach ($devices as $d) {
$sensors[$d->deviceId] = count($this->sensorProvider->findAllFromDevice($d->deviceId));
}
$devicesOnGateways[$g->gatewayId] = [0 => $g,
1 => $devices,
2 => $sensors
];
}
return view('devices.index', compact('devicesOnGateways'));
}

/**
Expand All @@ -62,16 +73,9 @@ public function index()
*/
public function show($device)
{
//$device = $this->provider->find($device);
///FAKER
$user = new Device();
$arr = array_combine(
array('deviceId', 'name', 'frequency', 'gatewayId'),
array("1", "dev1", 123, 1)
);
$user->fill($arr);
$device = $user;
//TODO remove
return view('devices.show', compact('device'));
$device = $this->deviceProvider->find($device);
$sensors = $this->sensorProvider->findAllFromDevice($device->deviceId);
$gateway = $this->gatewayProvider->findAllFromDevice($device->deviceId)[0];
return view('devices.show', compact(['device', 'sensors', 'gateway']));
}
}
15 changes: 14 additions & 1 deletion app/Http/Controllers/EntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Models\Entity;
use App\Providers\EntityServiceProvider;
use Illuminate\Contracts\View\Factory;
use Illuminate\View\View;
Expand All @@ -21,6 +22,18 @@ public function __construct()
$this->provider = new EntityServiceProvider();
}

public function create()
{
$entities = $this->provider->findAll();
return view('entities.create', compact(['entities']));
}

public function edit($entity)
{
$entity = $this->provider->find($entity);
return view('entities.edit', compact('entity'));
}

/**
* Display a listing of the resource.
*
Expand All @@ -40,7 +53,7 @@ public function index()
*/
public function show($entity)
{
$entity = $this->provider->retrieveById($entity);
$entity = $this->provider->find($entity);
return view('entities.show', compact('entity'));
}
}
18 changes: 17 additions & 1 deletion app/Http/Controllers/GatewayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Models\Gateway;
use App\Providers\GatewayServiceProvider;
use Illuminate\Contracts\View\Factory;
use Illuminate\View\View;
Expand Down Expand Up @@ -40,7 +41,22 @@ public function index()
*/
public function show($gateway)
{
$gateway = $this->provider->retrieveById($gateway);
$gateway = $this->provider->find($gateway);
return view('gateways.show', compact('gateway'));
}

/**
* @return Factory|View
*/
public function create() //TODO
{
$entities = $this->provider->findAll();
return view('gateways.create', compact(['entities']));
}

public function edit($gateway)
{
$gateway = $this->provider->find($gateway);
return view('gateways.edit', compact('gateway'));
}
}
18 changes: 11 additions & 7 deletions app/Http/Controllers/SensorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace App\Http\Controllers;

use App\Providers\DeviceServiceProvider;
use App\Providers\SensorServiceProvider;
use Illuminate\Contracts\View\Factory;
use Illuminate\View\View;

class SensorController extends Controller
{
private $provider;
private $sensorProvider;
private $deviceProvider;

/**
* Create a new controller instance.
Expand All @@ -18,7 +20,8 @@ class SensorController extends Controller
public function __construct()
{
$this->middleware('auth');
$this->provider = new SensorServiceProvider();
$this->sensorProvider = new SensorServiceProvider();
$this->deviceProvider = new DeviceServiceProvider();
}

/**
Expand All @@ -28,7 +31,7 @@ public function __construct()
*/
public function index($device)
{
$sensors = $this->provider->findAllFromDevice($device);
$sensors = $this->sensorProvider->findAllFromDevice($device);
return view('sensors.index', compact(['sensors', 'device']));
}

Expand All @@ -38,14 +41,15 @@ public function index($device)
* @param $sensor
* @return Factory|View
*/
public function show($device, $sensor)
public function show($deviceId, $sensorId)
{
$sensor = $this->provider->find($device, $sensor);
$sensor = $this->sensorProvider->find($deviceId, $sensorId);
$device = $this->deviceProvider->find($deviceId);
return view('sensors.show', compact(['sensor', 'device']));
}

public function fetch($device, $sensor)
public function fetch($sensorId)
{
return $this->provider->fetch($device, $sensor);
return $this->sensorProvider->fetch($sensorId);
}
}
5 changes: 2 additions & 3 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function create()
{
$entityProvider = new EntityServiceProvider();
$entities = $entityProvider->findAll();
return view('users.create', compact(['entities']));
return view('users.create', compact('entities'));
}

/**
Expand Down Expand Up @@ -155,9 +155,8 @@ public function destroy($userId)
*/
public function restore($userId)
{
dd($userId);//todo to remove
$user = $this->provider->retrieveById($userId);
$user->setDeleted(false);
$this->provider->update($user->getAuthIdentifier(), $user);
$this->provider->update($user->getAuthIdentifier(), json_encode($user->getAttributes(), JSON_FORCE_OBJECT));
}
}
36 changes: 36 additions & 0 deletions app/Http/Controllers/ViewController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Http\Controllers;

use App\Providers\ViewGraphProvider;
use App\Providers\ViewProvider;

class ViewController extends Controller
{
private $viewProvider;
private $viewGraphProvider;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->viewProvider = new ViewProvider();
$this->viewGraphProvider = new ViewGraphProvider();
}

public function index()
{
$views = $this->viewProvider->findAll();
return view('views.index', compact('views'));
}

public function show($viewId)
{
$graphs = $this->viewGraphProvider->findAllFromView($viewId);
return view('views.show', compact('graphs'));
}
}
14 changes: 1 addition & 13 deletions app/Models/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,5 @@

class Device extends Model
{
protected $fillable = ['deviceId', 'name', 'frequency', 'gatewayId'];

public function getSensors()
{
$provider = new SensorServiceProvider();
return $provider->findAllFromDevice($this->deviceId);
}

public function getEntity()
{
$provider = new EntityServiceProvider();
return $provider->findFromDevice($this->deviceId);
}
protected $fillable = ['deviceId', 'name', 'frequency', 'realDeviceId'];
}
5 changes: 0 additions & 5 deletions app/Models/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,4 @@
class Entity extends Model
{
protected $fillable = ['entityId', 'name', 'location', 'deleted'];

public function getName()
{
return $this->name;
}
}
2 changes: 1 addition & 1 deletion app/Models/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

class Gateway extends Model
{
protected $fillable = ['gatewayId', 'name'];
protected $fillable = ['gatewayId', 'name', 'devices'];
}
2 changes: 1 addition & 1 deletion app/Models/Sensor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

class Sensor extends Model
{
protected $fillable = ['sensorId', 'type', 'deviceSensorId', 'deviceId'];
protected $fillable = ['sensorId', 'type', 'realSensorId', 'device'];
}
10 changes: 10 additions & 0 deletions app/Models/View.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class View extends Model
{
protected $fillable = ['name', 'userId', 'viewId', 'viewGraphId'];
}
10 changes: 10 additions & 0 deletions app/Models/ViewGraph.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ViewGraph extends Model
{
protected $fillable = ['viewId', 'correlation', 'sensorId1', 'sensorId2', 'viewGraphId'];
}
Loading

0 comments on commit 49800d5

Please sign in to comment.