@stacksjs/defaults 0.75.551 → 0.75.555
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/skills/stacks-actions/SKILL.md +1 -1
- package/ai/skills/stacks-dashboard/SKILL.md +347 -14
- package/ai/skills/stacks-desktop/SKILL.md +19 -0
- package/ai/skills/stacks-models/SKILL.md +19 -0
- package/ai/skills/stacks-native/CATALOG.md +7 -7
- package/ai/skills/stacks-storage/SKILL.md +9 -0
- package/app/Actions/Dashboard/Content/file-manager.ts +9 -3
- package/app/Actions/Dashboard/Data/SubscriberIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/TeamIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/UserIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/data-records.ts +12 -0
- package/app/Actions/Dashboard/Models/ModelActionRunAction.ts +77 -0
- package/app/Actions/Dashboard/Models/ModelMarkdownAction.ts +42 -0
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +63 -21
- package/app/Actions/Dashboard/Models/ModelUploadAction.ts +83 -0
- package/app/Actions/Dashboard/Models/model-actions.ts +393 -0
- package/app/Actions/Dashboard/Models/model-fields.ts +198 -0
- package/app/Actions/Dashboard/Models/model-forms.ts +36 -0
- package/app/Actions/Dashboard/Models/model-related.ts +62 -11
- package/app/Actions/Dashboard/Models/model-upload.ts +81 -0
- package/app/Actions/Dashboard/Models/model-write.ts +92 -5
- package/app/Actions/Dashboard/Users/UserPasswordResetAction.ts +50 -0
- package/app/Actions/Desktop/UpdateArtifactAction.ts +37 -0
- package/app/Models/CardAttachment.ts +5 -0
- package/app/Models/Deployment.ts +5 -0
- package/app/Models/QueryLog.ts +5 -0
- package/app/Models/Request.ts +4 -0
- package/app/Models/Team.ts +4 -0
- package/app/Models/User.ts +18 -0
- package/functions/dashboard-markdown.ts +132 -0
- package/functions/dashboard-model-bulk.ts +224 -0
- package/functions/dashboard-model-format.ts +201 -0
- package/functions/dashboard-model-record.test.ts +53 -30
- package/functions/dashboard-model-record.ts +267 -19
- package/functions/data.ts +9 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +3 -3
- package/resources/components/Dashboard/Data/ActivityLog.stx +212 -0
- package/resources/components/Dashboard/Data/DataModelRecords.stx +89 -0
- package/resources/components/Dashboard/Models/ModelActionForm.stx +85 -0
- package/resources/components/Dashboard/Models/ModelBadge.stx +22 -0
- package/resources/components/Dashboard/Models/ModelFieldInputs.stx +43 -9
- package/resources/components/Dashboard/Models/ModelMarkdownInput.stx +139 -0
- package/resources/components/Dashboard/Models/ModelRecordActions.stx +32 -1
- package/resources/components/Dashboard/Models/ModelRecordCreate.stx +1 -1
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +114 -7
- package/resources/components/Dashboard/Models/ModelRecordEdit.stx +1 -1
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +387 -20
- package/resources/components/Dashboard/Models/ModelRelatedPanels.stx +197 -27
- package/resources/components/Dashboard/Models/ModelRelationPicker.stx +3 -0
- package/resources/components/Dashboard/Models/ModelUploadInput.stx +97 -0
- package/routes/dashboard-api.ts +9 -0
- package/routes/desktop-updates.ts +7 -0
- package/views/dashboard/data/activity/index.stx +1 -1
- package/views/dashboard/data/subscribers.stx +1 -3
- package/views/dashboard/data/teams.stx +1 -3
- package/views/dashboard/data/users.stx +1 -3
- package/resources/components/Dashboard/Data/DataRecords.stx +0 -427
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
@import('../UI/Table')
|
|
2
|
-
|
|
3
|
-
<script client>
|
|
4
|
-
import type {
|
|
5
|
-
DashboardActivity,
|
|
6
|
-
DashboardSubscriber,
|
|
7
|
-
DashboardTeam,
|
|
8
|
-
DashboardUser,
|
|
9
|
-
DataMode,
|
|
10
|
-
DataStats,
|
|
11
|
-
} from '../../../../functions/data'
|
|
12
|
-
import { fetchDashboardData } from '../../../../functions/data'
|
|
13
|
-
import type { ModelWriteCapabilities } from '../../../../functions/dashboard-model-record'
|
|
14
|
-
import { deleteModelRecord, fetchModelCapabilities, modelDeleteNotice, modelDeleteWarning, modelRecordCreateHref, modelRecordEditHref, modelRecordHref, NO_WRITES, userInviteHref } from '../../../../functions/dashboard-model-record'
|
|
15
|
-
import { pushToast } from '../../../../functions/toasts'
|
|
16
|
-
|
|
17
|
-
type DataRecord = DashboardActivity | DashboardSubscriber | DashboardTeam | DashboardUser
|
|
18
|
-
|
|
19
|
-
const mode = useReactiveProp<DataMode>('mode', 'activity')
|
|
20
|
-
const records = state<DataRecord[]>([])
|
|
21
|
-
const stats = state<DataStats>({ total: 0 })
|
|
22
|
-
const search = state('')
|
|
23
|
-
const loading = state(true)
|
|
24
|
-
const loadError = state('')
|
|
25
|
-
|
|
26
|
-
const metadata: Record<DataMode, { title: string, description: string, icon: string, empty: string, one: string, many: string, cards: number }> = {
|
|
27
|
-
activity: {
|
|
28
|
-
title: 'Activity Log',
|
|
29
|
-
description: 'Review the native application audit trail.',
|
|
30
|
-
icon: 'i-hugeicons-activity-03',
|
|
31
|
-
empty: 'No activity has been recorded.',
|
|
32
|
-
one: 'entry',
|
|
33
|
-
many: 'entries',
|
|
34
|
-
cards: 3,
|
|
35
|
-
},
|
|
36
|
-
users: {
|
|
37
|
-
title: 'Users',
|
|
38
|
-
description: 'Review registered application users.',
|
|
39
|
-
icon: 'i-hugeicons-user-group',
|
|
40
|
-
empty: 'No users have registered.',
|
|
41
|
-
one: 'user',
|
|
42
|
-
many: 'users',
|
|
43
|
-
cards: 3,
|
|
44
|
-
},
|
|
45
|
-
teams: {
|
|
46
|
-
title: 'Teams',
|
|
47
|
-
description: 'Review collaborative teams and membership totals.',
|
|
48
|
-
icon: 'i-hugeicons-user-multiple-02',
|
|
49
|
-
empty: 'No teams have been created.',
|
|
50
|
-
one: 'team',
|
|
51
|
-
many: 'teams',
|
|
52
|
-
cards: 4,
|
|
53
|
-
},
|
|
54
|
-
subscribers: {
|
|
55
|
-
title: 'Subscribers',
|
|
56
|
-
description: 'Review subscription status and acquisition sources.',
|
|
57
|
-
icon: 'i-hugeicons-mail-account-01',
|
|
58
|
-
empty: 'No subscribers have joined.',
|
|
59
|
-
one: 'subscriber',
|
|
60
|
-
many: 'subscribers',
|
|
61
|
-
cards: 4,
|
|
62
|
-
},
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const page = derived(() => metadata[mode()])
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The model behind each mode's rows, for the eye, pencil and trash. Which of
|
|
69
|
-
* the three a page offers comes from the model: Activity declares no write
|
|
70
|
-
* routes, so an audit entry can be opened and nothing more.
|
|
71
|
-
*/
|
|
72
|
-
const MODEL_SLUGS: Record<DataMode, string> = { activity: 'activity', users: 'user', teams: 'team', subscribers: 'subscriber' }
|
|
73
|
-
/** The row field an action names: "Edit Ava", "Delete ava@example.com". */
|
|
74
|
-
const ACTION_LABEL_KEYS: Record<DataMode, string> = { activity: 'description', users: 'name', teams: 'name', subscribers: 'email' }
|
|
75
|
-
|
|
76
|
-
const modelSlug = derived(() => MODEL_SLUGS[mode()] ?? '')
|
|
77
|
-
const capabilities = state<ModelWriteCapabilities>(NO_WRITES)
|
|
78
|
-
const confirmingDelete = state<Record<string, any> | null>(null)
|
|
79
|
-
const working = state(false)
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* An anonymized account keeps its eye and loses its pencil and trash: its
|
|
83
|
-
* name and email are gone, so there is nothing to edit, and deleting it again
|
|
84
|
-
* would only anonymize what already is.
|
|
85
|
-
*/
|
|
86
|
-
const NOT_ANONYMIZED = { key: 'anonymized', equals: false }
|
|
87
|
-
|
|
88
|
-
/** View always; edit and delete only where the model's API allows them. */
|
|
89
|
-
const rowActions = derived(() => {
|
|
90
|
-
if (!modelSlug())
|
|
91
|
-
return []
|
|
92
|
-
return [
|
|
93
|
-
{ action: 'view', label: 'View' },
|
|
94
|
-
...(capabilities().update ? [{ action: 'edit', label: 'Edit', when: NOT_ANONYMIZED }] : []),
|
|
95
|
-
...(capabilities().destroy ? [{ action: 'delete', label: 'Delete', when: NOT_ANONYMIZED }] : []),
|
|
96
|
-
]
|
|
97
|
-
})
|
|
98
|
-
const actionLabelKey = derived(() => ACTION_LABEL_KEYS[mode()] ?? 'id')
|
|
99
|
-
const deleteTitle = derived(() => `Delete this ${page().one}?`)
|
|
100
|
-
const deleteDescription = derived(() => {
|
|
101
|
-
const row = confirmingDelete()
|
|
102
|
-
const name = row ? String(row[actionLabelKey()] ?? row.id) : ''
|
|
103
|
-
return modelDeleteWarning(name, capabilities().anonymize)
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
async function loadCapabilities(): Promise<void> {
|
|
107
|
-
if (!modelSlug()) {
|
|
108
|
-
capabilities.set(NO_WRITES)
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
capabilities.set(await fetchModelCapabilities(modelSlug()))
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
// Without them the page still lists and views; it offers no writes.
|
|
116
|
-
capabilities.set(NO_WRITES)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Offered where the model can be added to from the dashboard at all. A user
|
|
122
|
-
* is invited, not typed in, and the button says so: pressing it leads to an
|
|
123
|
-
* email being sent, which "Create" would not have told anyone.
|
|
124
|
-
*/
|
|
125
|
-
const canInvite = derived(() => Boolean(modelSlug()) && capabilities().invite)
|
|
126
|
-
const canCreate = derived(() => Boolean(modelSlug()) && (capabilities().create || capabilities().invite))
|
|
127
|
-
const createLabel = derived(() => canInvite() ? `Invite ${page().one}` : `Create ${page().one}`)
|
|
128
|
-
|
|
129
|
-
// The create and invite pages come back here, like the record's own pages.
|
|
130
|
-
function createRecord(): void {
|
|
131
|
-
navigate(canInvite() ? userInviteHref(`/data/${mode()}`) : modelRecordCreateHref(modelSlug(), `/data/${mode()}`))
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** The eye and the pencil each open a page of the record's own, which comes back here. */
|
|
135
|
-
function handleRowAction(payload: { action: string, row: Record<string, any> }): void {
|
|
136
|
-
if (payload.action === 'delete')
|
|
137
|
-
confirmingDelete.set(payload.row)
|
|
138
|
-
else if (payload.action === 'edit')
|
|
139
|
-
navigate(modelRecordEditHref(modelSlug(), payload.row.id, { from: `/data/${mode()}` }))
|
|
140
|
-
else
|
|
141
|
-
navigate(modelRecordHref(modelSlug(), payload.row.id, `/data/${mode()}`))
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function confirmDelete(): Promise<void> {
|
|
145
|
-
const row = confirmingDelete()
|
|
146
|
-
if (!row)
|
|
147
|
-
return
|
|
148
|
-
working.set(true)
|
|
149
|
-
try {
|
|
150
|
-
const outcome = await deleteModelRecord(modelSlug(), row.id)
|
|
151
|
-
const notice = modelDeleteNotice(`${capitalize(page().one)} ${row[actionLabelKey()] ?? row.id}`, outcome)
|
|
152
|
-
pushToast('success', notice.title, { detail: notice.detail })
|
|
153
|
-
confirmingDelete.set(null)
|
|
154
|
-
await loadRecords()
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
pushToast('error', 'Could not delete', { detail: error instanceof Error ? error.message : String(error) })
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
working.set(false)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** Each mode's stats fill their row: three cards in a four-column grid left a hole. */
|
|
165
|
-
const statsGridClass = derived(() => page().cards === 3 ? 'grid-cols-1 sm:grid-cols-3' : 'grid-cols-2 lg:grid-cols-4')
|
|
166
|
-
|
|
167
|
-
/** "13 users", or "2 of 13 users" while a search narrows them. */
|
|
168
|
-
const countLabel = derived(() => {
|
|
169
|
-
const total = records().length
|
|
170
|
-
const shown = filteredRecords().length
|
|
171
|
-
const noun = (count: number) => count === 1 ? page().one : page().many
|
|
172
|
-
return shown === total ? `${total} ${noun(total)}` : `${shown} of ${total} ${noun(total)}`
|
|
173
|
-
})
|
|
174
|
-
const filteredRecords = derived(() => {
|
|
175
|
-
const query = search().trim().toLowerCase()
|
|
176
|
-
if (!query)
|
|
177
|
-
return records()
|
|
178
|
-
return records().filter(record => searchableText(record).includes(query))
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
function searchableText(record: DataRecord): string {
|
|
183
|
-
return Object.values(record)
|
|
184
|
-
.filter(value => typeof value === 'string' || typeof value === 'number')
|
|
185
|
-
.join(' ')
|
|
186
|
-
.toLowerCase()
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function statValue(key: string): number {
|
|
190
|
-
return Number(stats()[key] || 0)
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function formatSubject(record: DashboardActivity): string {
|
|
194
|
-
if (!record.subjectType)
|
|
195
|
-
return 'Application'
|
|
196
|
-
return record.subjectId > 0 ? `${record.subjectType} #${record.subjectId}` : record.subjectType
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** A status pill's colour: settled, ended, or still in progress. */
|
|
200
|
-
function statusTone(status: string): string {
|
|
201
|
-
if (['active', 'subscribed', 'completed'].includes(status))
|
|
202
|
-
return 'positive'
|
|
203
|
-
if (['bounced', 'inactive', 'unsubscribed'].includes(status))
|
|
204
|
-
return 'negative'
|
|
205
|
-
return 'pending'
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const TONES = {
|
|
209
|
-
positive: 'text-green-700 dark:text-green-300 bg-green-50 dark:bg-green-950/40',
|
|
210
|
-
negative: 'text-red-700 dark:text-red-300 bg-red-50 dark:bg-red-950/40',
|
|
211
|
-
pending: 'text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-950/40',
|
|
212
|
-
muted: 'text-neutral-600 dark:text-neutral-300 bg-neutral-100 dark:bg-white/10',
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function capitalize(value: string): string {
|
|
216
|
-
return value ? value.charAt(0).toUpperCase() + value.slice(1) : value
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const recorded = (key: string, label: string, emptyText = 'Never') => ({ key, label, type: 'datetime' as const, align: 'right' as const, sortable: true, emptyText, class: 'text-neutral-500 text-xs whitespace-nowrap dark:text-neutral-400' })
|
|
220
|
-
const statusColumn = { key: 'statusTone', label: 'Status', type: 'badge' as const, sortable: true, badgeLabelKey: 'statusLabel', badgeClasses: TONES }
|
|
221
|
-
|
|
222
|
-
const COLUMNS_BY_MODE = {
|
|
223
|
-
activity: [
|
|
224
|
-
{ key: 'description', label: 'Activity', sortable: true, subtitleKey: 'type', class: 'font-medium text-neutral-900 dark:text-white' },
|
|
225
|
-
{ key: 'subject', label: 'Subject', sortable: true, class: 'text-neutral-600 dark:text-neutral-300' },
|
|
226
|
-
{ key: 'causer', label: 'Causer', sortable: true, class: 'text-neutral-600 dark:text-neutral-300' },
|
|
227
|
-
recorded('createdAt', 'Recorded'),
|
|
228
|
-
],
|
|
229
|
-
users: [
|
|
230
|
-
{ key: 'name', label: 'User', sortable: true, subtitleKey: 'email', class: 'font-medium text-neutral-900 dark:text-white' },
|
|
231
|
-
{ key: 'verificationTone', label: 'Verification', type: 'badge' as const, sortable: true, badgeLabelKey: 'verificationLabel', badgeClasses: TONES },
|
|
232
|
-
// A user nobody has edited has no update time; "Never" read as if the
|
|
233
|
-
// account were broken.
|
|
234
|
-
recorded('updatedAt', 'Updated', 'Not since registering'),
|
|
235
|
-
recorded('createdAt', 'Registered'),
|
|
236
|
-
],
|
|
237
|
-
teams: [
|
|
238
|
-
{ key: 'name', label: 'Team', sortable: true, slotted: true },
|
|
239
|
-
{ key: 'memberCount', label: 'Members', type: 'number' as const, align: 'right' as const, sortable: true, class: 'font-mono text-neutral-700 dark:text-neutral-300' },
|
|
240
|
-
statusColumn,
|
|
241
|
-
recorded('createdAt', 'Created'),
|
|
242
|
-
],
|
|
243
|
-
subscribers: [
|
|
244
|
-
{ key: 'email', label: 'Subscriber', sortable: true, class: 'font-medium text-neutral-900 dark:text-white' },
|
|
245
|
-
{ key: 'sourceLabel', label: 'Source', sortable: true, class: 'text-neutral-600 dark:text-neutral-300' },
|
|
246
|
-
statusColumn,
|
|
247
|
-
recorded('createdAt', 'Subscribed'),
|
|
248
|
-
],
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const recordColumns = derived(() => COLUMNS_BY_MODE[mode()] ?? COLUMNS_BY_MODE.activity)
|
|
252
|
-
|
|
253
|
-
const recordRows = derived(() => filteredRecords().map((record) => {
|
|
254
|
-
const row = record as Record<string, any>
|
|
255
|
-
// An erased account is stored as "[erased]" and "erased-13". The table names
|
|
256
|
-
// it for what it is, and "Unverified" would be a strange thing to say of it.
|
|
257
|
-
const anonymized = mode() === 'users' && row.anonymized === true
|
|
258
|
-
return {
|
|
259
|
-
...row,
|
|
260
|
-
...(anonymized && { name: 'Anonymized user', email: 'Name and email removed' }),
|
|
261
|
-
// On every row, of every mode: the pencil and trash ask for exactly false.
|
|
262
|
-
anonymized,
|
|
263
|
-
subject: mode() === 'activity' ? formatSubject(record as DashboardActivity) : undefined,
|
|
264
|
-
verificationTone: anonymized ? 'muted' : row.emailVerifiedAt ? 'positive' : 'pending',
|
|
265
|
-
verificationLabel: anonymized ? 'Anonymized' : row.emailVerifiedAt ? 'Verified' : 'Unverified',
|
|
266
|
-
statusTone: statusTone(String(row.status ?? '')),
|
|
267
|
-
statusLabel: capitalize(String(row.status ?? '')),
|
|
268
|
-
sourceLabel: capitalize(String(row.source ?? '')),
|
|
269
|
-
descriptionLabel: row.description || 'No description',
|
|
270
|
-
modelLink: `/models/team?q=${encodeURIComponent(String(row.name ?? ''))}`,
|
|
271
|
-
}
|
|
272
|
-
}))
|
|
273
|
-
|
|
274
|
-
async function loadRecords(): Promise<void> {
|
|
275
|
-
loading.set(true)
|
|
276
|
-
loadError.set('')
|
|
277
|
-
try {
|
|
278
|
-
if (mode() === 'activity') {
|
|
279
|
-
const response = await fetchDashboardData<DashboardActivity>('activity')
|
|
280
|
-
records.set(response.activities || [])
|
|
281
|
-
stats.set(response.stats)
|
|
282
|
-
}
|
|
283
|
-
else if (mode() === 'users') {
|
|
284
|
-
const response = await fetchDashboardData<DashboardUser>('users')
|
|
285
|
-
records.set(response.users || [])
|
|
286
|
-
stats.set(response.stats)
|
|
287
|
-
}
|
|
288
|
-
else if (mode() === 'teams') {
|
|
289
|
-
const response = await fetchDashboardData<DashboardTeam>('teams')
|
|
290
|
-
records.set(response.teams || [])
|
|
291
|
-
stats.set(response.stats)
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
const response = await fetchDashboardData<DashboardSubscriber>('subscribers')
|
|
295
|
-
records.set(response.subscribers || [])
|
|
296
|
-
stats.set(response.stats)
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
catch (error) {
|
|
300
|
-
records.set([])
|
|
301
|
-
stats.set({ total: 0 })
|
|
302
|
-
loadError.set(error instanceof Error ? error.message : `${page().title} could not be loaded.`)
|
|
303
|
-
}
|
|
304
|
-
finally {
|
|
305
|
-
loading.set(false)
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
onMount(() => {
|
|
310
|
-
void loadRecords()
|
|
311
|
-
void loadCapabilities()
|
|
312
|
-
})
|
|
313
|
-
</script>
|
|
314
|
-
|
|
315
|
-
<div class="flex flex-col gap-6">
|
|
316
|
-
<header class="flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between">
|
|
317
|
-
<div>
|
|
318
|
-
<h1 class="font-bold text-2xl text-neutral-900 tracking-tight dark:text-white">{{ page().title }}</h1>
|
|
319
|
-
<p class="mt-1 text-neutral-500 text-sm dark:text-neutral-400">{{ page().description }}</p>
|
|
320
|
-
</div>
|
|
321
|
-
<div class="flex flex-none gap-2 items-center">
|
|
322
|
-
<Button variant="secondary" :loading="loading()" @click="loadRecords">
|
|
323
|
-
<span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>
|
|
324
|
-
Refresh
|
|
325
|
-
</Button>
|
|
326
|
-
<Button :if="canCreate()" variant="primary" @click="createRecord">
|
|
327
|
-
<span aria-hidden="true" :class="canInvite() ? 'h-4 w-4 i-hugeicons-mail-send-01' : 'h-4 w-4 i-hugeicons-add-01'"></span>
|
|
328
|
-
{{ createLabel() }}
|
|
329
|
-
</Button>
|
|
330
|
-
</div>
|
|
331
|
-
</header>
|
|
332
|
-
|
|
333
|
-
<div class="grid gap-4" :class="statsGridClass()">
|
|
334
|
-
<StatsCard :title="'Total ' + page().title" :icon="page().icon" iconBg="primary">
|
|
335
|
-
<template #value>{{ statValue('total') }}</template>
|
|
336
|
-
</StatsCard>
|
|
337
|
-
<StatsCard :if="mode() === 'activity'" title="Last 24 Hours" icon="i-hugeicons-clock-01" iconBg="success">
|
|
338
|
-
<template #value>{{ statValue('last24Hours') }}</template>
|
|
339
|
-
</StatsCard>
|
|
340
|
-
<StatsCard :if="mode() === 'activity'" title="Last 7 Days" icon="i-hugeicons-calendar-03" iconBg="info">
|
|
341
|
-
<template #value>{{ statValue('last7Days') }}</template>
|
|
342
|
-
</StatsCard>
|
|
343
|
-
<StatsCard :if="mode() === 'users'" title="New This Week" icon="i-hugeicons-user-add-01" iconBg="success">
|
|
344
|
-
<template #value>{{ statValue('newThisWeek') }}</template>
|
|
345
|
-
</StatsCard>
|
|
346
|
-
<StatsCard :if="mode() === 'users'" title="Email Verified" icon="i-hugeicons-mail-validation-01" iconBg="info">
|
|
347
|
-
<template #value>{{ statValue('verified') }}</template>
|
|
348
|
-
</StatsCard>
|
|
349
|
-
<StatsCard :if="mode() === 'teams'" title="Active Teams" icon="i-hugeicons-checkmark-circle-02" iconBg="success">
|
|
350
|
-
<template #value>{{ statValue('active') }}</template>
|
|
351
|
-
</StatsCard>
|
|
352
|
-
<StatsCard :if="mode() === 'teams'" title="Members" icon="i-hugeicons-user-multiple" iconBg="info">
|
|
353
|
-
<template #value>{{ statValue('members') }}</template>
|
|
354
|
-
</StatsCard>
|
|
355
|
-
<StatsCard :if="mode() === 'teams'" title="New This Month" icon="i-hugeicons-calendar-add-01" iconBg="warning">
|
|
356
|
-
<template #value>{{ statValue('newThisMonth') }}</template>
|
|
357
|
-
</StatsCard>
|
|
358
|
-
<StatsCard :if="mode() === 'subscribers'" title="Subscribed" icon="i-hugeicons-mail-open-01" iconBg="success">
|
|
359
|
-
<template #value>{{ statValue('subscribed') }}</template>
|
|
360
|
-
</StatsCard>
|
|
361
|
-
<StatsCard :if="mode() === 'subscribers'" title="Unsubscribed" icon="i-hugeicons-mail-remove-01" iconBg="warning">
|
|
362
|
-
<template #value>{{ statValue('unsubscribed') }}</template>
|
|
363
|
-
</StatsCard>
|
|
364
|
-
<StatsCard :if="mode() === 'subscribers'" title="New This Month" icon="i-hugeicons-calendar-add-01" iconBg="info">
|
|
365
|
-
<template #value>{{ statValue('newThisMonth') }}</template>
|
|
366
|
-
</StatsCard>
|
|
367
|
-
</div>
|
|
368
|
-
|
|
369
|
-
<div :if="loadError()" role="alert" class="px-4 py-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/40 border border-red-200 rounded-lg dark:border-red-900">
|
|
370
|
-
{{ loadError() }}
|
|
371
|
-
</div>
|
|
372
|
-
|
|
373
|
-
<Card padding="none">
|
|
374
|
-
<div class="flex flex-col gap-3 items-start sm:flex-row sm:items-center sm:justify-between p-5 border-b border-neutral-200 dark:border-neutral-700">
|
|
375
|
-
<div>
|
|
376
|
-
<h2 class="font-semibold text-neutral-900 dark:text-white">{{ page().title }}</h2>
|
|
377
|
-
<p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400">{{ countLabel() }}</p>
|
|
378
|
-
</div>
|
|
379
|
-
<label class="block relative w-full sm:w-72">
|
|
380
|
-
<span class="sr-only">Search {{ page().title.toLowerCase() }}</span>
|
|
381
|
-
<span aria-hidden="true" class="absolute left-3 top-1/2 h-4 w-4 text-neutral-400 pointer-events-none -translate-y-1/2 i-hugeicons-search-01"></span>
|
|
382
|
-
<input x-model="search" type="search" :placeholder="'Search ' + page().title.toLowerCase()" class="block pl-9 pr-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-neutral-300 rounded-lg dark:border-neutral-700 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20">
|
|
383
|
-
</label>
|
|
384
|
-
</div>
|
|
385
|
-
|
|
386
|
-
<div :if="loading()" class="flex items-center justify-center py-16 text-neutral-500 text-sm dark:text-neutral-400">
|
|
387
|
-
<span class="mr-2 h-5 w-5 animate-spin i-hugeicons-loading-03"></span>
|
|
388
|
-
Loading {{ page().title.toLowerCase() }}...
|
|
389
|
-
</div>
|
|
390
|
-
|
|
391
|
-
<EmptyState :if="!loading() && !loadError() && filteredRecords().length === 0" :icon="page().icon" :title="search() ? 'No matching records' : page().empty" :description="search() ? 'Try a different search term.' : 'New records will appear here automatically.'" />
|
|
392
|
-
|
|
393
|
-
{{--
|
|
394
|
-
Four column sets: the mode decides which. The page keeps its search,
|
|
395
|
-
loading and empty states; the table brings sorting and paging. Only a
|
|
396
|
-
team's name is slotted, for the link to its model page.
|
|
397
|
-
--}}
|
|
398
|
-
<div :if="!loading() && filteredRecords().length > 0">
|
|
399
|
-
{{--
|
|
400
|
-
Two tables rather than one with a slot: Table hands every cell to a
|
|
401
|
-
given cell slot when no column is slotted, so the slot can only be
|
|
402
|
-
passed in the mode that has a slotted column.
|
|
403
|
-
--}}
|
|
404
|
-
<template :if="mode() === 'teams'">
|
|
405
|
-
<Table :columns="recordColumns()" :data="recordRows()" paginated :page-size="25" :framed="false" :row-actions="rowActions()" :action-label-key="actionLabelKey()" @row-action="handleRowAction">
|
|
406
|
-
<template #cell="{ row }">
|
|
407
|
-
<StxLink :to="row.modelLink" class="font-medium text-neutral-900 text-sm dark:text-white hover:text-blue-600 dark:hover:text-blue-400">{{ row.name }}</StxLink>
|
|
408
|
-
<p class="mt-0.5 max-w-xl text-neutral-500 text-xs dark:text-neutral-400" x-text="row.descriptionLabel"></p>
|
|
409
|
-
</template>
|
|
410
|
-
</Table>
|
|
411
|
-
</template>
|
|
412
|
-
<template :else>
|
|
413
|
-
<Table :columns="recordColumns()" :data="recordRows()" paginated :page-size="25" :framed="false" :row-actions="rowActions()" :action-label-key="actionLabelKey()" @row-action="handleRowAction" />
|
|
414
|
-
</template>
|
|
415
|
-
</div>
|
|
416
|
-
</Card>
|
|
417
|
-
|
|
418
|
-
<ConfirmDialog
|
|
419
|
-
:isOpen="Boolean(confirmingDelete())"
|
|
420
|
-
:title="deleteTitle()"
|
|
421
|
-
:description="deleteDescription()"
|
|
422
|
-
:busy="working()"
|
|
423
|
-
:confirmLabel="working() ? 'Deleting' : 'Delete'"
|
|
424
|
-
@close="confirmingDelete.set(null)"
|
|
425
|
-
@confirm="confirmDelete"
|
|
426
|
-
/>
|
|
427
|
-
</div>
|