Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3849b596
Commit
3849b596
authored
Apr 11, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(updates): changed to new api
parent
31441f0b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
108 deletions
+23
-108
pkg/plugins/update_checker.go
+23
-17
public/app/plugins/panel/dashlist/module.js
+0
-91
No files found.
pkg/plugins/update_checker.go
View file @
3849b596
...
...
@@ -11,16 +11,8 @@ import (
"github.com/grafana/grafana/pkg/setting"
)
type
GrafanaNetPlugins
struct
{
Plugins
[]
GrafanaNetPlugin
`json:"plugins"`
}
type
GrafanaNetPlugin
struct
{
Id
string
`json:"id"`
Versions
[]
GrafanaNetPluginVersion
`json:"versions"`
}
type
GrafanaNetPluginVersion
struct
{
Slug
string
`json:"slug"`
Version
string
`json:"version"`
}
...
...
@@ -43,11 +35,27 @@ func StartPluginUpdateChecker() {
}
}
func
getAllExternalPluginSlugs
()
string
{
str
:=
""
for
_
,
plug
:=
range
Plugins
{
if
plug
.
IsCorePlugin
{
continue
}
str
+=
plug
.
Id
+
","
}
return
str
}
func
checkForUpdates
()
{
log
.
Trace
(
"Checking for updates"
)
client
:=
http
.
Client
{
Timeout
:
time
.
Duration
(
5
*
time
.
Second
)}
resp
,
err
:=
client
.
Get
(
"https://grafana.net/api/plugins/repo"
)
pluginSlugs
:=
getAllExternalPluginSlugs
()
resp
,
err
:=
client
.
Get
(
"https://grafana.net/api/plugins/versioncheck?slugIn="
+
pluginSlugs
+
"&grafanaVersion="
+
setting
.
BuildVersion
)
if
err
!=
nil
{
log
.
Trace
(
"Failed to get plugins repo from grafana.net, %v"
,
err
.
Error
())
...
...
@@ -62,23 +70,21 @@ func checkForUpdates() {
return
}
var
data
GrafanaNetPlugins
err
=
json
.
Unmarshal
(
body
,
&
data
)
gNetPlugins
:=
[]
GrafanaNetPlugin
{}
err
=
json
.
Unmarshal
(
body
,
&
gNetPlugins
)
if
err
!=
nil
{
log
.
Trace
(
"Failed to unmarshal plugin repo, reading response from grafana.net, %v"
,
err
.
Error
())
return
}
for
_
,
plug
:=
range
Plugins
{
for
_
,
gplug
:=
range
data
.
Plugins
{
if
gplug
.
Id
==
plug
.
Id
{
if
len
(
gplug
.
Versions
)
>
0
{
plug
.
GrafanaNetVersion
=
gplug
.
Versions
[
0
]
.
Version
for
_
,
gplug
:=
range
gNetPlugins
{
if
gplug
.
Slug
==
plug
.
Id
{
plug
.
GrafanaNetVersion
=
gplug
.
Version
plug
.
GrafanaNetHasUpdate
=
plug
.
Info
.
Version
!=
plug
.
GrafanaNetVersion
}
}
}
}
resp2
,
err
:=
client
.
Get
(
"https://raw.githubusercontent.com/grafana/grafana/master/latest.json"
)
if
err
!=
nil
{
...
...
public/app/plugins/panel/dashlist/module.js
deleted
100644 → 0
View file @
31441f0b
///<reference path="../../../headers/common.d.ts" />
"use strict"
;
var
__extends
=
(
this
&&
this
.
__extends
)
||
function
(
d
,
b
)
{
for
(
var
p
in
b
)
if
(
b
.
hasOwnProperty
(
p
))
d
[
p
]
=
b
[
p
];
function
__
()
{
this
.
constructor
=
d
;
}
d
.
prototype
=
b
===
null
?
Object
.
create
(
b
)
:
(
__
.
prototype
=
b
.
prototype
,
new
__
());
};
var
lodash_1
=
require
(
'lodash'
);
var
sdk_1
=
require
(
'app/plugins/sdk'
);
var
impression_store_1
=
require
(
'app/features/dashboard/impression_store'
);
// Set and populate defaults
var
panelDefaults
=
{
mode
:
'starred'
,
query
:
''
,
limit
:
10
,
tags
:
[],
recent
:
false
,
search
:
false
,
starred
:
true
};
var
DashListCtrl
=
(
function
(
_super
)
{
__extends
(
DashListCtrl
,
_super
);
/** @ngInject */
function
DashListCtrl
(
$scope
,
$injector
,
backendSrv
)
{
_super
.
call
(
this
,
$scope
,
$injector
);
this
.
backendSrv
=
backendSrv
;
lodash_1
[
"default"
].
defaults
(
this
.
panel
,
panelDefaults
);
if
(
this
.
panel
.
tag
)
{
this
.
panel
.
tags
=
[
this
.
panel
.
tag
];
delete
this
.
panel
.
tag
;
}
this
.
events
.
on
(
'refresh'
,
this
.
onRefresh
.
bind
(
this
));
this
.
events
.
on
(
'init-edit-mode'
,
this
.
onInitEditMode
.
bind
(
this
));
}
DashListCtrl
.
prototype
.
onInitEditMode
=
function
()
{
this
.
editorTabIndex
=
1
;
this
.
modes
=
[
'starred'
,
'search'
,
'recently viewed'
];
this
.
addEditorTab
(
'Options'
,
'public/app/plugins/panel/dashlist/editor.html'
);
};
DashListCtrl
.
prototype
.
onRefresh
=
function
()
{
var
promises
=
[];
if
(
this
.
panel
.
recent
)
{
promises
.
push
(
this
.
getRecentDashboards
());
}
if
(
this
.
panel
.
starred
)
{
promises
.
push
(
this
.
getStarred
());
}
if
(
this
.
panel
.
search
)
{
promises
.
push
(
this
.
getSearch
());
}
return
Promise
.
all
(
promises
)
.
then
(
this
.
renderingCompleted
.
bind
(
this
));
};
DashListCtrl
.
prototype
.
getSearch
=
function
()
{
var
_this
=
this
;
var
params
=
{
limit
:
this
.
panel
.
limit
,
query
:
this
.
panel
.
query
,
tag
:
this
.
panel
.
tags
};
return
this
.
backendSrv
.
search
(
params
).
then
(
function
(
result
)
{
_this
.
dashList
=
result
;
_this
.
renderingCompleted
();
});
};
DashListCtrl
.
prototype
.
getStarred
=
function
()
{
var
_this
=
this
;
var
params
=
{
limit
:
this
.
panel
.
limit
,
starred
:
"true"
};
return
this
.
backendSrv
.
search
(
params
).
then
(
function
(
result
)
{
_this
.
dashList
=
result
;
_this
.
renderingCompleted
();
});
};
DashListCtrl
.
prototype
.
getRecentDashboards
=
function
()
{
var
_this
=
this
;
var
dashIds
=
lodash_1
[
"default"
].
first
(
impression_store_1
.
impressions
.
getDashboardOpened
(),
this
.
panel
.
limit
);
return
this
.
backendSrv
.
search
({
dashboardIds
:
dashIds
,
limit
:
this
.
panel
.
limit
}).
then
(
function
(
result
)
{
_this
.
dashList
=
dashIds
.
map
(
function
(
orderId
)
{
return
lodash_1
[
"default"
].
find
(
result
,
function
(
dashboard
)
{
return
dashboard
.
id
===
orderId
;
});
}).
filter
(
function
(
el
)
{
return
el
!==
undefined
;
});
});
};
DashListCtrl
.
templateUrl
=
'module.html'
;
return
DashListCtrl
;
}(
sdk_1
.
PanelCtrl
));
exports
.
DashListCtrl
=
DashListCtrl
;
exports
.
PanelCtrl
=
DashListCtrl
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment