@things-factory/ai-dashboard 10.1.277 → 10.1.279
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/package.json +22 -8
- package/client/bootstrap.ts +0 -25
- package/client/components/card-dialogs.ts +0 -445
- package/client/components/card-library.ts +0 -285
- package/client/components/dashboard-card.ts +0 -411
- package/client/components/proposal-preview.ts +0 -95
- package/client/index.ts +0 -5
- package/client/pages/my-dashboard-page.ts +0 -373
- package/client/route.ts +0 -8
- package/client/tsconfig.json +0 -13
- package/client/utils/card-api.ts +0 -99
- package/client/utils/card-words.ts +0 -91
- package/client/utils/examples.ts +0 -15
- package/dist-client/bootstrap.js.map +0 -1
- package/dist-client/components/card-dialogs.js.map +0 -1
- package/dist-client/components/card-library.js.map +0 -1
- package/dist-client/components/dashboard-card.js.map +0 -1
- package/dist-client/components/proposal-preview.js.map +0 -1
- package/dist-client/index.js.map +0 -1
- package/dist-client/pages/my-dashboard-page.js.map +0 -1
- package/dist-client/route.js.map +0 -1
- package/dist-client/tsconfig.tsbuildinfo +0 -1
- package/dist-client/utils/card-api.js.map +0 -1
- package/dist-client/utils/card-words.js.map +0 -1
- package/dist-client/utils/examples.js.map +0 -1
- package/dist-server/index.js.map +0 -1
- package/dist-server/role-tasks.js.map +0 -1
- package/dist-server/service/card/card-access.js.map +0 -1
- package/dist-server/service/card/card-definition.js.map +0 -1
- package/dist-server/service/card/card-names.js.map +0 -1
- package/dist-server/service/card/card-proposal.js.map +0 -1
- package/dist-server/service/card/card-resolver.js.map +0 -1
- package/dist-server/service/card/card-run.js.map +0 -1
- package/dist-server/service/card/card-tool.js.map +0 -1
- package/dist-server/service/card/card-types.js.map +0 -1
- package/dist-server/service/card/dashboard-card.js.map +0 -1
- package/dist-server/service/card/long-text.js.map +0 -1
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/tsconfig.tsbuildinfo +0 -1
- package/server/index.ts +0 -16
- package/server/role-tasks.ts +0 -12
- package/server/service/card/card-access.test.ts +0 -173
- package/server/service/card/card-access.ts +0 -24
- package/server/service/card/card-definition.ts +0 -468
- package/server/service/card/card-intent.test.ts +0 -285
- package/server/service/card/card-names.ts +0 -12
- package/server/service/card/card-proposal.ts +0 -46
- package/server/service/card/card-resolver.ts +0 -440
- package/server/service/card/card-run.test.ts +0 -237
- package/server/service/card/card-run.ts +0 -302
- package/server/service/card/card-tool.ts +0 -368
- package/server/service/card/card-types.ts +0 -145
- package/server/service/card/card-words.test.ts +0 -72
- package/server/service/card/dashboard-card.ts +0 -303
- package/server/service/card/long-text.ts +0 -25
- package/server/service/index.ts +0 -16
- package/test/card-menu.test.ts +0 -50
- package/test/translations.test.ts +0 -42
- package/test/words-not-codes.test.ts +0 -24
- package/tsconfig.json +0 -9
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The card library - one's own cards and those shared with one (ADR-0160 decision 7). A card is placed on the
|
|
3
|
-
* dashboard from here, shared, copied, renamed, taken back to an earlier version or deleted by its owner.
|
|
4
|
-
*/
|
|
5
|
-
import '@material/web/icon/icon.js'
|
|
6
|
-
import '@material/web/button/filled-tonal-button.js'
|
|
7
|
-
import '@material/web/button/text-button.js'
|
|
8
|
-
|
|
9
|
-
import gql from 'graphql-tag'
|
|
10
|
-
import { LitElement, css, html, nothing } from 'lit'
|
|
11
|
-
import { customElement, state } from 'lit/decorators.js'
|
|
12
|
-
|
|
13
|
-
import { QueryController } from '@operato/graphql'
|
|
14
|
-
import { i18next, localize } from '@operato/i18n'
|
|
15
|
-
import { ScrollbarStyles } from '@operato/styles'
|
|
16
|
-
import { notify } from '@operato/layout'
|
|
17
|
-
import { OxPrompt } from '@operato/popup/ox-prompt.js'
|
|
18
|
-
|
|
19
|
-
import { cardApi, CARD_FIELDS, DASHBOARD_CHANGED, dashboardChanged, type CardItem } from '../utils/card-api.js'
|
|
20
|
-
import { ownershipLine, viewIcon } from '../utils/card-words.js'
|
|
21
|
-
import { openCardRename, openCardShare, openCardVersions } from './card-dialogs.js'
|
|
22
|
-
|
|
23
|
-
const t = (key: string, options: Record<string, unknown> = {}) => String(i18next.t(key, options))
|
|
24
|
-
|
|
25
|
-
@customElement('ai-dashboard-card-library')
|
|
26
|
-
export class CardLibrary extends localize(i18next)(LitElement) {
|
|
27
|
-
static styles = [
|
|
28
|
-
ScrollbarStyles,
|
|
29
|
-
css`
|
|
30
|
-
/* As tall as the popup, which clips what is past it - the list scrolls in it (2026-10-25: the lower cards were cut). */
|
|
31
|
-
:host {
|
|
32
|
-
display: flex;
|
|
33
|
-
flex-direction: column;
|
|
34
|
-
gap: 12px;
|
|
35
|
-
box-sizing: border-box;
|
|
36
|
-
height: 100%;
|
|
37
|
-
overflow-y: auto;
|
|
38
|
-
padding: 12px 20px 20px;
|
|
39
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
40
|
-
font-size: var(--ui-t-body, 13px);
|
|
41
|
-
line-height: 1.5;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.tabs {
|
|
45
|
-
display: flex;
|
|
46
|
-
gap: 4px;
|
|
47
|
-
padding: 3px;
|
|
48
|
-
border-radius: 10px;
|
|
49
|
-
background: var(--ui-panel-2, var(--md-sys-color-surface-container));
|
|
50
|
-
align-self: flex-start;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.tabs button {
|
|
54
|
-
padding: 6px 14px;
|
|
55
|
-
border: 0;
|
|
56
|
-
border-radius: 8px;
|
|
57
|
-
background: transparent;
|
|
58
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
59
|
-
font: inherit;
|
|
60
|
-
font-weight: 600;
|
|
61
|
-
cursor: pointer;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.tabs button[aria-selected='true'] {
|
|
65
|
-
background: var(--ui-panel, var(--md-sys-color-surface-container-lowest));
|
|
66
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
67
|
-
box-shadow: 0 1px 3px rgb(0 0 0 / 12%);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
ul {
|
|
71
|
-
flex-shrink: 0;
|
|
72
|
-
list-style: none;
|
|
73
|
-
margin: 0;
|
|
74
|
-
padding: 0;
|
|
75
|
-
display: grid;
|
|
76
|
-
grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
|
|
77
|
-
gap: 10px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
li {
|
|
81
|
-
display: flex;
|
|
82
|
-
flex-direction: column;
|
|
83
|
-
gap: 8px;
|
|
84
|
-
padding: 14px;
|
|
85
|
-
border: 1px solid var(--ui-line, var(--md-sys-color-outline-variant));
|
|
86
|
-
border-radius: 12px;
|
|
87
|
-
background: var(--ui-panel, var(--md-sys-color-surface-container-lowest));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.head {
|
|
91
|
-
display: flex;
|
|
92
|
-
gap: 10px;
|
|
93
|
-
align-items: flex-start;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.kind {
|
|
97
|
-
flex: none;
|
|
98
|
-
display: grid;
|
|
99
|
-
place-items: center;
|
|
100
|
-
width: 32px;
|
|
101
|
-
height: 32px;
|
|
102
|
-
border-radius: 8px;
|
|
103
|
-
background: var(--ui-accent-wash, color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent));
|
|
104
|
-
color: var(--ui-accent, var(--md-sys-color-primary));
|
|
105
|
-
--md-icon-size: 18px;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.names {
|
|
109
|
-
flex: 1;
|
|
110
|
-
min-width: 0;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.names strong {
|
|
114
|
-
display: block;
|
|
115
|
-
overflow: hidden;
|
|
116
|
-
text-overflow: ellipsis;
|
|
117
|
-
white-space: nowrap;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.names small {
|
|
121
|
-
display: block;
|
|
122
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.badge {
|
|
126
|
-
flex: none;
|
|
127
|
-
padding: 1px 8px;
|
|
128
|
-
border-radius: 999px;
|
|
129
|
-
background: var(--ui-panel-2, var(--md-sys-color-surface-container));
|
|
130
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
131
|
-
font-size: var(--ui-t-micro, 11px);
|
|
132
|
-
font-variant-numeric: tabular-nums;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.row {
|
|
136
|
-
display: flex;
|
|
137
|
-
flex-wrap: wrap;
|
|
138
|
-
align-items: center;
|
|
139
|
-
gap: 2px;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.row .placed {
|
|
143
|
-
display: inline-flex;
|
|
144
|
-
align-items: center;
|
|
145
|
-
gap: 4px;
|
|
146
|
-
margin-right: auto;
|
|
147
|
-
color: var(--ui-good, #2e7d32);
|
|
148
|
-
font-size: var(--ui-t-small, 12px);
|
|
149
|
-
--md-icon-size: 16px;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.row .spacer {
|
|
153
|
-
margin-right: auto;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
button.icon {
|
|
157
|
-
display: grid;
|
|
158
|
-
place-items: center;
|
|
159
|
-
width: 30px;
|
|
160
|
-
height: 30px;
|
|
161
|
-
padding: 0;
|
|
162
|
-
border: 0;
|
|
163
|
-
border-radius: 8px;
|
|
164
|
-
background: transparent;
|
|
165
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
166
|
-
cursor: pointer;
|
|
167
|
-
--md-icon-size: 18px;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
button.icon:hover {
|
|
171
|
-
background: var(--ui-hover, var(--md-sys-color-surface-container-high));
|
|
172
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.empty {
|
|
176
|
-
padding: 36px 12px;
|
|
177
|
-
text-align: center;
|
|
178
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
179
|
-
}
|
|
180
|
-
`
|
|
181
|
-
]
|
|
182
|
-
|
|
183
|
-
@state() private which: 'mine' | 'shared' = 'mine'
|
|
184
|
-
|
|
185
|
-
/* The tab's cards (ADR-0190); a change told from elsewhere reads them again. */
|
|
186
|
-
private library = new QueryController(
|
|
187
|
-
this,
|
|
188
|
-
gql`query ($which: String!) { dashboardCards(which: $which) { ${CARD_FIELDS} } }`,
|
|
189
|
-
{ variables: () => ({ which: this.which }) }
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
private get cards(): CardItem[] | undefined {
|
|
193
|
-
return this.library.data?.dashboardCards
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
private get error(): string | undefined {
|
|
197
|
-
const error = this.library.error as any
|
|
198
|
-
return error ? (error.message ?? String(error)) : undefined
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
private onChanged = () => this.library.refetch()
|
|
202
|
-
|
|
203
|
-
connectedCallback() {
|
|
204
|
-
super.connectedCallback()
|
|
205
|
-
window.addEventListener(DASHBOARD_CHANGED, this.onChanged)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
disconnectedCallback() {
|
|
209
|
-
window.removeEventListener(DASHBOARD_CHANGED, this.onChanged)
|
|
210
|
-
super.disconnectedCallback()
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
private show(which: 'mine' | 'shared') {
|
|
214
|
-
this.which = which
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
render() {
|
|
218
|
-
return html`<div class="tabs" role="tablist">
|
|
219
|
-
<button role="tab" aria-selected=${this.which === 'mine' ? 'true' : 'false'} @click=${() => this.show('mine')}>${t('ai-dashboard.library.mine')}</button>
|
|
220
|
-
<button role="tab" aria-selected=${this.which === 'shared' ? 'true' : 'false'} @click=${() => this.show('shared')}>${t('ai-dashboard.library.shared')}</button>
|
|
221
|
-
</div>
|
|
222
|
-
${this.error ? html`<p class="empty">${this.error}</p>` : nothing}
|
|
223
|
-
${this.cards && !this.cards.length ? html`<p class="empty">${t(this.which === 'mine' ? 'ai-dashboard.library.none-mine' : 'ai-dashboard.library.none-shared')}</p>` : nothing}
|
|
224
|
-
<ul>
|
|
225
|
-
${(this.cards ?? []).map(card => this.renderCard(card))}
|
|
226
|
-
</ul>`
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
private renderCard(card: CardItem) {
|
|
230
|
-
const owner = card.access === 'owner'
|
|
231
|
-
const icon = (action: () => unknown, name: string, key: string) => html`<button class="icon" title=${t(key)} aria-label=${t(key)} @click=${action}><md-icon>${name}</md-icon></button>`
|
|
232
|
-
const line = [card.description, ownershipLine(card, t)].filter(Boolean).join(' · ')
|
|
233
|
-
return html`<li>
|
|
234
|
-
<div class="head">
|
|
235
|
-
<span class="kind"><md-icon>${viewIcon(card.definition)}</md-icon></span>
|
|
236
|
-
<span class="names"><strong title=${card.name}>${card.name}</strong>${line ? html`<small>${line}</small>` : nothing}</span>
|
|
237
|
-
<span class="badge">v${card.version}</span>
|
|
238
|
-
</div>
|
|
239
|
-
<div class="row">
|
|
240
|
-
${card.placed
|
|
241
|
-
? html`<span class="placed"><md-icon>check_circle</md-icon>${t('ai-dashboard.library.placed')}</span>`
|
|
242
|
-
: html`<md-filled-tonal-button @click=${() => this.place(card)}>${t('ai-dashboard.library.place')}</md-filled-tonal-button><span class="spacer"></span>`}
|
|
243
|
-
${owner ? icon(() => openCardShare(card), 'share', 'ai-dashboard.card.share') : nothing}
|
|
244
|
-
${owner ? icon(() => openCardRename(card), 'edit', 'ai-dashboard.card.rename') : nothing}
|
|
245
|
-
${owner ? icon(() => openCardVersions(card), 'history', 'ai-dashboard.card.versions') : nothing}
|
|
246
|
-
${icon(() => this.copy(card), 'content_copy', owner ? 'ai-dashboard.card.duplicate' : 'ai-dashboard.card.copy')}
|
|
247
|
-
${owner ? icon(() => this.deleteCard(card), 'delete_outline', 'ai-dashboard.card.delete') : nothing}
|
|
248
|
-
</div>
|
|
249
|
-
</li>`
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
private async place(card: CardItem) {
|
|
253
|
-
await this.attempt(async () => {
|
|
254
|
-
await cardApi.place(card.id)
|
|
255
|
-
notify({ level: 'info', message: t('ai-dashboard.text.placed', { name: card.name }) })
|
|
256
|
-
})
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
private async copy(card: CardItem) {
|
|
260
|
-
await this.attempt(async () => {
|
|
261
|
-
await cardApi.copy(card.id)
|
|
262
|
-
notify({ level: 'info', message: t('ai-dashboard.text.copied', { name: card.name }) })
|
|
263
|
-
})
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
private async deleteCard(card: CardItem) {
|
|
267
|
-
const sure = await OxPrompt.open({
|
|
268
|
-
title: t('ai-dashboard.card.delete'),
|
|
269
|
-
text: t(card.shares?.length ? 'ai-dashboard.text.delete-shared' : 'ai-dashboard.text.delete', { name: card.name }),
|
|
270
|
-
confirmButton: { text: t('ai-dashboard.card.delete') },
|
|
271
|
-
cancelButton: { text: t('ai-dashboard.button.cancel') }
|
|
272
|
-
})
|
|
273
|
-
if (!sure) return
|
|
274
|
-
await this.attempt(() => cardApi.remove(card.id))
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
private async attempt(work: () => Promise<unknown>) {
|
|
278
|
-
try {
|
|
279
|
-
await work()
|
|
280
|
-
dashboardChanged()
|
|
281
|
-
} catch (error: any) {
|
|
282
|
-
notify({ level: 'error', message: error?.message ?? String(error) })
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* One card on the dashboard - its name and what it reads, the block its definition draws as the viewer, when it was
|
|
3
|
-
* read and how much of its source it was drawn from (ADR-0160 decisions 4-6, 8). Drawing it asks the server to run
|
|
4
|
-
* the definition; no model is asked.
|
|
5
|
-
*/
|
|
6
|
-
import '@material/web/icon/icon.js'
|
|
7
|
-
import '@things-factory/ai-assistant/dist-client/index.js'
|
|
8
|
-
|
|
9
|
-
import { LitElement, css, html, nothing } from 'lit'
|
|
10
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
11
|
-
|
|
12
|
-
import gql from 'graphql-tag'
|
|
13
|
-
import { QueryController } from '@operato/graphql'
|
|
14
|
-
import { i18next, localize } from '@operato/i18n'
|
|
15
|
-
import '@operato/popup/ox-popup-menu.js'
|
|
16
|
-
import { OxPopupMenu } from '@operato/popup/ox-popup-menu.js'
|
|
17
|
-
|
|
18
|
-
import { type CardItem, type CardRun } from '../utils/card-api.js'
|
|
19
|
-
import { drawsNothing, issueLine, ownershipLine, partialLine, readLine, viewIcon } from '../utils/card-words.js'
|
|
20
|
-
|
|
21
|
-
const t = (key: string, options: Record<string, unknown> = {}) => String(i18next.t(key, options))
|
|
22
|
-
|
|
23
|
-
export type CardAction = 'refresh' | 'ai' | 'rename' | 'share' | 'versions' | 'copy' | 'unplace' | 'left' | 'right' | 'wider' | 'narrower' | 'taller' | 'shorter'
|
|
24
|
-
|
|
25
|
-
@customElement('ai-dashboard-card')
|
|
26
|
-
export class AiDashboardCard extends localize(i18next)(LitElement) {
|
|
27
|
-
static styles = css`
|
|
28
|
-
:host {
|
|
29
|
-
display: block;
|
|
30
|
-
min-width: 0;
|
|
31
|
-
min-height: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
article {
|
|
35
|
-
position: relative;
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: column;
|
|
38
|
-
height: 100%;
|
|
39
|
-
box-sizing: border-box;
|
|
40
|
-
border: 1px solid var(--ui-line, var(--md-sys-color-outline-variant));
|
|
41
|
-
border-radius: var(--ui-r, 12px);
|
|
42
|
-
background: var(--ui-panel, var(--md-sys-color-surface-container-lowest));
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
transition:
|
|
45
|
-
box-shadow 0.18s ease,
|
|
46
|
-
border-color 0.18s ease,
|
|
47
|
-
transform 0.18s ease;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
article:hover {
|
|
51
|
-
border-color: color-mix(in srgb, var(--ui-accent, var(--md-sys-color-primary)) 35%, var(--ui-line, transparent));
|
|
52
|
-
box-shadow: 0 6px 20px -12px rgb(0 0 0 / 35%);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
:host([editing]) article {
|
|
56
|
-
border-style: dashed;
|
|
57
|
-
border-color: var(--ui-accent, var(--md-sys-color-primary));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
header {
|
|
61
|
-
display: flex;
|
|
62
|
-
align-items: flex-start;
|
|
63
|
-
gap: 10px;
|
|
64
|
-
padding: 14px 14px 6px 16px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.kind {
|
|
68
|
-
flex: none;
|
|
69
|
-
display: grid;
|
|
70
|
-
place-items: center;
|
|
71
|
-
width: 30px;
|
|
72
|
-
height: 30px;
|
|
73
|
-
border-radius: 8px;
|
|
74
|
-
background: var(--ui-accent-wash, color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent));
|
|
75
|
-
color: var(--ui-accent, var(--md-sys-color-primary));
|
|
76
|
-
--md-icon-size: 18px;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.titles {
|
|
80
|
-
flex: 1;
|
|
81
|
-
min-width: 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
h4 {
|
|
85
|
-
margin: 0;
|
|
86
|
-
font-size: var(--ui-t-title, 15px);
|
|
87
|
-
font-weight: 600;
|
|
88
|
-
line-height: 1.3;
|
|
89
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
90
|
-
overflow: hidden;
|
|
91
|
-
display: -webkit-box;
|
|
92
|
-
-webkit-line-clamp: 2;
|
|
93
|
-
-webkit-box-orient: vertical;
|
|
94
|
-
overflow-wrap: anywhere;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.sub {
|
|
98
|
-
display: block;
|
|
99
|
-
margin-top: 2px;
|
|
100
|
-
font-size: var(--ui-t-small, 12px);
|
|
101
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
102
|
-
overflow: hidden;
|
|
103
|
-
text-overflow: ellipsis;
|
|
104
|
-
white-space: nowrap;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.tools {
|
|
108
|
-
flex: none;
|
|
109
|
-
display: flex;
|
|
110
|
-
gap: 2px;
|
|
111
|
-
opacity: 0.55;
|
|
112
|
-
transition: opacity 0.15s ease;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
article:hover .tools,
|
|
116
|
-
article:focus-within .tools,
|
|
117
|
-
:host([editing]) .tools {
|
|
118
|
-
opacity: 1;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
button.icon {
|
|
122
|
-
display: grid;
|
|
123
|
-
place-items: center;
|
|
124
|
-
width: 30px;
|
|
125
|
-
height: 30px;
|
|
126
|
-
padding: 0;
|
|
127
|
-
border: 0;
|
|
128
|
-
border-radius: 8px;
|
|
129
|
-
background: transparent;
|
|
130
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
131
|
-
cursor: pointer;
|
|
132
|
-
--md-icon-size: 18px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
button.icon:hover,
|
|
136
|
-
button.icon:focus-visible {
|
|
137
|
-
background: var(--ui-hover, var(--md-sys-color-surface-container-high));
|
|
138
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
139
|
-
outline: none;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
button.icon[disabled] {
|
|
143
|
-
opacity: 0.35;
|
|
144
|
-
cursor: default;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
button.icon.spin md-icon {
|
|
148
|
-
animation: spin 0.9s linear infinite;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
@keyframes spin {
|
|
152
|
-
to {
|
|
153
|
-
transform: rotate(360deg);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.body {
|
|
158
|
-
flex: 1;
|
|
159
|
-
min-height: 0;
|
|
160
|
-
padding: 4px 16px 8px;
|
|
161
|
-
overflow: auto;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.skeleton {
|
|
165
|
-
display: flex;
|
|
166
|
-
flex-direction: column;
|
|
167
|
-
gap: 10px;
|
|
168
|
-
padding-top: 8px;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.skeleton span {
|
|
172
|
-
display: block;
|
|
173
|
-
height: 14px;
|
|
174
|
-
border-radius: 6px;
|
|
175
|
-
background: linear-gradient(90deg, var(--ui-line-soft, #eee) 0%, var(--ui-panel-2, #f6f6f6) 50%, var(--ui-line-soft, #eee) 100%);
|
|
176
|
-
background-size: 200% 100%;
|
|
177
|
-
animation: shimmer 1.4s ease-in-out infinite;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.skeleton span:nth-child(1) {
|
|
181
|
-
width: 40%;
|
|
182
|
-
height: 28px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.skeleton span:nth-child(2) {
|
|
186
|
-
width: 85%;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.skeleton span:nth-child(3) {
|
|
190
|
-
width: 65%;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
@keyframes shimmer {
|
|
194
|
-
from {
|
|
195
|
-
background-position: 200% 0;
|
|
196
|
-
}
|
|
197
|
-
to {
|
|
198
|
-
background-position: -200% 0;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.issue {
|
|
203
|
-
display: flex;
|
|
204
|
-
gap: 10px;
|
|
205
|
-
align-items: flex-start;
|
|
206
|
-
margin-top: 8px;
|
|
207
|
-
padding: 12px;
|
|
208
|
-
border-radius: 8px;
|
|
209
|
-
background: color-mix(in srgb, var(--ui-crit, #c62828) 8%, transparent);
|
|
210
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
211
|
-
font-size: var(--ui-t-body, 13px);
|
|
212
|
-
--md-icon-size: 18px;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.issue md-icon {
|
|
216
|
-
flex: none;
|
|
217
|
-
color: var(--ui-crit, #c62828);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.issue.access {
|
|
221
|
-
background: var(--ui-panel-2, var(--md-sys-color-surface-container));
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.issue.access md-icon {
|
|
225
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.nothing {
|
|
229
|
-
display: flex;
|
|
230
|
-
flex-direction: column;
|
|
231
|
-
align-items: center;
|
|
232
|
-
justify-content: center;
|
|
233
|
-
gap: 6px;
|
|
234
|
-
height: 100%;
|
|
235
|
-
min-height: 120px;
|
|
236
|
-
color: var(--ui-faint, var(--md-sys-color-on-surface-variant));
|
|
237
|
-
font-size: var(--ui-t-body, 13px);
|
|
238
|
-
text-align: center;
|
|
239
|
-
--md-icon-size: 28px;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
footer {
|
|
243
|
-
display: flex;
|
|
244
|
-
flex-wrap: wrap;
|
|
245
|
-
align-items: center;
|
|
246
|
-
gap: 4px 10px;
|
|
247
|
-
padding: 6px 16px 12px;
|
|
248
|
-
font-size: var(--ui-t-micro, 11px);
|
|
249
|
-
color: var(--ui-faint, var(--md-sys-color-on-surface-variant));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
footer .partial {
|
|
253
|
-
display: inline-flex;
|
|
254
|
-
align-items: center;
|
|
255
|
-
gap: 4px;
|
|
256
|
-
color: var(--ui-warn, #b26a00);
|
|
257
|
-
--md-icon-size: 14px;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.edit {
|
|
261
|
-
display: flex;
|
|
262
|
-
flex-wrap: wrap;
|
|
263
|
-
align-items: center;
|
|
264
|
-
justify-content: center;
|
|
265
|
-
gap: 4px;
|
|
266
|
-
padding: 8px;
|
|
267
|
-
border-top: 1px dashed var(--ui-line, var(--md-sys-color-outline-variant));
|
|
268
|
-
background: var(--ui-panel-2, var(--md-sys-color-surface-container-low));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.edit .size {
|
|
272
|
-
margin: 0 6px;
|
|
273
|
-
font-size: var(--ui-t-small, 12px);
|
|
274
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
275
|
-
font-variant-numeric: tabular-nums;
|
|
276
|
-
}
|
|
277
|
-
`
|
|
278
|
-
|
|
279
|
-
@property({ attribute: false }) card?: CardItem
|
|
280
|
-
/** The place's size, when it is on the dashboard. */
|
|
281
|
-
@property({ type: Number }) width = 2
|
|
282
|
-
@property({ type: Number }) height = 1
|
|
283
|
-
@property({ type: Boolean, reflect: true }) editing = false
|
|
284
|
-
@property({ type: Boolean }) first = false
|
|
285
|
-
@property({ type: Boolean }) last = false
|
|
286
|
-
|
|
287
|
-
/* The card drawn from the data - the server runs its definition as the viewer (ADR-0190). */
|
|
288
|
-
private cardRun = new QueryController(
|
|
289
|
-
this,
|
|
290
|
-
gql`
|
|
291
|
-
query ($id: String!) {
|
|
292
|
-
dashboardCardRun(id: $id)
|
|
293
|
-
}
|
|
294
|
-
`,
|
|
295
|
-
{ variables: () => (this.card ? { id: this.card.id } : undefined) }
|
|
296
|
-
)
|
|
297
|
-
|
|
298
|
-
private get run(): CardRun | undefined {
|
|
299
|
-
return this.cardRun.data?.dashboardCardRun
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
private get failed() {
|
|
303
|
-
const error = this.cardRun.error as any
|
|
304
|
-
return error ? (error.message ?? String(error)) : undefined
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
private get loading() {
|
|
308
|
-
return this.cardRun.loading
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
updated(changes: Map<string, unknown>) {
|
|
312
|
-
/* A new version of the same card is read again; a new card is read by its own variables. */
|
|
313
|
-
const old = changes.get('card') as CardItem | undefined
|
|
314
|
-
if (old && this.card && old.id === this.card.id && old.version !== this.card.version) this.refresh()
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/** Draws the card again from the data. */
|
|
318
|
-
refresh() {
|
|
319
|
-
return this.cardRun.refetch()
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
private act(action: CardAction) {
|
|
323
|
-
if (action === 'refresh') return this.refresh()
|
|
324
|
-
this.dispatchEvent(new CustomEvent('card-action', { detail: { action, card: this.card }, bubbles: true, composed: true }))
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
render() {
|
|
328
|
-
const card = this.card
|
|
329
|
-
if (!card) return nothing
|
|
330
|
-
const owner = card.access === 'owner'
|
|
331
|
-
const source = this.run?.source?.labelKey ? t(this.run.source.labelKey) : ''
|
|
332
|
-
const ownership = ownershipLine(card, t)
|
|
333
|
-
const sub = [card.description || source, ownership].filter(Boolean).join(' · ')
|
|
334
|
-
return html`<article aria-busy=${this.loading ? 'true' : 'false'}>
|
|
335
|
-
<header>
|
|
336
|
-
<span class="kind"><md-icon>${viewIcon(card.definition)}</md-icon></span>
|
|
337
|
-
<div class="titles">
|
|
338
|
-
<h4 title=${card.name}>${card.name}</h4>
|
|
339
|
-
${sub ? html`<span class="sub" title=${sub}>${sub}</span>` : nothing}
|
|
340
|
-
</div>
|
|
341
|
-
<div class="tools">
|
|
342
|
-
<button class="icon ${this.loading ? 'spin' : ''}" title=${t('ai-dashboard.card.refresh')} aria-label=${t('ai-dashboard.card.refresh')} ?disabled=${this.loading} @click=${() => this.act('refresh')}>
|
|
343
|
-
<md-icon>refresh</md-icon>
|
|
344
|
-
</button>
|
|
345
|
-
${owner
|
|
346
|
-
? html`<button class="icon" title=${t('ai-dashboard.card.ai')} aria-label=${t('ai-dashboard.card.ai')} @click=${() => this.act('ai')}><md-icon>auto_awesome</md-icon></button>`
|
|
347
|
-
: nothing}
|
|
348
|
-
<button class="icon" title=${t('ai-dashboard.card.more')} aria-label=${t('ai-dashboard.card.more')} aria-haspopup="menu" @click=${(e: MouseEvent) => this.openMenu(e, owner)}>
|
|
349
|
-
<md-icon>more_vert</md-icon>
|
|
350
|
-
</button>
|
|
351
|
-
</div>
|
|
352
|
-
</header>
|
|
353
|
-
<div class="body">${this.renderBody()}</div>
|
|
354
|
-
${this.run && !this.run.issue ? this.renderFooter() : nothing}
|
|
355
|
-
${this.editing ? this.renderEdit() : nothing}
|
|
356
|
-
</article>`
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* The card's actions in the platform's popup menu, placed in the body under the button - a menu drawn inside the card
|
|
361
|
-
* was cut by the card's own edge and the grid's (2026-10-25).
|
|
362
|
-
*/
|
|
363
|
-
private openMenu(event: MouseEvent, owner: boolean) {
|
|
364
|
-
event.stopPropagation()
|
|
365
|
-
const at = (event.currentTarget as HTMLElement).getBoundingClientRect()
|
|
366
|
-
const item = (action: CardAction, icon: string, key: string) =>
|
|
367
|
-
html`<ox-popup-menuitem label=${t(key)} @select=${() => this.act(action)}><md-icon slot="icon">${icon}</md-icon></ox-popup-menuitem>`
|
|
368
|
-
OxPopupMenu.open({
|
|
369
|
-
template: html`
|
|
370
|
-
${owner ? item('ai', 'auto_awesome', 'ai-dashboard.card.ai') : nothing} ${owner ? item('rename', 'edit', 'ai-dashboard.card.rename') : nothing}
|
|
371
|
-
${owner ? item('share', 'share', 'ai-dashboard.card.share') : nothing} ${owner ? item('versions', 'history', 'ai-dashboard.card.versions') : nothing}
|
|
372
|
-
${item('copy', 'content_copy', owner ? 'ai-dashboard.card.duplicate' : 'ai-dashboard.card.copy')}
|
|
373
|
-
<div separator></div>
|
|
374
|
-
${item('unplace', 'remove_circle_outline', 'ai-dashboard.card.unplace')}
|
|
375
|
-
`,
|
|
376
|
-
top: at.bottom,
|
|
377
|
-
right: window.innerWidth - at.right,
|
|
378
|
-
parent: document.body
|
|
379
|
-
})
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
private renderBody() {
|
|
383
|
-
if (this.failed) return html`<div class="issue"><md-icon>error</md-icon><span>${this.failed}</span></div>`
|
|
384
|
-
if (!this.run) return html`<div class="skeleton" aria-hidden="true"><span></span><span></span><span></span></div>`
|
|
385
|
-
const issue = issueLine(this.run, t)
|
|
386
|
-
if (issue) return html`<div class="issue ${issue.access ? 'access' : ''}"><md-icon>${issue.access ? 'lock' : 'error'}</md-icon><span>${issue.text}</span></div>`
|
|
387
|
-
if (drawsNothing(this.run)) return html`<div class="nothing"><md-icon>inbox</md-icon><span>${t('ai-dashboard.card.nothing')}</span></div>`
|
|
388
|
-
return html`<ox-assistant-workspace-view compact .workspace=${{ name: this.card!.id, title: this.card!.name, blocks: [this.run.block] }}></ox-assistant-workspace-view>`
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
private renderFooter() {
|
|
392
|
-
const partial = partialLine(this.run!, t)
|
|
393
|
-
return html`<footer>
|
|
394
|
-
<span>${readLine(this.run!, this.cardRun.answeredAt ?? new Date(), t, i18next.language)}</span>
|
|
395
|
-
${partial ? html`<span class="partial"><md-icon>warning</md-icon>${partial}</span>` : nothing}
|
|
396
|
-
</footer>`
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
private renderEdit() {
|
|
400
|
-
const button = (action: CardAction, icon: string, key: string, disabled = false) =>
|
|
401
|
-
html`<button class="icon" title=${t(key)} aria-label=${t(key)} ?disabled=${disabled} @click=${() => this.act(action)}><md-icon>${icon}</md-icon></button>`
|
|
402
|
-
return html`<div class="edit">
|
|
403
|
-
${button('left', 'arrow_back', 'ai-dashboard.edit.left', this.first)} ${button('right', 'arrow_forward', 'ai-dashboard.edit.right', this.last)}
|
|
404
|
-
${button('narrower', 'remove', 'ai-dashboard.edit.narrower', this.width <= 1)}
|
|
405
|
-
<span class="size">${this.width} × ${this.height}</span>
|
|
406
|
-
${button('wider', 'add', 'ai-dashboard.edit.wider', this.width >= 4)}
|
|
407
|
-
${button(this.height > 1 ? 'shorter' : 'taller', this.height > 1 ? 'unfold_less' : 'unfold_more', this.height > 1 ? 'ai-dashboard.edit.shorter' : 'ai-dashboard.edit.taller')}
|
|
408
|
-
${button('unplace', 'delete_outline', 'ai-dashboard.card.unplace')}
|
|
409
|
-
</div>`
|
|
410
|
-
}
|
|
411
|
-
}
|