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
|
// 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 {
|
for _, t := range missingTypes {
|
||||||
s.FillBy(presentType, t)
|
s.FillBy(presentType, t)
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ func (r *UserRepository) Update(user *models.User) (*models.User, error) {
|
||||||
"share_oss": user.ShareOSs,
|
"share_oss": user.ShareOSs,
|
||||||
"share_projects": user.ShareProjects,
|
"share_projects": user.ShareProjects,
|
||||||
"share_machines": user.ShareMachines,
|
"share_machines": user.ShareMachines,
|
||||||
|
"share_labels": user.ShareLabels,
|
||||||
"wakatime_api_key": user.WakatimeApiKey,
|
"wakatime_api_key": user.WakatimeApiKey,
|
||||||
"has_data": user.HasData,
|
"has_data": user.HasData,
|
||||||
"reset_token": user.ResetToken,
|
"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.ShareEditors, err = strconv.ParseBool(r.PostFormValue("share_editors"))
|
||||||
user.ShareOSs, err = strconv.ParseBool(r.PostFormValue("share_oss"))
|
user.ShareOSs, err = strconv.ParseBool(r.PostFormValue("share_oss"))
|
||||||
user.ShareMachines, err = strconv.ParseBool(r.PostFormValue("share_machines"))
|
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"))
|
user.ShareDataMaxDays, err = strconv.Atoi(r.PostFormValue("max_days"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -298,11 +298,9 @@
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
<select autocomplete="off" name="share_projects"
|
<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">
|
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
|
<option value="false" class="cursor-pointer" {{ if not .User.ShareProjects }} selected {{ end }}>No
|
||||||
{{ end }}>No
|
|
||||||
</option>
|
</option>
|
||||||
<option value="true" class="cursor-pointer" {{ if .User.ShareProjects }} selected {{ end
|
<option value="true" class="cursor-pointer" {{ if .User.ShareProjects }} selected {{ end }}>Yes
|
||||||
}}>Yes
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -314,11 +312,9 @@
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
<select autocomplete="off" name="share_languages"
|
<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">
|
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
|
<option value="false" class="cursor-pointer" {{ if not .User.ShareLanguages }} selected {{ end }}>No
|
||||||
{{ end }}>No
|
|
||||||
</option>
|
</option>
|
||||||
<option value="true" class="cursor-pointer" {{ if .User.ShareLanguages }} selected {{
|
<option value="true" class="cursor-pointer" {{ if .User.ShareLanguages }} selected {{ end }}>Yes
|
||||||
end }}>Yes
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -330,11 +326,9 @@
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
<select autocomplete="off" name="share_editors"
|
<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">
|
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 {{
|
<option value="false" class="cursor-pointer" {{ if not .User.ShareEditors }} selected {{ end }}>No
|
||||||
end }}>No
|
|
||||||
</option>
|
</option>
|
||||||
<option value="true" class="cursor-pointer" {{ if .User.ShareEditors }} selected {{ end
|
<option value="true" class="cursor-pointer" {{ if .User.ShareEditors }} selected {{ end }}>Yes
|
||||||
}}>Yes
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -346,8 +340,7 @@
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
<select autocomplete="off" name="share_oss"
|
<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">
|
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
|
<option value="false" class="cursor-pointer" {{ if not .User.ShareOSs }} selected {{ end }}>No
|
||||||
}}>No
|
|
||||||
</option>
|
</option>
|
||||||
<option value="true" class="cursor-pointer" {{ if .User.ShareOSs }} selected {{ end }}>
|
<option value="true" class="cursor-pointer" {{ if .User.ShareOSs }} selected {{ end }}>
|
||||||
Yes
|
Yes
|
||||||
|
@ -362,11 +355,23 @@
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
<select autocomplete="off" name="share_machines"
|
<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">
|
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
|
<option value="false" class="cursor-pointer" {{ if not .User.ShareMachines }} selected {{ end }}>No
|
||||||
{{ end }}>No
|
|
||||||
</option>
|
</option>
|
||||||
<option value="true" class="cursor-pointer" {{ if .User.ShareMachines }} selected {{ end
|
<option value="true" class="cursor-pointer" {{ if .User.ShareMachines }} selected {{ end }}>Yes
|
||||||
}}>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>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -657,8 +662,16 @@
|
||||||
|
|
||||||
// Time zone stuff
|
// Time zone stuff
|
||||||
|
|
||||||
const userTimeZone = {{ .User.Location }}
|
const userTimeZone = {
|
||||||
const userTzOffset = {{ .User.TZOffset.Hours }}
|
{ .
|
||||||
|
User.Location
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const userTzOffset = {
|
||||||
|
{ .
|
||||||
|
User.TZOffset.Hours
|
||||||
|
}
|
||||||
|
}
|
||||||
const selectTimezone = document.getElementById('select-timezone')
|
const selectTimezone = document.getElementById('select-timezone')
|
||||||
const createTzOption = (tz) => {
|
const createTzOption = (tz) => {
|
||||||
if (!tz) tz = 'Local'
|
if (!tz) tz = 'Local'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user