From 274324557ce9f2a5901e391486bab44e72182e10 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Fri, 20 Oct 2023 00:06:10 +0100 Subject: [PATCH] activity: start stubbed out example card, beginning frontend code completely broken, just need to commit so I can move between devices. --- html/admin.html | 58 ++++++++++------------- lang/admin/en-us.json | 3 +- ts/admin.ts | 5 ++ ts/modules/activity.ts | 102 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 35 deletions(-) create mode 100644 ts/modules/activity.ts diff --git a/html/admin.html b/html/admin.html index 6ea2dfb..40e6037 100644 --- a/html/admin.html +++ b/html/admin.html @@ -768,40 +768,30 @@ {{ .strings.sendPWR }} {{ .quantityStrings.deleteUser.Singular }} -
- - - - - - {{ if .jellyfinLogin }} - - {{ end }} - - {{ if .telegramEnabled }} - - {{ end }} - {{ if .matrixEnabled }} - - {{ end }} - {{ if .discordEnabled }} - - {{ end }} - {{ if .referralsEnabled }} - - {{ end }} - - - - - -
{{ .strings.username }}{{ .strings.accessJFA }}{{ .strings.emailAddress }}TelegramMatrixDiscord{{ .strings.referrals }}{{ .strings.expiry }}{{ .strings.lastActiveTime }}
-
-
- {{ .strings.noResultsFound }} - +
+
+
+ + +
+ + {{ .strings.aboutProgram }} + {{ .strings.userProfiles }} +
+
+
+
+ Account Created: "hrfee" + 26/10/23 14:32 +
+
+
+ From InviteBdBmpGDzuJhHSsboAsYgrE +
+
+ Referrerusername +
+
diff --git a/lang/admin/en-us.json b/lang/admin/en-us.json index e343d1b..c9cffef 100644 --- a/lang/admin/en-us.json +++ b/lang/admin/en-us.json @@ -130,7 +130,8 @@ "userPagePage": "User Page: Page", "buildTime": "Build Time", "builtBy": "Built By", - "loginNotAdmin": "Not an Admin?" + "loginNotAdmin": "Not an Admin?", + "referrer": "Referrer" }, "notifications": { "changedEmailAddress": "Changed email address of {n}.", diff --git a/ts/admin.ts b/ts/admin.ts index 2fe99c7..78010d1 100644 --- a/ts/admin.ts +++ b/ts/admin.ts @@ -120,6 +120,10 @@ const tabs: { url: string, reloader: () => void }[] = [ url: "accounts", reloader: accounts.reload }, + { + url: "activity", + reloader: () => {console.log("FIXME: Reload Activity")} + }, { url: "settings", reloader: settings.reload @@ -179,6 +183,7 @@ login.onLogin = () => { case "settings": settings.reload(); break; + // FIXME: Reload activity } } diff --git a/ts/modules/activity.ts b/ts/modules/activity.ts new file mode 100644 index 0000000..14e7fef --- /dev/null +++ b/ts/modules/activity.ts @@ -0,0 +1,102 @@ +export interface activity { + id: string; + type: string; + user_id: string; + source_type: string; + source: string; + invite_code: string; + value: string; + time: number; +} + +var activityTypeMoods = { + "creation": 1, + "deletion": -1, + "disabled": -1, + "enabled": 1, + "contactLinked": 1, + "contactUnlinked": -1, + "changePassword": 0, + "resetPassword": 0, + "createInvite": 1, + "deleteInvite": -1 +}; + +var moodColours = ["~warning", "~neutral", "~urge"]; + +export class Activity { // FIXME: Add "implements" + private _card: HTMLElement; + private _title: HTMLElement; + private _time: HTMLElement; + private _sourceType: HTMLElement; + private _source: HTMLElement; + private _referrer: HTMLElement; + private _act: activity; + + get type(): string { return this._act.type; } + set type(v: string) { + this._act.type = v; + + let mood = activityTypeMoods[v]; // 1 = positive, 0 = neutral, -1 = negative + + for (let i = 0; i < moodColours.length; i++) { + if (i-1 == mood) this._card.classList.add(moodColours[i]); + else this._card.classList.remove(moodColours[i]); + } + } + + get source_type(): string { return this._act.source_type; } + set source_type(v: string) { + this._act.source_type = v; + if (v == "user") { + if (this.type == "creation") { + this._referrer.innerHTML = `${window.lang.strings("referrer")}FIXME`; + } else if (this.type == "contactLinked" || this.type == "contactUnlinked" || this.type == "changePassword" || this.type == "resetPassword") { + // FIXME: Reflect in title + } + } else if (v == "admin") { + // FIXME: Handle contactLinked/Unlinked, creation/deletion, enable/disable, createInvite/deleteInvite + } else if (v == "anon") { + this._referrer.innerHTML = ``; + } else if (v == "daemon") { + // FIXME: Handle deleteInvite, disabled, deletion + } + } + + constructor(act: activity) { + this._card = document.createElement("div"); + + this._card.classList.add("card", "@low"); + this._card.innerHTML = ` +
+ + +
+
+
+ +
+
+ +
+
+ `; + + this._title = this._card.querySelector(".activity-title"); + this._time = this._card.querySelector(".activity-time"); + this._sourceType = this._card.querySelector(".activity-source-type"); + this._source = this._card.querySelector(".activity-source"); + this._referrer = this._card.querySelector(".activity-referrer"); + + this.update(act); + } + + update = (act: activity) => { + // FIXME + this._act = act; + this.type = act.type; + } + + asElement = () => { return this._card; }; +} +