Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#833: Added preference to be able to select which plugin to select on…
… startup.
  • Loading branch information
davsclaus committed Dec 12, 2013
1 parent a224161 commit e15f10b
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions hawtio-web/src/main/webapp/app/core/js/preferences.ts
Expand Up @@ -188,33 +188,28 @@ module Core {
}
};

$scope.plugins = [];
// add the default in the top
$scope.plugins = [{id: "_first", displayName: "First Plugin", selected: false}];

// setup the plugin tabs
// grab the top level tabs which is the plugins we can select as our default plugin
var topLevelTabs = Perspective.topLevelTabs($location, workspace, jolokia, localStorage);
// exclude invalid tabs at first
topLevelTabs = topLevelTabs.filter(tab => {
var href = tab.href();
return href && Perspective.isValidFunction(workspace, tab.isValid);
});

// now put those into the tabs, having the default first plugin in the top
$scope.plugins.push({id: "_first", displayName: "First Plugin", selected: false});
topLevelTabs.forEach(tab => {
$scope.plugins.push({id: tab.id, displayName: tab.content, selected: false});
});

// just try to select logs
// add each tab as a plugin we can select
var defaultPlugin = localStorage['defaultPlugin'];
var found = false;
if (defaultPlugin) {
$scope.plugins.forEach(plugin => {
if (plugin.id === defaultPlugin) {
plugin.selected = true;
found = true;
}
});
}
topLevelTabs.forEach(tab => {
var selected = tab.id === defaultPlugin;
if (selected) {
found = true;
}
$scope.plugins.push({id: tab.id, displayName: tab.content, selected: selected});
});
// now find the default plugin and mark it as selected if we did not find the chosen plugin
if (!found) {
$scope.plugins[0].selected = true;
}
Expand Down

0 comments on commit e15f10b

Please sign in to comment.