-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
329 lines (309 loc) · 8.74 KB
/
App.vue
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<template>
<loading v-if="loading" data-qa="tapestry-loading" style="height: 75vh;"></loading>
<div v-else id="app">
<!-- <div class="prompt-container" v-if="promptButtonClicked">
<form @submit="submitUserInput">
<button type="submit" class="prompt-submit-button">
</button>
<textarea class="prompt-text-field" v-model="userInput" rows="5" cols="40" placeholder="Enter a text prompt up to 1000 words to generate a Tapestry (e.g. Machine learning in the workplace). Do not use the ~ character in your text."></textarea>
</form>
<textarea class="lo-text-field" placeholder="Specify learning objectives (prompt) for the Tapestry"> </textarea>
</div>
<div>
<form @submit="deleteNodes">
<button type="submit" class="delete-submit-button">
Delete All Nodes
</button>
</form>
</div>
<div id="loading" v-if="generatingTapestry">
<img :src="LoadingGif" alt="Loading..."/>
</div> -->
<tapestry-app></tapestry-app>
<!-- <div
v-if="dropButtonClicked"
class="dropzone"
:class="{ 'dragging': dragging }"
@dragover.prevent
@dragenter="dragging = true"
@dragleave="dragging = false"
@drop="handleDrop"
>
Drag and drop a PDF file here or
<br>
<div v-if="droppedFileName">Dropped file: {{ droppedFileName }}</div>
<div>
<input type="file" ref="fileInput" style="display: none" @change="handleFileSelect"/>
<button class="select-pdf-button" @click="openFileInput">Select PDF File</button>
</div>
</div> -->
<!-- <div class="white-box">
A default connection between nodes is represented in <span class="navy-blue">navy blue</span><br>
The color of the connection represents the strength of the relevancy between grandchild nodes. It represents a correlation number - note that this number is generated by ChatGPT-3.5 after comparing the similarity of texts between two nodes.
<br>
<span class="correlation-text">Lower correlation</span> <span class="lighter-blue">70-79</span> <span class="medium-blue">80-89</span> <span class="darker-blue">90-100</span> <span class="correlation-text">Highest correlation</span>
</div> -->
<router-view></router-view>
<node-modal></node-modal>
<link-modal></link-modal>
<lightbox v-if="viewingNode" :node-id="nodeId"></lightbox>
<sidebar v-if="!isEmpty"></sidebar>
<tapestry-error></tapestry-error>
<b-modal
id="loggedOutModal"
:visible="!loggedIn"
title="Not Logged In"
no-close-on-backdrop
>
You can either refresh and stay logged out or log in again.
<template #modal-footer>
<b-button @click="refresh">Refresh</b-button>
<b-button @click="redirectToLogin">Log In</b-button>
</template>
</b-modal>
</div>
</template>
<script>
import { mapState, mapMutations, mapGetters, mapActions } from "vuex"
import { names } from "@/config/routes"
import Lightbox from "@/components/Lightbox"
import LinkModal from "@/components/modals/LinkModal"
import NodeModal from "@/components/modals/NodeModal"
import TapestryApp from "@/components/TapestryApp"
import Sidebar from "@/components/Sidebar"
import TapestryError from "@/components/TapestryError"
import Loading from "@/components/common/Loading"
import client from "@/services/TapestryAPI"
import { isLoggedIn } from "./services/wp"
import axios from 'axios'
import "@/assets/styles/themes.css"
export default {
name: "app",
components: {
Loading,
Lightbox,
NodeModal,
LinkModal,
TapestryApp,
Sidebar,
TapestryError,
},
data() {
return {
loading: true,
loggedIn: true,
userInput: "", // taking in user input data
generatingTapestry: false,
promptButtonClicked: false,
dropButtonClicked: false,
dragging: false,
droppedFileName: '',
}
},
computed: {
...mapState(["nodes", "rootId", "links", "highlightedLinks"]),
...mapGetters(["getTheme", "getNeighbouringLinks"]),
isEmpty() {
return Object.keys(this.nodes).length === 0
},
nodeId() {
return this.$route.params.nodeId
},
viewingNode() {
return (
this.$route.name === names.LIGHTBOX || this.$route.query.from === "lightbox"
)
},
},
// watch: {
// loggedIn(isStillLoggedIn) {
// if (!isStillLoggedIn) {
// this.$bvModal.show("loggedOutModal")
// }
// },
// },
mounted() {
// if (isLoggedIn()) {
// var that = this
// jQuery(function($) {
// wp.heartbeat.interval("fast")
// $(document).on("heartbeat-tick", function(event, data) {
// that.loggedIn = data["wp-auth-check"]
// })
// })
// }
window.addEventListener("click", this.recordAnalytics)
const data = [
client.getTapestry(),
client.getLastSelectedNode(),
client.getTheme(),
]
Promise.all(data).then(([tapestryData, selectedNode, theme]) => {
this.changeTheme(theme.data)
if (this.getTheme == "system") {
const isDarkMode =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
document.documentElement.setAttribute(
"data-theme",
isDarkMode ? "dark" : "light"
)
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", e => {
document.documentElement.setAttribute(
"data-theme",
e.matches ? "dark" : "light"
)
})
} else {
document.documentElement.setAttribute("data-theme", this.getTheme)
}
this.init(tapestryData)
this.loading = false
if (!this.$route.params.nodeId && tapestryData.nodes.length > 0) {
let path = `/nodes/${tapestryData.rootId}`
if (selectedNode) {
path = `/nodes/${selectedNode.nodeId}`
if (selectedNode.rowId) {
path = `${path}/view/${selectedNode.rowId}`
}
}
this.$router.push({
path,
query: this.$route.query,
})
}
})
},
beforeDestroy() {
window.removeEventListener("click", this.recordAnalytics)
},
methods: {
...mapMutations(["init", "changeTheme"]),
...mapActions(["deleteNode", "deleteLink"]),
refresh() {
this.$router.go()
},
redirectToLogin() {
window.location.href = `${window.location.origin}/wp-login.php?redirect_to=${window.location.href}`
},
recordAnalytics(evt) {
const x = evt.clientX + window.pageXOffset
const y = evt.clientY + window.pageYOffset
client.recordAnalyticsEvent("user", "click", "screen", null, {
x: x,
y: y,
})
},
}
}
</script>
<style lang="scss">
html {
#loading {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.5);
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
}
font-size: 100%;
body.single-tapestry {
background: var(--bg-color-primary);
.site-title a:link,
.site-title a:visited {
color: var(--text-color-secondary);
}
a:link,
a:visited {
color: var(--highlight-color);
}
}
#app {
color: var(--text-color-primary);
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
li {
line-height: initial;
}
h1,
h2,
h3,
h4,
h5 {
&::before {
display: none;
}
}
button:focus {
outline: none;
}
.btn {
&:disabled,
&.disabled {
* {
opacity: 50%;
}
}
}
}
// .white-box {
// height: 200px;
// width: 500px;
// border-radius: 10px;
// background-color: white;
// color: #77AEBF;
// justify-content: center;
// font-weight: lighter;
// top: 50%;
// margin-right: 10px;
// }
// .navy-blue {
// color:#006C92;
// font-weight: bold;
// }
// .lighter-blue {
// color: #77AEBF;
// font-size: 20px;
// font-weight: 1000;
// }
// .medium-blue {
// color: #1DADE1;
// font-size: 20px;
// font-weight: 1000;
// }
// .darker-blue {
// color: #006C92;
// font-size: 20px;
// font-weight: 1000;
// }
// .correlation-text {
// color: #59595B;
// font-size: 15px;
// }
}
</style>
<style lang="scss" scoped>
#loading {
background-color: white;
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
}
</style>