Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c80a95d

Browse files
author
Jijie Chen
committedSep 12, 2017
Automatically refresh mail list every 8 seconds;
1 parent 17dc631 commit c80a95d

File tree

4 files changed

+31
-42
lines changed

4 files changed

+31
-42
lines changed
 

‎src/Papercut.Module.WebUI/Papercut.Module.WebUI.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
<EmbeddedResource Include="assets\js\angular-1.3.8.js" />
119119
<EmbeddedResource Include="assets\js\bootstrap-3.3.2.min.js" />
120120
<EmbeddedResource Include="assets\js\controllers.js" />
121-
<EmbeddedResource Include="assets\js\filesize-3.1.2.min.js" />
122121
<EmbeddedResource Include="assets\js\iso88591_map.js" />
123122
<EmbeddedResource Include="assets\js\jquery-1.11.0.min.js" />
124123
<EmbeddedResource Include="assets\js\jquery-ui-1.10.4.min.js" />

‎src/Papercut.Module.WebUI/assets/index.html

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<head>
44
<title>Papercut</title>
55
<meta charset="utf-8">
6-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7-
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<meta name="referrer" content="no-referrer">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<meta name="referrer" content="no-referrer" />
99

10-
<link rel="icon" type="image/png" href="images/papercut.ico">
10+
<link rel="icon" type="image/png" href="images/papercut.ico" />
1111

12-
<link rel="stylesheet" href="css/jquery-ui-1.10.4-smoothness.css">
13-
<link rel="stylesheet" href="css/bootstrap-3.3.2.min.css">
14-
<link rel="stylesheet" href="css/style.css">
12+
<link rel="stylesheet" href="css/jquery-ui-1.10.4-smoothness.css" />
13+
<link rel="stylesheet" href="css/bootstrap-3.3.2.min.css" />
14+
<link rel="stylesheet" href="css/style.css" />
1515
</head>
1616
<body ng-controller="MailCtrl" ng-click="keepopen=false">
1717
<nav class="navbar navbar-default navbar-static-top" role="navigation">
@@ -175,7 +175,6 @@
175175
<script src="js/bootstrap-3.3.2.min.js"></script>
176176
<script src="js/angular-1.3.8.js"></script>
177177
<script src="js/moment-2.8.4.js"></script>
178-
<script src="js/filesize-3.1.2.min.js"></script>
179178
<script src="js/strutil.js"></script>
180179
<script src="js/controllers.js"></script>
181180
<script>

‎src/Papercut.Module.WebUI/assets/js/controllers.js

+24-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var papercutApp = angular.module('papercutApp', []);
22

33

4-
papercutApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
4+
papercutApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout, $interval) {
55
$scope.host = apiHost;
66

77
$scope.cache = {};
@@ -136,6 +136,11 @@ papercutApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
136136
});
137137
}
138138
$scope.refresh();
139+
$interval(function () {
140+
if ($scope.startIndex == 0) {
141+
$scope.refresh();
142+
}
143+
}, 8000);
139144

140145
$scope.showNewer = function() {
141146
$scope.startIndex -= $scope.itemsPerPage;
@@ -160,33 +165,24 @@ papercutApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
160165
$scope.refresh();
161166
}
162167

163-
$scope.hasSelection = function() {
164-
return $(".messages :checked").length > 0 ? true : false;
165-
}
166-
167-
$scope.selectMessage = function(message) {
168-
$timeout(function(){
169-
$scope.resizePreview();
170-
}, 0);
171-
if($scope.cache[message.Id]) {
172-
$scope.preview = $scope.cache[message.Id];
173-
//reflow();
174-
} else {
175-
$scope.preview = message;
176-
var e = $scope.startEvent("Loading message", message.Id, "glyphicon-download-alt");
177-
$http.get($scope.host + 'api/messages/' + message.Id).success(function(data) {
178-
$scope.cache[message.Id] = data;
179-
180-
data.previewHTML = $sce.trustAsHtml(data.HtmlBody);
181-
$scope.preview = data;
182-
e.done();
183-
});
184-
}
185-
}
186-
187-
188-
$scope.fileSize = function(bytes) {
189-
return filesize(bytes)
168+
$scope.selectMessage = function (message) {
169+
$timeout(function () {
170+
$scope.resizePreview();
171+
}, 0);
172+
173+
if ($scope.cache[message.Id]) {
174+
$scope.preview = $scope.cache[message.Id];
175+
} else {
176+
$scope.preview = message;
177+
var e = $scope.startEvent("Loading message", message.Id, "glyphicon-download-alt");
178+
$http.get($scope.host + 'api/messages/' + message.Id).success(function (data) {
179+
$scope.cache[message.Id] = data;
180+
181+
data.previewHTML = $sce.trustAsHtml(data.HtmlBody);
182+
$scope.preview = data;
183+
e.done();
184+
});
185+
}
190186
}
191187

192188
$scope.tryDecodeContent = function(message) {

‎src/Papercut.Module.WebUI/assets/js/filesize-3.1.2.min.js

-5
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.