1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Allow default symbol theme to be configured

This commit is contained in:
grossmj 2022-07-25 20:22:12 +02:00
parent bfbac2e93a
commit 72eb13d941
3 changed files with 22 additions and 2 deletions

View File

@ -49,6 +49,11 @@ symbols_path = /home/gns3/GNS3/symbols
; Path where custom configs are stored ; Path where custom configs are stored
configs_path = /home/gns3/GNS3/configs configs_path = /home/gns3/GNS3/configs
; Default symbol theme
; Currently available themes are "Classic", Affinity-square-blue", "Affinity-square-red"
; "Affinity-square-gray", "Affinity-circle-blue", "Affinity-circle-red" and "Affinity-circle-gray"
default_symbol_theme = Affinity-square-blue
; Option to automatically send crash reports to the GNS3 team ; Option to automatically send crash reports to the GNS3 team
report_errors = True report_errors = True

View File

@ -43,7 +43,9 @@ class Symbols:
# Keep a cache of symbols size # Keep a cache of symbols size
self._symbol_size_cache = {} self._symbol_size_cache = {}
self._current_theme = "Affinity-square-blue"
self._server_config = Config.instance().settings.Server
self._current_theme = self._server_config.default_symbol_theme
self._themes = BUILTIN_SYMBOL_THEMES self._themes = BUILTIN_SYMBOL_THEMES
@property @property
@ -66,7 +68,8 @@ class Symbols:
theme = self._themes.get(symbol_theme, None) theme = self._themes.get(symbol_theme, None)
if not theme: if not theme:
raise ControllerNotFoundError(f"Could not find symbol theme '{symbol_theme}'") log.warning(f"Could not find symbol theme '{self._current_theme}'")
return None
symbol_path = theme.get(symbol) symbol_path = theme.get(symbol)
if symbol_path not in self._symbols_path: if symbol_path not in self._symbols_path:
log.warning(f"Default symbol {symbol} was not found") log.warning(f"Default symbol {symbol} was not found")

View File

@ -109,6 +109,17 @@ class ServerProtocol(str, Enum):
https = "https" https = "https"
class BuiltinSymbolTheme(str, Enum):
classic = "Classic"
affinity_square_blue = "Affinity-square-blue"
affinity_square_red = "Affinity-square-red"
affinity_square_gray = "Affinity-square-gray"
affinity_circle_blue = "Affinity-circle-blue"
affinity_circle_red = "Affinity-circle-red"
affinity_circle_gray = "Affinity-circle-gray"
class ServerSettings(BaseModel): class ServerSettings(BaseModel):
local: bool = False local: bool = False
@ -124,6 +135,7 @@ class ServerSettings(BaseModel):
appliances_path: str = "~/GNS3/appliances" appliances_path: str = "~/GNS3/appliances"
symbols_path: str = "~/GNS3/symbols" symbols_path: str = "~/GNS3/symbols"
configs_path: str = "~/GNS3/configs" configs_path: str = "~/GNS3/configs"
default_symbol_theme: BuiltinSymbolTheme = BuiltinSymbolTheme.affinity_square_blue
report_errors: bool = True report_errors: bool = True
additional_images_paths: List[str] = Field(default_factory=list) additional_images_paths: List[str] = Field(default_factory=list)
console_start_port_range: int = Field(5000, gt=0, le=65535) console_start_port_range: int = Field(5000, gt=0, le=65535)