Skip to content

Commit

Permalink
Merge pull request #73 from Icinga/release/v1.0
Browse files Browse the repository at this point in the history
Release/v1.0
  • Loading branch information
martialblog authored Aug 9, 2024
2 parents 54c1aa2 + 6d318a3 commit b0f0e1a
Show file tree
Hide file tree
Showing 43 changed files with 1,357 additions and 657 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: monthly
41 changes: 38 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ on:
pull_request:
branches:
- main
- release/*

jobs:
lint:
name: Static analysis for php ${{ matrix.php }} on ${{ matrix.os }}
name: Lint and Code Style
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2']
php: ['8.2', '8.3']
os: ['ubuntu-latest']

steps:
- name: Checkout code base
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -40,3 +41,37 @@ jobs:
- name: PHP CodeSniffer
if: success() || matrix.allow_failure
run: phpcs -wps --colors

test:
name: Unittest
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3']
os: ['ubuntu-latest']

steps:
- name: Checkout code base
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: 'phpunit:10.4'

- name: Setup Libraries
run: |
mkdir -p _libraries
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git _libraries/ipl
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git _libraries/vendor
git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2
git clone --depth 1 https://github.com/Icinga/icingadb-web.git _icingaweb2/modules/icingadb
ln -s `pwd` _icingaweb2/modules/toplevelview
- name: PHPUnit
env:
ICINGAWEB_LIBDIR: _libraries/
run: phpunit
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
!.git*

# Artifacts from vendor parts in testing
_icingaweb2/
_libraries/
.phpunit.cache/
.phplint.cache/
reports/
/docker-compose.yml
/*.phar
/Icinga
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: setup test

setup:
mkdir -p _libraries &&\
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git _libraries/ipl &&\
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git _libraries/vendor &&\
git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2 &&\
git clone --depth 1 https://github.com/Icinga/icingadb-web.git _icingaweb2/modules/icingadb
ln -s `pwd` _icingaweb2/modules/toplevelview
test:
ICINGAWEB_LIBDIR=_libraries phpunit
lint:
phplint application/ library/
phpcs:
phpcs application/ library/
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@ children:
- host: anotherhost
service: ssh
- name: Tile 2
- hostgroup: linux-servers
- name: Tile 3
- name: Section 2
- name: Tile 1
- name: Tile 2
hostgroup: linux-servers
- servicegroup: http
```
With a caching layer, this view can aggregate thousands of status objects and make
them easily available for overview and drill down.
This view extends the status logic and behavior of Icinga Web 2 a bit,
please see the documentation on details.
## Requirements
* Icinga Web 2 >= 2.5.0
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Specify the release version.

```
VERSION=0.x.x
VERSION=1.x.x
```

## Issues
Expand Down
36 changes: 29 additions & 7 deletions application/controllers/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

namespace Icinga\Module\Toplevelview\Controllers;

use Icinga\Module\Toplevelview\Model\View;
use Icinga\Module\Toplevelview\Forms\EditForm;
use Icinga\Module\Toplevelview\ViewConfig;
use Icinga\Module\Toplevelview\Web\Controller;

use Icinga\Web\Url;
use Icinga\Application\Icinga;

class EditController extends Controller
{
Expand Down Expand Up @@ -39,26 +42,45 @@ public function indexAction()
{
$action = $this->getRequest()->getActionName();

$config_dir_module = Icinga::app()
->getModuleManager()
->getModule('toplevelview')
->getConfigDir();

$c = new ViewConfig($config_dir_module);
$view = null;

if ($action === 'add') {
$this->view->title = sprintf('%s Top Level View', $this->translate('Add'));
$view = new ViewConfig();
$view->setConfigDir();
$view = new View('', $c::FORMAT_YAML);
} elseif ($action === 'clone') {
// Clone the view and give it to the View
$name = $this->params->getRequired('name');
$this->view->title = sprintf('%s Top Level View', $this->translate('Clone'));
$view = clone ViewConfig::loadByName($name);

// Check if the user has permissions/restrictions for this View
$restrictions = $c->getRestrictions('toplevelview/filter/edit');
$c->assertAccessToView($restrictions, $name);

$view = clone $c->loadByName($name);
} else {
$this->view->name = $name = $this->params->getRequired('name');
$this->view->title = sprintf('%s Top Level View: %s', $this->translate('Edit'), $this->params->getRequired('name'));
$view = ViewConfig::loadByName($name);

// Check if the user has permissions/restrictions for this View
$restrictions = $c->getRestrictions('toplevelview/filter/edit');
$c->assertAccessToView($restrictions, $name);

$view = $c->loadByName($name);
}

$view->setFormat($c::FORMAT_YAML);

$this->view->form = $form = new EditForm();
$form->setViewConfig($c);
$form->setViews($view);

$view->setFormat(ViewConfig::FORMAT_YAML);
$form->setViewConfig($view);
$form->handleRequest();

$this->setViewScript('edit/index');
}

Expand Down
12 changes: 11 additions & 1 deletion application/controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Icinga\Module\Toplevelview\ViewConfig;
use Icinga\Module\Toplevelview\Web\Controller;

use Icinga\Application\Icinga;

/**
* IndexController loads all existing Views from their YAML files.
*/
Expand All @@ -19,7 +21,15 @@ public function indexAction()
])->activate('index');

