Skip to content

Plugins widgets and dashboards

charlie edited this page Aug 11, 2014 · 5 revisions

For each plugin you can add widget and dashboard. Just add folder {path/to/your/plugin}/ to your resources directory with the following files:

  • dashboard.html or dashboard.jade
  • widget.html or widget.jade
  • any .js files
  • styles.css or styles .less

Sample Widget

First step add ClientSender and @OnTimer to plugin.

package ru.yandex.qatools.camelot.sample;

@SuppressWarnings("unused")
@Filter(instanceOf = {Event.class})
@FSM(start = State.class)
@Transitions(
        @Transit(on = Event.class)
)
public class Sender extends AbstractPlugin {

    @ClientSender
    private ClientMessageSender client;

    @OnException(preserve = true)
    @OnTransit
    public void message(Event event) throws InterruptedException {
        out.produce(event);
    }

    @OnTimer(cron = "*/10 * * * * ?", perState = false)
    public void sendSomethingToClient() {
        client.send(new Event(2, 123));
    }

}

Then create ru.yandex.qatools.camelot.sample.Sender folder in resources directory and create script.js, widget.jade and styles.less files.

script.js:

angular.module('ru.yandex.qatools.camelot.sample.Sender', ['camelotUtil'])
    .controller('AppCtrl', ['$scope', '$http', 'subscribe', 'baseUrl', 'pluginId', 
                function ($scope, $http, subscribe, baseUrl, pluginId) {
        'use strict';

        subscribe(pluginId, function (message) {
            console.log(pluginId + ' ' + message)
        });
    }]);

widget.jade:

.launch-stat(ng-controller="AppCtrl")