Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export tsv files with column header by default #226

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
edadacd
migrated mocha, chai to npm
jshreyans Jan 23, 2020
7e088d9
remove bower related tasks from Gruntfile
jshreyans Jan 23, 2020
83f64ce
delete bower.json and bowerrc
jshreyans Jan 28, 2020
617d6ba
delete bower dependency, remove from package.json
jshreyans Jan 28, 2020
d8d33cb
remove bower related instructions from CONTRIBUTING.md
jshreyans Jan 28, 2020
593fbc3
Update dist files
heralden Jan 28, 2020
7ffde57
add new html to serve im-tables instance
jshreyans Feb 8, 2020
8daaaa4
add inline js pointing to flymine as service root
jshreyans Feb 8, 2020
08e59bb
remove linked umd-consume-global.js file
jshreyans Feb 8, 2020
fb7e63b
change contributing.md for local build
jshreyans Feb 9, 2020
cce75cf
modify npm start to run dev script
jshreyans Feb 10, 2020
6b15677
unstage changes
jshreyans Feb 10, 2020
ec3e79e
remove test task from build
jshreyans Feb 11, 2020
cbe5103
modify watch task
jshreyans Feb 13, 2020
65e1696
add new task to watch with tests
jshreyans Feb 13, 2020
d8860e5
add new script to watch without tests
jshreyans Feb 13, 2020
527398b
register new tasks to watch with tests
jshreyans Feb 13, 2020
4a744d4
remove comment
jshreyans Feb 13, 2020
9fb0bfc
change doc with latest npm configuration
jshreyans Feb 13, 2020
6e52f18
index.html: Use loadDash instead of loadTable to include menu buttons
heralden Feb 18, 2020
dee64e6
Update index.html to use https to fix CORS error
heralden Feb 18, 2020
1b25ded
Rename imtables package to im-tables in Javascript generator
Dhruvi16 Feb 19, 2020
bf3863e
change grunt config
jshreyans Feb 19, 2020
45cc26d
add grunt-concurrent as dev dependency
jshreyans Feb 20, 2020
d2cc370
add options for better logging
jshreyans Feb 20, 2020
0e06f5b
updated contribution guidelines
jshreyans Feb 20, 2020
14a2922
Update server error message
Dhruvi16 Feb 20, 2020
df17928
Update imtables bundles
heralden Feb 21, 2020
a88c3bb
made column headers default
Mar 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .bowerrc

This file was deleted.

