@things-factory/ai-dashboard 10.1.278 → 10.1.280
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,95 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The preview under a card the conversation offers (ADR-0160 decisions 6, 9). The proposal holds the definition only;
|
|
3
|
-
* the preview asks the server to run it as whoever is looking at the conversation, so a value is never kept in the
|
|
4
|
-
* conversation and nobody sees data their own doors do not open.
|
|
5
|
-
*/
|
|
6
|
-
import '@material/web/icon/icon.js'
|
|
7
|
-
import '@things-factory/ai-assistant/dist-client/index.js'
|
|
8
|
-
|
|
9
|
-
import gql from 'graphql-tag'
|
|
10
|
-
import { LitElement, css, html, nothing } from 'lit'
|
|
11
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
12
|
-
|
|
13
|
-
import { QueryController } from '@operato/graphql'
|
|
14
|
-
import { i18next, localize } from '@operato/i18n'
|
|
15
|
-
|
|
16
|
-
import { type CardRun } from '../utils/card-api.js'
|
|
17
|
-
import { drawsNothing, issueLine, partialLine } from '../utils/card-words.js'
|
|
18
|
-
|
|
19
|
-
const t = (key: string, options: Record<string, unknown> = {}) => String(i18next.t(key, options))
|
|
20
|
-
|
|
21
|
-
@customElement('ai-dashboard-proposal-preview')
|
|
22
|
-
export class ProposalPreview extends localize(i18next)(LitElement) {
|
|
23
|
-
static styles = css`
|
|
24
|
-
:host {
|
|
25
|
-
display: block;
|
|
26
|
-
margin: 4px 0 8px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.frame {
|
|
30
|
-
padding: 10px 12px 8px;
|
|
31
|
-
border: 1px solid var(--md-sys-color-outline-variant);
|
|
32
|
-
border-radius: 10px;
|
|
33
|
-
background: var(--md-sys-color-surface-container-lowest);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.waiting,
|
|
37
|
-
.note {
|
|
38
|
-
font-size: 12px;
|
|
39
|
-
color: var(--md-sys-color-on-surface-variant);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.note {
|
|
43
|
-
display: flex;
|
|
44
|
-
align-items: center;
|
|
45
|
-
gap: 4px;
|
|
46
|
-
margin-top: 6px;
|
|
47
|
-
--md-icon-size: 14px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.issue {
|
|
51
|
-
font-size: 12px;
|
|
52
|
-
color: var(--md-sys-color-error);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.partial {
|
|
56
|
-
color: var(--ui-warn, #b26a00);
|
|
57
|
-
}
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
@property({ attribute: false }) proposal: any
|
|
61
|
-
@property({ attribute: false }) sessionId?: string
|
|
62
|
-
@property({ attribute: false }) proposalKey?: string
|
|
63
|
-
|
|
64
|
-
/* The proposal run as the viewer, for the proposal shown (ADR-0190). */
|
|
65
|
-
private preview = new QueryController(
|
|
66
|
-
this,
|
|
67
|
-
gql`query ($s: String!, $k: String!) { dashboardCardProposalPreview(sessionId: $s, proposalKey: $k) }`,
|
|
68
|
-
{ variables: () => (this.sessionId && this.proposalKey ? { s: this.sessionId, k: this.proposalKey } : undefined) }
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
private get run(): CardRun | undefined {
|
|
72
|
-
return this.preview.data?.dashboardCardProposalPreview
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private get failed(): string | undefined {
|
|
76
|
-
const error = this.preview.error as any
|
|
77
|
-
return error ? (error.message ?? String(error)) : undefined
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
render() {
|
|
81
|
-
if (this.failed) return html`<div class="frame issue">${this.failed}</div>`
|
|
82
|
-
if (!this.run) return html`<div class="frame waiting">${t('ai-dashboard.preview.reading')}</div>`
|
|
83
|
-
const issue = issueLine(this.run, t)
|
|
84
|
-
const partial = partialLine(this.run, t)
|
|
85
|
-
return html`<div class="frame">
|
|
86
|
-
${issue
|
|
87
|
-
? html`<div class="issue">${issue.text}</div>`
|
|
88
|
-
: drawsNothing(this.run)
|
|
89
|
-
? html`<div class="waiting">${t('ai-dashboard.card.nothing')}</div>`
|
|
90
|
-
: html`<ox-assistant-workspace-view compact .workspace=${{ name: this.proposalKey, title: this.proposal?.card?.name ?? '', blocks: [this.run.block] }}></ox-assistant-workspace-view>`}
|
|
91
|
-
${partial ? html`<div class="note partial"><md-icon>warning</md-icon>${partial}</div>` : nothing}
|
|
92
|
-
<div class="note"><md-icon>bolt</md-icon>${t('ai-dashboard.preview.note', { day: this.run.asOf })}</div>
|
|
93
|
-
</div>`
|
|
94
|
-
}
|
|
95
|
-
}
|
package/client/index.ts
DELETED
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 나의 대시보드 - the cards a person placed, drawn from the data as them (ADR-0160 decision 8).
|
|
3
|
-
*
|
|
4
|
-
* Cards are made in the AI conversation beside the page (its card tool is in front here) and saved by pressing the
|
|
5
|
-
* card there; the library holds one's own cards and those shared with one. The page asks no model: each card asks
|
|
6
|
-
* the server to run its definition, each on its own, so a slow card waits in its place.
|
|
7
|
-
*/
|
|
8
|
-
import '@material/web/icon/icon.js'
|
|
9
|
-
import '../components/dashboard-card.js'
|
|
10
|
-
import '../components/card-library.js'
|
|
11
|
-
|
|
12
|
-
import gql from 'graphql-tag'
|
|
13
|
-
import { css, html, nothing } from 'lit'
|
|
14
|
-
import { customElement, state } from 'lit/decorators.js'
|
|
15
|
-
|
|
16
|
-
import { MutationController, QueryController } from '@operato/graphql'
|
|
17
|
-
import { i18next, localize } from '@operato/i18n'
|
|
18
|
-
import { notify, openPopup } from '@operato/layout'
|
|
19
|
-
import { PageView } from '@operato/shell'
|
|
20
|
-
import { DocumentPageStyles, ScrollbarStyles } from '@operato/styles'
|
|
21
|
-
import { askAssistant } from '@things-factory/ai-assistant/dist-client/index.js'
|
|
22
|
-
|
|
23
|
-
import { cardApi, CARD_FIELDS, DASHBOARD_CHANGED, dashboardChanged, type CardItem, type PlaceItem } from '../utils/card-api.js'
|
|
24
|
-
import { movedPlaces } from '../utils/card-words.js'
|
|
25
|
-
import { dashboardExamples } from '../utils/examples.js'
|
|
26
|
-
import { openCardAiPrompt, openCardRename, openCardShare, openCardVersions } from '../components/card-dialogs.js'
|
|
27
|
-
import type { CardAction } from '../components/dashboard-card.js'
|
|
28
|
-
|
|
29
|
-
const t = (key: string, options: Record<string, unknown> = {}) => String(i18next.t(key, options))
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@customElement('my-dashboard-page')
|
|
33
|
-
export class MyDashboardPage extends localize(i18next)(PageView) {
|
|
34
|
-
static styles = [
|
|
35
|
-
DocumentPageStyles,
|
|
36
|
-
ScrollbarStyles,
|
|
37
|
-
css`
|
|
38
|
-
.page {
|
|
39
|
-
gap: var(--spacing-large, 16px);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.lead {
|
|
43
|
-
display: flex;
|
|
44
|
-
flex-wrap: wrap;
|
|
45
|
-
align-items: center;
|
|
46
|
-
gap: 8px 16px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.lead p {
|
|
50
|
-
flex: 1;
|
|
51
|
-
min-width: 240px;
|
|
52
|
-
margin: 0;
|
|
53
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.chip {
|
|
57
|
-
display: inline-flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
gap: 6px;
|
|
60
|
-
padding: 4px 10px;
|
|
61
|
-
border-radius: 999px;
|
|
62
|
-
background: var(--ui-accent-wash, color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent));
|
|
63
|
-
color: var(--ui-accent, var(--md-sys-color-primary));
|
|
64
|
-
font-size: var(--ui-t-small, 12px);
|
|
65
|
-
font-weight: 600;
|
|
66
|
-
--md-icon-size: 16px;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.board {
|
|
70
|
-
container-type: inline-size;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.grid {
|
|
74
|
-
display: grid;
|
|
75
|
-
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
76
|
-
grid-auto-rows: minmax(250px, auto);
|
|
77
|
-
grid-auto-flow: dense;
|
|
78
|
-
gap: 16px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.grid > * {
|
|
82
|
-
grid-column: span var(--w, 2);
|
|
83
|
-
grid-row: span var(--h, 1);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@container (max-width: 1100px) {
|
|
87
|
-
.grid {
|
|
88
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.grid > .w3,
|
|
92
|
-
.grid > .w4 {
|
|
93
|
-
--w: 2;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@container (max-width: 640px) {
|
|
98
|
-
.grid {
|
|
99
|
-
grid-template-columns: minmax(0, 1fr);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.grid > * {
|
|
103
|
-
--w: 1 !important;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.empty {
|
|
108
|
-
display: flex;
|
|
109
|
-
flex-direction: column;
|
|
110
|
-
align-items: center;
|
|
111
|
-
gap: 14px;
|
|
112
|
-
max-width: 640px;
|
|
113
|
-
margin: 6vh auto 0;
|
|
114
|
-
padding: 36px 28px;
|
|
115
|
-
border: 1px dashed var(--ui-line, var(--md-sys-color-outline-variant));
|
|
116
|
-
border-radius: 16px;
|
|
117
|
-
background: radial-gradient(120% 100% at 50% 0%, var(--ui-accent-wash, color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent)) 0%, transparent 70%);
|
|
118
|
-
text-align: center;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.empty .mark {
|
|
122
|
-
display: grid;
|
|
123
|
-
place-items: center;
|
|
124
|
-
width: 56px;
|
|
125
|
-
height: 56px;
|
|
126
|
-
border-radius: 16px;
|
|
127
|
-
background: var(--ui-accent, var(--md-sys-color-primary));
|
|
128
|
-
color: var(--ui-on-accent, var(--md-sys-color-on-primary));
|
|
129
|
-
--md-icon-size: 30px;
|
|
130
|
-
box-shadow: 0 10px 24px -12px var(--ui-accent, var(--md-sys-color-primary));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.empty h2 {
|
|
134
|
-
margin: 4px 0 0;
|
|
135
|
-
font-size: var(--ui-t-page, 18px);
|
|
136
|
-
font-weight: 650;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.empty p {
|
|
140
|
-
margin: 0;
|
|
141
|
-
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.examples {
|
|
145
|
-
display: flex;
|
|
146
|
-
flex-direction: column;
|
|
147
|
-
gap: 8px;
|
|
148
|
-
width: 100%;
|
|
149
|
-
margin-top: 6px;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.examples button,
|
|
153
|
-
.empty .library {
|
|
154
|
-
display: flex;
|
|
155
|
-
align-items: center;
|
|
156
|
-
gap: 10px;
|
|
157
|
-
padding: 10px 14px;
|
|
158
|
-
border: 1px solid var(--ui-line, var(--md-sys-color-outline-variant));
|
|
159
|
-
border-radius: 10px;
|
|
160
|
-
background: var(--ui-panel, var(--md-sys-color-surface-container-lowest));
|
|
161
|
-
color: var(--ui-ink, var(--md-sys-color-on-surface));
|
|
162
|
-
font: inherit;
|
|
163
|
-
text-align: start;
|
|
164
|
-
cursor: pointer;
|
|
165
|
-
transition:
|
|
166
|
-
border-color 0.15s ease,
|
|
167
|
-
transform 0.15s ease;
|
|
168
|
-
--md-icon-size: 18px;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.examples button md-icon {
|
|
172
|
-
color: var(--ui-accent, var(--md-sys-color-primary));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.examples button:hover,
|
|
176
|
-
.examples button:focus-visible,
|
|
177
|
-
.empty .library:hover {
|
|
178
|
-
border-color: var(--ui-accent, var(--md-sys-color-primary));
|
|
179
|
-
transform: translateY(-1px);
|
|
180
|
-
outline: none;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
.empty .library {
|
|
184
|
-
justify-content: center;
|
|
185
|
-
border-style: dashed;
|
|
186
|
-
background: transparent;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.notice {
|
|
190
|
-
margin: 0;
|
|
191
|
-
padding: 12px 14px;
|
|
192
|
-
border-radius: 10px;
|
|
193
|
-
background: color-mix(in srgb, var(--ui-crit, #c62828) 8%, transparent);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.note {
|
|
197
|
-
margin: 0;
|
|
198
|
-
font-size: var(--ui-t-small, 12px);
|
|
199
|
-
color: var(--ui-faint, var(--md-sys-color-on-surface-variant));
|
|
200
|
-
}
|
|
201
|
-
`
|
|
202
|
-
]
|
|
203
|
-
|
|
204
|
-
@state() private editing = false
|
|
205
|
-
/** The places as moved here, shown while the move is being saved. */
|
|
206
|
-
@state() private arranged?: PlaceItem[]
|
|
207
|
-
|
|
208
|
-
/* A page refresh, or a change told from elsewhere, reads the board again. */
|
|
209
|
-
private board = new QueryController(this, gql`query { myDashboard { id order width height card { ${CARD_FIELDS} } } }`)
|
|
210
|
-
private arranging = new MutationController(this, gql`mutation ($places: [DashboardPlaceInput!]!) { arrangeDashboard(places: $places) }`, {
|
|
211
|
-
refetch: () => [this.board]
|
|
212
|
-
})
|
|
213
|
-
private unplacing = new MutationController(this, gql`mutation ($id: String!) { removeDashboardPlace(id: $id) }`, {
|
|
214
|
-
refetch: () => [this.board]
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
private get places(): PlaceItem[] {
|
|
218
|
-
return (this.arranging.pending && this.arranged) || this.board.data?.myDashboard || []
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
private get loaded() {
|
|
222
|
-
return !!this.board.answeredAt
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private get error(): string | undefined {
|
|
226
|
-
const error = this.board.error as any
|
|
227
|
-
return error ? (error.message ?? String(error)) : undefined
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
private onChanged = () => this.board.refetch()
|
|
231
|
-
|
|
232
|
-
get context() {
|
|
233
|
-
return {
|
|
234
|
-
title: t('ai-dashboard.title'),
|
|
235
|
-
frame: 'document',
|
|
236
|
-
actions: [
|
|
237
|
-
{ title: t(this.editing ? 'ai-dashboard.button.done' : 'ai-dashboard.button.arrange'), action: () => (this.editing = !this.editing), icon: this.editing ? 'check' : 'dashboard_customize' },
|
|
238
|
-
{ title: t('ai-dashboard.button.library'), action: () => this.openLibrary(), icon: 'collections_bookmark' },
|
|
239
|
-
{ title: t('ai-dashboard.button.make'), action: () => this.make(), icon: 'auto_awesome', emphasis: { raised: true } }
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
connectedCallback() {
|
|
245
|
-
super.connectedCallback()
|
|
246
|
-
window.addEventListener(DASHBOARD_CHANGED, this.onChanged)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
disconnectedCallback() {
|
|
250
|
-
window.removeEventListener(DASHBOARD_CHANGED, this.onChanged)
|
|
251
|
-
super.disconnectedCallback()
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
updated(changes: Map<string, unknown>) {
|
|
255
|
-
/* The action bar follows the mode - its words say what pressing it does now. */
|
|
256
|
-
if (changes.has('editing')) this.updateContext()
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
render() {
|
|
260
|
-
return html`<div class="page">
|
|
261
|
-
${this.error
|
|
262
|
-
? html`<p class="notice">${this.error}</p>`
|
|
263
|
-
: this.loaded && !this.places.length
|
|
264
|
-
? this.renderEmpty()
|
|
265
|
-
: this.places.length
|
|
266
|
-
? this.renderBoard()
|
|
267
|
-
: nothing}
|
|
268
|
-
</div>`
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
private renderBoard() {
|
|
272
|
-
const sorted = [...this.places].sort((a, b) => a.order - b.order)
|
|
273
|
-
return html`<div class="lead">
|
|
274
|
-
<p>${t('ai-dashboard.page.lead')}</p>
|
|
275
|
-
${this.editing ? html`<span class="chip"><md-icon>dashboard_customize</md-icon>${t('ai-dashboard.page.arranging')}</span>` : nothing}
|
|
276
|
-
</div>
|
|
277
|
-
<div class="board">
|
|
278
|
-
<div class="grid" @card-action=${(event: CustomEvent) => this.onCardAction(event)}>
|
|
279
|
-
${sorted.map(
|
|
280
|
-
(place, i) => html`<ai-dashboard-card
|
|
281
|
-
class="w${place.width} h${place.height}"
|
|
282
|
-
style="--w: ${place.width}; --h: ${place.height}"
|
|
283
|
-
data-place=${place.id}
|
|
284
|
-
.card=${place.card}
|
|
285
|
-
.width=${place.width}
|
|
286
|
-
.height=${place.height}
|
|
287
|
-
?editing=${this.editing}
|
|
288
|
-
?first=${i === 0}
|
|
289
|
-
?last=${i === sorted.length - 1}
|
|
290
|
-
></ai-dashboard-card>`
|
|
291
|
-
)}
|
|
292
|
-
</div>
|
|
293
|
-
</div>
|
|
294
|
-
<p class="note">${t('ai-dashboard.page.no-tokens')}</p>`
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
private renderEmpty() {
|
|
298
|
-
return html`<div class="empty">
|
|
299
|
-
<span class="mark"><md-icon>auto_awesome</md-icon></span>
|
|
300
|
-
<h2>${t('ai-dashboard.page.empty-title')}</h2>
|
|
301
|
-
<p>${t('ai-dashboard.page.empty-text')}</p>
|
|
302
|
-
${dashboardExamples().length
|
|
303
|
-
? html`<div class="examples">
|
|
304
|
-
${dashboardExamples().map(key => html`<button @click=${() => this.askFor(t(key))}><md-icon>chat_bubble</md-icon><span>${t(key)}</span></button>`)}
|
|
305
|
-
</div>`
|
|
306
|
-
: nothing}
|
|
307
|
-
<button class="library" @click=${() => this.openLibrary()}><md-icon>collections_bookmark</md-icon>${t('ai-dashboard.page.from-library')}</button>
|
|
308
|
-
<p class="note">${t('ai-dashboard.page.no-tokens')}</p>
|
|
309
|
-
</div>`
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/** Sends a request to the conversation beside the page - this screen's, where the card tool is in front. */
|
|
313
|
-
private async askFor(ask: string) {
|
|
314
|
-
await askAssistant({ ask, continueCurrent: true })
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
private make() {
|
|
318
|
-
askAssistant({ draft: t('ai-dashboard.page.make-draft'), continueCurrent: true })
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
private openLibrary() {
|
|
322
|
-
openPopup(html`<ai-dashboard-card-library></ai-dashboard-card-library>`, { backdrop: true, size: 'large', title: t('ai-dashboard.library.title') })
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
private placeOf(card: CardItem) {
|
|
326
|
-
return this.places.find(one => one.card.id === card.id)
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/* The board shows the move at once; a failed one goes back to the board read. */
|
|
330
|
-
private async arrange(next: PlaceItem[]) {
|
|
331
|
-
this.arranged = next
|
|
332
|
-
await this.arranging.run({ places: next.map(({ id, order, width, height }) => ({ id, order, width, height })) })
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
private async onCardAction(event: CustomEvent) {
|
|
336
|
-
const { action, card } = event.detail as { action: CardAction; card: CardItem }
|
|
337
|
-
const place = this.placeOf(card)
|
|
338
|
-
try {
|
|
339
|
-
switch (action) {
|
|
340
|
-
case 'ai':
|
|
341
|
-
return openCardAiPrompt(card)
|
|
342
|
-
case 'rename':
|
|
343
|
-
return openCardRename(card)
|
|
344
|
-
case 'share':
|
|
345
|
-
return openCardShare(card)
|
|
346
|
-
case 'versions':
|
|
347
|
-
return openCardVersions(card)
|
|
348
|
-
case 'copy':
|
|
349
|
-
await cardApi.copy(card.id)
|
|
350
|
-
notify({ level: 'info', message: t('ai-dashboard.text.copied', { name: card.name }) })
|
|
351
|
-
return dashboardChanged()
|
|
352
|
-
case 'unplace':
|
|
353
|
-
if (!place) return
|
|
354
|
-
if (await this.unplacing.run({ id: place.id })) notify({ level: 'info', message: t('ai-dashboard.text.unplaced', { name: card.name }) })
|
|
355
|
-
return
|
|
356
|
-
case 'left':
|
|
357
|
-
case 'right':
|
|
358
|
-
return place && this.arrange(movedPlaces(this.places, place.id, action === 'left' ? -1 : 1))
|
|
359
|
-
case 'wider':
|
|
360
|
-
case 'narrower':
|
|
361
|
-
case 'taller':
|
|
362
|
-
case 'shorter': {
|
|
363
|
-
if (!place) return
|
|
364
|
-
const width = Math.min(4, Math.max(1, place.width + (action === 'wider' ? 1 : action === 'narrower' ? -1 : 0)))
|
|
365
|
-
const height = Math.min(2, Math.max(1, place.height + (action === 'taller' ? 1 : action === 'shorter' ? -1 : 0)))
|
|
366
|
-
return this.arrange(this.places.map(one => (one.id === place.id ? { ...one, width, height } : one)))
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
} catch (error: any) {
|
|
370
|
-
notify({ level: 'error', message: error?.message ?? String(error) })
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
package/client/route.ts
DELETED
package/client/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig-base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"experimentalDecorators": true,
|
|
5
|
-
"skipLibCheck": true,
|
|
6
|
-
"strict": true,
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"module": "esnext",
|
|
9
|
-
"outDir": "../dist-client",
|
|
10
|
-
"baseUrl": "./"
|
|
11
|
-
},
|
|
12
|
-
"include": ["./**/*"]
|
|
13
|
-
}
|
package/client/utils/card-api.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The dashboard's changes (server: card-resolver.ts), and the card fields the screens read - one place, so the page,
|
|
3
|
-
* the library and the conversation's card read the same fields. Each screen declares its own reads (ADR-0190).
|
|
4
|
-
*/
|
|
5
|
-
import gql from 'graphql-tag'
|
|
6
|
-
|
|
7
|
-
import { client } from '@operato/graphql'
|
|
8
|
-
|
|
9
|
-
export interface CardShare {
|
|
10
|
-
scope: 'USER' | 'DEPARTMENT' | 'ROLE' | 'DOMAIN'
|
|
11
|
-
targetId: string
|
|
12
|
-
targetName?: string | null
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface CardItem {
|
|
16
|
-
id: string
|
|
17
|
-
name: string
|
|
18
|
-
description?: string | null
|
|
19
|
-
version: number
|
|
20
|
-
definition: any
|
|
21
|
-
access: 'owner' | 'shared'
|
|
22
|
-
ownerName?: string | null
|
|
23
|
-
copiedFromId?: string | null
|
|
24
|
-
placed: boolean
|
|
25
|
-
shares?: CardShare[] | null
|
|
26
|
-
updatedAt?: string | null
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface PlaceItem {
|
|
30
|
-
id: string
|
|
31
|
-
order: number
|
|
32
|
-
width: number
|
|
33
|
-
height: number
|
|
34
|
-
card: CardItem
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface CardCounts {
|
|
38
|
-
read: number
|
|
39
|
-
total: number
|
|
40
|
-
complete: boolean
|
|
41
|
-
shaped: number
|
|
42
|
-
shown: number
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface CardRun {
|
|
46
|
-
block?: any
|
|
47
|
-
issue?: { code: string; params?: Record<string, unknown> }
|
|
48
|
-
counts?: CardCounts
|
|
49
|
-
asOf: string
|
|
50
|
-
source?: { key: string; labelKey?: string }
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ShareOptions {
|
|
54
|
-
domainId: string
|
|
55
|
-
domainName: string
|
|
56
|
-
departments: { id: string; name: string }[]
|
|
57
|
-
peopleAvailable: boolean
|
|
58
|
-
roles: { id: string; name: string; note?: string | null }[]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface CardVersion {
|
|
62
|
-
version: number
|
|
63
|
-
name: string
|
|
64
|
-
definition: any
|
|
65
|
-
creatorName?: string
|
|
66
|
-
createdAt?: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const CARD_FIELDS = `id name description version definition access ownerName copiedFromId placed shares { scope targetId targetName } updatedAt`
|
|
70
|
-
|
|
71
|
-
async function ask<T>(document: string, variables: Record<string, unknown> = {}): Promise<T> {
|
|
72
|
-
const response: any = await client.mutate({ mutation: gql(document), variables })
|
|
73
|
-
if (response.errors?.length) throw new Error(response.errors[0].message)
|
|
74
|
-
return response.data
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const cardApi = {
|
|
78
|
-
saveProposal: async (sessionId: string, proposalKey: string) =>
|
|
79
|
-
(await ask<any>(`mutation ($s: String!, $k: String!) { saveDashboardCardProposal(sessionId: $s, proposalKey: $k) }`, { s: sessionId, k: proposalKey })).saveDashboardCardProposal as {
|
|
80
|
-
cardId: string
|
|
81
|
-
version: number
|
|
82
|
-
placeId: string
|
|
83
|
-
again?: boolean
|
|
84
|
-
},
|
|
85
|
-
rename: async (id: string, name: string) => (await ask<any>(`mutation ($id: String!, $name: String!) { renameDashboardCard(id: $id, name: $name) { id } }`, { id, name })).renameDashboardCard,
|
|
86
|
-
restore: async (id: string, version: number) => (await ask<any>(`mutation ($id: String!, $v: Int!) { restoreDashboardCardVersion(id: $id, version: $v) { id } }`, { id, v: version })).restoreDashboardCardVersion,
|
|
87
|
-
copy: async (id: string) => (await ask<any>(`mutation ($id: String!) { copyDashboardCard(id: $id) { id } }`, { id })).copyDashboardCard,
|
|
88
|
-
remove: async (id: string) => (await ask<any>(`mutation ($id: String!) { deleteDashboardCard(id: $id) }`, { id })).deleteDashboardCard,
|
|
89
|
-
share: async (id: string, shares: CardShare[]) =>
|
|
90
|
-
(await ask<any>(`mutation ($id: String!, $shares: [DashboardCardShareInput!]!) { shareDashboardCard(id: $id, shares: $shares) { ${CARD_FIELDS} } }`, { id, shares })).shareDashboardCard as CardItem,
|
|
91
|
-
place: async (cardId: string) => (await ask<any>(`mutation ($id: String!) { placeDashboardCard(cardId: $id) { id } }`, { id: cardId })).placeDashboardCard
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** Told when a card is saved, copied, placed or removed elsewhere - an open dashboard reads itself again. */
|
|
95
|
-
export const DASHBOARD_CHANGED = 'ai-dashboard-changed'
|
|
96
|
-
|
|
97
|
-
export function dashboardChanged(): void {
|
|
98
|
-
window.dispatchEvent(new CustomEvent(DASHBOARD_CHANGED))
|
|
99
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* What a card says besides its block - why it is not drawn, how much of its source it was drawn from, when it was
|
|
3
|
-
* read, what it reads (ADR-0160 decisions 4, 6). Pure - tested without a browser.
|
|
4
|
-
*/
|
|
5
|
-
import type { CardItem, CardRun } from './card-api.js'
|
|
6
|
-
|
|
7
|
-
export type Translate = (key: string, options?: Record<string, unknown>) => string
|
|
8
|
-
|
|
9
|
-
/** The axis of a saved card - the server's `CARD_AXIS` (card-names.ts); a test holds the two equal. */
|
|
10
|
-
export const CARD_AXIS = 'dashboard-card'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A card picked to change, as the conversation is handed it (`askAssistant({ selection })`): its key
|
|
14
|
-
* `dashboard-card:<uuid>`, like any picked row - the bare uuid named no record, and the change failed on it (2026-10-25).
|
|
15
|
-
*/
|
|
16
|
-
export function cardSelection(card: Pick<CardItem, 'id' | 'name'>, title: string) {
|
|
17
|
-
return { title, list: 'dashboardCards', records: [{ id: `${CARD_AXIS}:${card.id}`, label: card.name }] }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** The refusals a card names in the reader's words - others are said by their code. */
|
|
21
|
-
export const KNOWN_ISSUES = [
|
|
22
|
-
'door-closed',
|
|
23
|
-
'not-found',
|
|
24
|
-
'list-missing',
|
|
25
|
-
'query-failed',
|
|
26
|
-
'condition-unreadable',
|
|
27
|
-
'mixed-currency-order',
|
|
28
|
-
'too-many-series',
|
|
29
|
-
'too-many-figures',
|
|
30
|
-
'unknown-read',
|
|
31
|
-
'not-a-card-source',
|
|
32
|
-
'unknown-list',
|
|
33
|
-
'unknown-column',
|
|
34
|
-
'unknown-condition'
|
|
35
|
-
] as const
|
|
36
|
-
|
|
37
|
-
/** Why a card is not drawn - one sentence, and whether it is the reader's access (shown calmly, not as a fault). */
|
|
38
|
-
export function issueLine(run: CardRun, t: Translate): { text: string; access: boolean } | undefined {
|
|
39
|
-
const issue = run.issue
|
|
40
|
-
if (!issue) return undefined
|
|
41
|
-
const code = issue.code
|
|
42
|
-
const known = (KNOWN_ISSUES as readonly string[]).includes(code)
|
|
43
|
-
const params = { ...(issue.params ?? {}), code } as Record<string, unknown>
|
|
44
|
-
if (Array.isArray(params.currencies)) params.currencies = (params.currencies as string[]).join(', ')
|
|
45
|
-
return {
|
|
46
|
-
text: t(known ? `ai-dashboard.issue.${code}` : 'ai-dashboard.issue.other', { ...params, defaultValue: known ? code : 'This card cannot be drawn ({code}).' }),
|
|
47
|
-
access: code === 'door-closed'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** How much of its source a card was drawn from - said only when it was not all of it. */
|
|
52
|
-
export function partialLine(run: CardRun, t: Translate): string | undefined {
|
|
53
|
-
const counts = run.counts
|
|
54
|
-
if (!counts || counts.complete) return undefined
|
|
55
|
-
return t('ai-dashboard.card.partial', { read: counts.read.toLocaleString(), total: counts.total.toLocaleString(), defaultValue: 'Drawn from {read} of {total} rows - sums and ranks are of those.' })
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** A table or chart with no row to draw - said in words, never an empty axis. A number of nothing is 0, and drawn. */
|
|
59
|
-
export function drawsNothing(run: CardRun): boolean {
|
|
60
|
-
return !run.issue && !!run.block && run.block.kind !== 'metrics' && (run.counts?.shown ?? 0) === 0
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** The day relative periods were read for, and the time it was read. */
|
|
64
|
-
export function readLine(run: CardRun, readAt: Date, t: Translate, locale?: string): string {
|
|
65
|
-
const time = readAt.toLocaleTimeString(locale || undefined, { hour: '2-digit', minute: '2-digit' })
|
|
66
|
-
return t('ai-dashboard.card.read-at', { day: run.asOf, time, defaultValue: 'as of {day} · read {time}' })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Who a card came from, for a card shared with the reader; whom it is shared with, for its owner. */
|
|
70
|
-
export function ownershipLine(card: CardItem, t: Translate): string | undefined {
|
|
71
|
-
if (card.access === 'shared') return t('ai-dashboard.card.shared-by', { name: card.ownerName ?? '', defaultValue: 'shared by {name}' })
|
|
72
|
-
const shares = card.shares ?? []
|
|
73
|
-
if (!shares.length) return undefined
|
|
74
|
-
const names = shares.map(one => (one.scope === 'DOMAIN' ? t('ai-dashboard.share.everyone', { defaultValue: 'everyone' }) : one.targetName || one.targetId))
|
|
75
|
-
return t('ai-dashboard.card.shared-with', { names: names.slice(0, 3).join(', ') + (names.length > 3 ? ` +${names.length - 3}` : ''), defaultValue: 'shared with {names}' })
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** The kind of drawing a definition asks for - the icon a card and the library show. */
|
|
79
|
-
export function viewIcon(definition: any): string {
|
|
80
|
-
return ({ number: 'pin', table: 'table_rows', bar: 'bar_chart', line: 'show_chart' } as Record<string, string>)[definition?.view?.kind] ?? 'dashboard'
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Moves one place in a list of places and gives every place its order again - what arranging sends. */
|
|
84
|
-
export function movedPlaces<P extends { id: string; order: number }>(places: readonly P[], id: string, step: -1 | 1): P[] {
|
|
85
|
-
const list = [...places].sort((a, b) => a.order - b.order)
|
|
86
|
-
const at = list.findIndex(one => one.id === id)
|
|
87
|
-
const to = at + step
|
|
88
|
-
if (at < 0 || to < 0 || to >= list.length) return list.map((one, order) => ({ ...one, order }))
|
|
89
|
-
;[list[at], list[to]] = [list[to], list[at]]
|
|
90
|
-
return list.map((one, order) => ({ ...one, order }))
|
|
91
|
-
}
|