package wa.server;

import zutil.io.file.FileUtil;
import zutil.log.CompactLogFormatter;
import zutil.log.LogUtil;
import zutil.net.http.HttpServer;
import zutil.net.http.page.HttpFilePage;
import zutil.plugin.PluginManager;

import java.util.logging.Level;
import java.util.logging.Logger;

public class WebAdminServer {
    private static Logger log = LogUtil.getLogger();

    private PluginManager pluginManager;

    public static void main(String[] args){
        LogUtil.setGlobalLevel(Level.FINEST);
        LogUtil.setGlobalFormatter(new CompactLogFormatter());

        new WebAdminServer();
    }

    public WebAdminServer(){
        try {
            pluginManager = new PluginManager();

            HttpServer http = new HttpServer(80);
            http.setPage("/", new WAAbstractPage(pluginManager));
            //http.setPage("status", new StatusPage(pluginManager));
            //http.setPage("service", new ServicePage(pluginManager));
            //http.setPage("servicestatus", new ServiceStatusPage(pluginManager));
            //http.setPage("config", new ConfigPage(pluginManager));
            http.setDefaultPage(new HttpFilePage(FileUtil.find("WebContent/")));
            http.start();

        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