21 changes: 18 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ a node environment manager such as [nvm](https://github.com/nvm-sh/nvm)).
We assume you have the following global packages:

- browserify
- bower
- grunt
- coffeescript
- brfs

to install, run:

```sh
npm install -g browserify bower grunt coffeescript brfs
npm install -g browserify grunt coffeescript brfs
```

#### Build library and install dependencies
Expand All @@ -60,16 +59,32 @@ npm install
```

Start a development server, which builds (and rebuilds the test indices) and
serves them to the world (and runs the tests):
serves them to the world:

```sh
npm start
```
To view the running instance, navigate to `localhost:9000`.
Note that this build execute all tests if changes are made to any file while the script is running.

To get a similar instance running in the `watch` mode _without_ any tests, run the script:
```bash
npm run dev
```
Both these builds use Flymine as the service root and hence do not require setting up a local testmine.

### Testing

To use the test indices you will need a data server running the intermine-demo
application at port 8080 on your machine - you can get this by running the
`testmodel/setup.sh` script in the `intermine/intermine` repo.

Apart from this, the current configuration includes a `watchTests` task defined in the [Gruntfile](https://github.com/intermine/im-tables/blob/dev/Gruntfile.js). This can be used to run tests on the project in `watch` mode. Type in the following command into your terminal:
```bash
grunt watchTests
```
The task uses `mocha` (the default testing framework for this project) and will log the test results after any changes are made.

### Coding Style

Code contributed to this library is expected to be coffee-script files, following
Expand Down
38 changes: 29 additions & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-sandbox-css');
grunt.loadNpmTasks('grunt-concurrent');

var env = process.env;

Expand All @@ -17,16 +18,22 @@ var serverPort = (grunt.option('port') || env.PORT || env.npm_package_config_por
var NO_SPAWN = {spawn: false};

grunt.initConfig({
watch: { // Hwat! This task lays out the dependency graph.
watch: {
coffee: {
files: ['src/**', 'templates/**', 'package.json'],
tasks: [
'compile',
'run:test',
'build'
],
options: NO_SPAWN
},
coffee_test: {
files: ['src/**', 'templates/**', 'package.json'],
tasks: [
'run:test',
],
options: NO_SPAWN
},
umd_consumers: {
files: ['test/scripts/**'],
tasks: [
Expand Down Expand Up @@ -108,10 +115,6 @@ grunt.initConfig({
test: {
exec: "mocha --require coffeescript/register test/unit/*"
},
bower_install: {
cmd: 'bower',
args: ['install']
},
bundle_test_indices: {
cmd: './bin/bundle-test-indices'
},
Expand Down Expand Up @@ -175,6 +178,13 @@ grunt.initConfig({
prefix: '.imtables'
}
}
},
concurrent: {
start: ['watchTests', 'serve'],
options: {
logConcurrentOutput: true,
indent: false
}
}
});

Expand All @@ -195,9 +205,15 @@ grunt.registerTask('style', [
'sandbox_css'
]);

grunt.registerTask('watchTests', [
'watch:coffee_test',
'watch:test',
'watch:test_styles',
'watch:indices'
]);

grunt.registerTask('build', [
'build:dist',
'build:test',
'notify:build'
]);

Expand All @@ -210,7 +226,6 @@ grunt.registerTask('build:dist', [
]);

grunt.registerTask('build:test', [
'run:bower_install',
'run:build_custom_style',
'run:compile_umd_consumers',
'run:bundle_test_indices',
Expand All @@ -219,7 +234,12 @@ grunt.registerTask('build:test', [
grunt.registerTask('serve', [
'build',
'run:server',
'watch'
'watch:coffee',
'watch:umd_consumers',
'watch:less',
'notify:build'
]);

grunt.registerTask('start', ['concurrent:start']);

grunt.registerTask('default', ['build']);
39 changes: 0 additions & 39 deletions bower.json

This file was deleted.

2 changes: 1 addition & 1 deletion dist/imtables.js
Original file line number Diff line number Diff line change
Expand Up @@ -5456,7 +5456,7 @@ function getTemplate (name) {
}
// Simple templates we can define inline.
TEMPLATES.clear = '<div style="clear:both"></div>';
exports.code_gen_js = "<% if (asHTML) { %>\n<!-- The Element we will target -->\n<div id=\"some-elem\"></div>\n<!-- The imtables source -->\n<script src=\"<%= imtablesJS %>\" charset=\"UTF-8\"></script>\n<link rel=\"stylesheet\" href=\"<%= imtablesCSS %>\">\n<script>\n<% } %>\n<% if (!asHTML) { %>\n/* Install from npm: npm install imtables\n * This snippet assumes the presence on the page of an element like:\n * <div id=\"some-elem\"></div>\n */\nvar imtables = require('imtables');\n<% } %>\n\nvar selector = '#some-elem';\nvar service = {root: '<%= service.root %>'};\nvar query = <%= JSON.stringify(query, null, 2) %>;\n\nimtables.loadTable(\n selector, // Can also be an element, or a jQuery object.\n <%= JSON.stringify(page) %>, // May be null\n {service: service, query: query} // May be an imjs.Query\n).then(\n function (table) { console.log('Table loaded', table); },\n function (error) { console.error('Could not load table', error); }\n);\n<% if (asHTML) { %>\n</script>\n<% } %>\n";
exports.code_gen_js = "<% if (asHTML) { %>\n<!-- The Element we will target -->\n<div id=\"some-elem\"></div>\n<!-- The imtables source -->\n<script src=\"<%= imtablesJS %>\" charset=\"UTF-8\"></script>\n<link rel=\"stylesheet\" href=\"<%= imtablesCSS %>\">\n<script>\n<% } %>\n<% if (!asHTML) { %>\n/* Install from npm: npm install im-tables\n * This snippet assumes the presence on the page of an element like:\n * <div id=\"some-elem\"></div>\n */\nvar imtables = require('im-tables');\n<% } %>\n\nvar selector = '#some-elem';\nvar service = {root: '<%= service.root %>'};\nvar query = <%= JSON.stringify(query, null, 2) %>;\n\nimtables.loadTable(\n selector, // Can also be an element, or a jQuery object.\n <%= JSON.stringify(page) %>, // May be null\n {service: service, query: query} // May be an imjs.Query\n).then(\n function (table) { console.log('Table loaded', table); },\n function (error) { console.error('Could not load table', error); }\n);\n<% if (asHTML) { %>\n</script>\n<% } %>\n";
exports.select_with_label = "<label><%- Messages.getText(label) %></label>\n\n<% if (options.length) { %>\n <select class=\"form-control\">\n <% _.each(options, function (option) { %>\n <option selected=\"<%= selected(option) ? 'selected' : void 0 %>\"\n value=\"<%- option.name %>\">\n <%- Messages.getText(optionLabel, option) %>\n </option>\n <% }) %>\n </select>\n <% if (helpMessage) { %>\n <span style=\"display:<%= hasProblem ? 'block' : 'none' %>\"\n class=\"help-block\">\n <%- Messages.getText(helpMessage) %>\n </span>\n <% } %>\n<% } else { %>\n <span class=\"help-block\">\n <%- Messages.getText(noOptionsMessage, {model: model}) %>\n </span>\n<% } %>\n\n";
exports.modal_base = "<div class=\"modal-dialog <%- modalSize %>\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <button type=\"button\" class=\"close\">\n <span aria-hidden=\"true\">&times;</span>\n <span class=\"sr-only\">Close</span>\n </button>\n <h4 class=\"modal-title\"><%- title %></h4>\n </div>\n <div class=\"modal-body\">\n <%= body %>\n </div>\n </div>\n</div>\n";
exports.constraints_heading = "<% /* requires constraints.length */ %>\n<h3>\n <%- Messages.getText('constraints.Heading', {n: constraints.length}) %>\n</h3>\n";
Expand Down
2 changes: 1 addition & 1 deletion dist/imtables.min.js

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../dist/main.css">
<script charset="UTF-8"
type="text/javascript"
src="../dist/imtables.js">
</script>
</head>
<body>
<div class="panel panel-default">
<div id="demo"></div>
</div>

<script>
var selector = '#demo';
var service = {root: 'https://www.flymine.org/flymine/service/'};
var query = {
"from": "Gene",
"select": [
"secondaryIdentifier",
"symbol",
"primaryIdentifier",
"organism.name"
],
"orderBy": [
{
"path": "secondaryIdentifier",
"direction": "ASC"
}
]
};
imtables.configure({
TableCell: {
PreviewTrigger: 'hover',
IndicateOffHostLinks: false
}
});

imtables.loadDash(
selector, // Can also be an element, or a jQuery object.
{"start":0,"size":25}, // May be null
{service: service, query: query} // May be an imjs.Query
).then(
function (table) { console.log('Table loaded', table); },
function (error) { console.error('Could not load table', error); }
);
</script>
</body>
</html>
Loading