Skip to content

Commit de107c8

Browse files
committed
updated instructions for rundeck 3.0.12 and updated xkcd sources
1 parent 35d9343 commit de107c8

6 files changed

Lines changed: 322 additions & 1754 deletions

File tree

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,29 @@ This plugin includes some basic UI demostrations:
77
* Usage of javascript + ajax request to modify Jobs list page
88
* Usage of javascript + css to modify the execution page
99

10-
### Hello World.
10+
### Hello World.
11+
12+
(Disabled by default. It can be enabled on `main.js` code)
1113
Display `Hello world` text from `messages.properties`, if the user change the language to Spanish on Rundeck, the message changes to `Hola Mundo`.
1214

1315
### XKCD random image.
14-
On the jobs page, it adds on top of the job list, a random image from a source json.
16+
17+
(Enabled by default)
18+
On the jobs page, it adds on top of the job list, a random image from a json source file.
1519
To retrieve this image, the code uses a ajax call to a local file, this can be replaced with a call to a webservice on the same server as the rundeck instance.
1620

21+
Since rundeck 3.0.12 you need to add this to `rundeck-config.properties`:
22+
`rundeck.security.httpHeaders.provider.csp.config.img-src=self https://imgs.xkcd.com`
23+
1724
### Panic mode
18-
On the execution page, changes the header to red when a failed execution is open.
25+
26+
(Disabled by default. It can be enabled on `main.js` code)
27+
On the execution page, changes the header to red when a failed execution is open.
28+
29+
30+
31+
## Update the xkcd source
32+
33+
Edit `getSources.sh` Set TODAY to the latest xkcd comic of the day.
34+
Run:
35+
`./getSources.sh > xkcdsource.json`

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ plugins {
55
}
66
ext.pluginName = "Rundeckpro UI Test"
77
ext.pluginDescription = "Rundeck UI test"
8-
ext.sopsCopyright = "© 2017, Rundeck, Inc."
8+
ext.sopsCopyright = "© 2019, Rundeck, Inc."
99
ext.sopsUrl = "http://rundeck.com"
1010
ext.buildDateString=new Date().format("yyyy-MM-dd'T'HH:mm:ssX")
1111
ext.name="test"
12-
version="1.0"
12+
version="1.1"
1313

1414

1515

getSources.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
TODAY=2109
3+
START=$TODAY-365
4+
echo "{ \"list\": ["
5+
6+
for (( c=$START; c<=$TODAY; c++ ))
7+
do
8+
curl https://xkcd.com/$c/info.0.json
9+
if [ "$c" -ne "$TODAY" ];
10+
then
11+
echo ","
12+
fi
13+
done
14+
15+
echo "] }"
Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
jQuery(function () {
2+
var useHelloWorld=false;
3+
var useXKCD=true;
4+
var usePanic=false;
25
var project = rundeckPage.project();
3-
4-
if(project){
5-
console.log(project);
6-
}else{
7-
console.log('main sccreen');
6+
if(useHelloWorld){
7+
if(project){
8+
console.log(project);
9+
}else{
10+
console.log('main sccreen');
11+
}
812
}
913
var path = rundeckPage.path();
10-
console.log(path);
14+
1115

1216
var para = document.createElement("div");
1317
para.style.fontSize = "150%";
1418
para.style.textAlign = "center";
1519
para.style.marginBottom = "10px";
1620

1721
//element only in Home
18-
if(!project){
22+
if(useHelloWorld && !project){
1923
var div = document.createElement("div");
2024
div.style.fontSize = "250%";
2125
div.id = "testuifield";
@@ -24,57 +28,63 @@ if(!project){
2428
para.appendChild(div);
2529
}
2630

27-
var xkcd = document.createElement("div");
28-
xkcd.id = "xkcdfield";
29-
para.appendChild(xkcd);
30-
31+
if(useXKCD){
32+
var xkcd = document.createElement("div");
33+
xkcd.id = "xkcdfield";
34+
para.appendChild(xkcd);
35+
}
3136

3237
var x = jQuery(".main-panel .content").prepend(para);
3338

3439
var pluginName = UI_PLUGIN_EXAMPLES['test-ui'];
3540

3641

3742
demo_init_plugin(pluginName, function () {
38-
if(rundeckPage.path() === "menu/home"){
39-
var salute = 'Hello';
40-
if(window.Messages){
41-
//loaded i18n
42-
//rundeck-ui-hello-world
43-
salute = window.Messages[pluginName+'.Salute'];
43+
if(useHelloWorld){
44+
if(rundeckPage.path() === "menu/home"){
45+
var salute = 'Hello';
46+
if(window.Messages){
47+
//loaded i18n
48+
//rundeck-ui-hello-world
49+
salute = window.Messages[pluginName+'.Salute'];
50+
}
51+
jQuery("#testuifield").text(salute);
52+
}
4453
}
45-
jQuery("#testuifield").text(salute);
46-
}
47-
48-
if(rundeckPage.path() === "menu/jobs"){
49-
//on any project page
50-
jQuery.ajax({
51-
beforeSend: function(xhr){
52-
if (xhr.overrideMimeType)
53-
{
54-
xhr.overrideMimeType("application/json");
55-
}
56-
},
57-
dataType: 'json',
58-
url: url_path(rundeckPage.pluginBasei18nUrl(pluginName))+'/service/xkcdsource.json',
59-
success: function (data) {
60-
var imgCount = data.list.length;
61-
var n = Math.floor(Math.random() * imgCount);
62-
var image = data.list[n];
63-
if(image.img){
64-
jQuery("#xkcdfield").prepend(jQuery('<img>',{id:'xcdImg',src:image.img}));
65-
}
66-
}
67-
});
68-
}
69-
//dramatic failed job
70-
if(rundeckPage.path() === "execution/show"){
71-
console.log("job status");
72-
var status = (jQuery(".exec-status")[0].getAttribute("data-execstate"));
73-
if(status && status.toLowerCase() === 'failed' ){
74-
//bs-example-navbar-collapse-1
75-
jQuery(".main-panel .mainbar").css("backgroundColor", "red");
54+
if(useXKCD){
55+
if(rundeckPage.path() === "menu/jobs"){
56+
//on any project page
57+
jQuery.ajax({
58+
beforeSend: function(xhr){
59+
if (xhr.overrideMimeType)
60+
{
61+
xhr.overrideMimeType("application/json");
62+
}
63+
},
64+
dataType: 'json',
65+
url: url_path(rundeckPage.pluginBasei18nUrl(pluginName))+'/service/xkcdsource.json',
66+
success: function (data) {
67+
var imgCount = data.list.length;
68+
var n = Math.floor(Math.random() * imgCount);
69+
var image = data.list[n];
70+
if(image.img){
71+
jQuery("#xkcdfield").prepend(jQuery('<img>',{id:'xcdImg',src:image.img, title:image.alt}));
72+
}
73+
}
74+
});
75+
}
7676
}
77-
}
78-
});
77+
if(usePanic){
78+
//dramatic failed job
79+
if(rundeckPage.path() === "execution/show"){
80+
console.log("job status");
81+
var status = (jQuery(".exec-status")[0].getAttribute("data-execstate"));
82+
if(status && status.toLowerCase() === 'failed' ){
83+
//bs-example-navbar-collapse-1
84+
jQuery(".main-panel .mainbar").css("backgroundColor", "red");
85+
}
86+
}
87+
}
88+
});
7989

8090
});
14.8 KB
Loading

0 commit comments

Comments
 (0)