Skip to content

Commit

Permalink
Merge pull request #67 from diggyk/master
Browse files Browse the repository at this point in the history
Added email capability to web ui
  • Loading branch information
leojli committed Oct 5, 2015
2 parents 34761ed + 983481b commit 2b40618
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 48 deletions.
37 changes: 35 additions & 2 deletions hermes/handlers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .util import ApiHandler, PluginHelper
from .. import exc
from ..models import Host, EventType, Event, Labor, Fate, Quest
from ..settings import settings

from datetime import datetime
from dateutil import parser
Expand Down Expand Up @@ -2371,7 +2372,6 @@ def get(self):
GET /api/v1/currentUser HTTP/1.1
Host: localhost
X-NSoT-Email: user@localhost
**Example response**:
Expand Down Expand Up @@ -2399,4 +2399,37 @@ def get(self):
"user": user
}

self.success(result_json);
self.success(result_json)


class ServerConfig(ApiHandler):
def get(self):
""" **Get the server's configuration information**
This is used to get the config information that the front end might
want to know about.
**Example Request**:
.. sourcecode:: http
GET /api/v1/serverConfig HTTP/1.1
Host: localhost
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "ok",
"domain": "example.com"
}
"""
result_json = {
"domain": settings.domain
}

self.success(result_json)
3 changes: 3 additions & 0 deletions hermes/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
# Query for the current user
(r"/api/v1/currentUser", api.CurrentUserHandler),

# Query the server for its configs
(r"/api/v1/serverConfig", api.ServerConfig),

