示例#1
0
def frontend_routes_templating(app=None):
    if not app:
        app = get_app_for_cmd(with_external_mods=False)
    log.info('Generating frontend routing')
    from geonature.utils.env import list_frontend_enabled_modules
    with open(
        str(ROOT_DIR / 'frontend/src/app/routing/app-routing.module.ts.sample'),
        'r'
    ) as input_file:
        template = Template(input_file.read())
        routes = []
        for url_path, module_code in list_frontend_enabled_modules(app):
            location = Path(GN_EXTERNAL_MODULE / module_code.lower())

            # test if module have frontend
            if (location / 'frontend').is_dir():
                path = url_path.lstrip('/')
                location = '{}/{}#GeonatureModule'.format(
                    location, GN_MODULE_FE_FILE
                )
                routes.append(
                    {'path': path, 'location': location, 'module_code': module_code}
                )

            # TODO test if two modules with the same name is okay for Angular

        route_template = template.render(routes=routes)

        with open(
            str(ROOT_DIR / 'frontend/src/app/routing/app-routing.module.ts'), 'w'
        ) as output_file:
            output_file.write(route_template)

    log.info("...%s\n", MSG_OK)
示例#2
0
def frontend_routes_templating():
    from geonature.utils.env import list_frontend_enabled_modules
    from geonature.core.gn_commons.models import TModules
    with open(
            str(ROOT_DIR /
                'frontend/src/app/routing/app-routing.module.ts.sample'),
            'r') as input_file:
        template = Template(input_file.read())
        routes = []
        for conf, manifest in list_frontend_enabled_modules():
            location = Path(GN_EXTERNAL_MODULE / manifest['module_name'])
            # test if module have frontend
            if (location / 'frontend').is_dir():
                path = conf['api_url'].lstrip('/')
                location = '{}/{}#GeonatureModule'.format(
                    location.resolve(), GN_MODULE_FE_FILE)
                routes.append({
                    'path': path,
                    'location': location,
                    'id_module': conf['id_application']
                })

            # TODO test if two modules with the same name is okay for Angular

        route_template = template.render(routes=routes)

        with open(
                str(ROOT_DIR /
                    'frontend/src/app/routing/app-routing.module.ts'),
                'w') as output_file:
            output_file.write(route_template)
示例#3
0
def tsconfig_app_templating(app=None):
    if not app:
        app = get_app_for_cmd(with_external_mods=False)
    log.info("Generating tsconfig.app.json")
    from geonature.utils.env import list_frontend_enabled_modules

    with open(str(ROOT_DIR / "frontend/src/tsconfig.app.json.sample"),
              "r") as input_file:
        template = Template(input_file.read())
        routes = []
        for url_path, module_code in list_frontend_enabled_modules(app):
            location = Path(GN_EXTERNAL_MODULE / module_code.lower())

            # test if module have frontend
            if (location / "frontend").is_dir():
                location = "{}/frontend/app".format(location)
                routes.append({"location": location})

            # TODO test if two modules with the same name is okay for Angular

        route_template = template.render(routes=routes)

        with open(str(ROOT_DIR / "frontend/src/tsconfig.app.json"),
                  "w") as output_file:
            output_file.write(route_template)

    log.info("...%s\n", MSG_OK)
示例#4
0
def frontend_routes_templating(app=None):
    if not app:
        app = get_app_for_cmd(with_external_mods=False)

    log.info("Generating frontend routing")
    # recuperation de la configuration
    configs_gn = load_config(get_config_file_path())

    from geonature.utils.env import list_frontend_enabled_modules

    with open(
            str(ROOT_DIR /
                "frontend/src/app/routing/app-routing.module.ts.sample"),
            "r") as input_file:
        template = Template(input_file.read())
        routes = []
        for url_path, module_code in list_frontend_enabled_modules(app):
            location = Path(GN_EXTERNAL_MODULE / module_code.lower())

            # test if module have frontend
            if (location / "frontend").is_dir():
                path = url_path.lstrip("/")
                location = "{}/{}#GeonatureModule".format(
                    location, GN_MODULE_FE_FILE)
                routes.append({
                    "path": path,
                    "location": location,
                    "module_code": module_code
                })

            # TODO test if two modules with the same name is okay for Angular

        route_template = template.render(
            routes=routes,
            enable_user_management=configs_gn["ACCOUNT_MANAGEMENT"].get(
                "ENABLE_USER_MANAGEMENT"),
            enable_sign_up=configs_gn["ACCOUNT_MANAGEMENT"].get(
                "ENABLE_SIGN_UP"),
        )

        with open(
                str(ROOT_DIR /
                    "frontend/src/app/routing/app-routing.module.ts"),
                "w") as output_file:
            output_file.write(route_template)

    log.info("...%s\n", MSG_OK)
示例#5
0
def frontend_routes_templating(app=None):
    if not app:
        app = get_app_for_cmd(with_external_mods=False)
    log.info('Generating frontend routing')
    from geonature.utils.env import list_frontend_enabled_modules
    with open(
            str(ROOT_DIR /
                'frontend/src/app/routing/app-routing.module.ts.sample'),
            'r') as input_file:
        template = Template(input_file.read())
        routes = []
        for url_path, module_code in list_frontend_enabled_modules(app):
            location = Path(GN_EXTERNAL_MODULE / module_code.lower())

            # test if module have frontend
            if (location / 'frontend').is_dir():
                path = url_path.lstrip('/')
                location = '{}/{}#GeonatureModule'.format(
                    location, GN_MODULE_FE_FILE)
                routes.append({
                    'path': path,
                    'location': location,
                    'module_code': module_code
                })

            # TODO test if two modules with the same name is okay for Angular

        route_template = template.render(routes=routes)

        with open(
                str(ROOT_DIR /
                    'frontend/src/app/routing/app-routing.module.ts'),
                'w') as output_file:
            output_file.write(route_template)

    log.info("...%s\n", MSG_OK)