-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfarm_grafana_integration.module
55 lines (47 loc) · 1.39 KB
/
farm_grafana_integration.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* @file
* Module file for grafana intergration
*/
/**
* Implements hook_theme().
*/
function farm_grafana_integration_theme() {
return array(
'grafana_integration_panel_formatter' => array(
'variables' => array('url' => NULL),
),
'grafana_integration_full_view' => array(
'variables' => array('url' => NULL),
),
);
}
/**
* Implements hook_entity_base_field_info().
*/
function farm_grafana_integration_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'asset') {
$fields['grafana_panel_link'] = BaseFieldDefinition::create('grafana_integration')
->setLabel(t('Grafana Panel Link'))
->setDescription(t('Option to add a Grafana Panel'))
->setRevisionable(TRUE);
$fields['grafana_panel_link']->setDisplayOptions('form', [
'type' => 'options_buttons',
'weight' => $options['weight']['form'] ?? 0,
]);
$fields['grafana_panel_link']->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'list_default',
'weight' => $options['weight']['view'] ?? 0,
]);
return $fields;
}
}
/**
* Implements hook_preprocess_HOOK().
*/
function farm_grafana_integration_preprocess_toolbar(&$variables) {
$variables['#attached']['library'][] = 'farm_grafana_integration/grafana_toolbar';
}