-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
217 lines (205 loc) · 8.82 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Voila embed</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.0.17/vuetify.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.0.17/vuetify.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet">
<script src="voila-embed.js"></script>
</head>
<body>
<div id="app">
<v-app>
<v-layout>
<v-navigation-drawer v-model="showNavBar" absolute app>
<v-toolbar flat>
<v-list>
<v-list-item>
<v-list-item-title class="title">
Navigation
</v-list-item-title>
</v-list-item>
</v-list>
</v-toolbar>
<v-divider></v-divider>
<v-list dense class="pt-0">
<v-list-item v-for="item in items" :key="item.title" :href="item.url"
target="_blank">
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
<v-divider></v-divider>
<jupyter-widget-embed
style="margin-top: 40px"
voila-url="http://localhost:8000"
notebook="bqplot_vuetify_example.ipynb"
mount-id="histogram_bins2"
></jupyter-widget-embed>
</v-navigation-drawer>
<v-app-bar app absolute>
<v-app-bar-nav-icon
v-if="!showNavBar"
@click.stop="showNavBar = !showNavBar"
></v-app-bar-nav-icon>
<v-toolbar-title>{{ title }}</v-toolbar-title>
</v-app-bar>
<v-content>
<jupyter-widget-embed
voila-url="http://localhost:8000"
notebook="bqplot_vuetify_example.ipynb"
mount-id="content-main"
></jupyter-widget-embed>
<jupyter-widget-embed
voila-url="http://localhost:8000"
notebook="notebook2.ipynb"
mount-id="dialog"
></jupyter-widget-embed>
<v-card v-if="sliderModel" class="ma-4 mx-auto" width="600">
<v-card-title class="headline">Access widget models from the page</v-card-title>
<v-card-text>
<v-row style="height: 60px">
<v-col cols="3">
<v-chip class="px-2">bins: {{ bins }}</v-chip>
</v-col>
<v-col class="flex-grow-1">
<v-slider v-model="bins" hide-details></v-slider>
</v-col>
</v-row>
<v-row class="align-center">
<v-col cols="3">
<jupyter-widget-embed
voila-url="http://localhost:8000"
notebook="notebook2.ipynb"
mount-id="event_demo"
></jupyter-widget-embed>
</v-col>
<v-col class="flex-grow-1">
<v-btn @click="sendClickEvent" class="mr-2">Send click event</v-btn>
<v-btn @click="sendCustomEvent">Send custom event</v-btn>
</v-col>
</v-row>
<v-row class="align-center">
<v-col cols="3">
<jupyter-widget-embed
voila-url="http://localhost:8000"
notebook="notebook2.ipynb"
mount-id="template_event_demo"
></jupyter-widget-embed>
</v-col>
<v-col class="flex-grow-1">
<v-btn @click="sendClickEventTemplate">Send click event (template)</v-btn>
</v-col>
</v-row>
</v-card-text>
</v-card>
<v-card v-if="sliderModel" class="ma-4 mx-auto" width="600">
<v-card-title class="headline">Debug</v-card-title>
<v-card-text>
<jupyter-widget-embed
voila-url="http://localhost:8000"
notebook="notebook2.ipynb"
mount-id="out"
></jupyter-widget-embed>
</v-card-text>
</v-card>
</v-content>
</v-layout>
</v-app>
</div>
<script>
new Vue({
vuetify: new Vuetify({
icons: {
iconfont: 'md',
},
}),
el: '#app',
data() {
return {
showNavBar: null,
url: 'https://www.w3schools.com/',
items: [
{icon: "dashboard", title: "voila", url: "https://github.com/voila-dashboards/voila"},
{icon: "touch_app", title: "voila-vuetify", url: "https://github.com/voila-dashboards/voila-vuetify"},
{icon: "web", title: "ipvuetify", url: "https://github.com/mariobuikhuizen/ipyvuetify"},
{icon: "web", title: "vuetify", url: "https://v15.vuetifyjs.com/en/"},
{icon: "widgets", title: "jupyter widgets", url: "https://github.com/jupyter-widgets/ipywidgets"},
{icon: "bar_chart", title: "bqplot", url: "https://github.com/bloomberg/bqplot/"},
],
title: 'Voilà embed',
sliderModel: null,
bins: null,
eventDemoModel: null,
templateEventDemoModel: null,
}
},
created() {
/* Get the widgets models. These are backbone.js models, see
* https://backbonejs.org/#Model for more information */
requestWidget({
voilaUrl: 'http://localhost:8000',
notebook: 'bqplot_vuetify_example.ipynb',
mountId: 'histogram_bins2',
}).then(sliderModel => {
this.sliderModel = sliderModel;
/* sync widget model changes to the vue model */
this.bins = sliderModel.get('v_model');
sliderModel.on('change:v_model', () => {
this.bins = sliderModel.get('v_model')
});
});
requestWidget({
voilaUrl: 'http://localhost:8000',
notebook: 'notebook2.ipynb',
mountId: 'event_demo',
}).then(eventDemoModel => {
this.eventDemoModel = eventDemoModel;
});
requestWidget({
voilaUrl: 'http://localhost:8000',
notebook: 'notebook2.ipynb',
mountId: 'template_event_demo',
}).then(templateEventDemoModel => {
this.templateEventDemoModel = templateEventDemoModel;
});
},
watch: {
/* sync vue model change to the widget model */
bins(value) {
if (this.sliderModel && value !== null) {
this.sliderModel.set('v_model', value);
this.sliderModel.save_changes();
}
},
},
methods: {
sendClickEvent() {
this.eventDemoModel.send({
event: 'click',
data: {},
});
},
sendCustomEvent() {
this.eventDemoModel.send({
type: 'custom',
time: new Date().toISOString().substr(11, 8),
});
},
sendClickEventTemplate() {
this.templateEventDemoModel.send({
event: 'my_click',
data: {},
});
}
},
});
</script>
</body>
</html>