pipelines.createWindow(() => {

    const View = new ViewWindow({
        title: `<i class="fa fa-code-merge"></i> Gestion des pipelines`,
        width: "900px",
        height: "600px"
    })

    const pipelinesList = new Array()

    View.setContent(`<div style='font-size: 24px; margin-top: 225px;'  class='t-center'>
        <p><i class="fa-solid fa-rotate fa-spin"></i> Chargement en cours ...</p>
    </div>`)

    var AllPipelines = new Array()

    function getPipelines() {

        const pipes = get("PL_GET_ALL")
        pipes.then((ANS_pipes) => {
        
            AllPipelines.length = 0
           pipelinesList.length = 0

            if(ANS_pipes != "UNAVAILABLE") {
                ANS_pipes.jobs.forEach((pipe) => {
                    console.log(pipe)
                    const pipeline = new Pipeline({
                        pipeline: pipe,
                        View: View
                    })
        
                    pipelinesList.push(pipeline.generateHTML())
                    AllPipelines.push(pipeline)
                })
        
                View.setContent(`
                <div class="pipelines">
                    <div id='reload_Btn_pipeline' class='pl-reload'><i class='fa fa-rotate-left'></i> Recharger les pipelines</div>
                    ${pipelinesList.join("")}
                </div>`)

                for(const pipeline of AllPipelines) {
                    pipeline.loadScript()
                }

                getID("reload_Btn_pipeline").addEventListener("click", () => {
                    View.setContent(`<div style='font-size: 24px; margin-top: 225px;'  class='t-center'>
                    <p><i class="fa-solid fa-rotate fa-spin"></i> Chargement en cours ...</p>
                    </div>`)
                    getPipelines()
                })


            } else {
                View.setContent(`<div style='font-size: 24px; margin-top: 225px;'  class='t-center lightred'>
                <p><i class="fa-solid fa-warning"></i> Une erreur est survenue lors du chargement des pipelines</p>
                </div>`)
            }
            
        })
    }

    getPipelines()

})