Skip to content

Commit

Permalink
Merge pull request #143 from diggyk/sendmail
Browse files Browse the repository at this point in the history
Added ability to send email to quest participants from the WebGUI
  • Loading branch information
jathanism committed Feb 18, 2016
2 parents 699d194 + ce7f7e7 commit 2256e7e
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 16 deletions.
4 changes: 2 additions & 2 deletions hermes/handlers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2733,7 +2733,7 @@ def post(self, id):
if labor.for_owner:
# add machine owner to recipients
owner = owners[labor.host.hostname]
if owner in strongpoc_contacts:
if strongpoc_contacts and owner in strongpoc_contacts:
recipients.add(strongpoc_contacts[owner])
else:
recipients.add("{}@{}".format(owner, settings.domain))
Expand All @@ -2744,7 +2744,7 @@ def post(self, id):
for labor in labors:
# add machine owner to recipients
owner = owners[labor.host.hostname]
if owner in strongpoc_contacts:
if strongpoc_contacts and owner in strongpoc_contacts:
recipients.add(strongpoc_contacts[owner])
else:
recipients.add("{}@{}".format(owner, settings.domain))
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.7.18"
__version__ = "0.7.19"
43 changes: 38 additions & 5 deletions hermes/webapp/src/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,9 @@ a {
padding: 5px;
width: 20%;
border-bottom: 2px solid @blue;
span {
font-size: 1.75em;
font-weight: bold;
}
a {
font-size: 1.75em;
font-weight: bold;
.quest-buttons {
font-size: 0.65em;
}
}
Expand All @@ -478,6 +476,41 @@ a {
font-weight: normal;
clear: both;
}
.message-block {
padding: 10px;
background: @xlight-blue;
overflow: auto;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
label, button {
margin-top: 10px;
}

-moz-transition: 0.5s ease-out all;
-ms-transition: 0.5s ease-out all;
-o-transition: 0.5s ease-out all;
transition: 0.5s ease-out all;
height: auto;
max-height: 500px;
}
.message-block.ng-enter {
max-height: 0;
transition: 0.25s ease-out all;
}

.message-block.ng-enter-active {
max-height: 500px;
}

.message-block.ng-leave {
max-height: 500px;
transition: 0.25s ease-out all;
}

.message-block.ng-leave-active {
max-height: 0;
}
}
.quest-overview {
font-size: 1.5em;
Expand Down
16 changes: 16 additions & 0 deletions hermes/webapp/src/js/controllers/questStatusCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
vm.limit = 10;
vm.offset = 0;
vm.totalQuests = 10;
vm.messageSubject = null;
vm.messageEmail = null;
vm.showMessageBlock = false;

vm.colors = ['#688ab4', '#9cbfea', '#232f3e', '#7e8184'];

Expand All @@ -46,6 +49,7 @@
vm.deselectAll = deselectAll;
vm.throwableTypesSelection = throwableTypesSelection;
vm.createEvents = createEvents;
vm.createQuestEmail = createQuestEmail;

vm.selectOptions = {
updateOn: 'default change blur',
Expand Down Expand Up @@ -195,6 +199,18 @@
getOpenQuests();
}

function createQuestEmail() {
hermesService.createQuestEmail(vm.selectedQuestDetails['id'], vm.messageEmail, vm.messageSubject, vm.user, true, false)
.then(function (response){
vm.createSuccessMessage = "Successfully sent email.";
vm.messageSubject = null;
vm.messageEmail = null;
vm.showMessageBlock = false;
}).catch(function (error){
vm.createErrorMessage = "Email failed to send"
})
}

function getOpenQuests() {
vm.errorMessage = null;

Expand Down
32 changes: 32 additions & 0 deletions hermes/webapp/src/js/services/hermesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
getQuestCreatorThrowableEventTypes: getQuestCreatorThrowableEventTypes,
runQuery: runQuery,
createQuest: createQuest,
createQuestEmail: createQuestEmail,
updateQuest: updateQuest,
createEvents: createEvents,
getServerConfig: getServerConfig
Expand Down Expand Up @@ -77,6 +78,37 @@
}
}

/**
* Try to send an email to server or labor owners for a given quest
* @param questId ID for the quest to email about
* @param message message to send to server or labor owners
* @param subject subject of message to send
* @param sender email address to send from
* @param serverOwners boolean to send or not send to server owners
* @param laborOwners boolean to send or not send to labor owners
* @returns {*}
*/
function createQuestEmail(questId, message, subject, sender, serverOwners, laborOwners) {
return $http.post("/api/v1/quests/" + questId + "/mail", {
'serverOwners': serverOwners,
'laborOwners': laborOwners,
'from': sender,
'subject': subject,
'message': message
}).then(createQuestEmailCompleted)
.catch(createQuestEmailFailed);

function createQuestEmailCompleted(response) {
console.log("hermes service: message sent")
return response;
}

function createQuestEmailFailed(error) {
console.error("API for creating a quest email failed! " + error.status + " " + error.statusText);
throw error;
}
}

/**
* Update a given quest with new values
* @param questId the id of the quest to update
Expand Down
20 changes: 12 additions & 8 deletions hermes/webapp/src/templates/questStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,15 @@
<img src="/img/loading.gif"/>
</div>
<div ng-if="qc.labors" class="quest-details">
<!--<div quest-progress-chart-->
<!--colors="qc.colors"-->
<!--types="qc.countByTypes"-->
<!--data="qc.selectedQuestDetails">-->
<!--</div>-->
<div class="quest-info-holder">
<div class="flex-row" ng-class="qc.selectedQuest.overDue ? 'overdue' : ''">
<div class="quest-number">
<span>Quest {{qc.selectedQuest.id}}</span>
<a ng-href="/v1/quests/{{qc.selectedQuest.id}}/edit">
<span ng-if="qc.selectedQuest.creator == qc.user" id="toggleEditing" aria-label="Edit this quest" role="checkbox" class="glyphicon glyphicon-edit btn-glyph">
<span class="quest-buttons">
<a ng-href="/v1/quests/{{qc.selectedQuest.id}}/edit"><span ng-if="qc.selectedQuest.creator == qc.user" id="toggleEditing" aria-label="Edit this quest" role="checkbox" class="glyphicon glyphicon-edit btn-glyph"></span></a>
<span id="toggleMailBlock" aria-label="Send email to this quest" role="checkbox" ng-class="{'selected': qc.showMessageBlock}" class="glyphicon glyphicon-envelope btn-glyph email-button" ng-click="qc.showMessageBlock=!qc.showMessageBlock" >
</span>
</a>
</span>
</div>
<div class="sub-info">
<span ng-if="qc.selectedQuest.overDue">OVERDUE</span>
Expand All @@ -189,6 +185,14 @@
<span>on {{qc.selectedQuest.embarkTime}}</span>
</div>
</div>
<div class="success-message" ng-if="qc.createSuccessMessage">{{ qc.createSuccessMessage }}</div>
<div class="message-block" ng-if="qc.showMessageBlock">
<label for="messageSubject">Subject:</label>
<input type="text" ng-model="qc.messageSubject" id="messageSubject"/>
<label for="messageEmail">Email:</label>
<textarea ng-model="qc.messageEmail" id="messageEmail"></textarea>
<button type="button" ng-click="qc.createQuestEmail()">Send Message</button>
</div>
<div class="description">{{qc.selectedQuest.description}}</div>
</div>
<div class="quest-overview">
Expand Down

0 comments on commit 2256e7e

Please sign in to comment.