Commit 3da7d66a authored by Matija Obreza's avatar Matija Obreza

Package existing tree data with the app, append to menu

parent ed137ffd
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
// devserver configuration
const HOST = process.env.HOST || 'localhost';
......@@ -25,7 +26,7 @@ module.exports = {
warnings: true,
errors: true,
},
clientLogLevel: "warning",
clientLogLevel: 'warning',
},
module: {
rules: [
......@@ -51,7 +52,8 @@ module.exports = {
plugins: [
new ExtractTextPlugin('styles.css'),
new webpack.optimize.UglifyJsPlugin(),
new CopyWebpackPlugin([ 'trees/**' ]),
new HtmlWebpackPlugin({template: './index.html'}),
new webpack.ProvidePlugin({$: "jquery", jQuery: "jquery", d3: "d3", _: "underscore"})
new webpack.ProvidePlugin({$: 'jquery', jQuery: 'jquery', d3: 'd3', _: 'underscore'})
]
};
......@@ -14,9 +14,10 @@
<li>
<a href="#">Load tree</a>
<ul class="menu vertical" id="existing-trees">
<li><a href="#" class="load-tree" x-url="wheat.json">Wheat #1</a></li>
<li><a href="#" class="load-tree">TBD</a></li>
<!-- Filled -->
<!-- <li><a href="#" class="load-tree" x-url="wheat.json">Wheat #1</a></li>
<li><a href="#" class="load-tree">TBD</a></li>
<li><a href="#" class="load-tree">TBD</a></li> -->
</ul>
</li>
<li>
......
This diff is collapsed.
......@@ -12,7 +12,9 @@ import '../src/d3-context-menu';
import {draw_tree, create_node, rename_node} from './dndTree';
const TREE_BASE_URL = 'https://gitlab.croptrust.org/genesys-pgr/diversity-tree-editor/raw/master/trees/';
import { MENU_TREES } from './menu/trees';
const TREE_BASE_URL = 'trees/';
const ax = axios.create({
baseURL: TREE_BASE_URL,
......@@ -29,6 +31,11 @@ const ax = axios.create({
$('document').ready(function() {
$(document).foundation();
for (const menuItem of MENU_TREES) {
console.log('Appending', menuItem);
$('#existing-trees').append($(`<li><a href="#" class="load-tree" x-url="${menuItem.url}">${menuItem.title}</a></li>`));
}
$(document).on('opened', '[data-reveal]', function() {
var element = $(".inputName:visible").first();
element.focus(function() {
......@@ -73,7 +80,8 @@ $('document').ready(function() {
url: url,
method: 'GET',
}).then((r) => {
draw_tree($('#tree-container'), r);
// console.log('Response', r);
draw_tree($('#tree-container'), r.data);
}).catch((error) => {
console.log(error);
});
......
// Existing trees menu
const MENU_TREES = [
{ title: 'Wheat', url: 'wheat.json' },
// Add items here
];
export { MENU_TREES };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment