To turn on the DLUX UI, install DLUX core feature via running following command on the Karaf console -
feature:install odl-dlux-core
The above command will install odl-restconf and DLUX topology application internally, along with core DLUX components. Once this feature is successfully installed, access the UI at http://localhost:8181/index.html. The default credentials for login are admin/admin.
All the applications in DLUX are Karaf features. A user can install other dlux applications such as node and yang-ui from Karaf console using commands such as -
$ feature:install odl-dluxapps-nodes
$ feature:install odl-dluxapps-yangui
DLUX modules are the individual features such as nodes and topology. Each module has a defined structure and you can find all existing modules at https://github.com/opendaylight/dlux/tree/stable/boron/modules.
For each new module, you must have at least these two dependencies :
The following are not mandatory, but very often used.
Your module.js file might look like this:
define(['angularAMD','app/routingConfig', 'angular-ui-router','app/core/core.services'], function(ng) {
var module = angular.module('app.a_module', ['ui.router.state', 'app.core']);
// module configuration
module.config(function() {
[...]
});
return module;
});
AngularJS allows lazy registration of a module’s components such as controller, factory etc. Once you will install your application, DLUX will load your module javascript, but not your angular component during bootstrap phase. You have to register your angular components to make sure they are available at the runtime.
Here is how to register your module’s component for lazy initialization -
module.config(function($compileProvider, $controllerProvider, $provide) {
module.register = {
controller : $controllerProvider.register,
directive : $compileProvider.directive,
factory : $provide.factory,
service : $provide.service
};
});
The next step is to set up the route for your module. This part is also done in the configuration method of the module. We have to add $stateProvider as a parameter.
module.config(function($stateProvider) {
var access = routingConfig.accessLevels;
$stateProvider.state('main.module', {
url: 'module',
views : {
'content' : {
templateUrl: 'src/app/module/module.tpl.html',
controller: 'ModuleCtrl'
}
}
});
});
To include the module’s controller file, you can use the NavHelperProvider. It contains a method that will load the given file.
[...]
NavHelperProvider.addControllerUrl('<path_to_module_folder>/<module_name>.controller');
This completes your module.js file.
Creating the controller and other components is similar to the module.
For example -
define(['<relative_path_to_module>/<module_name>.module'], function(module) {
module.register.controller('ModuleCtrl', function($rootScope, $scope) {
});
});
DLUX works as a Karaf based UI platform, where you can create a new Karaf feature of your UI component and install that UI applications in DLUX using blueprint. This page will help you to create and load a new application for DLUX. You don’t have to add new module in DLUX repository.
The OSGi Blueprint Container specification allows us to use dependency injection in our OSGi environment. Each DLUX application module registers itself via blueprint configuration. Each application will have its own blueprint.xml to place its configuration.
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<reference id="httpService" availability="mandatory" activation="eager" interface="org.osgi.service.http.HttpService"/>
<reference id="loader" availability="mandatory" activation="eager" interface="org.opendaylight.dlux.loader.DluxModuleLoader"/>
<bean id="bundle" init-method="initialize" destroy-method="clean" class="org.opendaylight.dlux.loader.DluxModule">
<property name="httpService" ref="httpService"/>
<property name="loader" ref="loader"/>
<property name="moduleName" value="topology "/>
<property name="url" value="/src/app/topology"/>
<property name="directory" value="/topology"/>
<property name="requireJs" value="app/topology/topology.module"/>
<property name="angularJs" value="app.topology"/>
<property name="cssDependencies">
<list>
<value>http://yui.yahooapis.com/3.18.1/build/cssreset/cssreset-min.css</value>
<value>src/app/topology/topology-custom.css</value>
</list>
</property>
</bean>
</blueprint>
In above configuration, there are two references with id httpService and loader. These two beans will already be initialized by dlux-core, so any new application can use them. Without these two bean references, a new application will not be able to register.
Next is the initialization of your application bean, which will be an instance of class org.opendaylight.dlux.loader.DluxModule. There are 5 properties that you should provide in this bean besides the references of httpService and loader. Lets talk about those bean properties in little more detail.
moduleName : Name of your module. This name should be unique in DLUX.
url: This is the url via which RequireJS in DLUX will try to load your module JS/HTML files. Also, this is the url that browser will use to load the static HTML, JS or CSS files. RequireJS in DLUX has a base path of src, so all the url should start with /src so RequireJS and the browser can correctly find the files.
directory: In your bundle’s pom.xml, you unpack your module code. This is the directory where your actual static files will reside. The above mentioned url is registered with httpService, so when browser makes a call to that url, it will be redirected to the directory mentioned here. In the above example, all the topology files are present under /topology directory and the browser/RequireJS can access those files with uri /src/app/topology.
requireJS: This is the path to your RequireJS module. If you notice closely, you will see the initial path of RequireJS app/topology in the above example matches with the last part of url. This path will be be used by RequireJS. As mentioned above, we have kept src as base path in RequireJS, that is the exact reason that url start with /src.
angularJS: name of your AngularJS module.
cssDependencies: If the application has any external/internal css dependencies, then those can be added here. If you create your own css files, just point to those css files here. Use the url path that you mentioned above, so the browser can find your css file.
OSGi understands blueprint.xml, once you will deploy your bundle in karaf (or you can create a new feature for your application), karaf will read your blueprint.xml and it will try to register your application with dlux. Once successful, if you refresh your dlux UI, you will see your application in left hand navigation bar of dlux.
Yang Utils are used by UI to perform all CRUD operations. All of these utilities are present in yangutils.services.js file. It has following AngularJS factories -