@@ -245,7 +245,65 @@ export default {
245
245
}
246
246
}
247
247
},
248
+ mounted () {
249
+
250
+ let axios = this .$axios
251
+ this .$data .status = null
252
+ this .pollStatus ();
253
+ setInterval (function () {
254
+ this .pollStatus ();
255
+ }.bind (this ), 1000 )
256
+
257
+
258
+ axios .get (this .$data .CBv1 + ' /config' )
259
+ .then (function (response ) {
260
+ let toolbox = response .data .prog_level
261
+ this .initBlockly (toolbox)
262
+ }.bind (this ))
263
+
264
+ },
248
265
methods: {
266
+ initBlockly : function (toolboxLevel ) {
267
+ const blocklyDiv = this .$refs .blocklyDiv
268
+ // console.log(toolboxLevel)
269
+ var toolbox = require (' ../assets/toolbox_' + toolboxLevel + ' .xml' )
270
+
271
+ // Clean the base64 encoding of the resource, removing meta infos
272
+ var b64Toolbox = toolbox .substring (21 ).toString ()
273
+ // Decode it and get the clean serialized XML as plain string
274
+ var serializedToolbox = this .$base64 .decode (b64Toolbox)
275
+ // Initialise Blockly Instance
276
+ this .$data .workspace = Blockly .inject (
277
+ // Blockly container
278
+ blocklyDiv,
279
+ // Options
280
+ {
281
+ toolbox: serializedToolbox,
282
+ // path : '../../', // ? this makes to load audio assets from /media FIXME
283
+ // TODO: Use values from fetched configuration!
284
+ scrollbars: true ,
285
+ // MaxBlocks : -1, // -1 as infinite not working FIXME
286
+ zoom: {
287
+ controls: true ,
288
+ wheel: false ,
289
+ startScale: 1.0 ,
290
+ maxScale: 1.5 ,
291
+ minScale: 0.2
292
+ }
293
+ }
294
+ );
295
+
296
+ // Pass the reference to the method to call, don't execute it (`()`)
297
+ window .addEventListener (' resize' , this .resizeWorkspace , false );
298
+
299
+ // Initial resize
300
+ this .resizeWorkspace ()
301
+ Blockly .svgResize (this .$data .workspace );
302
+
303
+
304
+
305
+ this .blocksExtensions ();
306
+ },
249
307
toggleSidebar : function () {
250
308
let currentStatus = this .$store .getters .drawerStatus
251
309
this .$store .commit (' toggleDrawer' , ! currentStatus)
@@ -1589,56 +1647,6 @@ export default {
1589
1647
};
1590
1648
}
1591
1649
},
1592
-
1593
- mounted () {
1594
- this .$data .status = null
1595
- this .pollStatus ();
1596
- setInterval (function () {
1597
- this .pollStatus ();
1598
- }.bind (this ), 1000 )
1599
-
1600
- const blocklyDiv = this .$refs .blocklyDiv
1601
- // Should be dependent on the chosen toolbox,
1602
- // possibly an AJAX call if it's a custom toolbox (?)
1603
- var toolbox = require (' ../assets/toolbox_advanced.xml' )
1604
- // Clean the base64 encoding of the resource, removing meta infos
1605
- var b64Toolbox = toolbox .substring (21 ).toString ()
1606
- // Decode it and get the clean serialized XML as plain string
1607
- var serializedToolbox = this .$base64 .decode (b64Toolbox)
1608
-
1609
- // Initialise Blockly Instance
1610
- this .$data .workspace = Blockly .inject (
1611
- // Blockly container
1612
- blocklyDiv,
1613
- // Options
1614
- {
1615
- toolbox: serializedToolbox,
1616
- // path : '../../', // ? this makes to load audio assets from /media FIXME
1617
- // TODO: Use values from fetched configuration!
1618
- scrollbars: true ,
1619
- // MaxBlocks : -1, // -1 as infinite not working FIXME
1620
- zoom: {
1621
- controls: true ,
1622
- wheel: false ,
1623
- startScale: 1.0 ,
1624
- maxScale: 1.5 ,
1625
- minScale: 0.2
1626
- }
1627
- }
1628
- );
1629
-
1630
- // Pass the reference to the method to call, don't execute it (`()`)
1631
- window .addEventListener (' resize' , this .resizeWorkspace , false );
1632
-
1633
- // Initial resize
1634
- this .resizeWorkspace ()
1635
- Blockly .svgResize (this .$data .workspace );
1636
-
1637
-
1638
-
1639
- this .blocksExtensions ();
1640
-
1641
- }
1642
1650
};
1643
1651
1644
1652
</script >
0 commit comments