2024-12-13 17:00:17 +01:00
|
|
|
import Component from "@glimmer/component";
|
|
|
|
|
import { tracked } from "@glimmer/tracking";
|
2024-12-20 18:56:02 +01:00
|
|
|
import { on } from "@ember/modifier";
|
2024-12-13 17:00:17 +01:00
|
|
|
import { action } from "@ember/object";
|
|
|
|
|
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
2024-12-13 17:51:06 +01:00
|
|
|
import DButton from "discourse/components/d-button";
|
|
|
|
|
import concatClass from "discourse/helpers/concat-class";
|
2024-12-13 17:00:17 +01:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2025-11-18 09:03:41 -05:00
|
|
|
import { i18n } from "discourse-i18n";
|
2024-12-20 18:56:02 +01:00
|
|
|
import ActivityCalendar from "discourse/plugins/discourse-rewind/discourse/components/reports/activity-calendar";
|
2025-12-02 11:41:30 -03:00
|
|
|
import AiUsage from "discourse/plugins/discourse-rewind/discourse/components/reports/ai-usage";
|
|
|
|
|
import Assignments from "discourse/plugins/discourse-rewind/discourse/components/reports/assignments";
|
2024-12-20 18:56:02 +01:00
|
|
|
import BestPosts from "discourse/plugins/discourse-rewind/discourse/components/reports/best-posts";
|
|
|
|
|
import BestTopics from "discourse/plugins/discourse-rewind/discourse/components/reports/best-topics";
|
2025-12-02 11:41:30 -03:00
|
|
|
import ChatUsage from "discourse/plugins/discourse-rewind/discourse/components/reports/chat-usage";
|
|
|
|
|
// import FavoriteGifs from "discourse/plugins/discourse-rewind/discourse/components/reports/favorite-gifs";
|
2024-12-20 18:56:02 +01:00
|
|
|
import FBFF from "discourse/plugins/discourse-rewind/discourse/components/reports/fbff";
|
2025-01-13 10:48:23 -06:00
|
|
|
import RewindHeader from "discourse/plugins/discourse-rewind/discourse/components/reports/header";
|
2025-12-02 11:41:30 -03:00
|
|
|
import Invites from "discourse/plugins/discourse-rewind/discourse/components/reports/invites";
|
2025-11-07 10:20:25 +10:00
|
|
|
import MostViewedCategories from "discourse/plugins/discourse-rewind/discourse/components/reports/most-viewed-categories";
|
|
|
|
|
import MostViewedTags from "discourse/plugins/discourse-rewind/discourse/components/reports/most-viewed-tags";
|
2025-12-02 11:41:30 -03:00
|
|
|
import NewUserInteractions from "discourse/plugins/discourse-rewind/discourse/components/reports/new-user-interactions";
|
2024-12-13 17:51:06 +01:00
|
|
|
import Reactions from "discourse/plugins/discourse-rewind/discourse/components/reports/reactions";
|
2024-12-20 18:56:02 +01:00
|
|
|
import ReadingTime from "discourse/plugins/discourse-rewind/discourse/components/reports/reading-time";
|
2025-12-02 11:41:30 -03:00
|
|
|
import TimeOfDayActivity from "discourse/plugins/discourse-rewind/discourse/components/reports/time-of-day-activity";
|
2025-01-13 13:12:12 +01:00
|
|
|
import TopWords from "discourse/plugins/discourse-rewind/discourse/components/reports/top-words";
|
2025-12-02 11:41:30 -03:00
|
|
|
import WritingAnalysis from "discourse/plugins/discourse-rewind/discourse/components/reports/writing-analysis";
|
2024-12-13 17:00:17 +01:00
|
|
|
|
|
|
|
|
export default class Rewind extends Component {
|
|
|
|
|
@tracked rewind = [];
|
2024-12-13 17:51:06 +01:00
|
|
|
@tracked fullScreen = true;
|
2024-12-20 18:56:02 +01:00
|
|
|
@tracked loadingRewind = false;
|
2025-01-03 16:56:49 -06:00
|
|
|
|
2024-12-20 18:56:02 +01:00
|
|
|
@action
|
|
|
|
|
registerScrollWrapper(element) {
|
|
|
|
|
this.scrollWrapper = element;
|
|
|
|
|
}
|
2024-12-13 17:51:06 +01:00
|
|
|
|
2024-12-13 17:00:17 +01:00
|
|
|
@action
|
|
|
|
|
async loadRewind() {
|
|
|
|
|
try {
|
2024-12-20 18:56:02 +01:00
|
|
|
this.loadingRewind = true;
|
2024-12-13 17:00:17 +01:00
|
|
|
this.rewind = await ajax("/rewinds");
|
|
|
|
|
} catch (e) {
|
|
|
|
|
popupAjaxError(e);
|
2024-12-20 18:56:02 +01:00
|
|
|
} finally {
|
|
|
|
|
this.loadingRewind = false;
|
2024-12-13 17:00:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-13 17:51:06 +01:00
|
|
|
@action
|
|
|
|
|
toggleFullScreen() {
|
|
|
|
|
this.fullScreen = !this.fullScreen;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-20 18:56:02 +01:00
|
|
|
@action
|
|
|
|
|
handleEscape(event) {
|
|
|
|
|
if (this.fullScreen && event.key === "Escape") {
|
|
|
|
|
this.fullScreen = false;
|
2024-12-13 17:51:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-03 09:42:42 -06:00
|
|
|
@action
|
2025-11-18 09:03:41 -05:00
|
|
|
handleBackdropClick(event) {
|
|
|
|
|
if (this.fullScreen && event.target === event.currentTarget) {
|
|
|
|
|
this.fullScreen = false;
|
2025-01-03 16:52:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@action
|
|
|
|
|
registerRewindContainer(element) {
|
|
|
|
|
this.rewindContainer = element;
|
2025-01-03 09:42:42 -06:00
|
|
|
}
|
|
|
|
|
|
2025-12-02 11:41:30 -03:00
|
|
|
getReportComponent(identifier) {
|
|
|
|
|
switch (identifier) {
|
|
|
|
|
case "fbff":
|
|
|
|
|
return FBFF;
|
|
|
|
|
case "reactions":
|
|
|
|
|
return Reactions;
|
|
|
|
|
case "top-words":
|
|
|
|
|
return TopWords;
|
|
|
|
|
case "best-posts":
|
|
|
|
|
return BestPosts;
|
|
|
|
|
case "best-topics":
|
|
|
|
|
return BestTopics;
|
|
|
|
|
case "activity-calendar":
|
|
|
|
|
return ActivityCalendar;
|
|
|
|
|
case "most-viewed-tags":
|
|
|
|
|
return MostViewedTags;
|
|
|
|
|
case "reading-time":
|
|
|
|
|
return ReadingTime;
|
|
|
|
|
case "most-viewed-categories":
|
|
|
|
|
return MostViewedCategories;
|
|
|
|
|
case "ai-usage":
|
|
|
|
|
return AiUsage;
|
|
|
|
|
case "assignments":
|
|
|
|
|
return Assignments;
|
|
|
|
|
case "chat-usage":
|
|
|
|
|
return ChatUsage;
|
|
|
|
|
// case "favorite-gifs":
|
|
|
|
|
// return FavoriteGifs;
|
|
|
|
|
case "invites":
|
|
|
|
|
return Invites;
|
|
|
|
|
case "new-user-interactions":
|
|
|
|
|
return NewUserInteractions;
|
|
|
|
|
case "time-of-day-activity":
|
|
|
|
|
return TimeOfDayActivity;
|
|
|
|
|
case "writing-analysis":
|
|
|
|
|
return WritingAnalysis;
|
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-13 17:00:17 +01:00
|
|
|
<template>
|
2024-12-13 17:51:06 +01:00
|
|
|
<div
|
2024-12-20 18:56:02 +01:00
|
|
|
class={{concatClass
|
|
|
|
|
"rewind-container"
|
2025-12-02 11:41:30 -03:00
|
|
|
(if this.fullScreen "--fullscreen")
|
2024-12-20 18:56:02 +01:00
|
|
|
}}
|
2024-12-13 17:51:06 +01:00
|
|
|
{{didInsert this.loadRewind}}
|
2024-12-20 18:56:02 +01:00
|
|
|
{{on "keydown" this.handleEscape}}
|
2025-11-18 09:03:41 -05:00
|
|
|
{{on "click" this.handleBackdropClick}}
|
2025-01-03 16:52:21 +01:00
|
|
|
{{didInsert this.registerRewindContainer}}
|
2024-12-20 18:56:02 +01:00
|
|
|
tabindex="0"
|
2024-12-13 17:51:06 +01:00
|
|
|
>
|
2024-12-20 18:56:02 +01:00
|
|
|
<div class="rewind">
|
2025-01-13 10:48:23 -06:00
|
|
|
<RewindHeader />
|
2024-12-20 18:56:02 +01:00
|
|
|
{{#if this.loadingRewind}}
|
|
|
|
|
<div class="rewind-loader">
|
|
|
|
|
<div class="spinner small"></div>
|
2025-11-18 09:03:41 -05:00
|
|
|
<div class="rewind-loader__text">
|
|
|
|
|
{{i18n "discourse_rewind.loading"}}
|
|
|
|
|
</div>
|
2024-12-13 17:51:06 +01:00
|
|
|
</div>
|
2024-12-20 18:56:02 +01:00
|
|
|
{{else}}
|
|
|
|
|
<DButton
|
2025-11-18 09:03:41 -05:00
|
|
|
class="btn-default rewind__exit-fullscreen-btn --special-kbd"
|
2024-12-20 18:56:02 +01:00
|
|
|
@icon={{if this.fullScreen "discourse-compress" "discourse-expand"}}
|
|
|
|
|
@action={{this.toggleFullScreen}}
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
class="rewind__scroll-wrapper"
|
|
|
|
|
{{didInsert this.registerScrollWrapper}}
|
|
|
|
|
>
|
2025-01-09 16:52:32 +01:00
|
|
|
|
2024-12-20 18:56:02 +01:00
|
|
|
{{#each this.rewind as |report|}}
|
2025-12-02 11:41:30 -03:00
|
|
|
{{#let
|
|
|
|
|
(this.getReportComponent report.identifier)
|
|
|
|
|
as |ReportComponent|
|
|
|
|
|
}}
|
|
|
|
|
{{#if ReportComponent}}
|
|
|
|
|
<div class={{concatClass "rewind-report" report.identifier}}>
|
|
|
|
|
<ReportComponent @report={{report}} />
|
|
|
|
|
</div>
|
2024-12-20 18:56:02 +01:00
|
|
|
{{/if}}
|
2025-12-02 11:41:30 -03:00
|
|
|
{{/let}}
|
2024-12-20 18:56:02 +01:00
|
|
|
{{/each}}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{{#if this.showPrev}}
|
|
|
|
|
<DButton
|
|
|
|
|
class="rewind__prev-btn"
|
|
|
|
|
@icon="chevron-left"
|
|
|
|
|
@action={{this.prev}}
|
|
|
|
|
/>
|
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
|
|
{{#if this.showNext}}
|
|
|
|
|
<DButton
|
|
|
|
|
class="rewind__next-btn"
|
|
|
|
|
@icon="chevron-right"
|
|
|
|
|
@action={{this.next}}
|
|
|
|
|
/>
|
|
|
|
|
{{/if}}
|
2024-12-13 17:51:06 +01:00
|
|
|
{{/if}}
|
2024-12-20 18:56:02 +01:00
|
|
|
</div>
|
2024-12-13 17:00:17 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
}
|