1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-06-15 00:05:15 +02:00

UI: Add favicon unread message counter

This commit is contained in:
Ralph Slooten
2022-09-14 22:37:47 +12:00
parent 4e2e59ec87
commit f6a8de3215
3 changed files with 41 additions and 4 deletions

11
package-lock.json generated
View File

@ -13,6 +13,7 @@
"bootstrap-icons": "^1.9.1", "bootstrap-icons": "^1.9.1",
"moment": "^2.29.4", "moment": "^2.29.4",
"prismjs": "^1.29.0", "prismjs": "^1.29.0",
"tinycon": "^0.6.8",
"vue": "^3.2.13" "vue": "^3.2.13"
}, },
"devDependencies": { "devDependencies": {
@ -1124,6 +1125,11 @@
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==" "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA=="
}, },
"node_modules/tinycon": {
"version": "0.6.8",
"resolved": "https://registry.npmjs.org/tinycon/-/tinycon-0.6.8.tgz",
"integrity": "sha512-bF8Lxm4JUXF6Cw0XlZdugJ44GV575OinZ0Pt8vQPr8ooNqd2yyNkoFdCHzmdpHlgoqfSLfcyk4HDP1EyllT+ug=="
},
"node_modules/tmp": { "node_modules/tmp": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
@ -1902,6 +1908,11 @@
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==" "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA=="
}, },
"tinycon": {
"version": "0.6.8",
"resolved": "https://registry.npmjs.org/tinycon/-/tinycon-0.6.8.tgz",
"integrity": "sha512-bF8Lxm4JUXF6Cw0XlZdugJ44GV575OinZ0Pt8vQPr8ooNqd2yyNkoFdCHzmdpHlgoqfSLfcyk4HDP1EyllT+ug=="
},
"tmp": { "tmp": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",

View File

@ -13,6 +13,7 @@
"bootstrap-icons": "^1.9.1", "bootstrap-icons": "^1.9.1",
"moment": "^2.29.4", "moment": "^2.29.4",
"prismjs": "^1.29.0", "prismjs": "^1.29.0",
"tinycon": "^0.6.8",
"vue": "^3.2.13" "vue": "^3.2.13"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,7 +1,8 @@
<script> <script>
import commonMixins from './mixins.js' import commonMixins from './mixins.js';
import Message from './templates/Message.vue'; import Message from './templates/Message.vue';
import moment from 'moment' import moment from 'moment';
import Tinycon from 'tinycon';
export default { export default {
mixins: [commonMixins], mixins: [commonMixins],
@ -26,7 +27,8 @@ export default {
messageNext: false, messageNext: false,
notificationsSupported: false, notificationsSupported: false,
notificationsEnabled: false, notificationsEnabled: false,
selected: [] selected: [],
tcStatus: 0
} }
}, },
watch: { watch: {
@ -36,6 +38,17 @@ export default {
} else { } else {
this.message = false; this.message = false;
} }
},
unread(v, old) {
if (v == this.tcStatus) {
return;
}
this.tcStatus = v;
if (v == 0) {
Tinycon.reset();
} else {
Tinycon.setBubble(v);
}
} }
}, },
computed: { computed: {
@ -56,6 +69,12 @@ export default {
&& ("Notification" in window && Notification.permission !== "denied"); && ("Notification" in window && Notification.permission !== "denied");
this.notificationsEnabled = this.notificationsSupported && Notification.permission == "granted"; this.notificationsEnabled = this.notificationsSupported && Notification.permission == "granted";
Tinycon.setOptions({
height: 11,
background: '#dd0000',
fallback: false
});
this.connect(); this.connect();
this.loadMessages(); this.loadMessages();
}, },
@ -192,6 +211,7 @@ export default {
let self = this; let self = this;
let uri = 'api/delete' let uri = 'api/delete'
self.get(uri, false, function(response) { self.get(uri, false, function(response) {
window.location.hash = "";
self.reloadMessages(); self.reloadMessages();
}); });
}, },
@ -206,7 +226,6 @@ export default {
window.location.hash = ""; window.location.hash = "";
self.scrollInPlace = true; self.scrollInPlace = true;
self.loadMessages(); self.loadMessages();
}); });
}, },
@ -388,6 +407,12 @@ export default {
let selecting = false; let selecting = false;
let lastSelected = this.selected.length > 0 && this.selected[this.selected.length - 1]; let lastSelected = this.selected.length > 0 && this.selected[this.selected.length - 1];
if (lastSelected == id) {
this.selected = this.selected.filter(function(ele){
return ele != id;
});
return
}
if (lastSelected === false) { if (lastSelected === false) {
this.selected.push(id); this.selected.push(id);