// Load add views from the existing YAML files
$this->view->views = ViewConfig::loadAll();
$config_dir_module = Icinga::app()
->getModuleManager()
->getModule('toplevelview')
->getConfigDir();

$c = new ViewConfig($config_dir_module);
$views = $c->loadAll();

$this->view->views = $views;

$this->setAutorefreshInterval(30);
}
Expand Down
50 changes: 45 additions & 5 deletions application/controllers/ShowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

use Icinga\Module\Toplevelview\ViewConfig;
use Icinga\Module\Toplevelview\Web\Controller;

use Icinga\Web\Url;
use Icinga\Application\Icinga;

class ShowController extends Controller
{
public function init()
{
$tabs = $this->getTabs();

$url = Url::fromRequest()->setParams(clone $this->params);

$tiles = Url::fromPath('toplevelview/show', ['name' => $this->params->getRequired('name')]);

$tabs->add('index', [
Expand Down Expand Up @@ -43,7 +43,21 @@ public function init()
public function indexAction()
{
$this->view->name = $name = $this->params->getRequired('name');
$this->view->view = $view = ViewConfig::loadByName($name);

$config_dir_module = Icinga::app()
->getModuleManager()
->getModule('toplevelview')
->getConfigDir();

$c = new ViewConfig($config_dir_module);

// Check if the user has permissions/restrictions for this View
$restrictions = $c->getRestrictions('toplevelview/filter/views');
$c->assertAccessToView($restrictions, $name);

$view = $c->loadByName($name);
$this->view->view = $view;

$tree = $view->getTree();

if (($lifetime = $this->getParam('cache')) !== null) {
Expand All @@ -56,7 +70,20 @@ public function indexAction()
public function treeAction()
{
$this->view->name = $name = $this->params->getRequired('name');
$this->view->view = $view = ViewConfig::loadByName($name);

$config_dir_module = Icinga::app()
->getModuleManager()
->getModule('toplevelview')
->getConfigDir();

$c = new ViewConfig($config_dir_module);

// Check if the user has permissions/restrictions for this View
$restrictions = $c->getRestrictions('toplevelview/filter/views');
$c->assertAccessToView($restrictions, $name);

$view = $c->loadByName($name);
$this->view->view = $view;

$tree = $view->getTree();

Expand All @@ -72,7 +99,20 @@ public function treeAction()
public function sourceAction()
{
$this->view->name = $name = $this->params->getRequired('name');
$this->view->view = $view = ViewConfig::loadByName($name);

$config_dir_module = Icinga::app()
->getModuleManager()
->getModule('toplevelview')
->getConfigDir();

$c = new ViewConfig($config_dir_module);

// Check if the user has permissions/restrictions for this View
$restrictions = $c->getRestrictions('toplevelview/filter/views');
$c->assertAccessToView($restrictions, $name);

$view = $c->loadByName($name);
$this->view->view = $view;

$this->view->text = $view->getText();
$this->setViewScript('index', 'text');
Expand Down
Loading

0 comments on commit b0f0e1a

Please sign in to comment.