Skip to content

stopwatch notif: check if timetracking is enabled #14750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func NewFuncMap() []template.FuncMap {
"UseServiceWorker": func() bool {
return setting.UI.UseServiceWorker
},
"EnableTimetracking": func() bool {
return setting.Service.EnableTimetracking
},
"FilenameIsImage": func(filename string) bool {
mimeType := mime.TypeByExtension(filepath.Ext(filename))
return strings.HasPrefix(mimeType, "image/")
Expand Down
1 change: 1 addition & 0 deletions templates/base/head.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
MaxTimeout: {{NotificationSettings.MaxTimeout}},
EventSourceUpdateTime: {{NotificationSettings.EventSourceUpdateTime}},
},
EnableTimetracking: {{if EnableTimetracking}}true{{else}}false{{end}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a side note, we could probably get these into the system info api endpoint to better integrate SPAs in the future (this isn't a note for this PR though).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with lfs enable/disable info ... - will add a pull

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome. thanks :)

PageIsProjects: {{if .PageIsProjects }}true{{else}}false{{end}},
{{if .RequireTribute}}
tributeValues: Array.from(new Map([
Expand Down
7 changes: 5 additions & 2 deletions web_src/js/features/stopwatch.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import prettyMilliseconds from 'pretty-ms';
const {AppSubUrl, csrf, NotificationSettings} = window.config;
const {AppSubUrl, csrf, NotificationSettings, EnableTimetracking} = window.config;

let updateTimeInterval = null; // holds setInterval id when active

export async function initStopwatch() {
const stopwatchEl = $('.active-stopwatch-trigger');
if (!EnableTimetracking) {
return;
}

const stopwatchEl = $('.active-stopwatch-trigger');
stopwatchEl.removeAttr('href'); // intended for noscript mode only
stopwatchEl.popup({
position: 'bottom right',
Expand Down