@pb33f/cowboy-components 0.7.5 → 0.7.7
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/dist/components/auth/login-button.d.ts +3 -0
- package/dist/components/auth/login-button.js +29 -8
- package/dist/components/auth/login-panel.d.ts +2 -1
- package/dist/components/auth/login-panel.js +3 -2
- package/dist/components/auth/oauth-login.d.ts +1 -0
- package/dist/components/auth/oauth-login.js +11 -5
- package/dist/components/editor/editor-breadcrumb.css.js +1 -1
- package/dist/components/model-renderer/rendered-node.d.ts +2 -0
- package/dist/components/model-renderer/rendered-node.js +18 -0
- package/dist/components/model-renderer/responses.d.ts +11 -0
- package/dist/components/model-renderer/responses.js +46 -0
- package/dist/components/model-tree/tree.js +1 -1
- package/dist/components/paginator/paginator.css.js +1 -1
- package/dist/components/paginator/paginator.d.ts +2 -0
- package/dist/components/paginator/paginator.js +6 -6
- package/dist/components/problems-overview/problems-overview.js +6 -0
- package/dist/components/rodeo/rodeo.js +1 -1
- package/dist/components/the-doctor/sparks.d.ts +1 -0
- package/dist/components/the-doctor/sparks.js +36 -21
- package/dist/components/the-doctor/status-bar.css.js +10 -8
- package/dist/components/the-doctor/status-bar.d.ts +2 -0
- package/dist/components/the-doctor/status-bar.js +18 -8
- package/dist/components/the-doctor/the-doctor.css.js +1 -1
- package/dist/components/the-doctor/the-doctor.d.ts +113 -120
- package/dist/components/the-doctor/the-doctor.js +141 -1735
- package/dist/components/the-doctor/upload-archive.d.ts +1 -0
- package/dist/components/the-doctor/upload-archive.js +29 -12
- package/dist/controllers/{auth.d.ts → auth-controller.d.ts} +11 -6
- package/dist/controllers/auth-controller.js +165 -0
- package/dist/controllers/broker-controller.d.ts +22 -0
- package/dist/controllers/broker-controller.js +107 -0
- package/dist/controllers/diagnostic-controller.d.ts +6 -0
- package/dist/controllers/diagnostic-controller.js +262 -0
- package/dist/controllers/docs-controller.d.ts +8 -0
- package/dist/controllers/docs-controller.js +144 -0
- package/dist/controllers/model-controller.d.ts +8 -0
- package/dist/controllers/model-controller.js +87 -0
- package/dist/controllers/node-clicker-controller.d.ts +11 -0
- package/dist/controllers/node-clicker-controller.js +362 -0
- package/dist/controllers/problem-controller.d.ts +7 -0
- package/dist/controllers/problem-controller.js +46 -0
- package/dist/controllers/rolodex-controller.d.ts +10 -0
- package/dist/controllers/rolodex-controller.js +126 -0
- package/dist/controllers/rule-controller.d.ts +19 -0
- package/dist/controllers/rule-controller.js +264 -0
- package/dist/controllers/spec-controller.d.ts +8 -0
- package/dist/controllers/spec-controller.js +78 -0
- package/dist/controllers/state-controller.d.ts +9 -0
- package/dist/controllers/state-controller.js +279 -0
- package/dist/cowboy-components.umd.cjs +768 -736
- package/dist/css/pb33f-theme.css +1 -0
- package/dist/css/shared.css.js +5 -0
- package/dist/events/doctor.d.ts +12 -0
- package/dist/events/doctor.js +4 -0
- package/dist/model/api-response.d.ts +7 -0
- package/dist/model/api-response.js +2 -0
- package/dist/services/auth-service.d.ts +1 -0
- package/dist/services/auth-service.js +28 -0
- package/dist/services/linting-service.js +11 -2
- package/dist/services/model-service.d.ts +2 -1
- package/dist/services/model-service.js +31 -5
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/controllers/auth.js +0 -101
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { DiagnosticBag, DocumentProblems, SettingsBag } from "../components/the-doctor/the-doctor.js";
|
|
2
|
+
import { LintingService } from "../services/linting-service.js";
|
|
3
|
+
import { ModelService } from "../services/model-service.js";
|
|
4
|
+
import { ToastType } from "../model/toast.js";
|
|
5
|
+
export class DiagnosticController extends EventTarget {
|
|
6
|
+
constructor(doc) {
|
|
7
|
+
super();
|
|
8
|
+
this.doc = doc;
|
|
9
|
+
}
|
|
10
|
+
lintSpec(value, url) {
|
|
11
|
+
this.doc.activitySpinner.show();
|
|
12
|
+
this.doc.editor.breadcumb.isInvalid = false;
|
|
13
|
+
if (url) {
|
|
14
|
+
if (url === 'root') {
|
|
15
|
+
url = '';
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.doc.urlProblem.style.display = 'none';
|
|
19
|
+
this.doc.urlOverlay.style.display = "block";
|
|
20
|
+
this.doc.urlSpinner.style.display = "block";
|
|
21
|
+
this.doc.referenceMapBag?.reset(); // wipe out refs.
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.doc.urlProblem.style.display = 'none';
|
|
26
|
+
this.doc.urlOverlay.style.display = "none";
|
|
27
|
+
this.doc.urlSpinner.style.display = "none";
|
|
28
|
+
}
|
|
29
|
+
let replaceResults = false;
|
|
30
|
+
let currentPath = this.doc.rolodexActivePath;
|
|
31
|
+
if (this.doc.rolodexActivePath === this.doc.rolodexRootPath || this.doc.rolodexActivePath === 'root') {
|
|
32
|
+
replaceResults = true;
|
|
33
|
+
currentPath = '';
|
|
34
|
+
this.doc.editor.showBreadcrumb = false;
|
|
35
|
+
}
|
|
36
|
+
if (url && url != '') {
|
|
37
|
+
try {
|
|
38
|
+
const parsedUrl = new URL(url);
|
|
39
|
+
if (parsedUrl) {
|
|
40
|
+
currentPath = parsedUrl.pathname;
|
|
41
|
+
this.doc.rolodexActivePath = currentPath;
|
|
42
|
+
this.doc.rolodexRootPath = currentPath;
|
|
43
|
+
replaceResults = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
// do nothing for now.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let revive = true;
|
|
51
|
+
LintingService.lintFile(value, this.doc.brokerController.brokerConnectionId, url, currentPath, this.doc.skipTimeline).then((result) => {
|
|
52
|
+
//if (replaceResults) {
|
|
53
|
+
this.doc.activitySpinner.hide();
|
|
54
|
+
const map = this.doc.rolodexController.buildRolodexResultMap(result);
|
|
55
|
+
if (url) {
|
|
56
|
+
this.doc.urlOverlay.style.display = "none";
|
|
57
|
+
this.doc.urlSpinner.style.display = "none";
|
|
58
|
+
this.doc.urlProblem.style.display = 'none';
|
|
59
|
+
}
|
|
60
|
+
// extract empty location problems as we are replacing the root results
|
|
61
|
+
let rootProblems = this.doc.rolodexProblemMap.get("root");
|
|
62
|
+
if (!this.doc.rolodexRoot) {
|
|
63
|
+
rootProblems = [];
|
|
64
|
+
}
|
|
65
|
+
if (result && !Array.isArray(result)) {
|
|
66
|
+
const r = [result];
|
|
67
|
+
if (this.doc.rolodexProblemMap.size > 0 && this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)) {
|
|
68
|
+
const probs = this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);
|
|
69
|
+
if (probs) {
|
|
70
|
+
if (rootProblems) {
|
|
71
|
+
probs.push(...rootProblems);
|
|
72
|
+
}
|
|
73
|
+
this.doc.editor.setMarkers(probs);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
if (rootProblems) {
|
|
77
|
+
r.push(...rootProblems);
|
|
78
|
+
}
|
|
79
|
+
this.doc.editor.setMarkers(r);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
if (rootProblems) {
|
|
84
|
+
r.push(...rootProblems);
|
|
85
|
+
}
|
|
86
|
+
this.doc.editor.setMarkers(r);
|
|
87
|
+
}
|
|
88
|
+
this.doc.problemBag?.set(DocumentProblems, r);
|
|
89
|
+
this.doc.problemList.problems = r;
|
|
90
|
+
this.doc.problems = r;
|
|
91
|
+
this.doc.problemsOverview.problems = this.doc.problemList.problemItems;
|
|
92
|
+
}
|
|
93
|
+
if (result && Array.isArray(result)) {
|
|
94
|
+
if (result.length == 0) {
|
|
95
|
+
this.doc.editor.clearAllMarkers();
|
|
96
|
+
this.doc.editor.breadcumb.isInvalid = false;
|
|
97
|
+
this.doc.editor.showBreadcrumb = false;
|
|
98
|
+
revive = true;
|
|
99
|
+
this.doc.problemList.isInvalid = false;
|
|
100
|
+
}
|
|
101
|
+
// check if this problem is 'unable to parse'
|
|
102
|
+
if (result.length == 1 && result[0].message.startsWith('unable to parse')) {
|
|
103
|
+
// short circuit, we are dead.
|
|
104
|
+
this.doc.editor.clearDecorations();
|
|
105
|
+
this.doc.editor.clearAllMarkers();
|
|
106
|
+
this.doc.editor.setMarkers(result);
|
|
107
|
+
this.doc.editor.breadcumb.isInvalid = true;
|
|
108
|
+
this.doc.editor.showBreadcrumb = true;
|
|
109
|
+
this.doc.editor.dead();
|
|
110
|
+
this.doc.problemList.isInvalid = true;
|
|
111
|
+
revive = false;
|
|
112
|
+
}
|
|
113
|
+
// extract empty location problems as we are replacing the root results
|
|
114
|
+
if (revive && this.doc.rolodexProblemMap.size > 0 && this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)) {
|
|
115
|
+
const probs = this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);
|
|
116
|
+
if (probs) {
|
|
117
|
+
if (rootProblems) {
|
|
118
|
+
probs.push(...rootProblems);
|
|
119
|
+
}
|
|
120
|
+
this.doc.editor.setMarkers(probs);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
if (rootProblems) {
|
|
124
|
+
result.push(...rootProblems);
|
|
125
|
+
}
|
|
126
|
+
this.doc.editor.setMarkers(result);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (replaceResults) {
|
|
131
|
+
this.doc.editor.setMarkers(result);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this.doc.modelController.fetchRefMap(currentPath);
|
|
135
|
+
if ((this.doc.rolodexRootPath == this.doc.rolodexActivePath || this.doc.rolodexActivePath == 'root') || url || currentPath != '') {
|
|
136
|
+
ModelService.fetchLatestGraph().then((result) => {
|
|
137
|
+
this.doc.modelController.extractGraph(result);
|
|
138
|
+
this.doc.timeVortex.checkHistory();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
this.doc.problemBag?.set(DocumentProblems, result);
|
|
145
|
+
this.doc.problemList.problems = result;
|
|
146
|
+
this.doc.problems = result;
|
|
147
|
+
this.doc.problemsOverview.problems = this.doc.problemList.problemItems;
|
|
148
|
+
if (this.doc.problemsOverview.statistics) {
|
|
149
|
+
if (result.length == 1) {
|
|
150
|
+
this.doc.problemsOverview.statistics.statistics.totalErrors = 1;
|
|
151
|
+
this.doc.problemsOverview.statistics.statistics.overallScore = 0;
|
|
152
|
+
this.doc.problemsOverview.statistics.evaluation = 'Useless';
|
|
153
|
+
this.doc.problemsOverview.statistics.diagnosis = '<strong>Specification cannot be used</strong>: <br/><br/>' + result[0].message;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// enable pb33f theme.
|
|
158
|
+
if (revive) {
|
|
159
|
+
this.doc.editor.revive();
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// fetch graph
|
|
165
|
+
if ((this.doc.rolodexRootPath == this.doc.rolodexActivePath || this.doc.rolodexActivePath == 'root') || url || currentPath != '') {
|
|
166
|
+
ModelService.fetchLatestGraph().then((result) => {
|
|
167
|
+
this.doc.modelController.extractGraph(result);
|
|
168
|
+
this.doc.timeVortex.checkHistory();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (this.doc.rolodexNeedsReset) {
|
|
172
|
+
this.doc.rolodexController.queryRolodex(currentPath);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.doc.modelController.fetchRefMap(currentPath);
|
|
176
|
+
//this.timeVortex.tardisControl.fetchHistory()
|
|
177
|
+
}
|
|
178
|
+
// update the overview statistics
|
|
179
|
+
LintingService.fetchStatistics().then((result) => {
|
|
180
|
+
let oldScore = 0;
|
|
181
|
+
if (this.doc.problemsOverview.statistics) {
|
|
182
|
+
oldScore = this.doc.problemsOverview.statistics.statistics.overallScore;
|
|
183
|
+
}
|
|
184
|
+
this.doc.diagnosticBag?.set(DiagnosticBag, result);
|
|
185
|
+
this.doc.activitySpinner.hide();
|
|
186
|
+
if (result?.remainingCredit <= 10) {
|
|
187
|
+
this.doc.statusBar.callsRemaining = result.remainingCredit;
|
|
188
|
+
this.doc.statusBar.visible = true;
|
|
189
|
+
console.warn("You are running low on credit, you will need to authenticate soon. " +
|
|
190
|
+
"" + result.remainingCredit + " credits remaining.");
|
|
191
|
+
}
|
|
192
|
+
// determine if the score went up or down and toast it!
|
|
193
|
+
this.doc.problemsOverview.statistics = result;
|
|
194
|
+
const settings = this.doc.settingsBag?.get(SettingsBag);
|
|
195
|
+
// only toast if we're NOT using auto diagnose, otherwise they are a pain in the ass.
|
|
196
|
+
if (!settings?.autoDiagnose) {
|
|
197
|
+
if (this.doc.problemsOverview.statistics) {
|
|
198
|
+
const newScore = result.statistics.overallScore;
|
|
199
|
+
if (oldScore > newScore) {
|
|
200
|
+
this.doc.sendToast({
|
|
201
|
+
id: crypto.randomUUID(),
|
|
202
|
+
type: ToastType.SCOREDOWN,
|
|
203
|
+
body: "Your score has decreased. It is now " + newScore + "%",
|
|
204
|
+
title: "Score went down by " + (oldScore - newScore) + "%"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (oldScore < newScore) {
|
|
208
|
+
this.doc.sendToast({
|
|
209
|
+
id: crypto.randomUUID(),
|
|
210
|
+
type: ToastType.SCOREUP,
|
|
211
|
+
body: "Your score has increased to " + newScore + "%",
|
|
212
|
+
title: "Score went up by " + (newScore - oldScore) + "%"
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}).catch((e) => {
|
|
218
|
+
console.error("statistics service is down", e);
|
|
219
|
+
this.doc.sendToast({
|
|
220
|
+
id: crypto.randomUUID(),
|
|
221
|
+
type: ToastType.ERROR,
|
|
222
|
+
body: e.detail,
|
|
223
|
+
title: "Statistics request failed"
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
if (!this.doc.explorerBooted) {
|
|
227
|
+
this.doc.explorer.equalizer.initializeEqualizer();
|
|
228
|
+
this.doc.explorerBooted = true;
|
|
229
|
+
}
|
|
230
|
+
}).catch((e) => {
|
|
231
|
+
this.doc.activitySpinner.hide();
|
|
232
|
+
if (!url) {
|
|
233
|
+
//this.platformUnavailable(e);
|
|
234
|
+
console.error("so sorry, the doctor cannot see you right now, the clinic is closed.");
|
|
235
|
+
if (e) {
|
|
236
|
+
console.error(e.detail);
|
|
237
|
+
if (e.instance === 'https://pb33f.io/errors/no-credit-remaining') {
|
|
238
|
+
this.doc.statusBar.callsRemaining = 0;
|
|
239
|
+
this.doc.statusBar.visible = true;
|
|
240
|
+
this.doc.sendToast({
|
|
241
|
+
id: crypto.randomUUID(),
|
|
242
|
+
type: ToastType.ERROR,
|
|
243
|
+
body: "Run out of credit, please authenticate for more or wait 24 hours.",
|
|
244
|
+
title: "Credit exhausted!",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
this.doc.sendToast({
|
|
249
|
+
id: crypto.randomUUID(),
|
|
250
|
+
type: ToastType.ERROR,
|
|
251
|
+
body: e.detail,
|
|
252
|
+
title: "Platform Error",
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
this.doc.showUrlError(e);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TheDoctor } from "../components/the-doctor/the-doctor";
|
|
2
|
+
import { ProblemDrawerEvent } from "../components/problem-list/details-drawer";
|
|
3
|
+
export declare class DocsController extends EventTarget {
|
|
4
|
+
doc: TheDoctor;
|
|
5
|
+
constructor(doc: TheDoctor);
|
|
6
|
+
fetchDocs(): void;
|
|
7
|
+
ruleDocsClicked(event: CustomEvent<ProblemDrawerEvent>): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { DocumentationExpirationBag, FunctionDocumentationBag, RuleDocumentationBag } from "../components/the-doctor/the-doctor";
|
|
2
|
+
import { LintingService } from "../services/linting-service";
|
|
3
|
+
import { ProblemDrawerEventType } from "../components/problem-list/details-drawer";
|
|
4
|
+
import { ToastType } from "../model/toast";
|
|
5
|
+
export class DocsController extends EventTarget {
|
|
6
|
+
constructor(doc) {
|
|
7
|
+
super();
|
|
8
|
+
this.doc = doc;
|
|
9
|
+
}
|
|
10
|
+
fetchDocs() {
|
|
11
|
+
//return;
|
|
12
|
+
this.doc.activitySpinner.show();
|
|
13
|
+
const url = new URL(window.location.href);
|
|
14
|
+
const urlParam = url.searchParams.get('url');
|
|
15
|
+
if (urlParam) {
|
|
16
|
+
//this.urlInput.value = urlParam;
|
|
17
|
+
this.doc.activeURL = urlParam;
|
|
18
|
+
this.doc.diagnosticController.lintSpec('', urlParam);
|
|
19
|
+
}
|
|
20
|
+
LintingService.fetchAllHowToFix().then((result) => {
|
|
21
|
+
if (result) {
|
|
22
|
+
result.forEach((howToFix) => {
|
|
23
|
+
this.doc.howToFixBag?.set(howToFix.ruleId, howToFix);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}).catch((e) => {
|
|
27
|
+
this.doc.platformUnavailable(e);
|
|
28
|
+
console.error("documentation service is down");
|
|
29
|
+
});
|
|
30
|
+
this.doc.ruleDocsBag = this.doc.bagManager.getBag(RuleDocumentationBag);
|
|
31
|
+
this.doc.functionDocsBag = this.doc.bagManager.getBag(FunctionDocumentationBag);
|
|
32
|
+
// populate docs via worker.
|
|
33
|
+
this.doc.ruleDocsWorker.addEventListener("message", (event) => {
|
|
34
|
+
const data = event.data;
|
|
35
|
+
if (data) {
|
|
36
|
+
data.forEach((doc) => {
|
|
37
|
+
if (doc.ruleId) {
|
|
38
|
+
this.doc.ruleDocsBag?.set(doc.ruleId, doc);
|
|
39
|
+
}
|
|
40
|
+
if (doc.functionId) {
|
|
41
|
+
this.doc.functionDocsBag?.set(doc.functionId, doc);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.doc.activitySpinner.hide();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
// let ruleDocs: string[] = [];
|
|
48
|
+
// let functionDocs: string[] = [];
|
|
49
|
+
// if (this.ruleDocsBag) {
|
|
50
|
+
// ruleDocs = Array.from(this.ruleDocsBag.export().keys());
|
|
51
|
+
// }
|
|
52
|
+
// if (this.functionDocsBag) {
|
|
53
|
+
// functionDocs = Array.from(this.functionDocsBag.export().keys());
|
|
54
|
+
// }
|
|
55
|
+
const fetchDocs = () => {
|
|
56
|
+
this.doc.ruleDocsWorker.postMessage({
|
|
57
|
+
start: true,
|
|
58
|
+
endpoint: this.doc.doctorEndpoint,
|
|
59
|
+
existingRules: [],
|
|
60
|
+
existingFunctions: []
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
// check expiration
|
|
64
|
+
if (this.doc.docExpirationBag) {
|
|
65
|
+
const expiration = this.doc.docExpirationBag.get(DocumentationExpirationBag);
|
|
66
|
+
// if the docs are older than 15 days, refresh them.
|
|
67
|
+
if (expiration) {
|
|
68
|
+
const now = new Date().getTime();
|
|
69
|
+
const then = new Date(expiration).getTime();
|
|
70
|
+
// if (now - then > 1296000000) {
|
|
71
|
+
// fetchDocs();
|
|
72
|
+
// } else {
|
|
73
|
+
// this.activitySpinner.hide();
|
|
74
|
+
// }
|
|
75
|
+
fetchDocs(); // always fetch for now.
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
fetchDocs();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
fetchDocs();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
ruleDocsClicked(event) {
|
|
86
|
+
const ruleId = event.detail.rule;
|
|
87
|
+
if (ruleId) {
|
|
88
|
+
switch (event.detail.type) {
|
|
89
|
+
case ProblemDrawerEventType.RULE_DOCS:
|
|
90
|
+
const ruleDoc = this.doc.ruleDocsBag?.get(ruleId);
|
|
91
|
+
if (ruleDoc) {
|
|
92
|
+
event.detail.body = ruleDoc.body;
|
|
93
|
+
this.doc.detailsDrawer.open(event.detail);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.doc.sendToast({
|
|
97
|
+
id: crypto.randomUUID(),
|
|
98
|
+
type: ToastType.INFO,
|
|
99
|
+
title: "Rule documentation unavailable",
|
|
100
|
+
body: `Documentation for '${ruleId}' not available`
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case ProblemDrawerEventType.HOW_TO_FIX:
|
|
105
|
+
const howToFix = this.doc.howToFixBag?.get(ruleId);
|
|
106
|
+
if (howToFix) {
|
|
107
|
+
event.detail.body = howToFix.howToFix;
|
|
108
|
+
this.doc.detailsDrawer.open(event.detail);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.doc.sendToast({
|
|
112
|
+
id: crypto.randomUUID(),
|
|
113
|
+
type: ToastType.INFO,
|
|
114
|
+
title: "How to fix unavailable",
|
|
115
|
+
body: `Information on how to fix '${ruleId}' not available`
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case ProblemDrawerEventType.FUNCTION_DOCS:
|
|
120
|
+
const funcDocs = this.doc.functionDocsBag?.get(ruleId);
|
|
121
|
+
if (funcDocs) {
|
|
122
|
+
event.detail.body = funcDocs.body;
|
|
123
|
+
this.doc.detailsDrawer.open(event.detail);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.doc.sendToast({
|
|
127
|
+
id: crypto.randomUUID(),
|
|
128
|
+
type: ToastType.INFO,
|
|
129
|
+
title: "Function documentation unavailable",
|
|
130
|
+
body: `Documentation for '${ruleId}' not available`
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
switch (event.detail.type) {
|
|
138
|
+
case ProblemDrawerEventType.RENDERED_EXAMPLE:
|
|
139
|
+
case ProblemDrawerEventType.MARKDOWN:
|
|
140
|
+
this.doc.detailsDrawer.open(event.detail);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TheDoctor } from "../components/the-doctor/the-doctor.js";
|
|
2
|
+
import { GraphResponse } from "../model/graph";
|
|
3
|
+
export declare class ModelController extends EventTarget {
|
|
4
|
+
doc: TheDoctor;
|
|
5
|
+
constructor(doc: TheDoctor);
|
|
6
|
+
fetchRefMap(currentPath?: string): void;
|
|
7
|
+
extractGraph(graph: GraphResponse): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { GraphBag } from "../components/the-doctor/the-doctor.js";
|
|
2
|
+
import { ModelService } from "../services/model-service";
|
|
3
|
+
import { ToastType } from "../model/toast";
|
|
4
|
+
export class ModelController extends EventTarget {
|
|
5
|
+
constructor(doc) {
|
|
6
|
+
super();
|
|
7
|
+
this.doc = doc;
|
|
8
|
+
}
|
|
9
|
+
fetchRefMap(currentPath = '') {
|
|
10
|
+
ModelService.fetchReferenceMap(currentPath).then((result) => {
|
|
11
|
+
this.doc.editor.clearDecorations();
|
|
12
|
+
this.doc.references = result;
|
|
13
|
+
this.doc.editor.links = result;
|
|
14
|
+
this.doc.editor.applyLinkDecorations();
|
|
15
|
+
// add references to our stateful bag
|
|
16
|
+
this.doc.updateRefmapBag(currentPath, result);
|
|
17
|
+
}).catch((e) => {
|
|
18
|
+
console.error('an error occurred fetching the reference map', currentPath, e);
|
|
19
|
+
this.doc.editor.clearDecorations();
|
|
20
|
+
this.doc.editor.clearAllMarkers();
|
|
21
|
+
this.doc.toastManager.addToastManually({
|
|
22
|
+
id: crypto.randomUUID(),
|
|
23
|
+
type: ToastType.INFO,
|
|
24
|
+
title: "File not analyzed",
|
|
25
|
+
body: "Cannot extract the references from this file.",
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
extractGraph(graph) {
|
|
30
|
+
// handled stripped nodes
|
|
31
|
+
if (graph.stripped) {
|
|
32
|
+
this.doc.explorer.nodeLimitExceeded = true;
|
|
33
|
+
this.doc.modelTree.nodeLimitExceeded = true;
|
|
34
|
+
if (graph.strippedCount) {
|
|
35
|
+
this.doc.explorer.nodeLimit = graph.strippedCount;
|
|
36
|
+
this.doc.modelTree.nodeLimit = graph.strippedCount;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.doc.explorer.nodeLimitExceeded = false;
|
|
41
|
+
this.doc.modelTree.nodeLimitExceeded = false;
|
|
42
|
+
}
|
|
43
|
+
this.doc.explorer.renderedNodeMap.clear();
|
|
44
|
+
this.doc.nodeMap.clear();
|
|
45
|
+
this.doc.nodeIdMap.clear();
|
|
46
|
+
this.doc.nodeIdHashMap.clear();
|
|
47
|
+
const renderedNodes = new Map();
|
|
48
|
+
graph?.nodesRendered?.forEach((node) => {
|
|
49
|
+
this.doc.explorer.renderedNodeMap.set(node.id, node);
|
|
50
|
+
renderedNodes.set(node.id, node);
|
|
51
|
+
});
|
|
52
|
+
for (let i = 0; i < graph?.nodesRendered?.length; i++) {
|
|
53
|
+
this.doc.renderedNodeMap.set(graph.nodesRendered[i].id, graph.nodesRendered[i]);
|
|
54
|
+
}
|
|
55
|
+
graph?.nodes?.forEach((node) => {
|
|
56
|
+
this.doc.nodeMap.set(node.id, node);
|
|
57
|
+
if (node.idHash.includes('root')) {
|
|
58
|
+
this.doc.nodeIdMap.set('root', node);
|
|
59
|
+
this.doc.nodeIdHashMap.set(node.id, node);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.doc.nodeIdMap.set(node.id, node);
|
|
63
|
+
this.doc.nodeIdHashMap.set(node.idHash, node);
|
|
64
|
+
}
|
|
65
|
+
if (node.filtered) {
|
|
66
|
+
this.doc.filteredNodes.set(node.id, node);
|
|
67
|
+
}
|
|
68
|
+
const renderedNode = this.doc.renderedNodeMap.get(node.id);
|
|
69
|
+
if (this.doc.activeNode?.id === node.id && this.doc.renderedNodeMap.get(node.id)) {
|
|
70
|
+
if (this.doc.renderedNode && renderedNode) {
|
|
71
|
+
this.doc.renderedNode.node = renderedNode;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
this.doc.graphBag?.set(GraphBag, graph);
|
|
76
|
+
this.doc.explorer.updateGraphResponse(graph);
|
|
77
|
+
if (graph && graph.nodes) {
|
|
78
|
+
this.doc.modelTree.node = graph?.nodesRendered[0]; // update tree
|
|
79
|
+
}
|
|
80
|
+
if (!this.doc.explorer.equalizer.isInitialized()) {
|
|
81
|
+
this.doc.explorer.equalizer.initializeEqualizer();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.doc.explorer.equalizer.runEQ(true);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TheDoctor } from "../components/the-doctor/the-doctor.js";
|
|
2
|
+
import { DocumentReference, NodeClickedEvent, NodeReferenceEvent } from "../events/doctor.js";
|
|
3
|
+
export declare class NodeClickerController extends EventTarget {
|
|
4
|
+
doc: TheDoctor;
|
|
5
|
+
constructor(doc: TheDoctor);
|
|
6
|
+
rolodexTreeNodeClicked(evt: CustomEvent<NodeClickedEvent>): void;
|
|
7
|
+
explorerNodeClicked(evt: CustomEvent<NodeClickedEvent>, replaceRenderedNode?: boolean): void;
|
|
8
|
+
modelTreeNodeClicked(evt: CustomEvent<NodeClickedEvent>): void;
|
|
9
|
+
explorerReferenceClicked(evt: CustomEvent<NodeReferenceEvent>): void;
|
|
10
|
+
documentReferenceClicked(evt: CustomEvent<DocumentReference>): void;
|
|
11
|
+
}
|