Skip to content

Commit

Permalink
Merge pull request #93 from diggyk/master
Browse files Browse the repository at this point in the history
Added filtering by host on labors page
  • Loading branch information
mcot2 committed Nov 12, 2015
2 parents 7f2ac54 + dd5b3c8 commit 488b9fb
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 15 deletions.
2 changes: 1 addition & 1 deletion hermes/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.9"
__version__ = "0.5.10"
2 changes: 1 addition & 1 deletion hermes/webapp/src/js/controllers/fateCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

function getGraphingData() {
hermesService.getFatesSigma().then(function (data) {
hermesService.getFatesGraph().then(function (data) {
vm.graphData = data;
return data;
}).then(function(graphData){
Expand Down
26 changes: 21 additions & 5 deletions hermes/webapp/src/js/controllers/laborStatusCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
vm.filterOwn = false;
vm.fates = false;
vm.queryInput = null;
vm.hostnameInput = null;
vm.filterFate = null;
vm.selectedEventType = null;

Expand Down Expand Up @@ -61,23 +62,30 @@

// if the user went straight to this page without any params, lets
// modify the search to only show their labors
if ($location.path() == "/v1/labors/" && Object.keys($routeParams).length == 0) {
if (
$location.path() == "/v1/labors/"
&& Object.keys($routeParams).length == 0
) {
vm.hostOwnerInput = vm.user;
vm.filterOwn = true;
}

getOpenLabors();
} else {
vm.errorMessages.push("Cannot create a new quest if not authenticated.");
vm.errorMessages = "Cannot create a new quest if not authenticated.";
}
});

if ($routeParams.byQuery) {
vm.queryInput = $routeParams.byQuery;
}

if ($routeParams.host) {
vm.hostnameInput = $routeParams.host;
}

hermesService.getFates().then(function(fates) {
vm.allFates = [null];
vm.allFates = [""];
for (var idx in fates) {
if (fates[idx].precedesIds.length != 0) {
vm.allFates.push(fates[idx]);
Expand Down Expand Up @@ -177,7 +185,7 @@
vm.hostOwnerInput = vm.user;
} else {
vm.filterOwn = false;
vm.errorMessages.push("Your username is unknown.");
vm.errorMessages = "Your username is unknown.";
}
}
}
Expand Down Expand Up @@ -246,6 +254,11 @@
options['filterByState'] = vm.filterFate.creationEventType.state;
}

if (vm.hostnameInput) {
options['filterByHostname'] = vm.hostnameInput;
$location.search('host', vm.hostnameInput, false);
}

hermesService.getOpenLabors(options).then(function (data) {
if (!data
|| !data['labors']
Expand Down Expand Up @@ -379,7 +392,10 @@
}
}

vm.result = hermesService.createEvents(vm.user, hostnames, vm.selectedEventType, "Created via Web UI.")
vm.result = hermesService.createEvents(
vm.user, hostnames,
vm.selectedEventType, "Created via Web UI."
)
.then(function(response) {
vm.createInProgress = false;
vm.selected = [];
Expand Down
23 changes: 16 additions & 7 deletions hermes/webapp/src/js/services/hermesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
'use strict';

function HermesService($http, $q) {
var fates;
var fates = null;
var fatesGraph = null;
var serverConfig = null;
var service = {
getFates: getFates,
getFatesSigma: getFatesSigma,
getFatesGraph: getFatesGraph,
getOpenLabors: getOpenLabors,
getOpenQuests: getOpenQuests,
getQuestDetails: getQuestDetails,
Expand Down Expand Up @@ -133,6 +134,10 @@
url += "&state=" + encodeURIComponent(options['filterByState']);
}

if (options['filterByHostname']) {
url += "&hostname=" + encodeURIComponent(options['filterByHostname']);
}

return $http.get(url)
.then(getLaborsComplete)
.catch(getLaborsFailed);
Expand Down Expand Up @@ -264,9 +269,14 @@
}

/**
* Get the fates but return them as a JSON that's consumable by SigmaJS
* Get the fates and return them in a graph format
*/
function getFatesSigma() {
function getFatesGraph() {
if (fatesGraph) {
var promise = $q.defer();
promise.resolve(fatesGraph);
return promise.promise;
}
var graphData = {
nodes: [],
edges: []
Expand All @@ -287,9 +297,8 @@
baseY += YINC;
}
}

})
.then(function() {
}).then(function() {
fatesGraph = graphData;
return graphData;
});

Expand Down
18 changes: 17 additions & 1 deletion hermes/webapp/src/templates/laborList.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,30 @@
</span>
</div>
</div>
<div style="margin-top: 5px">
<label for="queryFilter">Filter by hostname:</label>
</div>
<div class="row">
<div class="col-md-10">
<form ng-submit="lsc.runFilter()">
<input id="hostnameFilter" type="text" ng-model="lsc.hostnameInput" />
</form>
</div>
<div class="col-md-2">
<span role="button" aria-label="Clear hostname filter"
class="glyphicon glyphicon-remove-sign btn-glyph"
ng-click="lsc.hostnameInput = ''">
</span>
</div>
</div>
<div style="margin-top: 5px">
<label for="event-type-selection">Filter by labor:</label>
</div>
<div class="row">
<div class="col-md-10">
<select style="margin-left: 0" id="event-type-selection" ng-model="lsc.filterFatesSelection"
ng-model-options="lsc.selectOptions"
ng-options="optValue.description for optValue in lsc.allFates">
ng-options="optValue.description || '' for optValue in lsc.allFates">
</select>
</div>
<div class="col-md-2">
Expand Down

0 comments on commit 488b9fb

Please sign in to comment.