-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from diggyk/master
Added new landing page
- Loading branch information
Showing
11 changed files
with
213 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.5.1" | ||
__version__ = "0.5.3" |
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
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,129 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
function UserHomeCtrl(hermesService, $q, $routeParams, $location, smoothScroll) { | ||
var vm = this; | ||
|
||
vm.errorMessage = null; | ||
|
||
vm.domain = null; | ||
vm.user = null; | ||
vm.questData = null; | ||
vm.totalQuests = null; | ||
vm.totalUserCreatedQuests = null; | ||
vm.totalLabors = null; | ||
vm.totalUserLabors = null; | ||
|
||
vm.questsUrl = null; | ||
vm.laborsUrl = null; | ||
|
||
vm.goToQuestsPage = goToQuestsPage; | ||
vm.goToLaborsPage = goToLaborsPage; | ||
|
||
hermesService.getCurrentUser().then(function (user) { | ||
if (user) { | ||
vm.user = user; | ||
} | ||
|
||
// find labors and quests for this user | ||
getOpenQuests(); | ||
getOpenLabors(); | ||
}); | ||
|
||
hermesService.getServerConfig().then(function(config) { | ||
vm.domain = config['domain']; | ||
}); | ||
|
||
function goToCreatePage() { | ||
$location.url("/v1/quest/new"); | ||
} | ||
|
||
function goToQuestsPage() { | ||
$location.url(vm.questsUrl); | ||
} | ||
|
||
function goToLaborsPage() { | ||
$location.url(vm.laborsUrl); | ||
} | ||
|
||
/** | ||
* Get open quest information, but we only want basic overview information. | ||
*/ | ||
function getOpenQuests() { | ||
vm.errorMessage = null; | ||
|
||
var options = {}; | ||
options['overviewOnly'] = true; | ||
|
||
hermesService.getOpenQuests(options).then(function (questData) { | ||
vm.questData = questData['quests']; | ||
vm.totalQuests = questData['totalQuests']; | ||
|
||
// see which quests are overdue and which are owned by this user | ||
vm.totalUserCreatedQuests = 0; | ||
for (var idx in vm.questData) { | ||
evalDueDate(vm.questData[idx]); | ||
if (vm.questData[idx]['creator'] == vm.user) { | ||
vm.totalUserCreatedQuests++; | ||
} | ||
} | ||
|
||
if (vm.totalUserCreatedQuests == 0) { | ||
vm.questsUrl = "/v1/quests/?byCreator="; | ||
} else { | ||
vm.questsUrl = "/v1/quests?byCreator=" + vm.user; | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Get labor information (overview only) for all open labors and labors | ||
* that apply to this user. | ||
*/ | ||
function getOpenLabors() { | ||
var options = {}; | ||
options['overviewOnly'] = true; | ||
|
||
hermesService.getOpenLabors(options).then(function (laborData){ | ||
vm.totalLabors = laborData['totalLabors']; | ||
}); | ||
|
||
options['filterByOwner'] = vm.user; | ||
|
||
hermesService.getOpenLabors(options).then(function (laborData) { | ||
vm.totalUserLabors = laborData['totalLabors']; | ||
vm.laborsUrl = "/v1/labors?byOwner=" + vm.user; | ||
}).catch(function(error) { | ||
vm.totalUserLabors = 0; | ||
vm.laborsUrl = "/v1/labors?byOwner="; | ||
}); | ||
} | ||
|
||
/** | ||
* Determine if the quest is overdue and add a property to indicate | ||
* @param quest the quest to analyze | ||
*/ | ||
function evalDueDate(quest) { | ||
if (quest.targetTime) { | ||
var dateRegex = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/; | ||
var dateArray = dateRegex.exec(quest.targetTime); | ||
var targetDate = new Date( | ||
(+dateArray[1]), | ||
(+dateArray[2]) - 1, // Careful, month starts at 0! | ||
(+dateArray[3]), | ||
(+dateArray[4]), | ||
(+dateArray[5]), | ||
(+dateArray[6]) | ||
); | ||
|
||
if (targetDate - new Date() <= 0) quest.overDue = true; | ||
else quest.overDue = false; | ||
} else { | ||
quest.overDue = false; | ||
} | ||
} | ||
} | ||
|
||
angular.module('hermesApp').controller('UserHomeCtrl', UserHomeCtrl); | ||
UserHomeCtrl.$inject = ['HermesService', '$q', '$routeParams', '$location', 'smoothScroll']; | ||
})(); |
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
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
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 @@ | ||
<div ng-controller="UserHomeCtrl as ctrl" class="user-home"> | ||
<div class="row"> | ||
<div class="col-md-12 banner" ng-if="ctrl.user">Hello {{ctrl.user}}</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-3 col-md-offset-3 quest-info"><button ng-if="ctrl.totalQuests != null" ng-click="ctrl.goToQuestsPage()">{{ctrl.totalQuests}} total open quests.<br/>{{ctrl.totalUserCreatedQuests}} created by you.</button></div> | ||
<div class="col-md-3 labor-info"><button ng-if="ctrl.totalUserLabors != null" ng-click="ctrl.goToLaborsPage()">{{ctrl.totalLabors}} total open labors.<br/>{{ctrl.totalUserLabors}} are for you.</button></div> | ||
</div> | ||
</div> |