mirror of
https://gitlab.com/ric_harvey/MailHog.git
synced 2025-02-21 10:15:56 +00:00
Message preview UI fixes
This commit is contained in:
parent
05b50913c1
commit
4f6125ba5c
3 changed files with 36 additions and 9 deletions
|
@ -26,15 +26,12 @@ func Index() string {
|
||||||
background: #eee;
|
background: #eee;
|
||||||
}
|
}
|
||||||
table#headers {
|
table#headers {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 1px;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
}
|
}
|
||||||
#content .nav>li>a {
|
#content .nav>li>a {
|
||||||
padding: 5px 8px;
|
padding: 5px 8px;
|
||||||
}
|
}
|
||||||
#content {
|
|
||||||
padding: 0px 2px;
|
|
||||||
}
|
|
||||||
.preview #headers tbody td {
|
.preview #headers tbody td {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -50,10 +47,20 @@ func Index() string {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
font-family: Courier New, Courier, System, fixed-width;
|
font-family: Courier New, Courier, System, fixed-width;
|
||||||
}
|
}
|
||||||
.tab-content {
|
.preview .tab-content {
|
||||||
padding: 3px;
|
padding: 0;
|
||||||
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<script>
|
||||||
|
var reflow = function() {
|
||||||
|
var remaining = $(window).height() - $('.preview .nav-tabs').offset().top
|
||||||
|
$('.preview .tab-content').height(remaining - 32)
|
||||||
|
}
|
||||||
|
$(function() {
|
||||||
|
reflow();
|
||||||
|
})
|
||||||
|
</script>
|
||||||
<div class="modal fade" id="confirm-delete-all">
|
<div class="modal fade" id="confirm-delete-all">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -121,7 +128,7 @@ func Index() string {
|
||||||
<tr>
|
<tr>
|
||||||
<th>To</th>
|
<th>To</th>
|
||||||
<td>
|
<td>
|
||||||
<button ng-click="$parent.previewAllHeaders = true" type="button" class="btn btn-default pull-right btn-xs">Show headers <span class="glyphicon glyphicon-chevron-down"></span></button>
|
<button id="show-headers" ng-click="toggleHeaders(true)" type="button" class="btn btn-default pull-right btn-xs">Show headers <span class="glyphicon glyphicon-chevron-down"></span></button>
|
||||||
{{ preview.Content.Headers["To"].join(', ') }}
|
{{ preview.Content.Headers["To"].join(', ') }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -132,7 +139,7 @@ func Index() string {
|
||||||
{{ header }}
|
{{ header }}
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<button ng-if="$last" ng-click="$parent.$parent.$parent.previewAllHeaders = false" type="button" class="btn btn-default pull-right btn-xs">Hide headers <span class="glyphicon glyphicon-chevron-up"></span></button>
|
<button id="hide-headers" ng-if="$last" ng-click="toggleHeaders(false)" type="button" class="btn btn-default pull-right btn-xs">Hide headers <span class="glyphicon glyphicon-chevron-up"></span></button>
|
||||||
<div ng-repeat="v in value">{{ v }}</div>
|
<div ng-repeat="v in value">{{ v }}</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -6,6 +6,7 @@ var mailhogApp = angular.module('mailhogApp', []);
|
||||||
|
|
||||||
mailhogApp.controller('MailCtrl', function ($scope, $http, $sce) {
|
mailhogApp.controller('MailCtrl', function ($scope, $http, $sce) {
|
||||||
$scope.cache = {};
|
$scope.cache = {};
|
||||||
|
$scope.previewAllHeaders = false;
|
||||||
|
|
||||||
$scope.refresh = function() {
|
$scope.refresh = function() {
|
||||||
$http.get('/api/v1/messages').success(function(data) {
|
$http.get('/api/v1/messages').success(function(data) {
|
||||||
|
@ -17,6 +18,7 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce) {
|
||||||
$scope.selectMessage = function(message) {
|
$scope.selectMessage = function(message) {
|
||||||
if($scope.cache[message.Id]) {
|
if($scope.cache[message.Id]) {
|
||||||
$scope.preview = $scope.cache[message.Id];
|
$scope.preview = $scope.cache[message.Id];
|
||||||
|
reflow();
|
||||||
} else {
|
} else {
|
||||||
$scope.preview = message;
|
$scope.preview = message;
|
||||||
$http.get('/api/v1/messages/' + message.Id).success(function(data) {
|
$http.get('/api/v1/messages/' + message.Id).success(function(data) {
|
||||||
|
@ -24,10 +26,28 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce) {
|
||||||
data.previewHTML = $sce.trustAsHtml($scope.getMessageHTML(data));
|
data.previewHTML = $sce.trustAsHtml($scope.getMessageHTML(data));
|
||||||
$scope.preview = data;
|
$scope.preview = data;
|
||||||
preview = $scope.cache[message.Id];
|
preview = $scope.cache[message.Id];
|
||||||
|
reflow();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.toggleHeaders = function(val) {
|
||||||
|
$scope.previewAllHeaders = val;
|
||||||
|
var t = window.setInterval(function() {
|
||||||
|
if(val) {
|
||||||
|
if($('#hide-headers').length) {
|
||||||
|
window.clearInterval(t);
|
||||||
|
reflow();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if($('#show-headers').length) {
|
||||||
|
window.clearInterval(t);
|
||||||
|
reflow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
|
||||||
$scope.getMessagePlain = function(message) {
|
$scope.getMessagePlain = function(message) {
|
||||||
var part;
|
var part;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ func Layout(content string) string {
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.15/angular.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.15/angular.js"></script>
|
||||||
<script src="/js/controllers.js"></script>
|
<script src="/js/controllers.js"></script>
|
||||||
<style>
|
<style>
|
||||||
body, html { height: 100%; }
|
body, html { height: 100%; overflow: hidden; }
|
||||||
.navbar {
|
.navbar {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
Loading…
Add table
Reference in a new issue