From b5b1b44c8db3bb49d872001bd7a54fe670f8a509 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 28 Oct 2021 21:31:12 +0200 Subject: [PATCH] fix: update manager commits list icon and show days if smaller than 1 day ago Signed-off-by: Stefan Dej --- src/components/panels/Machine/UpdatePanel.vue | 35 +++++++------------ src/locales/en.json | 1 + 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/components/panels/Machine/UpdatePanel.vue b/src/components/panels/Machine/UpdatePanel.vue index 26eb79a4..029f4f59 100644 --- a/src/components/panels/Machine/UpdatePanel.vue +++ b/src/components/panels/Machine/UpdatePanel.vue @@ -30,8 +30,8 @@ .v-timeline.groupedCommits { .v-timeline-item__dot--small { width: 18px; - height: 14px; - left: calc(50% - 9px); + height: 15px; + margin-top: 2px; &:before { display: block; @@ -39,7 +39,7 @@ position: relative; width: 18px; height: 2px; - top: 8px; + top: 7px; background: rgba(255, 255, 255, 0.50); z-index: 1; } @@ -52,7 +52,8 @@ height: 8px; position: relative; z-index: 2; - margin-left: 5px + margin-left: 5px; + margin-top: 2px; } } @@ -179,7 +180,7 @@

{{ commit.subject }}mdi-dots-horizontal

-

+

{{ commit.author}} {{ convertCommitDate(commit.date) }}

@@ -478,23 +479,6 @@ export default class UpdatePanel extends Mixins(BaseMixin) { } } - convertCommitMessage(message: string) { - //message = this.trimEndLineBreak(message) - message.replace(/(?:\r\n|\r|\n)/g, '
') - //message.replaceAll('\\n', '
') - - return message - } - - trimEndLineBreak(message: string) { - if (['\n', '\r'].includes(message.substr(-1))) { - message = message.substr(0, message.length - 2) - this.trimEndLineBreak(message) - } - - return message - } - convertCommitDate(timestamp: number) { const commitDay = new Date(timestamp * 1000) commitDay.setHours(0,0,0,0) @@ -502,7 +486,12 @@ export default class UpdatePanel extends Mixins(BaseMixin) { todayDay.setHours(0,0,0,0) const diff = Math.floor(todayDay.getTime() - commitDay.getTime()) / (1000 * 60 * 60 * 24) - if (diff === 1) return this.$t('Machine.UpdatePanel.CommittedYesterday') + if (diff === 0) { + const diffHours = Math.floor(((new Date()).getTime() - timestamp * 1000) / (1000 * 60 * 60)) + + return this.$t('Machine.UpdatePanel.CommittedHoursAgo', { hours: diffHours }) + } + else if (diff === 1) return this.$t('Machine.UpdatePanel.CommittedYesterday') else if (diff < 29) return this.$t('Machine.UpdatePanel.CommittedDaysAgo', { days: diff }) else return this.$t('Machine.UpdatePanel.CommittedOnDate', { date: commitDay.toLocaleDateString(this.language, this.dateOptions) }) } diff --git a/src/locales/en.json b/src/locales/en.json index a68837af..799dceb6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -479,6 +479,7 @@ "Unknown": "unknown", "ERROR": "ERROR", "CommitsOnDate": "Commits on {date}", + "CommittedHoursAgo": "committed {hours} hours ago", "CommittedYesterday": "committed yesterday", "CommittedDaysAgo": "committed {days} days ago", "CommittedOnDate": "committed on {date}"