# -*- encoding: utf-8 -*-
"""
License: MIT
Copyright (c) 2019 - present AppSeed.us
"""

import os
from os import environ


class Config(object):
    basedir = os.path.abspath(os.path.dirname(__file__))

    SECRET_KEY = 'key'

    # This will connect to the FTS db
    SQLALCHEMY_DATABASE_URI = os.getenv(
        "SQLALCHEMY_DATABASE_URI", "sqlite:///./FTSDataBase.db")

    # certificates path
    certpath = os.getenv("FTS_CERTS_PATH", "certs")

    # crt file path
    crtfilepath = f"{certpath}/pubserver.pem"

    # key file path
    keyfilepath = f"{certpath}/pubserver.key.unencrypted"

    # this IP will be used to connect with the FTS API
    IP = os.getenv("FTS_API_IP", "freetakserver")

    # Port the  UI uses to communicate with the API
    PORT = os.getenv("FTS_API_PORT", "19023")

    # the public IP your server is exposing
    APPIP = os.getenv("FTS_PUBLIC_IP", "freetakserver")

    # this port will be used to listen
    APPPort = int(os.getenv("FTS_UI_PORT", 5000))

    # the webSocket  key used by the UI to communicate with FTS.
    WEBSOCKETKEY = 'YourWebsocketKey'

    # the API key used by the UI to comunicate with FTS.
    # generate a new system user and then set it
    APIKEY = 'Bearer token'

    # For 'in memory' database, please use:
    # SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'

    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # THEME SUPPORT
    #  if set then url_for('static', filename='', theme='')
    #  will add the theme name to the static URL:
    #    /static/<DEFAULT_THEME>/filename
    # DEFAULT_THEME = "themes/dark"
    DEFAULT_THEME = None


class ProductionConfig(Config):
    DEBUG = False

    # Security
    SESSION_COOKIE_HTTPONLY = True
    REMEMBER_COOKIE_HTTPONLY = True
    REMEMBER_COOKIE_DURATION = 3600

    # PostgreSQL database
    SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
        environ.get('APPSEED_DATABASE_USER', 'appseed'),
        environ.get('APPSEED_DATABASE_PASSWORD', '<PASSWORD>'),
        environ.get('APPSEED_DATABASE_HOST', 'db'),
        environ.get('APPSEED_DATABASE_PORT', 5432),
        environ.get('APPSEED_DATABASE_NAME', 'appseed')
    )


class DebugConfig(Config):
    DEBUG = True


config_dict = {
    'Production': ProductionConfig,
    'Debug': DebugConfig
}

# -*- encoding: utf-8 -*-
"""
License: MIT
Copyright (c) 2019 - present AppSeed.us
"""

import os
from os import environ


class Config(object):
    basedir = os.path.abspath(os.path.dirname(__file__))

    SECRET_KEY = 'key'

    # This will connect to the FTS db
    SQLALCHEMY_DATABASE_URI = os.getenv(
        "SQLALCHEMY_DATABASE_URI", "sqlite:///./FTSDataBase.db")

    # certificates path
    certpath = os.getenv("FTS_CERTS_PATH", "certs")

    # crt file path
    crtfilepath = f"{certpath}/pubserver.pem"

    # key file path
    keyfilepath = f"{certpath}/pubserver.key.unencrypted"

    # this IP will be used to connect with the FTS API
    IP = os.getenv("FTS_API_IP", "freetakserver")

    # Port the  UI uses to communicate with the API
    PORT = os.getenv("FTS_API_PORT", "19023")

    # the public IP your server is exposing
    APPIP = os.getenv("FTS_PUBLIC_IP", "freetakserver")

    # this port will be used to listen
    APPPort = int(os.getenv("FTS_UI_PORT", 5000))

    # the webSocket  key used by the UI to communicate with FTS.
    WEBSOCKETKEY = 'YourWebsocketKey'

    # the API key used by the UI to comunicate with FTS.
    # generate a new system user and then set it
    APIKEY = 'Bearer token'

    # For 'in memory' database, please use:
    # SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'

    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # THEME SUPPORT
    #  if set then url_for('static', filename='', theme='')
    #  will add the theme name to the static URL:
    #    /static/<DEFAULT_THEME>/filename
    # DEFAULT_THEME = "themes/dark"
    DEFAULT_THEME = None


class ProductionConfig(Config):
    DEBUG = False

    # Security
    SESSION_COOKIE_HTTPONLY = True
    REMEMBER_COOKIE_HTTPONLY = True
    REMEMBER_COOKIE_DURATION = 3600

    # PostgreSQL database
    SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
        environ.get('APPSEED_DATABASE_USER', 'appseed'),
        environ.get('APPSEED_DATABASE_PASSWORD', '<PASSWORD>'),
        environ.get('APPSEED_DATABASE_HOST', 'db'),
        environ.get('APPSEED_DATABASE_PORT', 5432),
        environ.get('APPSEED_DATABASE_NAME', 'appseed')
    )


class DebugConfig(Config):
    DEBUG = True


config_dict = {
    'Production': ProductionConfig,
    'Debug': DebugConfig
}

# -*- encoding: utf-8 -*- License: MIT Copyright (c) 2019 - present AppSeed.us # This will connect to the FTS db # certificates path # crt file path # key file path # this IP will be used to connect with the FTS API # Port the  UI uses to communicate with the API # the public IP your server is exposing # this port will be used to listen # the webSocket  key used by the UI to communicate with FTS. # the API key used by the UI to comunicate with FTS. # generate a new system user and then set it # For 'in memory' database, please use: # SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:' # THEME SUPPORT #  if set then url_for('static', filename='', theme='') #  will add the theme name to the static URL: #    /static/<DEFAULT_THEME>/filename # DEFAULT_THEME = "themes/dark" # Security # PostgreSQL database