
import { ConfigurationApplication } from "./src/configuration"
import "./css/styles.css"
import { Model } from "../globular-mvc/src/Model"
import { HasRuningProcessRequest } from "globular-web-client/lib/admin/admin_pb"
import { HasRuningProcessResponse } from "globular-web-client/lib/admin/admin_pb"

function hasRuningProcess(name: string, callback:(result: boolean)=>void){
    let rqst: HasRuningProcessRequest
    rqst.setName(name)

    Model.globular.adminService.hasRuningProcess(rqst)
    .then((rsp:HasRuningProcessResponse)=>{
        callback(rsp.getResult())
    })
    .catch((err:any)=>{
        console.log(err)
        callback(false)
    })
}

/**
 * The main entry point of an applicaition.
 */
function main() {

    // The application.
    /*
    let application = new ConfigurationApplication();
    
    // Connected to the backend.
    application.init(() => {

    }, (err: any) => {
        console.log(err)
    })
    */
    
    // First thing I will do is test if the server is configure...
    let model = new Model
    model.init(()=>{
        // Test if mongoDB is running...
        hasRuningProcess("mongod", ()=>{

        })
        
    }, (err:any)=>{

    })
}

/**
 * The main function will be call a the end of document initialisation.
 */
document.addEventListener("DOMContentLoaded", function (event) {
    main()
})
