mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05:00
Heatmap days clickable (#13935)
* Heatmap days clickable * Error handling * Unselect filter * better dayclick handler * made linter happy * clickable heatmap for profiles Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
f3e64f677f
commit
343c756357
4 changed files with 41 additions and 7 deletions
|
@ -295,6 +295,7 @@ type GetFeedsOptions struct {
|
|||
IncludePrivate bool // include private actions
|
||||
OnlyPerformedBy bool // only actions performed by requested user
|
||||
IncludeDeleted bool // include deleted actions
|
||||
Date string // the day we want activity for: YYYY-MM-DD
|
||||
}
|
||||
|
||||
// GetFeeds returns actions according to the provided options
|
||||
|
@ -380,5 +381,17 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
|
|||
cond = cond.And(builder.Eq{"is_deleted": false})
|
||||
}
|
||||
|
||||
if opts.Date != "" {
|
||||
dateLow, err := time.Parse("2006-01-02", opts.Date)
|
||||
if err != nil {
|
||||
log.Warn("Unable to parse %s, filter not applied: %v", opts.Date, err)
|
||||
} else {
|
||||
dateHigh := dateLow.Add(86399000000000) // 23h59m59s
|
||||
|
||||
cond = cond.And(builder.Gte{"created_unix": dateLow.Unix()})
|
||||
cond = cond.And(builder.Lte{"created_unix": dateHigh.Unix()})
|
||||
}
|
||||
}
|
||||
|
||||
return cond, nil
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ func Dashboard(ctx *context.Context) {
|
|||
IncludePrivate: true,
|
||||
OnlyPerformedBy: false,
|
||||
IncludeDeleted: false,
|
||||
Date: ctx.Query("date"),
|
||||
})
|
||||
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -202,6 +202,7 @@ func Profile(ctx *context.Context) {
|
|||
IncludePrivate: showPrivate,
|
||||
OnlyPerformedBy: true,
|
||||
IncludeDeleted: false,
|
||||
Date: ctx.Query("date"),
|
||||
})
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
:end-date="endDate"
|
||||
:values="values"
|
||||
:range-color="colorRange"
|
||||
@day-click="handleDayClick($event)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -48,7 +49,25 @@ export default {
|
|||
}
|
||||
return s;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleDayClick(e) {
|
||||
// Reset filter if same date is clicked
|
||||
const params = new URLSearchParams(document.location.search);
|
||||
const queryDate = params.get('date');
|
||||
// Timezone has to be stripped because toISOString() converts to UTC
|
||||
const clickedDate = new Date(e.date - (e.date.getTimezoneOffset() * 60000)).toISOString().substring(0, 10);
|
||||
|
||||
if (queryDate && queryDate === clickedDate) {
|
||||
params.delete('date');
|
||||
} else {
|
||||
params.set('date', clickedDate);
|
||||
}
|
||||
|
||||
const newSearch = params.toString();
|
||||
window.location.search = newSearch.length ? `?${newSearch}` : '';
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped/>
|
||||
|
|
Loading…
Reference in a new issue