Commit 451a8bef by Torkel Ödegaard

feat(pluginslist): minor update

parent c518fdc1
...@@ -55,6 +55,11 @@ ...@@ -55,6 +55,11 @@
<section class="page-sidebar-section"> <section class="page-sidebar-section">
<h4>Version</h4> <h4>Version</h4>
<span>{{ctrl.model.info.version}}</span> <span>{{ctrl.model.info.version}}</span>
<div ng-show="ctrl.model.hasUpdate">
<a href="https://grafana.net/plugins/{{ctrl.model.id}}" target="_blank">
Update Available!
</a>
</div>
</section> </section>
<section class="page-sidebar-section" ng-show="ctrl.model.type === 'app'"> <section class="page-sidebar-section" ng-show="ctrl.model.type === 'app'">
<h5>Includes</h4> <h5>Includes</h4>
......
<div class="pluginlist"> <div class="pluginlist">
<div class="pluginlist-section" ng-repeat="category in ctrl.viewModel"> <div class="pluginlist-section" ng-repeat="category in ctrl.viewModel">
<h5 class="pluginlist-section-header"> <h6 class="pluginlist-section-header">
<i class="icon-gf icon-gf-{{category.type}} pluginlist-icon"></i>
{{category.header}} {{category.header}}
</h5> </h6>
<div class="pluginlist-item" ng-repeat="plugin in category.list"> <div class="pluginlist-item" ng-repeat="plugin in category.list">
<a class="pluginlist-link pluginlist-link-{{plugin.state}}" href="plugins/{{plugin.id}}/edit"> <a class="pluginlist-link pluginlist-link-{{plugin.state}}" href="plugins/{{plugin.id}}/edit">
<img ng-src="{{plugin.info.logos.small}}" class="pluginlist-image"> <img ng-src="{{plugin.info.logos.small}}" class="pluginlist-image">
...@@ -12,7 +11,7 @@ ...@@ -12,7 +11,7 @@
<span class="pluginlist-message pluginlist-message--update" ng-show="plugin.hasUpdate"> <span class="pluginlist-message pluginlist-message--update" ng-show="plugin.hasUpdate">
Update available! Update available!
</span> </span>
<span class="pluginlist-message pluginlist-message--enable" ng-show="!plugin.enabled"> <span class="pluginlist-message pluginlist-message--enable" ng-show="!plugin.enabled && !plugin.hasUpdate">
Enable now Enable now
</span> </span>
<span class="pluginlist-message pluginlist-message--no-update" ng-show="plugin.enabled && !plugin.hasUpdate"> <span class="pluginlist-message pluginlist-message--no-update" ng-show="plugin.enabled && !plugin.hasUpdate">
......
...@@ -26,6 +26,7 @@ class DashListCtrl extends PanelCtrl { ...@@ -26,6 +26,7 @@ class DashListCtrl extends PanelCtrl {
{header: "Installed Panels", list: [], type: 'panel'}, {header: "Installed Panels", list: [], type: 'panel'},
{header: "Installed Datasources", list: [], type: 'datasource'}, {header: "Installed Datasources", list: [], type: 'datasource'},
]; ];
this.update(); this.update();
} }
...@@ -42,30 +43,10 @@ class DashListCtrl extends PanelCtrl { ...@@ -42,30 +43,10 @@ class DashListCtrl extends PanelCtrl {
this.viewModel[2].list = _.filter(plugins, {type: 'datasource'}); this.viewModel[2].list = _.filter(plugins, {type: 'datasource'});
for (let plugin of this.pluginList) { for (let plugin of this.pluginList) {
if (!plugin.enabled) { if (plugin.hasUpdate) {
plugin.state = 'not-enabled';
}
}
}).then(this.checkForUpdates.bind(this));
}
checkForUpdates() {
return this.backendSrv.get('api/gnet/plugins/repo').then(data => {
var gNetPlugins = _.reduce(data.plugins, (memo, val) => {
memo[val.id] = val;
return memo;
}, {});
for (let plugin of this.pluginList) {
var source = gNetPlugins[plugin.id];
if (!source) {
continue;
}
if (plugin.info.version !== source.versions[0].version) {
plugin.hasUpdate = true;
plugin.state = 'has-update'; plugin.state = 'has-update';
} else if (!plugin.enabled) {
plugin.state = 'not-enabled';
} }
} }
}); });
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
} }
.pluginlist-title { .pluginlist-title {
margin-right: $spacer / 3; margin-right: $spacer / 3;
} }
.pluginlist-version { .pluginlist-version {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment