Skip to content

Commit 81bf3a7

Browse files
author
shrank
committed
initial commit
1 parent dab2257 commit 81bf3a7

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# zabbix-widget-html
22
Simple Widget that lets you put arbitrary HTML code on a Zabbix Dashboard
3+
4+
## Install

html_widget/actions/WidgetView.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace Modules\HtmlWidget\Actions;
3+
use CControllerDashboardWidgetView,
4+
CControllerResponseData;
5+
class WidgetView extends CControllerDashboardWidgetView {
6+
protected function doAction(): void {
7+
$this->setResponse(new CControllerResponseData([
8+
'name' => $this->getInput('name', $this->widget->getName()),
9+
'content' => $this->fields_values['content'],
10+
'user' => [
11+
'debug_mode' => $this->getDebugMode()
12+
]
13+
]));
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace Modules\HtmlWidget\Includes;
3+
use Zabbix\Widgets\CWidgetForm;
4+
use Zabbix\Widgets\Fields\CWidgetFieldTextArea;
5+
class WidgetForm extends CWidgetForm {
6+
public function addFields(): self {
7+
return $this
8+
->addField(
9+
new CWidgetFieldTextArea('content', _('HTML Content'))
10+
);
11+
}
12+
}

html_widget/manifest.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"manifest_version": 2.0,
3+
"id": "html_widget",
4+
"type": "widget",
5+
"name": "HTML",
6+
"namespace": "HtmlWidget",
7+
"version": "1.0",
8+
"author": "shrank",
9+
"actions": {
10+
"widget.html_widget.view": {
11+
"class": "WidgetView"
12+
}
13+
}
14+
}

html_widget/views/widget.edit.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* HTML widget form view.
4+
*
5+
* @var CView $this
6+
* @var array $data
7+
*/
8+
9+
(new CWidgetFormView($data))
10+
->addField(
11+
new CWidgetFieldTextArea($data['fields']['content'])
12+
)
13+
->show();
14+
?>

html_widget/views/widget.view.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* HTML widget view. < *
4+
* @var CView $this
5+
* @var array $data
6+
*/
7+
(new CWidgetView($data))
8+
->addItem(
9+
new CJsScript($data['content'])
10+
)
11+
->show();
12+
13+
?>

0 commit comments

Comments
 (0)