|
|
|
@ -47,6 +47,7 @@ INVALID_FOLDER = """
|
|
|
|
|
#
|
|
|
|
|
# handling cli interface
|
|
|
|
|
cli = typer.Typer()
|
|
|
|
|
cli_theme = typer.Typer()
|
|
|
|
|
|
|
|
|
|
def to_Table(df: pd.DataFrame):
|
|
|
|
|
"""Displays a Pandas DataFrame as a rich table."""
|
|
|
|
@ -359,10 +360,77 @@ def bootup (
|
|
|
|
|
# manifest = os.sep.join([manifest,'qcms-manifest.json'])
|
|
|
|
|
manifest = get_manifest(manifest)
|
|
|
|
|
index.start(manifest,port)
|
|
|
|
|
@cli.command(name='theme')
|
|
|
|
|
@cli_theme .command(name='list')
|
|
|
|
|
def theme_list (
|
|
|
|
|
manifest:Annotated[str,typer.Argument(help="path of the manifest file")],
|
|
|
|
|
# manifest:str= typer.Option(default=None,help="Optional path to a site, otherwise remote themes will be listed"),
|
|
|
|
|
url:str=typer.Option(default="https://dev.the-phi.com/git/qcms/themes.git", help="git/github site where the themes live")
|
|
|
|
|
# remote:bool = typer.Option("--remote/--local",help="print list of themes available (remotely)"),
|
|
|
|
|
) :
|
|
|
|
|
"""
|
|
|
|
|
This function will list themes available remotely in contrast to those installed for a given qcms site
|
|
|
|
|
"""
|
|
|
|
|
# if not manifest :
|
|
|
|
|
_available = themes.List(url)
|
|
|
|
|
# _available = [100]
|
|
|
|
|
# else:
|
|
|
|
|
manifest = get_manifest(manifest)
|
|
|
|
|
_layout = cms.engine.config.get(manifest) ['layout']
|
|
|
|
|
# if manifest.endswith('.json') :
|
|
|
|
|
manifest = os.sep.join(manifest.split(os.sep)[:-1])
|
|
|
|
|
|
|
|
|
|
path = os.sep.join([manifest, _layout['root']])#,'_assets/themes'])
|
|
|
|
|
_installed = themes.Installed(path)
|
|
|
|
|
_df = pd.DataFrame()
|
|
|
|
|
if _available :
|
|
|
|
|
_intCount = len(list(set(_installed) - set(_available)))
|
|
|
|
|
|
|
|
|
|
_installed = [PASSED if _name in _installed else FAILED for _name in _available ]
|
|
|
|
|
_df = pd.DataFrame({'available':_available,'installed':_installed})
|
|
|
|
|
|
|
|
|
|
print ( to_Table(_df))
|
|
|
|
|
if _intCount :
|
|
|
|
|
print (f"{PASSED} found {_intCount } custom theme{'' if _intCount == 1 else 's'} in [bold]{_layout['header']['title']}[/bold]")
|
|
|
|
|
else:
|
|
|
|
|
print (f"{FAILED} unable to list themes, insure the {url} and qcms-site is valid")
|
|
|
|
|
return _df
|
|
|
|
|
@cli_theme .command(name='set')
|
|
|
|
|
def theme_set (
|
|
|
|
|
manifest:Annotated[str,typer.Argument(help="path of the manifest file")],
|
|
|
|
|
name:str = typer.Option(default='default',help='name of the theme to apply'),
|
|
|
|
|
url:str=typer.Option(default="https://dev.the-phi.com/git/qcms/themes.git", help="git/github site where the themes live")
|
|
|
|
|
) :
|
|
|
|
|
manifest = get_manifest(manifest)
|
|
|
|
|
_config = cms.engine.config.get(manifest)
|
|
|
|
|
_layout = _config['layout']
|
|
|
|
|
path = os.sep.join([os.sep.join(manifest.split(os.sep)[:-1]), _layout['root']])#,'_assets/themes'])
|
|
|
|
|
task = []
|
|
|
|
|
# _msg = ""
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
# _df = theme_list(manifest)
|
|
|
|
|
_installed = themes.Installed(path)
|
|
|
|
|
|
|
|
|
|
if name not in _installed :
|
|
|
|
|
themes.Get(name,path)
|
|
|
|
|
_config['system']['theme'] = name
|
|
|
|
|
cms.engine.config.write(_config,manifest)
|
|
|
|
|
task.append("installed")
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
task.append( "updated")
|
|
|
|
|
themes.UpdateTheme (path,name,url)
|
|
|
|
|
_msg = f"{PASSED} successfully {'/'.join(task)} [bold] {name} [/bold] to [bold] {_layout['header']['title']}[/bold]"
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print (e)
|
|
|
|
|
_msg = f"{FAILED} unable to set theme [bold] {name} [/bold] to {_layout['header']['title']}"
|
|
|
|
|
pass
|
|
|
|
|
print (_msg)
|
|
|
|
|
pass
|
|
|
|
|
def handle_theme (
|
|
|
|
|
manifest:Annotated[str,typer.Argument(help="path of the manifest file")],
|
|
|
|
|
show:bool = typer.Option(default=False,help="print list of themes available"),
|
|
|
|
|
show:bool = typer.Option(default=False,help="print list of themes available (remotely)"),
|
|
|
|
|
name:str = typer.Option(default='default',help='name of the theme to apply')
|
|
|
|
|
) :
|
|
|
|
|
"""
|
|
|
|
@ -375,6 +443,7 @@ def handle_theme (
|
|
|
|
|
|
|
|
|
|
if show :
|
|
|
|
|
_available = themes.List()
|
|
|
|
|
|
|
|
|
|
_df = pd.DataFrame({"available":_available})
|
|
|
|
|
# if _df.shape[0] > 0 :
|
|
|
|
|
if _available :
|
|
|
|
@ -427,4 +496,5 @@ def handle_theme (
|
|
|
|
|
|
|
|
|
|
global SYS_ARGS
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
cli.add_typer(cli_theme,name="themes",help="manage themes associated with a site")
|
|
|
|
|
cli()
|
|
|
|
|