Commit 27370198 authored by svilayphiou's avatar svilayphiou
Browse files

browsing in and up folders

parent a5402dfe
......@@ -38,6 +38,7 @@
</section>
<section id="tree" class="repo-views" >
<h3>Tree</h3>
<a href="#" v-on:click.prevent="tree('up', upPath)">↑↑ Parent directory</a>
<ul v-for="blob in fileList">
<li v-bind:class="blob.type">
<a v-on:click.prevent="tree(blob.type, blob.path, blob.id)" href="#">
......@@ -99,6 +100,7 @@
// T R E E
var fileList = [];
var formerTree = [];
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){
......@@ -111,22 +113,37 @@
el: '#tree',
data: {
fileList,
bloup: "?"
upPath: "/",
bloup: "?",
},
delimiters: ['[[',']]'],
methods: {
tree: function(type, path, blobID){
vm = this;
if (type == "tree") {
currentPath = path;
var treeURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?per_page=100&path="+ path;
fileList.splice(0);
vm.fileList.splice(0);
fetch(treeURL).then(function(resp){ return resp.json(); })
.then(function(data){
return data.map(function(file) {
fileList.push(file);
vm.fileList.push(file);
})
})
} else {
} else if (type == "up") {
upPath = currentPath.split("/");
upPath.pop();
currentPath = upPath.join("");
var treeURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?per_page=100&path="+ upPath;
vm.fileList.splice(0);
fetch(treeURL).then(function(resp){ return resp.json(); })
.then(function(data){
return data.map(function(file) {
vm.fileList.push(file);
})
})
} else if (type == "blob") {
let blobURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/blobs/" + blobID + "/raw";
fetch(blobURL).then((resp) => resp.blob())
.then(function(data){
......@@ -146,8 +163,6 @@
})
}
},
file: function(blobID){
}
}
})
......
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