GlobalNOC / globalnoc-networkmap-panel

A network map panel for Grafana
Other
195 stars 29 forks source link

map 自动读取json文件,刷新页面后数据不丢失 #105

Open tangyang9988 opened 4 years ago

tangyang9988 commented 4 years ago

我想要自动读取json文件,不要手动配置。做法如下:在atlas.js中给定本地json的路径,利用ajax读取json内容,将json内容传给ctrl.panel.mapSrc[j]后可以显示节点信息,但是整个页面刷新之后数据没了。 问题:如何在不点击右上角的Save dashboard情况下,自动保存我们的地图数据,刷新页面不影响???源码怎么去改??? 我的json文件如下:急急急!!!! { "results": [ { "links": [

    {
      "path": [
        {
          "lon": "120.291547",
          "order": "1",
          "lat": "31.926044"
        },
        {
          "lon": "119.725848",
          "order": "2",
          "lat": "31.501712"
        }
      ],
      "name": "Link Name"
    },
    {
      "path": [
        {
          "lon": "120.291547",
          "order": "3",
          "lat": "31.926044"
        },
        {
          "lon": "120.304573",
          "order": "3",
          "lat": "31.686696"
        }
      ]
    }
  ],
  "endpoints": [
    {
      "pop_id": "jp",
      "lon": "120.291547",
      "real_lon": null,
      "real_lat": null,
      "name": "endpoint1",
      "lat": "31.926044"
    },
    {
      "pop_id": "usa",
      "lon": "120.304573",
      "real_lon": null,
      "real_lat": null,
      "name": "endpoint2",
      "lat": "31.686696"
    },
    {
      "pop_id": "ch",
      "lon": "120.318559",
      "real_lon": null,
      "real_lat": null,
      "name": "endpoint3",
      "lat": "31.498764"
    },
    {
      "pop_id": "yx",
      "lon": "119.725848",
      "real_lon": null,
      "real_lat": null,
      "name": "endpoint4",
      "lat": "31.501712"
    }
  ]
}

] }

daldoyle commented 4 years ago

Hi there,

Unfortunately I don't speak/read Chinese, but I was able to get a colleague to translate.

I want to automatically load json file without manually configuration. For example, define json file path in the atlas.js then use ajax to load json file. After json file is passed to ctrl.panel.mapSrc[j] the node information is able to show on the map. However, the data can’t be persistent after refreshing the page. Question: Is there a way to automatically save the map data without clicking the Save dashboard on the top right? And make it persistent with page refreshing. Could you point me to the source code where controls that part? Here is my json file

If I'm reading this right, you want to load the map topology from an external resource. In the spot where you would put JSON normally, you should be able to just put a URL to a JSON file in some web accessible location and it will load that as the topology when it loads up. You can then have whatever external process regenerate that file and put it into the same location.