Skip to content
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

Add dashboard redirect option #92

Merged
merged 4 commits into from
Nov 14, 2023
Merged

Add dashboard redirect option #92

merged 4 commits into from
Nov 14, 2023

Conversation

asimonok
Copy link
Collaborator

Resolves #91

SQL to create table

CREATE TABLE dashboards (
    device_id text NOT NULL,
    dashboard_id text NOT NULL
);

insert into dashboards values('device1', 'e591d2bb-5bce-40ae-9df7-70c1aace684c');
insert into dashboards values('device2', 'O4tc_E6Gz');
insert into dashboards values('device3', 'e591d2bb-5bce-40ae-9df7-70c1aace684c');

Dashboard for testing

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 4,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "marcusolsson-static-datasource",
        "uid": "P1D2C73DC01F2359B"
      },
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 1,
      "options": {
        "alwaysVisibleFilter": false,
        "autoScroll": false,
        "dashboardVariable": "dashboardId",
        "displayMode": "table",
        "emptyValue": false,
        "favorites": false,
        "filter": false,
        "groupSelection": false,
        "header": true,
        "padding": 10,
        "showName": false,
        "statusSort": false,
        "sticky": false,
        "variable": "device"
      },
      "title": "Panel Title",
      "type": "volkovlabs-variable-panel"
    }
  ],
  "refresh": "",
  "schemaVersion": 38,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "device1",
          "value": "device1"
        },
        "description": "",
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "name": "device",
        "options": [
          {
            "selected": true,
            "text": "device1",
            "value": "device1"
          },
          {
            "selected": false,
            "text": "device2",
            "value": "device2"
          },
          {
            "selected": false,
            "text": "device3",
            "value": "device3"
          }
        ],
        "query": "device1, device2, device3",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "current": {
          "selected": false,
          "text": "e591d2bb-5bce-40ae-9df7-70c1aace684c",
          "value": "e591d2bb-5bce-40ae-9df7-70c1aace684c"
        },
        "datasource": {
          "type": "postgres",
          "uid": "timescale"
        },
        "definition": "SELECT dashboard_id FROM dashboards where device_id='$device'",
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "name": "dashboardId",
        "options": [],
        "query": "SELECT dashboard_id FROM dashboards where device_id='$device'",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Device 1",
  "uid": "e591d2bb-5bce-40ae-9df7-70c1aace684c",
  "version": 5,
  "weekStart": ""
}

@asimonok asimonok requested a review from mikhail-vl November 13, 2023 15:08
@asimonok asimonok self-assigned this Nov 13, 2023
@asimonok asimonok marked this pull request as draft November 13, 2023 15:09
@mikhail-vl mikhail-vl added the enhancement New feature or request label Nov 13, 2023
@mikhail-vl mikhail-vl added this to the Version 2.2.0 milestone Nov 13, 2023
@asimonok asimonok marked this pull request as ready for review November 14, 2023 05:49
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2d000f9) 98.14% compared to head (a456b58) 98.17%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
+ Coverage   98.14%   98.17%   +0.02%     
==========================================
  Files          51       52       +1     
  Lines         862      876      +14     
  Branches      185      186       +1     
==========================================
+ Hits          846      860      +14     
  Misses          2        2              
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@mikhail-vl mikhail-vl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@mikhail-vl mikhail-vl merged commit a92cb2d into main Nov 14, 2023
4 checks passed
@mikhail-vl mikhail-vl deleted the feat/dashboard-redirect branch November 14, 2023 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for different types of devices in variables
3 participants