summaryrefslogtreecommitdiff
path: root/widgets/jenkins_build_status
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/jenkins_build_status')
-rw-r--r--widgets/jenkins_build_status/jenkins_build_status.coffee28
-rw-r--r--widgets/jenkins_build_status/jenkins_build_status.html16
-rw-r--r--widgets/jenkins_build_status/jenkins_build_status.scss56
3 files changed, 100 insertions, 0 deletions
diff --git a/widgets/jenkins_build_status/jenkins_build_status.coffee b/widgets/jenkins_build_status/jenkins_build_status.coffee
new file mode 100644
index 0000000..d7d8630
--- /dev/null
+++ b/widgets/jenkins_build_status/jenkins_build_status.coffee
@@ -0,0 +1,28 @@
+class Dashing.JenkinsBuildStatus extends Dashing.Widget
+
+ lastPlayed: 0
+ timeBetweenSounds: 300000
+
+ onData: (data) ->
+ if data.failed
+ $(@node).find('div.build-failed').show()
+ $(@node).find('div.build-succeeded').hide()
+ $(@node).css("background-color", "red")
+
+ if 'speechSynthesis' of window
+ @playSoundForUser data.failedJobs[0].value if Date.now() - @lastPlayed > @timeBetweenSounds
+ else
+ $(@node).find('div.build-failed').hide()
+ $(@node).find('div.build-succeeded').show()
+ $(@node).css("background-color", "#12b0c5")
+
+ playSoundForUser: (user) ->
+ @lastPlayed = Date.now()
+ texts = ["#{user} has broken the build.", "The build is broken by #{user}", "#{user} is great, but lacks some programming skills", "Oops, I did it again."]
+ textNr = Math.floor((Math.random() * texts.length));
+ @playSound texts[textNr]
+
+ playSound: (text) ->
+ msg = new SpeechSynthesisUtterance(text)
+ msg.voice = speechSynthesis.getVoices()[0]
+ speechSynthesis.speak msg \ No newline at end of file
diff --git a/widgets/jenkins_build_status/jenkins_build_status.html b/widgets/jenkins_build_status/jenkins_build_status.html
new file mode 100644
index 0000000..472bc73
--- /dev/null
+++ b/widgets/jenkins_build_status/jenkins_build_status.html
@@ -0,0 +1,16 @@
+<div class="build-failed">
+ <h1 class="jenkins-status"><span data-bind="title"></span> FAILED</h1>
+ <ul class="list-nostyle list-failed">
+ <li data-foreach-item="failedJobs">
+ <div class="label" data-bind="item.label"></div>
+ <div class="value" data-bind="item.value"></div>
+ </li>
+ </ul>
+</div>
+
+<div class="build-succeeded">
+ <h1 class="jenkins-status">All <span data-bind="title"></span> builds are successful</h1>
+ <i class="fa fa-thumbs-o-up"></i>
+</div>
+
+<p class="updated-at" data-bind="updatedAtMessage"></p>
diff --git a/widgets/jenkins_build_status/jenkins_build_status.scss b/widgets/jenkins_build_status/jenkins_build_status.scss
new file mode 100644
index 0000000..5e1eff1
--- /dev/null
+++ b/widgets/jenkins_build_status/jenkins_build_status.scss
@@ -0,0 +1,56 @@
+// ----------------------------------------------------------------------------
+// Sass declarations
+// ----------------------------------------------------------------------------
+$background-color: #ec663c;
+$title-color: rgba(255, 255, 255, 0.7);
+$label-color: rgba(255, 255, 255, 0.7);
+$value-color: #fff;
+
+// ----------------------------------------------------------------------------
+// Widget-text styles
+// ----------------------------------------------------------------------------
+.widget-jenkins-build-status {
+
+ background-color: $background-color;
+
+ .title {
+ color: $title-color;
+ }
+ .updated-at {
+ color: rgba(255, 255, 255, 0.7);
+ }
+
+ ol, ul {
+ margin: 0 15px;
+ text-align: left;
+ color: $label-color;
+ }
+
+ li {
+ margin-bottom: 5px;
+ font-size: 40px;
+ }
+
+ .label {
+ color: $label-color;
+ }
+
+ .value {
+ margin-left: 12px;
+ font-weight: 600;
+ color: $value-color;
+ }
+
+ .updated-at {
+ color: rgba(0, 0, 0, 0.3);
+ }
+
+ .build-failed {
+ display: none;
+ }
+
+ .fa {
+ font-size: 10em;
+ color: $label-color;
+ }
+}