mirror of
https://github.com/go-gitea/gitea
synced 2024-09-27 06:44:06 +00:00
pass seconds again, can not emit datetime from backend
This commit is contained in:
parent
cfee93d481
commit
5079641d1a
@ -6,7 +6,6 @@ package repo
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
@ -101,7 +100,7 @@ func GetActiveStopwatch(ctx *context.Context) {
|
|||||||
issue.Link(),
|
issue.Link(),
|
||||||
issue.Repo.FullName(),
|
issue.Repo.FullName(),
|
||||||
issue.Index,
|
issue.Index,
|
||||||
time.Unix(time.Now().Unix() - sw.Seconds(), 0).Format(time.RFC3339),
|
sw.Seconds() + 1, // ensure time is never zero in ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,5 +109,5 @@ type StopwatchTmplInfo struct {
|
|||||||
IssueLink string
|
IssueLink string
|
||||||
RepoSlug string
|
RepoSlug string
|
||||||
IssueIndex int64
|
IssueIndex int64
|
||||||
Datetime string
|
Seconds int64
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,10 @@
|
|||||||
<!-- mobile right menu, it must be here because in mobile view, each item is a flex column, the first item is a full row column -->
|
<!-- mobile right menu, it must be here because in mobile view, each item is a flex column, the first item is a full row column -->
|
||||||
<div class="ui secondary menu item navbar-mobile-right only-mobile">
|
<div class="ui secondary menu item navbar-mobile-right only-mobile">
|
||||||
{{if and .IsSigned EnableTimetracking .ActiveStopwatch}}
|
{{if and .IsSigned EnableTimetracking .ActiveStopwatch}}
|
||||||
<a id="mobile-stopwatch-icon" class="active-stopwatch item tw-mx-0" href="{{.ActiveStopwatch.IssueLink}}" title="{{ctx.Locale.Tr "active_stopwatch"}}" data-datetime="{{.ActiveStopwatch.Datetime}}">
|
<a id="mobile-stopwatch-icon" class="active-stopwatch item tw-mx-0" href="{{.ActiveStopwatch.IssueLink}}" title="{{ctx.Locale.Tr "active_stopwatch"}}" data-seconds="{{.ActiveStopwatch.Seconds}}">
|
||||||
<div class="tw-relative">
|
<div class="tw-relative">
|
||||||
{{svg "octicon-stopwatch"}}
|
{{svg "octicon-stopwatch"}}
|
||||||
<span class="header-stopwatch-dot">
|
<span class="header-stopwatch-dot"></span>
|
||||||
<relative-time
|
|
||||||
format="micro"
|
|
||||||
datetime="{{.ActiveStopwatch.Datetime}}"
|
|
||||||
data-no-tooltip="true"
|
|
||||||
></relative-time>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -89,15 +83,10 @@
|
|||||||
</div><!-- end dropdown avatar menu -->
|
</div><!-- end dropdown avatar menu -->
|
||||||
{{else if .IsSigned}}
|
{{else if .IsSigned}}
|
||||||
{{if and EnableTimetracking .ActiveStopwatch}}
|
{{if and EnableTimetracking .ActiveStopwatch}}
|
||||||
<a class="item not-mobile active-stopwatch tw-mx-0" href="{{.ActiveStopwatch.IssueLink}}" title="{{ctx.Locale.Tr "active_stopwatch"}}" data-datetime="{{.ActiveStopwatch.Datetime}}">
|
<a class="item not-mobile active-stopwatch tw-mx-0" href="{{.ActiveStopwatch.IssueLink}}" title="{{ctx.Locale.Tr "active_stopwatch"}}" data-seconds="{{.ActiveStopwatch.Seconds}}">
|
||||||
<div class="tw-relative">
|
<div class="tw-relative">
|
||||||
{{svg "octicon-stopwatch"}}
|
{{svg "octicon-stopwatch"}}
|
||||||
<span class="header-stopwatch-dot">
|
<span class="header-stopwatch-dot"></relative-time>
|
||||||
<relative-time
|
|
||||||
format="micro"
|
|
||||||
datetime="{{.ActiveStopwatch.Datetime}}"
|
|
||||||
data-no-tooltip="true"
|
|
||||||
></relative-time>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -17,9 +17,9 @@ export function initStopwatch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// global stop watch (in the head_navbar), it should always work in any case either the EventSource or the PeriodicPoller is used.
|
// global stop watch (in the head_navbar), it should always work in any case either the EventSource or the PeriodicPoller is used.
|
||||||
const datetime = stopwatchEls[0]?.getAttribute('data-datetime');
|
const seconds = stopwatchEls[0]?.getAttribute('data-seconds');
|
||||||
if (datetime) {
|
if (seconds) {
|
||||||
updateStopwatchTime(datetime);
|
updateStopwatchTime(seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const stopwatchEl of stopwatchEls) {
|
for (const stopwatchEl of stopwatchEls) {
|
||||||
@ -137,17 +137,14 @@ function updateStopwatchData(data) {
|
|||||||
document.querySelector('.stopwatch-cancel')?.setAttribute('action', `${issueUrl}/times/stopwatch/cancel`);
|
document.querySelector('.stopwatch-cancel')?.setAttribute('action', `${issueUrl}/times/stopwatch/cancel`);
|
||||||
const stopwatchIssue = document.querySelector('.stopwatch-issue');
|
const stopwatchIssue = document.querySelector('.stopwatch-issue');
|
||||||
if (stopwatchIssue) stopwatchIssue.textContent = `${repo_owner_name}/${repo_name}#${issue_index}`;
|
if (stopwatchIssue) stopwatchIssue.textContent = `${repo_owner_name}/${repo_name}#${issue_index}`;
|
||||||
updateStopwatchTime(secondsToDatetime(seconds));
|
updateStopwatchTime(seconds);
|
||||||
showElem(btnEl);
|
showElem(btnEl);
|
||||||
}
|
}
|
||||||
return Boolean(data.length);
|
return Boolean(data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
function secondsToDatetime(seconds) {
|
function updateStopwatchTime(seconds) {
|
||||||
return (new Date(Date.now() - seconds * 1000)).toISOString();
|
const datetime = (new Date(Date.now() - seconds * 1000)).toISOString();
|
||||||
}
|
|
||||||
|
|
||||||
function updateStopwatchTime(datetime) {
|
|
||||||
for (const parent of document.querySelectorAll('.header-stopwatch-dot')) {
|
for (const parent of document.querySelectorAll('.header-stopwatch-dot')) {
|
||||||
const existing = parent.querySelector(':scope > relative-time');
|
const existing = parent.querySelector(':scope > relative-time');
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
Loading…
Reference in New Issue
Block a user