Ejemplo n.º 1
0
func loadPluginDashboard(plugin *PluginBase, path string) (*m.Dashboard, error) {

	dashboardFilePath := filepath.Join(plugin.PluginDir, path)
	reader, err := os.Open(dashboardFilePath)
	if err != nil {
		return nil, err
	}

	defer reader.Close()

	data, err := simplejson.NewFromReader(reader)
	if err != nil {
		return nil, err
	}

	return m.NewDashboardFromJson(data), nil
}
Ejemplo n.º 2
0
func loadDashboardFromFile(filename string) (*JsonDashIndexItem, error) {
	reader, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer reader.Close()

	data, err := simplejson.NewFromReader(reader)
	if err != nil {
		return nil, err
	}

	stat, _ := os.Stat(filename)

	item := &JsonDashIndexItem{}
	item.Dashboard = m.NewDashboardFromJson(data)
	item.TitleLower = strings.ToLower(item.Dashboard.Title)
	item.TagsCsv = strings.Join(item.Dashboard.GetTags(), ",")
	item.Path = stat.Name()

	return item, nil
}
Ejemplo n.º 3
0
func loadPluginDashboard(pluginId, path string) (*m.Dashboard, error) {
	plugin, exists := Plugins[pluginId]

	if !exists {
		return nil, PluginNotFoundError{pluginId}
	}

	dashboardFilePath := filepath.Join(plugin.PluginDir, path)
	reader, err := os.Open(dashboardFilePath)
	if err != nil {
		return nil, err
	}

	defer reader.Close()

	data, err := simplejson.NewFromReader(reader)
	if err != nil {
		return nil, err
	}

	return m.NewDashboardFromJson(data), nil
}