-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to font size and number of columns are now persisted
- Loading branch information
Showing
7 changed files
with
168 additions
and
94 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...rces/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/main-jobViews.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<ul id="job-views" | ||
style="font-size: {{fontSize}}em" | ||
class="columns-{{ numberOfColumns }}"> | ||
|
||
<li ng-repeat="job in jobs" class="{{job.status}}"> | ||
<div class="progress" style="width: {{job.progress}}%"> | ||
<span>{{job.progress}}%</span> | ||
</div> | ||
|
||
<div class="meta"> | ||
<h2> | ||
<a title="{{job.name}}" | ||
href="${jobsURL}/{{job.name}}">{{job.name}}</a> | ||
</h2> | ||
<ul data-ng-show="job.culprits.size() > 0" class="culprits"> | ||
<li data-ng-repeat="name in job.culprits"> | ||
{{name}} | ||
</li> | ||
</ul> | ||
<a data-ng-show="!!job.buildNumber" class="build-number" | ||
title="Console output for {{job.name}}, build #{{job.buildNumber}}" | ||
href="${jobsURL}/{{job.name}}/{{job.buildNumber}}/console">#{{job.buildNumber}}</a> | ||
</div> | ||
</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
AngularJS v1.1.5 | ||
(c) 2010-2012 Google, Inc. http://angularjs.org | ||
License: MIT | ||
*/ | ||
(function(m,f,l){'use strict';f.module("ngCookies",["ng"]).factory("$cookies",["$rootScope","$browser",function(d,b){var c={},g={},h,i=!1,j=f.copy,k=f.isUndefined;b.addPollFn(function(){var a=b.cookies();h!=a&&(h=a,j(a,g),j(a,c),i&&d.$apply())})();i=!0;d.$watch(function(){var a,e,d;for(a in g)k(c[a])&&b.cookies(a,l);for(a in c)e=c[a],f.isString(e)?e!==g[a]&&(b.cookies(a,e),d=!0):f.isDefined(g[a])?c[a]=g[a]:delete c[a];if(d)for(a in e=b.cookies(),c)c[a]!==e[a]&&(k(e[a])?delete c[a]:c[a]=e[a])});return c}]).factory("$cookieStore", | ||
["$cookies",function(d){return{get:function(b){return(b=d[b])?f.fromJson(b):b},put:function(b,c){d[b]=f.toJson(c)},remove:function(b){delete d[b]}}}])})(window,window.angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
angular. | ||
module('buildMonitor', [ 'buildMonitor.controllers', 'uiSlider' ]). | ||
run(function($rootScope, notifyUser) { | ||
$rootScope.$on('communication-error', function(event, error) { | ||
notifyUser.about(error.status); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
angular. | ||
module('buildMonitor.controllers', [ 'buildMonitor.services', 'uiSlider']). | ||
|
||
controller('JobViews', function($scope, $dialog, $timeout, fetch, storage) { | ||
$scope.fontSize = storage.retrieve('fontSize', 1); | ||
$scope.numberOfColumns = storage.retrieve('numberOfColumns', 2); | ||
|
||
$scope.$watch('fontSize', function(currentFontSize) { | ||
storage.persist('fontSize', currentFontSize); | ||
}); | ||
$scope.$watch('numberOfColumns', function(currentNumberOfColumns) { | ||
storage.persist('numberOfColumns', currentNumberOfColumns); | ||
}); | ||
|
||
|
||
$scope.jobs = {}; | ||
var update = function() { | ||
var updating; | ||
fetch.current().then(function(current) { | ||
$scope.jobs = current.jobs; | ||
updating = $timeout(update, 5000) | ||
}, function(error) { | ||
$timeout.cancel(updating); | ||
$rootScope.$broadcast("communication-error", error); | ||
}); | ||
} | ||
|
||
update(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
'use strict'; | ||
|
||
angular.module('buildMonitor.services', ['ui.bootstrap.dialog', 'template/dialog/message.html', 'ngCookies']). | ||
|
||
service('notifyUser',function ($dialog, $window) { | ||
this.about = function (problemStatus) { | ||
|
||
var title = "Sorry to bother you, but there is a slight issue ..." | ||
var message = "Jenkins returned a \"" + problemStatus + "\" response " + | ||
"causing the last request to fail. " + | ||
"This usually means a network connection problem " + | ||
"or that Jenkins is being restarted. " + | ||
"Don't worry, reloading the page should help :-)"; | ||
|
||
$dialog.messageBox(title, message, [ | ||
{ result: "reload", label: "Reload the page"} | ||
]).open().then(function (result) { | ||
$window.location.reload(); | ||
}); | ||
} | ||
}). | ||
|
||
service('fetch',function ($q, $rootScope, jenkins) { | ||
this.current = function () { | ||
var deferred = $q.defer(); | ||
|
||
jenkins.proxy.fetchJobViews(function (response) { | ||
|
||
if (response.status === 200) { | ||
deferred.resolve(response.responseObject()); | ||
} else { | ||
deferred.reject({ status: response.status }); | ||
} | ||
|
||
$rootScope.$apply(); | ||
}); | ||
|
||
return deferred.promise; | ||
} | ||
}). | ||
|
||
service('storage',function ($cookies, jenkins, hashCode) { | ||
this.persist = function (name, value) { | ||
$cookies[prefix(name)] = value; | ||
} | ||
|
||
this.retrieve = function (name, defaultValue) { | ||
var value = $cookies[prefix(name)]; | ||
|
||
return (typeof value !== 'undefined') | ||
? value | ||
: defaultValue; | ||
} | ||
|
||
function prefix(name) { | ||
return 'buildMonitor.' + hashCode.of(jenkins.buildMonitorName) + '.' + name; | ||
} | ||
}). | ||
|
||
service('hashCode', function() { | ||
this.of = function(name) { | ||
var hash = 0, | ||
char; | ||
|
||
if (name.length == 0) { | ||
return hash; | ||
} | ||
|
||
for (var i = 0; i < name.length; i++) { | ||
char = name.charCodeAt(i); | ||
hash = ((hash << 5) - hash) + char; | ||
hash = hash & hash; // Convert to 32bit integer | ||
} | ||
|
||
return hash; | ||
} | ||
}) | ||
; |