mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: nil pointer dereference
chore: allow to share labels publicly on settings page
This commit is contained in:
parent
0d64858721
commit
628ea0b9dd
@ -136,7 +136,10 @@ func (s *Summary) FillMissing() {
|
||||
}
|
||||
|
||||
// construct dummy item for all missing types
|
||||
presentType, _ := s.findFirstPresentType()
|
||||
presentType, err := s.findFirstPresentType()
|
||||
if err != nil {
|
||||
return // all types are either zero or missing entirely, nothing to fill
|
||||
}
|
||||
for _, t := range missingTypes {
|
||||
s.FillBy(presentType, t)
|
||||
}
|
||||
|
@ -147,6 +147,7 @@ func (r *UserRepository) Update(user *models.User) (*models.User, error) {
|
||||
"share_oss": user.ShareOSs,
|
||||
"share_projects": user.ShareProjects,
|
||||
"share_machines": user.ShareMachines,
|
||||
"share_labels": user.ShareLabels,
|
||||
"wakatime_api_key": user.WakatimeApiKey,
|
||||
"has_data": user.HasData,
|
||||
"reset_token": user.ResetToken,
|
||||
|
@ -252,6 +252,7 @@ func (h *SettingsHandler) actionUpdateSharing(w http.ResponseWriter, r *http.Req
|
||||
user.ShareEditors, err = strconv.ParseBool(r.PostFormValue("share_editors"))
|
||||
user.ShareOSs, err = strconv.ParseBool(r.PostFormValue("share_oss"))
|
||||
user.ShareMachines, err = strconv.ParseBool(r.PostFormValue("share_machines"))
|
||||
user.ShareLabels, err = strconv.ParseBool(r.PostFormValue("share_labels"))
|
||||
user.ShareDataMaxDays, err = strconv.Atoi(r.PostFormValue("max_days"))
|
||||
|
||||
if err != nil {
|
||||
|
@ -298,11 +298,9 @@
|
||||
<div class="flex justify-end">
|
||||
<select autocomplete="off" name="share_projects"
|
||||
class="cursor-pointer shadow appearance-nonshadow appearance-none bg-gray-800 focus:bg-gray-700 text-gray-300 border-green-700 focus:border-gray-500 border rounded py-1 px-3">
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareProjects }} selected
|
||||
{{ end }}>No
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareProjects }} selected {{ end }}>No
|
||||
</option>
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareProjects }} selected {{ end
|
||||
}}>Yes
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareProjects }} selected {{ end }}>Yes
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -314,11 +312,9 @@
|
||||
<div class="flex justify-end">
|
||||
<select autocomplete="off" name="share_languages"
|
||||
class="cursor-pointer shadow appearance-nonshadow appearance-none bg-gray-800 focus:bg-gray-700 text-gray-300 border-green-700 focus:border-gray-500 border rounded py-1 px-3">
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareLanguages }} selected
|
||||
{{ end }}>No
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareLanguages }} selected {{ end }}>No
|
||||
</option>
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareLanguages }} selected {{
|
||||
end }}>Yes
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareLanguages }} selected {{ end }}>Yes
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -330,11 +326,9 @@
|
||||
<div class="flex justify-end">
|
||||
<select autocomplete="off" name="share_editors"
|
||||
class="cursor-pointer shadow appearance-nonshadow appearance-none bg-gray-800 focus:bg-gray-700 text-gray-300 border-green-700 focus:border-gray-500 border rounded py-1 px-3">
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareEditors }} selected {{
|
||||
end }}>No
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareEditors }} selected {{ end }}>No
|
||||
</option>
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareEditors }} selected {{ end
|
||||
}}>Yes
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareEditors }} selected {{ end }}>Yes
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -346,8 +340,7 @@
|
||||
<div class="flex justify-end">
|
||||
<select autocomplete="off" name="share_oss"
|
||||
class="cursor-pointer shadow appearance-nonshadow appearance-none bg-gray-800 focus:bg-gray-700 text-gray-300 border-green-700 focus:border-gray-500 border rounded py-1 px-3">
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareOSs }} selected {{ end
|
||||
}}>No
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareOSs }} selected {{ end }}>No
|
||||
</option>
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareOSs }} selected {{ end }}>
|
||||
Yes
|
||||
@ -362,11 +355,23 @@
|
||||
<div class="flex justify-end">
|
||||
<select autocomplete="off" name="share_machines"
|
||||
class="cursor-pointer shadow appearance-nonshadow appearance-none bg-gray-800 focus:bg-gray-700 text-gray-300 border-green-700 focus:border-gray-500 border rounded py-1 px-3">
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareMachines }} selected
|
||||
{{ end }}>No
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareMachines }} selected {{ end }}>No
|
||||
</option>
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareMachines }} selected {{ end
|
||||
}}>Yes
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareMachines }} selected {{ end }}>Yes
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center w-full text-gray-300 text-sm justify-between my-2">
|
||||
<div class="flex justify-start">
|
||||
<span class="mr-2">Share project labels: </span>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<select autocomplete="off" name="share_labels"
|
||||
class="cursor-pointer shadow appearance-nonshadow appearance-none bg-gray-800 focus:bg-gray-700 text-gray-300 border-green-700 focus:border-gray-500 border rounded py-1 px-3">
|
||||
<option value="false" class="cursor-pointer" {{ if not .User.ShareLabels }} selected {{ end }}>No
|
||||
</option>
|
||||
<option value="true" class="cursor-pointer" {{ if .User.ShareLabels }} selected {{ end }}>Yes
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -657,8 +662,16 @@
|
||||
|
||||
// Time zone stuff
|
||||
|
||||
const userTimeZone = {{ .User.Location }}
|
||||
const userTzOffset = {{ .User.TZOffset.Hours }}
|
||||
const userTimeZone = {
|
||||
{ .
|
||||
User.Location
|
||||
}
|
||||
}
|
||||
const userTzOffset = {
|
||||
{ .
|
||||
User.TZOffset.Hours
|
||||
}
|
||||
}
|
||||
const selectTimezone = document.getElementById('select-timezone')
|
||||
const createTzOption = (tz) => {
|
||||
if (!tz) tz = 'Local'
|
||||
|
Loading…
Reference in New Issue
Block a user