vue.html 2.93 KB
Newer Older
svilayphiou's avatar
svilayphiou committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    <title>Vue</title>
    
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>
<body>
    <div id="repos">

        <div class="repo" v-for="repo in repos" v-bind:class="repo.archived"  v-bind:key="repo.id">
            <h2>{{repo.name}}</h2>
            <div class='iceberg'>
                <h3>Iceberg</h3>
                <div v-for="image in repo.iceberg">
                    <img v-bind:src="image.src">
                </div>
            </div>
            <!--<div class='processus'>-->
                <!--<h3>Processus</h3>-->
                <!--<img v-for="image in processus">-->
            <!--</div>-->
        </div>
    </div>

    <script type="text/javascript" charset="utf-8">
        var gitlab_url = "http://gitlab.constantvzw.org";
        var user_name = "osp";
        var reposList = [448, 456, 512]
        var repos = []
        

        for (i=0; i < reposList.length; i++) {
            getMetadata(reposList[i]);
            getIceberg(i, reposList[i]);
        }
        document.addEventListener('DOMContentLoaded', function(){
            console.log(repos);
            var reposApp = new Vue({
                el: '#repos',
                data: {
                  repos
                }
              })
        }, false);
        // 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 = {};
                repo.id = repoID;
                repo.repo = data.name;
                repo.name = name.replace(",", " ");
                repo.iceberg = [];

                if (data.default_branch == "archive"){
                    repo.archived = "archived";
                }

                repos.push(repo);
            })
        }
        function getIceberg(i, repoID){
            let icebergURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?path=iceberg";

            fetch(icebergURL).then(function(resp){ return resp.json(); })
            .then(function(data){
                return data.map(function(image) {
                    item = {};
                    item.name = image.name;
                    console.log(repos[i]);
                    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);
                })
            });
        }

    </script>
    
    <script type="text/javascript" charset="utf-8" src="pad.js"> </script>
</body>
</html>