blob: d0181eedeaa67c431c068ceb019389933b275332 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
import { makeAutoObservable } from 'mobx';
import GraphStore from '../graph/GraphStore';
import type { SemanticsSuccessResult } from '../xtext/xtextServiceResults';
export default class GeneratedModelStore {
title: string;
message = 'Waiting for server';
error = false;
graph: GraphStore | undefined;
constructor() {
const time = new Date().toLocaleTimeString(undefined, { hour12: false });
this.title = `Generated at ${time}`;
makeAutoObservable(this);
}
get running(): boolean {
return !this.error && this.graph === undefined;
}
setMessage(message: string): void {
if (this.running) {
this.message = message;
}
}
setError(message: string): void {
if (this.running) {
this.error = true;
this.message = message;
}
}
setSemantics(semantics: SemanticsSuccessResult): void {
if (this.running) {
this.graph = new GraphStore();
this.graph.setSemantics(semantics);
}
}
}
|