Skip to content
This repository has been archived by the owner on Mar 14, 2018. It is now read-only.

Create a test vue page and set up Laravel Mix #200

Open
wants to merge 36 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ef29260
Create a test vue page and set up Laravel Mix.
murrant May 25, 2017
8cb7dbf
Not quite working. jquery-ui draggable isn't working.
murrant May 26, 2017
e82bbc8
Import jquery-ui properly.
murrant May 26, 2017
58f5e9e
Extract a Vue dashboard component.
murrant May 26, 2017
251e7e9
Set up git ignores for generated files.
murrant May 26, 2017
4704e82
Populate data from API, a little bit of hard coding for now.
murrant May 26, 2017
225db20
Make dashboard stuff happen.
murrant May 27, 2017
5564544
remove app.js
murrant May 27, 2017
707e522
Attempt at AvailabilityWidget
murrant May 28, 2017
f9845cd
Fix port/sensor count relationships always being appended...
murrant May 29, 2017
be06808
Re-organize WidgetData to support multiple widget types.
murrant May 29, 2017
4919002
Refresh every 5 mins, this will do until web sockets is implemented.
murrant May 29, 2017
1095185
pull the availability map into the dashboard
murrant May 29, 2017
417c081
Add some animations, yay
murrant May 30, 2017
2e103fd
first try fixing travis
murrant May 31, 2017
d20982d
remove caching
murrant May 31, 2017
3bbc6ed
set node_js version
murrant May 31, 2017
97dd5d3
install node, use trusty
murrant May 31, 2017
d71d27b
hopefully get version 7 of node.js
murrant May 31, 2017
2700073
Use the root user for mysql
murrant May 31, 2017
7b30f02
switch to sudo required to hopefully fix mysql issues.
murrant May 31, 2017
c2b8883
Fix code style
murrant May 31, 2017
c70c75e
Cache the right things?
murrant May 31, 2017
2740f60
Compile node.js stuff in scrutinzer too
murrant May 31, 2017
a20d4f1
hard code webpack dependency
murrant May 31, 2017
ff6340f
work around node-sass issue
murrant May 31, 2017
7014ff9
Working on echo
murrant Jun 2, 2017
c357376
Add device:update command line helper
murrant Jun 2, 2017
189e4ac
Use private channels all working
murrant Jun 2, 2017
2700c43
Add Deleted and Created events.
murrant Jun 4, 2017
ca5b504
Use standard API endpoints...
murrant Jun 5, 2017
c87041f
Use standard API endpoints...
murrant Jun 12, 2017
7b5663c
Use laravel-echo-server (socket.io + redis) instead of pusher.
murrant Jun 12, 2017
4c6bf54
Broadcast settings
murrant Jun 15, 2017
5dea4d2
Start on widget settings
murrant Jun 19, 2017
2aa2d50
Make Laravel Echo Server use settings from .env
murrant Jun 20, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ DB_DATABASE=librenms
DB_USERNAME=librenms
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
BROADCAST_DRIVER=redis
CACHE_DRIVER=redis
SESSION_DRIVER=file
QUEUE_DRIVER=sync

Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
!/.php_cs
!/.github/

# Generated files #
###################
/public/css/app.css
/public/js/manifest.js
/public/js/vendor.js
/public/js/app.js
/public/mix-manifest.json

# Others #
##########
/node_modules
Expand All @@ -21,6 +29,7 @@ Homestead.yaml
.env
/logs/
/storage/logs/
npm-debug.log
composer.lock
/storage/*.sqlite

Expand Down
4 changes: 4 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ build:

dependencies:
override:
- 'nvm install 7'
- 'npm install'
- 'npm rebuild node-sass'
- 'npm run production'
- 'composer install --no-interaction'
- 'cp .env.example .env'
- 'php artisan key:generate'
Expand Down
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
dist: trusty
sudo: required # mysql socket bug in container based trusty image

language: php

php:
- 5.6
- 7.0
- 7.1
- hhvm

matrix:
Expand All @@ -18,21 +22,26 @@ env:

cache:
directories:
- vendor
- $HOME/.cache/composer
- $HOME/.composer/cache/files
- $HOME/.cache/composer/files
- $HOME/.npm

before_install:
# Disable xdebug (hhvm doesn't support xdebug)
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi
- mysql -e 'CREATE DATABASE phpunit_librenms;'
- mysql -e 'GRANT ALL ON phpunit_librenms.* TO 'travis'@'localhost';'
- nvm install 7

install:
- travis_retry composer install --no-interaction --prefer-dist
- travis_retry npm install

before_script:
- cp .env.example .env
- php artisan key:generate
- npm run production

script:
- vendor/bin/phpunit
- vendor/bin/phpcs -n -p --colors --extensions=php --standard=PSR2 --ignore=/vendor,/storage,/database,/public,/bootstrap/cache,/_ide_helper.php ./
- vendor/bin/phpcs -n -p --colors --extensions=php --standard=PSR2 --ignore=/vendor,/node_modules,/storage,/database,/public,/bootstrap/cache,/_ide_helper.php ./
7 changes: 4 additions & 3 deletions app/Api/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace App\Api\Controllers;

use Dingo\Api\Routing\Helpers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, Helpers;
}
2 changes: 1 addition & 1 deletion app/Api/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct()
*/
public function index(Request $request)
{
$dashboards = Dashboard::allAvailable($request->user())->get();
$dashboards = Dashboard::allAvailable($request->user())->get()->keyBy('dashboard_id');
return $dashboards;
}

