Add link to cockpit navigation with dynamic value


#1

I’d like to add a link to the navigation in the cockpit application(next to Processes, Decisions, …).
I was able to create the link by modifying an example https://github.com/camunda/camunda-bpm-examples/tree/master/cockpit/cockpit-sample-plugin

define(['angular'], function (angular) {   
  ...
  var Configuration = function Configuration(ViewsProvider) {
       ViewsProvider.registerDefaultView('cockpit.navigation', {
           id: 'cockpit-plugin',
           label: 'MY_LINK',                
           pagePath: 'http://something',
           priority: 200
    });
  };
...

This works fine and the link is added:
image

The problem is that I need to retrieve the http://something from the server.
I can do that when defining a controller function using

$http.get(Uri.appUri("plugin://cockpit-plugin/:engine/my-link-url"))
        .success(function (data) {
            $scope.link-url = data;
        });

But I don’t know how to get this value into the pagePath in the configuration. The solution is probably simple, but I have a very limited knowledge of AngularJS. I cannot figure out how to inject $http outside of the scope of controller function or how to synchronously wait for the result.