Skip to content

Commit

Permalink
Add NewDashletsForm usig ipl/html
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Mar 27, 2020
1 parent 9532855 commit e5d7664
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 0 deletions.
22 changes: 22 additions & 0 deletions modules/dashboards/application/controllers/DashletsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Icinga\Module\Dashboards\Controllers;

use Icinga\Module\Dashboards\Web\Controller;
use Icinga\Module\Dashboards\Form\NewDashletsForm;

class DashletsController extends Controller
{
public function indexAction()
{

}

public function newAction()
{
$this->setTitle('New Dashlet');

$dashletsForm = new NewDashletsForm();
$this->addContent($dashletsForm);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
var_dump("Hello World");
186 changes: 186 additions & 0 deletions modules/dashboards/library/Dashboards/Form/NewDashletsForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?php

namespace Icinga\Module\Dashboards\Form;

use ipl\Html\Form;
use ipl\Html\Html;

class NewDashletsForm extends Form
{
protected $defaultAttributes = [
'name' => 'dashboard_addurl',
'class' => 'icinga-form icinga-controls',
];

public function newAction()
{
$form = new Form();
$form->setAction('dashboards/dashlets/new');

$form->add(Html::tag('h1', ['class' => 'hint'], 'Add Dashlet To Dashboard'));
$form->addElement('hidden', 'org_pane', [
'value' => true,
'id' => 'form_dashboard_addurl_org_pane-ksrlagijhocp'
]);

$form->addElement('hidden', 'org_dashlet', [
'value' => true,
'id' => 'form_dashboard_addurl_org_dashlet-ksrlagijhocp'
]);

$form->add(Html::tag('div', [
'class' => 'control-group'
], [Html::tag('div', [
'class' => 'control-label-group'
], Html::tag('span', [
'id' => 'form_dashboard_addurl_url-tjucoyahpznm-label'
], Html::tag('label', [
'for' => 'form_dashboard_addurl_url-tjucoyahpznm',
'class' => 'control-label required'
], ['Url', Html::tag('span', [
'aria-hidden' => 'true'
], ' *')]))), Html::tag('textarea', [
'name' => 'url',
'rows' => '3',
'id' => 'url_textarea',
'required' => true,
'aria-describedby' => 'desc_form_dashboard_addurl_url-qvzeyghfujib',
'cols' => '80'
]), Html::tag('i', [
'class' => 'control-info icon-info-circled',
'aria-hidden' => true,
'role' => 'img',
'title' => 'Enter url to be loaded in the dashlet. You can paste the full URL, including filters.'
])]));

$form->add(Html::tag('div', [
'class' => 'control-group'
], [Html::tag('div', [
'class' => 'control-label-group'
], Html::tag('span', [
'id' => 'form_dashboard_addurl_dashlet-qnpsbfrlizec-label',
], Html::tag('label', [
'for' => 'form_dashboard_addurl_dashlet-qnpsbfrlizec',
'class' => 'control-label required'
], ['Dashlet Name', Html::tag('span', [
'aria-hidden' => 'true'
], '*')]))), Html::tag('input', [
'type' => 'text',
'name' => 'dashlet',
'id' => 'dashlet_name',
'value' => true,
'aria-required' => 'true',
'required' => true,
'aria-describedby' => 'desc_form_dashboard_addurl_dashlet-yubfwqingarm'
]), Html::tag('i', [
'class' => 'control-info icon-info-circled',
'aria-hidden' => 'true',
'role' => 'img',
'title' => 'Enter a title for the dashlet.'
])]));

$form->add(Html::tag('hr'));

$form->add(Html::tag('div', [
'class' => 'control-group'
], [Html::tag('span', [
'id' => 'autosubmit_warning_form_dashboard_addurl_create_new_pane-jtyoxcgivlsq',
'class' => 'sr-only'
], 'The page will be automatically updated upon change of the value'),
Html::tag('div', [
'class' => 'control-label-group'
], Html::tag('span', [
'id' => 'form_dashboard_addurl_create_new_pane-jtyoxcgivlsq-label'
], Html::tag('label', [
'for' => 'form_dashboard_addurl_create_new_pane-jtyoxcgivlsq',
'class' => 'control-label optional'
], 'New dashboard'))), Html::tag('input', [
'type' => 'hidden',
'class' => 'create_new_pane',
'value' => '0'
]), Html::tag('input', [
'type' => 'checkbox',
'name' => 'create_new_pane',
'id' => 'create_new_dashboard',
'value' => '1',
'class' => 'autosubmit sr-only',
'aria-describedby' => 'desc_form_dashboard_addurl_create_new_pane-jtyoxcgivlsq autosubmit_warning_form
_dashboard_addurl_create_new_pane-jtyoxcgivlsq'
]), Html::tag('label', [
'for' => 'form_dashboard_addurl_create_new_pane-scxfgqkmjzya',
'class' => 'toggle-switch'
], Html::tag('span', [
'class' => 'toggle-slider'
])), Html::tag('i', [
'aria-hidden' => 'true',
'class' => 'spinner autosubmit-info icon-cw',
'role' => 'img',
'title' => 'This page will be automatically updated upon change of the value'
]), Html::tag('i', [
'class' => 'control-info icon-info-circled',
'aria-hidden' => 'true',
'role' => 'img',
'title' => 'Check this box if you want to add the dashlet to a new dashboard'
]), Html::tag('span', [
'id' => 'desc_form_dashboard_addurl_create_new_pane-scxfgqkmjzya',
'class' => 'sr-only'
], 'Check this box if you want to add the dashlet to a new dashboard')
]));

$form->add(Html::tag('div', [
'class' => 'control-group',
], [Html::tag('div', [
'class' => 'control-label-group'
], Html::tag('span', [
'id' => 'form_dashboard_addurl_pane-ifmxqlncwujp-label',
], Html::tag('label', [
'for' => 'form_dashboard_addurl_pane-ifmxqlncwujp',
'class' => 'control-label required'
], ['Dashboard', Html::tag('span', [
'aria-hidden' => 'true'
], ' *')]))), Html::tag('select', [
'name' => 'pane',
'id' => 'dashboards_select',
'aria-required' => 'true',
'aria-describedby' => 'desc_form_dashboard_addurl_pane-ifmxqlncwujp'
], [Html::tag('option', [
'value' => 'Current Incidents'
], 'Current Incidents'), Html::tag('option', [
'value' => 'Muted'
], 'Muted')]), Html::tag('i', [
'class' => 'control-info icon-info-circled',
'aria-hidden' => 'true',
'role' => 'img',
'title' => 'Select a dashboard you want to add the dashlet to'
]), Html::tag('span', [
'id' => 'desc_form_dashboard_addurl_pane-onmwybfqarvi',
'class' => 'sr-only'
], 'Select a dashboard you want to add the dashlet to')]));

$form->add(Html::tag('div', [
'class' => 'control-group form-controls'
], [Html::tag('input', [
'type' => 'submit',
'name' => 'btn_submit',
'id' => 'submit_button',
'value' => 'Add To Dashboard',
'class' => 'btn-primary'
]), Html::tag('div', [
'class' => 'spinner'
], Html::tag('i', [
'class' => 'icon-spin6',
'aria-hidden' => 'true'
]))]));

$form->add(Html::tag('ul', [
'class' => 'form-info'
], Html::tag('li', null, '* Required field')));

return $form;
}

protected function assemble()
{
$this->addFrom($this->newAction());
}
}

0 comments on commit e5d7664

Please sign in to comment.