Skip to content

Fix accessmode conditional in config form #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
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
23 changes: 21 additions & 2 deletions application/forms/Config/GeneralConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function createElements(array $formData)
'required' => true
]
);

$this->addElement(
'select',
'grafana_protocol',
Expand All @@ -48,6 +49,7 @@ public function createElements(array $formData)
]
);

// TLS configuration
if (isset($formData['grafana_protocol']) && $formData['grafana_protocol'] === 'https') {
$this->addElement(
'checkbox',
Expand All @@ -69,6 +71,8 @@ public function createElements(array $formData)
]
);
}

// Timerange configuration
$this->addElement(
'select',
'grafana_timerange',
Expand All @@ -88,6 +92,8 @@ public function createElements(array $formData)
'description' => $this->translate('The default timerange to use for show all graphs.')
]
);

// Custom Variable configuration
$this->addElement(
'text',
'grafana_custvardisable',
Expand All @@ -104,6 +110,8 @@ public function createElements(array $formData)
'description' => $this->translate('Name of the custom variable that, if set, hold the config name to be used.'),
]
);

// Grafana dashboard configuration
$this->addElement(
'text',
'grafana_defaultdashboard',
Expand Down Expand Up @@ -141,6 +149,8 @@ public function createElements(array $formData)
'description' => $this->translate('ID of the default organization.'),
]
);

// Graphs shadow configuration
$this->addElement(
'checkbox',
'grafana_shadows',
Expand All @@ -150,6 +160,8 @@ public function createElements(array $formData)
'description' => $this->translate('Show shadows around the graph.'),
]
);

// Grafana datasource configuration
$this->addElement(
'select',
'grafana_datasource',
Expand All @@ -162,6 +174,8 @@ public function createElements(array $formData)
'description' => $this->translate('Select the Grafana datasource.')
]
);

// Grafana access mode configuration
$this->addElement(
'select',
'grafana_accessmode',
Expand All @@ -177,6 +191,7 @@ public function createElements(array $formData)
]
);

// Indirect proxy mode configuration
if (isset($formData['grafana_accessmode']) && $formData['grafana_accessmode'] === 'indirectproxy') {
$this->addElement(
'number',
Expand All @@ -202,6 +217,8 @@ public function createElements(array $formData)
'class' => 'autosubmit'
]
);

// Indirect proxy mode authentication configuration
if (isset($formData['grafana_authentication']) && $formData['grafana_authentication'] === 'basic') {
$this->addElement(
'text',
Expand Down Expand Up @@ -236,6 +253,7 @@ public function createElements(array $formData)
}
}

// Indirect proxy mode cache configuration
if (isset($formData['grafana_accessmode']) && $formData['grafana_accessmode'] === 'indirectproxy') {
$this->addElement(
'select',
Expand All @@ -252,6 +270,7 @@ public function createElements(array $formData)
);
}

// iFrame mode configuration
if (isset($formData['grafana_accessmode']) && ( $formData['grafana_accessmode'] != 'iframe' )) {
$this->addElement(
'number',
Expand All @@ -271,8 +290,6 @@ public function createElements(array $formData)
'description' => $this->translate('The default graph width in pixels.')
]
);
}
if (( $formData['grafana_accessmode'] != 'iframe' )) {
$this->addElement(
'select',
'grafana_usepublic',
Expand All @@ -288,6 +305,8 @@ public function createElements(array $formData)
]
);
}

// iFrame mode public link configuration
if (isset($formData['grafana_usepublic']) && ( $formData['grafana_usepublic'] === 'yes' ) && ( $formData['grafana_accessmode'] != 'iframe' )) {
$this->addElement(
'text',
Expand Down