# Frontend Handlers
(
r"/((?:css|img|js|vendor|templates)/.*)",
Expand Down
2 changes: 1 addition & 1 deletion hermes/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.14"
__version__ = "0.4.15"
5 changes: 3 additions & 2 deletions hermes/webapp/src/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ a {
}

.quest-labors {
font-size: 1.2em;
font-size: 1em;
.row {
margin: 0;
}
Expand All @@ -433,6 +433,7 @@ a {
border-radius: 5px;
cursor: pointer;
margin-bottom: 1px;
padding: 2px;
transition: 0.15s ease-out all;
-webkit-transition: 0.15s ease-out all;
-moz-transition: 0.15s ease-out all;
Expand Down Expand Up @@ -468,7 +469,7 @@ a {
margin-left: -15px;
margin-right: -15px;
&:nth-child(odd) {
background: @alt-row-color;
//background: @alt-row-color;
}
.type-group {
padding-bottom: 5px;
Expand Down
Binary file added hermes/webapp/src/img/send_email_15.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions hermes/webapp/src/js/controllers/questStatusCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
vm.filterByCreator = null;
vm.queryInput = null;

vm.domain = null;
vm.questData = null;
vm.selectedQuest = null;
vm.selectedQuestDetails = null;
Expand Down Expand Up @@ -48,6 +49,12 @@
}
});

console.log(hermesService.getServerConfig);

hermesService.getServerConfig().then(function(config) {
vm.domain = config['domain'];
});

hermesService.getCreatorThrowableEventsTypes().then(function(types) {
vm.throwableTypes = types;
vm.throwableEventTypesSelection(vm.throwableTypes[0])
Expand Down
18 changes: 17 additions & 1 deletion hermes/webapp/src/js/services/hermesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

function HermesService($http, $q) {
var fates;
var serverConfig = null;
var service = {
getFates: getFates,
getFatesSigma: getFatesSigma,
Expand All @@ -20,7 +21,8 @@
getQuestCreatorThrowableEventTypes: getQuestCreatorThrowableEventTypes,
runQuery: runQuery,
createQuest: createQuest,
createEvents: createEvents
createEvents: createEvents,
getServerConfig: getServerConfig
};

return service;
Expand Down Expand Up @@ -521,6 +523,20 @@
throw error;
}
}

/**
* Get the server's config.
* @returns a config promise
*/
function getServerConfig() {
if (serverConfig == null) {
serverConfig = $http.get("/api/v1/serverConfig")
.then(function(response) {
return response.data
});
}
return serverConfig;
}
}

angular.module('hermesApp')
Expand Down
119 changes: 77 additions & 42 deletions hermes/webapp/src/templates/questStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,58 +83,93 @@
</div>
<div class="col-md-9">
<div class="row" style="margin-left: 0px">
<div class="col-md-12">
<div ng-if="!qc.selectedQuest && !qc.errorMessage" style="padding: 10px;">
<img src="/img/loading.gif"/>
</div>
<div ng-if="qc.labors" class="quest-details">
<div quest-progress-chart
colors="qc.colors"
types="qc.types"
data="qc.selectedQuestDetails"></div>
<div class="quest-overview">
<div class="col-md-12">
<div ng-if="!qc.selectedQuest && !qc.errorMessage"
style="padding: 10px;">
<img src="/img/loading.gif"/>
</div>
<div ng-if="qc.labors" class="quest-details">
<div quest-progress-chart
colors="qc.colors"
types="qc.types"
data="qc.selectedQuestDetails"></div>
<div class="quest-overview">
<span>
{{qc.selectedQuestDetails.totalLabors}} total labors. {{qc.selectedQuestDetails.openLabors}} remain open.
</span>
</div>
<div class="quest-labors">
<div class="header row">
<div class="col-md-4">Owner</div><div class="col-md-4">Host</div><div class="col-md-4">Labor</div>
</div>
<div class="owner-group" ng-repeat="(owner, labors) in qc.labors">
<div class="type-group" ng-repeat="(laborType, details) in labors">
<div class="labor-entry row"
ng-repeat="host in details.hosts track by $index"
ng-class="qc.selectedLabors.indexOf(host) != -1 ? 'selected': ''"
ng-click="qc.toggleSelect(host)"
>
<div class="col-md-4"><span ng-if="$parent.$first && $first">{{owner}}</span></div><div class="col-md-4">{{host}}</div><div class="col-md-4">{{laborType}}</div>
</div>
<div class="quest-labors">
<div class="header row">
<div class="col-md-1"></div>
<div class="col-md-11 labor-entry row">
<div class="col-md-3">Labor Owner</div>
<div class="col-md-2">Host</div>
<div class="col-md-3">Host Owner</div>
<div class="col-md-4">Labor</div>
</div>
</div>
<div class="owner-group"
ng-repeat="(owner, labors) in qc.labors">
<div class="type-group"
ng-repeat="(laborType, details) in labors">
<div class="row"
ng-repeat="host in details.hosts track by $index">
<div class="col-md-1">
<span ng-if="$parent.$first && $first">
<a href="mailto:{{owner}}{{
owner.indexOf('@') == -1 ? '@' + qc.domain : ''
}}"
target="_blank"
>
<img src="/img/send_email_15.png" alt="Send email to {{owner}}" />
</a>
</span>
</div>
<div class="col-md-11 labor-entry row"
ng-class="qc.selectedLabors.indexOf(host) != -1 ? 'selected': ''"
ng-click="qc.toggleSelect(host)"
>
<div class="col-md-3">
<span ng-if="$parent.$first && $first">
{{owner}}
</span>
</div>
<div class="col-md-2">{{host}}</div>
<div class="col-md-3">{{qc.hostOwners[host]}}</div>
<div class="col-md-4">{{laborType}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="quest-actions">
<button style="float:left" ng-click="qc.selectAll()">
Select All
</button>
<button style="float:left" ng-click="qc.deselectAll()">
Deselect All
</button>
<div class="quest-actions">
<button style="float:left"
ng-click="qc.selectAll()">
Select All
</button>
<button style="float:left"
ng-click="qc.deselectAll()">
Deselect All
</button>
<span>
Throw <select ng-disabled="qc.selectedLabors.length == 0"
ng-model="qc.throwableEventTypesSelection"
ng-model-options="qc.selectOptions"
ng-options="optValue.category + ' ' + optValue.state for optValue in qc.throwableTypes">
</select> for {{qc.selectedLabors.length}} selected hosts.
ng-model="qc.throwableEventTypesSelection"
ng-model-options="qc.selectOptions"
ng-options="optValue.category + ' ' + optValue.state for optValue in qc.throwableTypes">
</select> for {{qc.selectedLabors.length}} selected hosts.
</span>
<button class="create-button be-positive" ng-click="qc.createEventsModal = true" ng-disabled="qc.selectedLabors.length == 0">
<img ng-if="qc.createInProgress" src="/img/loading_15.gif" style="margin: 5px; float: left" />
Throw Events
</button>
<button class="create-button be-positive"
ng-click="qc.createEventsModal = true"
ng-disabled="qc.selectedLabors.length == 0">
<img ng-if="qc.createInProgress"
src="/img/loading_15.gif"
style="margin: 5px; float: left"/>
Throw Events
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div ng-cloak class="modal-wrapper fade" ng-if="qc.createEventsModal">
Expand Down

0 comments on commit 2b40618

Please sign in to comment.