Commit 8665b6ae authored by svilayphiou's avatar svilayphiou
Browse files

iceberg is working yay

parent afe41217
......@@ -31,7 +31,7 @@
</section>
<section id="iceberg" class="repo-views">
<h3>Iceberg</h3>
<div v-for="image in repo.iceberg">
<div v-for="image in iceberg">
<img v-bind:src="image.src">
</div>
</section>
......@@ -63,38 +63,19 @@
<script type="text/javascript" charset="utf-8">
var gitlab_url = "http://gitlab.constantvzw.org";
var user_name = "osp";
var repoID = {{ project.id }}
var repo = {}
var repoID = {{ project.id }};
var iceberg = [];
getMetadata(repoID);
getIceberg(repoID);
var reposApp = new Vue({
el: '#repo',
var icebergApp = new Vue({
el: '#iceberg',
data: {
repo
iceberg
}
})
// METADATA ///////////////////////////////
function getMetadata(repoID) {
let repo_url = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID;
fetch(repo_url).then(function(resp){ return resp.json(); })
.then(function(data){
name = data.name.split(".").slice(1);
repo.id = repoID;
repo.repo = data.name;
repo.name = name.replace(",", " ");
repo.iceberg = [];
if (data.default_branch == "archive"){
repo.archived = "archived";
}
})
}
function getIceberg(repoID){
let icebergURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?path=iceberg";
......@@ -103,10 +84,9 @@
return data.map(function(image) {
item = {};
item.name = image.name;
project_path = [gitlab_url, user_name, repo.repo].join('/');
if(repo.archived){ branch = "archive";} else { branch = "master" }
item.src = project_path + "/raw/" + branch + "/" + image.path;
repo.iceberg.push(item);
project_path = [gitlab_url, user_name, "{{ project.name }}"].join('/');
item.src = project_path + "/raw/{{ project.default_branch }}/" + image.path;
iceberg.push(item);
})
});
}
......
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