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 #41 from RedRoundRobin/develop
Browse files Browse the repository at this point in the history
Baseline 0.14
  • Loading branch information
Maxelweb authored Apr 11, 2020
2 parents 8ca2534 + 1c1edeb commit 1032068
Show file tree
Hide file tree
Showing 84 changed files with 10,373 additions and 1,662 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": [["env", { "modules": false }]],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"presets": [["env", { "targets": { "node": "current" } }]]
Expand Down
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"
}
}
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public/js
public/webfonts
public/mix-manifest.json

composer.lock
package-lock.json

.php_cs.cache

fix.sh
.DS_Store
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
### Installazione e primo avvio

1. composer update
2. npm update
3. php artisan migrate:fresh
4. npm run dev
5. php artisan serve
2. npm install
3. npm run dev
4. php artisan serve


### In caso di corruzione JS :fire:

`npm install --package-lock`
26 changes: 20 additions & 6 deletions __tests__/ChartManagement.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
window.axios = require("axios");

import { mount } from "@vue/test-utils";
import ChartManagement from "../resources/js/components/ChartManagement.vue";
import DoubleChart from "../resources/js/components/DoubleChart.vue";
import SingleChart from "../resources/js/components/SingleChart";

describe("ChartManagement", () => {
describe("DoubleChart", () => {
test("is a Vue instance", () => {
const deviceId = 1;
const sensorId = 1;
const chart = mount(ChartManagement, {
propsData: { deviceId, sensorId },
const sensor2 =
'{"type":"stick","realSensorId":1,"device":1,"sensorId":1}';
const sensor1 =
'{"type":"stick","realSensorId":1,"device":1,"sensorId":1}';
const chart = mount(DoubleChart, {
propsData: { sensor2, sensor1 },
});
expect(chart.isVueInstance()).toBeTruthy();
});
});

describe("SingleChart", () => {
test("is a Vue instance", () => {
const sensor =
'{"type":"stick","realSensorId":1,"device":1,"sensorId":1}';
const chart = mount(SingleChart, {
propsData: { sensor },
});
expect(chart.isVueInstance()).toBeTruthy();
});
Expand Down
40 changes: 40 additions & 0 deletions app/Http/Controllers/AlertsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Http\Controllers;

use App\Providers\AlertServiceProvider;
use App\Providers\DeviceServiceProvider;
use App\Providers\SensorServiceProvider;

class AlertsController extends Controller
{
private $alertsProvider;
private $devicesProvider;
private $sensorsProvider;


public function __construct()
{
$this->middleware('auth');
$this->alertsProvider = new AlertServiceProvider();
$this->devicesProvider = new DeviceServiceProvider();
$this->sensorsProvider = new SensorServiceProvider();
}

public function index()
{
$alerts = $this->alertsProvider->findAll();
$alertsWithSensors = [];
foreach ($alerts as $state => $alertsList) {
foreach ($alertsList as $alert) {
$sensor = $this->sensorsProvider->findFromLogicalId($alert->sensor);
$alertsWithSensors[$state][] = [
'alert' => $alert,
'sensor' => $sensor,
'device' => $this->devicesProvider->find($sensor->device)
];
}
}
return view('alerts.index', compact('alertsWithSensors'));
}
}
5 changes: 1 addition & 4 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ protected function redirectTo()
*/
public function __construct()
{
/*session()->flush();
session_reset();
Auth::logout();*/
$this->middleware('guest')->except('logout');
}

Expand Down Expand Up @@ -126,7 +123,7 @@ protected function credentials(Request $request)
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|void
* @return Response
*
* @throws \Illuminate\Validation\ValidationException
*/
Expand Down
19 changes: 13 additions & 6 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,25 @@ public function index()
$entities = $entityProvider->findAll();//enti presenti
$users = $userProvider->findAll();//utenti registrati
$devices = $deviceProvider->findAll();//dispositivi registrati
$entity = null;
$devicesEntity = [];
$usersEntity = [];
$usersActiveEntity = [];

$devicesEntity = $deviceProvider->findAllFromEntity($entityProvider->findFromUser($user->getAuthIdentifier()));
$usersEntity = $userProvider->findAllFromEntity($entityProvider->findFromUser($user->getAuthIdentifier()));
if ($user->getRole() != 'Amministratore') {
$entity = $entityProvider->findFromUser($user->getAuthIdentifier());
$devicesEntity = $deviceProvider->findAllFromEntity($entity->entityId);
$usersEntity = $userProvider->findAllFromEntity($entity->entityId);
$usersActiveEntity = array_filter($usersEntity, function ($u) {
return !$u->deleted;
});
}

$usersActive = array_filter($users, function ($u) {
return !$u->deleted;
});
$usersActiveEntity = array_filter($usersEntity, function ($u) {
return !$u->deleted;
});
return view('dashboard.index', compact([
'user', 'users', 'entities', 'devices', 'devicesEntity', 'usersEntity', 'usersActive', 'usersActiveEntity'
'user', 'users', 'entities', 'devices', 'devicesEntity', 'usersEntity', 'usersActive', 'usersActiveEntity', 'entity'
]));
}
}
62 changes: 33 additions & 29 deletions app/Http/Controllers/DeviceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

namespace App\Http\Controllers;

use App\Models\Device;
use App\Models\Gateway;
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->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) //TODO
{
$gateway = $this->provider->find($gateway);
return view('gateways.edit', compact('gateway'));
}
}
Loading

0 comments on commit 1032068

Please sign in to comment.