Adds axios and initial call.

This commit is contained in:
Jacob Schatz 2017-06-17 02:28:17 -04:00
parent 687ec90727
commit bf405af425
7 changed files with 82 additions and 2 deletions

View file

@ -1,4 +1,14 @@
/* global monaco */
import Sidebar from './repo_sidebar'
import Service from './repo_service'
class RepoBundle {
constructor(id, url) {
this.service = Service;
this.service.url = url;
this.sidebar = new Sidebar(url);
}
}
window.require.config({ paths: { vs: '/monaco-editor/min/vs' } });
window.require(['vs/editor/editor.main'], () => {
@ -7,3 +17,10 @@ window.require(['vs/editor/editor.main'], () => {
language: 'javascript',
});
});
document.addEventListener('DOMContentLoaded', ()=> {
const ideRoot = document.getElementById('ide');
const bundle = new RepoBundle(
ideRoot,
ideRoot.dataset.url
);
});

View file

@ -0,0 +1,15 @@
import axios from 'axios';
let RepoService = {
url: '',
setUrl(url) {
this.url = url;
},
getTree() {
return axios.get(this.url);
}
};
export default RepoService;

View file

@ -0,0 +1,26 @@
import Service from './repo_service'
import Vue from 'vue';
export default class RepoSidebar {
constructor(url) {
this.url = url;
this.getTree();
this.initVue();
}
getTree() {
Service.getTree()
.then((response)=> {
console.log('response', response.data);
})
.catch((response)=> {
console.log('error response', response);
});
}
initVue() {
this.vue = new Vue({
});
}
}

View file

@ -12,6 +12,10 @@ module TreeHelper
tree.html_safe
end
def repo_url()
url_for(params.merge(format: :json))
end
# Return an image icon depending on the file type and mode
#
# type - String type of the tree item; either 'folder' or 'file'

View file

@ -1,5 +1,5 @@
.tree-content-holder
#ide{ style: "height:400px;" }
#ide{ data: { url: repo_url }, style: "height:400px;" }
- if tree.readme
= render "projects/tree/readme", readme: tree.readme

View file

@ -12,6 +12,7 @@
"webpack-prod": "NODE_ENV=production webpack --config config/webpack.config.js"
},
"dependencies": {
"axios": "^0.16.2",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-define": "^1.2.0",

View file

@ -233,6 +233,13 @@ aws4@^1.2.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"
axios@^0.16.2:
version "0.16.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.16.2.tgz#ba4f92f17167dfbab40983785454b9ac149c3c6d"
dependencies:
follow-redirects "^1.2.3"
is-buffer "^1.1.5"
babel-code-frame@^6.11.0, babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"
@ -1560,7 +1567,7 @@ debug@2.6.0, debug@^2.1.0, debug@^2.1.1, debug@^2.2.0:
dependencies:
ms "0.7.2"
debug@2.6.7:
debug@2.6.7, debug@^2.4.5:
version "2.6.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.7.tgz#92bad1f6d05bbb6bba22cca88bcd0ec894c2861e"
dependencies:
@ -2373,6 +2380,12 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
follow-redirects@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.3.tgz#01abaeca85e3609837d9fcda3167a7e42fdaca21"
dependencies:
debug "^2.4.5"
for-in@^0.1.5:
version "0.1.6"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8"
@ -2860,6 +2873,10 @@ is-buffer@^1.0.2:
version "1.1.4"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b"
is-buffer@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
is-builtin-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe"