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

iceberg is working yay

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