Expand Down
78 changes: 40 additions & 38 deletions app/Api/Controllers/DeviceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,49 @@
use App\Models\User;
use Illuminate\Http\Request;

/**
* Device resource representation.
*
* @Resource("Device", uri="/api/devices")
*/
class DeviceController extends Controller
{
public function __construct()
{
}

/**
* Display a listing of all authorized devices
* Get a list of all devices
*
* @return \Illuminate\Http\Response
* @Get("/")
* @Versions({"v1"})
* @Transaction({
* @Request("/"),
* @Response(200, body={"devices":{{"id":34,"os":"linux","icon":"https://hostname/images/os/linux.svg","status":1,"uptime":423452},{"id":38,"os":"ios","icon":"https://hostname/images/os/cisco.svg","status":0,"uptime":452}}})
* })
* @Parameters({
* @Parameter("fields", type="sting", required=false, description="Comma separated list of fields to return"),
* @Parameter("per_page", type="integer", required=false, description="Pagination per-page count")
* })
*/
public function index(Request $request)
{
// fetch devices from the database
$per_page = $request->per_page ?: 25;
if ($request->user()->hasGlobalRead()) {
$devices = Device::paginate($per_page);
$devices = Device::query();
} else {
$devices = User::find($request->user()->user_id)->devices()->paginate($per_page);
$devices = $request->user()->devices();
}
return $devices;
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
$fields = isset($request->fields) ? explode(',', $request->fields) : ['*'];

// paginate if requested (is this needed/documented?)
if (isset($request->per_page)) {
return $devices->paginate($request->per_page, $fields);
}

return $devices->get($fields);
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
Expand All @@ -51,10 +57,17 @@ public function store(Request $request)
}

/**
* Display the specified resource.
* Fetch a device
*
* @param int $id
* @return \Illuminate\Http\Response
* @Get("/{id}")
* @Versions({"v1"})
* @Transaction({
* @Request("/34"),
* @Response(200, body={"device":{"id":34,"os":"linux","icon":"https://hostname/images/os/linux.svg","status":1,"uptime":423452}})
* })
* @Parameters({
* @Parameter("id", type="integer", required=true, description="The id of the device to show")
* })
*/
public function show(Request $request, $id)
{
Expand All @@ -72,22 +85,11 @@ public function show(Request $request, $id)
return $device;
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
Expand All @@ -98,7 +100,7 @@ public function update(Request $request, $id)
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
Expand Down
143 changes: 143 additions & 0 deletions app/Api/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?php
/**
* SettingsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Tony Murray
* @author Tony Murray <[email protected]>
*/

namespace App\Api\Controllers;

use App\Http\Controllers\Controller;
use Dingo\Api\Routing\Helpers;
use Illuminate\Http\Request;
use Settings;

/**
* Settings resource representation.
*
* @Resource("Settings", uri="/api/settings")
*/
class SettingsController extends Controller
{
use Helpers;

/**
* List all settings
*
* @Get("/")
* @Versions({"v1"})
* @Transaction({
* @Request("/"),
* @Response(200, body={"multi":{"dimensional","json"},"array":"values"})
* })
*/
public function index()
{
return Settings::all();
}

/**
* Save a setting or array of settings
*
* @Post("/{setting}")
* @Versions({"v1"})
* @Transaction({
* @Request({"setting":"snmp.community", "value":{"public","private"}}),
* @Response(200)
* })
* @Parameters({
* @Parameter("setting", type="string", required=true, description="The setting path, separated by periods"),
* @Parameter("value", type="string", required=true, description="The value to set")
* })
*/
public function store(Request $request)
{
// TODO move to validation
if (!$request->user()->isAdmin()) {
return $this->response->errorForbidden('Only Admins can change settings');
}

Settings::set($request->setting, $request->value);
return $this->response->accepted();
}

/**
* Retrieve a setting
*
* @Get("/{setting}")
* @Versions({"v1"})
* @Transaction({
* @Request("/snmp.community"),
* @Response(200, body={"public","private"})
* })
* @Parameters({
* @Parameter("setting", type="string", required=true, description="The setting path, separated by periods")
* })
*/
public function show($id)
{
return Settings::get($id);
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
if (!$request->user()->isAdmin()) {
return $this->response->errorForbidden('Only Admins can change settings');
}

if (!isset($request->value)) {
return $this->response->errorBadRequest('Missing value');
}

Settings::set($id, $request->value);
return $this->response->accepted();
}

/**
* Unset a setting
*
* @Delete("/{setting}")
* @Versions({"v1"})
* @Transaction({
* @Request("/snmp.community"),
* @Response(200)
* })
* @Parameters({
* @Parameter("setting", type="string", required=true, description="The setting path, separated by periods")
* })
*/
public function destroy(Request $request, $id)
{
if (!$request->user()->isAdmin()) {
return $this->response->errorForbidden('Only Admins can change settings');
}

Settings::forget($id);
return $this->response->accepted();
}
}
Loading