Commit 9d794d0b authored by svilayphiou's avatar svilayphiou
Browse files

When clicking on a folder, it gets the new files/folders at the end of

the existing tree.

Blob access works in the console but not in the DOM.
parent cc841e14
......@@ -40,12 +40,16 @@
<h3>Tree</h3>
<ul v-for="blob in fileList">
<li v-bind:class="blob.type">
<a v-on:click="folder(blob.path)" href="#">
<a v-on:click.prevent="folder(blob.path)" href="#">
<!-- v-on:click.prevent="file(blob.id)" -->
<span v-if="blob.type === 'tree'"></span>
[[ blob.name ]]
</a>
</li>
</ul>
<div id="blob">
[[ bloup ]]
</div>
</section>
<section id="commits" class="repo-views">
......@@ -97,11 +101,11 @@
// T R E E
var fileList = [];
var bloup = "*";
var treeURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?per_page=100";
fetch(treeURL).then(function(resp){ return resp.json(); })
.then(function(data){
return data.map(function(file) {
console.log(file);
fileList.push(file);
})
})
......@@ -109,7 +113,8 @@
var treeApp = new Vue({
el: '#tree',
data: {
fileList
fileList,
bloup
},
delimiters: ['[[',']]'],
methods: {
......@@ -117,13 +122,25 @@
var treeURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?per_page=100&path="+ path;
fetch(treeURL).then(function(resp){ return resp.json(); })
.then(function(data){
fileList = [];
return data.map(function(file) {
fileList.push(file);
console.log(fileList);
})
})
},
file: function(blobID){
console.log(this);
let blobURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/blobs/" + blobID + "/raw";
console.log(blobURL);
fetch(blobURL).then((resp) => resp.blob())
.then(function(data){
console.log(data)
var reader = new FileReader();
reader.readAsText(data);
reader.onloadend=function(){
bloup = reader.result;
};
console.log(bloup);
})
}
}
})
......
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