Compare commits

...

3 Commits

Author SHA1 Message Date
Arthur c59641a0b5 Merge branch 'feature' into 15154-uwsgi 2024-03-27 07:17:44 -07:00
Jeremy Stretch 04d8db7c52
Closes #15236: Clean up unused static resources (#15539)
* Remove unused images

* Remove unused stylesheets
2024-03-26 15:27:25 -04:00
Arthur Hanson 0cff4c9795
14799 Fix sync of scripts from data source (#15303)
* 14799 fix script creation from data-source

* 14799 dont cache module_scripts

* 14799 fix sync_classes call
2024-03-26 08:36:36 -04:00
9 changed files with 34 additions and 139 deletions

View File

@ -89,6 +89,9 @@ class ManagedFile(SyncedDataMixin, models.Model):
def clean(self):
super().clean()
if self.data_file and not self.file_path:
self.file_path = os.path.basename(self.data_path)
# Ensure that the file root and path make a unique pair
if self._meta.model.objects.filter(file_root=self.file_root, file_path=self.file_path).exclude(pk=self.pk).exists():
raise ValidationError(

View File

@ -108,7 +108,7 @@ class ScriptModule(PythonModuleMixin, JobsMixin, ManagedFile):
def __str__(self):
return self.python_name
@cached_property
@property
def module_scripts(self):
def _get_name(cls):
@ -137,9 +137,13 @@ class ScriptModule(PythonModuleMixin, JobsMixin, ManagedFile):
Syncs the file-based module to the database, adding and removing individual Script objects
in the database as needed.
"""
db_classes = {
script.name: script for script in self.scripts.all()
}
if self.id:
db_classes = {
script.name: script for script in self.scripts.all()
}
else:
db_classes = {}
db_classes_set = set(db_classes.keys())
module_classes_set = set(self.module_scripts.keys())
@ -158,10 +162,10 @@ class ScriptModule(PythonModuleMixin, JobsMixin, ManagedFile):
def sync_data(self):
super().sync_data()
self.sync_classes()
def save(self, *args, **kwargs):
self.file_root = ManagedFileRootPathChoices.SCRIPTS
self.sync_classes()
return super().save(*args, **kwargs)

View File

@ -1 +1 @@
:root{--nbx-trace-color: #000;--nbx-trace-node-bg: #e9ecef;--nbx-trace-termination-bg: #f8f9fa;--nbx-trace-cable-shadow: #343a40;--nbx-trace-attachment: #ced4da}:root[data-netbox-color-mode=dark]{--nbx-trace-color: #fff;--nbx-trace-node-bg: #212529;--nbx-trace-termination-bg: #343a40;--nbx-trace-cable-shadow: #e9ecef;--nbx-trace-attachment: #6c757d}*{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-size:.875rem}text{text-anchor:middle;dominant-baseline:middle}text:not([fill]){fill:var(--nbx-trace-color)}text.bold{font-weight:700}svg rect{fill:var(--nbx-trace-node-bg);stroke:#606060;stroke-width:1}svg rect .termination{fill:var(--nbx-trace-termination-bg)}svg .connector text{text-anchor:start}svg line{stroke-width:5px}svg polyline{fill:none;stroke-width:5px}svg .cable-shadow{stroke:var(--nbx-trace-cable-shadow);stroke-width:7px}svg line.wireless-link{stroke:var(--nbx-trace-attachment);stroke-dasharray:4px 12px;stroke-linecap:round}svg line.attachment{stroke:var(--nbx-trace-attachment);stroke-dasharray:5px}
:root{--nbx-trace-color: #000;--nbx-trace-node-bg: #e9ecef;--nbx-trace-termination-bg: #f8f9fa;--nbx-trace-cable-shadow: #343a40;--nbx-trace-attachment: #ced4da}:root[data-bs-theme=dark]{--nbx-trace-color: #fff;--nbx-trace-node-bg: #212529;--nbx-trace-termination-bg: #343a40;--nbx-trace-cable-shadow: #e9ecef;--nbx-trace-attachment: #6c757d}*{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-size:.875rem}text{text-anchor:middle;dominant-baseline:middle}text:not([fill]){fill:var(--nbx-trace-color)}text.bold{font-weight:700}svg rect{fill:var(--nbx-trace-node-bg);stroke:#606060;stroke-width:1}svg rect .termination{fill:var(--nbx-trace-termination-bg)}svg .connector text{text-anchor:start}svg line{stroke-width:5px}svg polyline{fill:none;stroke-width:5px}svg .cable-shadow{stroke:var(--nbx-trace-cable-shadow);stroke-width:7px}svg line.wireless-link{stroke:var(--nbx-trace-attachment);stroke-dasharray:4px 12px;stroke-linecap:round}svg line.attachment{stroke:var(--nbx-trace-attachment);stroke-dasharray:5px}

View File

@ -1 +1 @@
svg{--nbx-rack-bg: #e9ecef;--nbx-rack-border: #000;--nbx-rack-slot-bg: #e9ecef;--nbx-rack-slot-border: #adb5bd;--nbx-rack-slot-hover-bg: #ced4da;--nbx-rack-link-color: #0d6efd;--nbx-rack-unit-color: var(--bs-secondary-color)}svg[data-netbox-color-mode=dark]{--nbx-rack-bg: #343a40;--nbx-rack-border: #6c757d;--nbx-rack-slot-bg: #343a40;--nbx-rack-slot-border: #495057;--nbx-rack-slot-hover-bg: #212529;--nbx-rack-link-color: #9ec5fe;--nbx-rack-unit-color: var(--bs-secondary-color)}*{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-size:.875rem}rect{box-sizing:border-box}text{text-anchor:middle;dominant-baseline:middle}svg .unit{margin:0;padding:5px 0;fill:var(--nbx-rack-unit-color)}svg .hidden{visibility:hidden}svg rect.shaded,svg image.shaded{opacity:25%}svg text.shaded{opacity:50%}svg .rack{fill:none;stroke-width:2px;stroke:var(--nbx-rack-border);background-color:var(--nbx-rack-bg)}svg .slot{fill:var(--nbx-rack-slot-bg);stroke:var(--nbx-rack-slot-border)}svg .slot:hover{fill:var(--nbx-rack-slot-hover-bg)}svg .slot+.add-device{fill:var(--nbx-rack-link-color);opacity:0;pointer-events:none}svg .slot:hover+.add-device{opacity:1}svg .slot.occupied[class],svg .slot.occupied:hover[class]{fill:url(#occupied)}svg .slot.blocked[class],svg .slot.blocked:hover[class]{fill:url(#blocked)}svg .slot.blocked:hover+.add-device{opacity:0}svg .reservation[class]{fill:url(#reserved)}
svg{--nbx-rack-bg: #e9ecef;--nbx-rack-border: #000;--nbx-rack-slot-bg: #e9ecef;--nbx-rack-slot-border: #adb5bd;--nbx-rack-slot-hover-bg: #ced4da;--nbx-rack-link-color: #0d6efd;--nbx-rack-unit-color: var(--bs-secondary-color)}svg[data-bs-theme=dark]{--nbx-rack-bg: #343a40;--nbx-rack-border: #6c757d;--nbx-rack-slot-bg: #343a40;--nbx-rack-slot-border: #495057;--nbx-rack-slot-hover-bg: #212529;--nbx-rack-link-color: #9ec5fe;--nbx-rack-unit-color: var(--bs-secondary-color)}*{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Noto Sans,Liberation Sans,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-size:.875rem}rect{box-sizing:border-box}text{text-anchor:middle;dominant-baseline:middle}svg .unit{margin:0;padding:5px 0;fill:var(--nbx-rack-unit-color)}svg .hidden{visibility:hidden}svg rect.shaded,svg image.shaded{opacity:25%}svg text.shaded{opacity:50%}svg .rack{fill:none;stroke-width:2px;stroke:var(--nbx-rack-border);background-color:var(--nbx-rack-bg)}svg .slot{fill:var(--nbx-rack-slot-bg);stroke:var(--nbx-rack-slot-border)}svg .slot:hover{fill:var(--nbx-rack-slot-hover-bg)}svg .slot+.add-device{fill:var(--nbx-rack-link-color);opacity:0;pointer-events:none}svg .slot:hover+.add-device{opacity:1}svg .slot.occupied[class],svg .slot.occupied:hover[class]{fill:url(#occupied)}svg .slot.blocked[class],svg .slot.blocked:hover[class]{fill:url(#blocked)}svg .slot.blocked:hover+.add-device{opacity:0}svg .reservation[class]{fill:url(#reserved)}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,119 +0,0 @@
// Base NetBox Theme Overrides and Settings - color mode agnostic.
@import '../../node_modules/bootstrap/scss/functions';
$card-cap-bg: 'unset';
$border-radius-md: 0.375rem;
$border-radius-lg: 0.5rem;
$border-radius-xl: 0.75rem;
$border-radius-2xl: 1.5rem;
$border-radius: $border-radius-md;
$border-radius-sm: $border-radius;
$border-radius-lg: $border-radius-xl;
$badge-border-radius: $border-radius-md;
$progress-border-radius: $border-radius-md;
$font-weight-lighter: 200;
$font-weight-medium: 600;
$font-weight-bolder: 800;
$font-size-xs: 0.75rem;
$line-height-base: 1.5;
$line-height-xs: 1;
$line-height-sm: 1.25;
$line-height-lg: 1.75;
$darker: #1b1f22;
$darkest: #171b1d;
@import '../../node_modules/bootstrap/scss/variables';
@import '../../node_modules/bootstrap/scss/variables-dark';
// This is the same value as the default from Bootstrap, but it needs to be in scope prior to
// importing _variables.scss from Bootstrap.
$btn-close-width: 1em;
$accordion-padding-y: 0.8125rem;
$accordion-padding-x: 0.8125rem;
$sidebar-width: 280px;
$sidebar-bottom-height: 4rem;
$transition-100ms-ease-in-out: all 0.1s ease-in-out;
// Sidebar/Sidenav
$sidenav-width-closed: 3rem;
$sidenav-width-open: 16rem;
$sidenav-icon-width: 2rem;
$sidenav-spacing-x: 1.5rem;
$sidenav-link-spacing-x: 1rem;
$sidenav-link-spacing-y: 0.5rem;
// Theme colors (BS5 classes)
$primary: #337ab7;
$secondary: $gray-600;
$success: $green-500;
$info: #54d6f0;
$warning: $yellow-500;
$danger: $red-500;
$light: $gray-200;
$dark: $gray-800;
$theme-colors: (
// BS5 theme colors
'primary': $primary,
'secondary': $secondary,
'success': $success,
'info': $info,
'warning': $warning,
'danger': $danger,
'light': $light,
'dark': $dark,
// General-purpose palette
'blue': $blue-500,
'indigo': $indigo-500,
'purple': $purple-500,
'pink': $pink-500,
'red': $red-500,
'orange': $orange-500,
'yellow': $yellow-500,
'green': $green-500,
'teal': $teal-500,
'cyan': $cyan-500,
'gray': $gray-500,
'black': $black,
'white': $white
);
$light: $gray-200;
$navbar-light-color: $gray-100;
$card-cap-color: $gray-800;
$accordion-bg: transparent;
$accordion-button-bg: $accordion-bg;
$accordion-body-active-bg: $gray-100;
$accordion-border-color: $border-color;
$accordion-button-active-bg: $blue-100;
$accordion-button-active-color: $gray-800;
$breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");
$code-color: $gray-900;
$list-group-color: $gray-700;
$list-group-disabled-color: $gray-500;
$table-flush-header-bg: $gray-100;
$input-placeholder-color: $gray-500;
$form-select-disabled-color: $gray-600;
// Tabbed content
$tab-content-bg: $gray-100;

View File

@ -1,17 +1,21 @@
@import '../old/theme-light';
@import '../../node_modules/bootstrap/scss/functions';
@import '../../node_modules/bootstrap/scss/variables';
@import '../../node_modules/bootstrap/scss/variables-dark';
// Cable Trace Styles.
/*
* Cable trace SVG styling
*/
:root {
// Light Mode Variables.
// Light mode values
--nbx-trace-color: #{$black};
--nbx-trace-node-bg: #{$gray-200};
--nbx-trace-termination-bg: #{$gray-100};
--nbx-trace-cable-shadow: #{$gray-800};
--nbx-trace-attachment: #{$gray-400};
&[data-netbox-color-mode='dark'] {
// Dark Mode Variables.
// Note: only the `theme-light.scss` file is in-scope for simplicity.
&[data-bs-theme='dark'] {
// Dark mode values
--nbx-trace-color: #{$white};
--nbx-trace-node-bg: #{$gray-900};
--nbx-trace-termination-bg: #{$gray-800};

View File

@ -1,9 +1,13 @@
@import '../old/theme-light';
@import '../../node_modules/bootstrap/scss/functions';
@import '../../node_modules/bootstrap/scss/variables';
@import '../../node_modules/bootstrap/scss/variables-dark';
// Rack Elevation Styles.
/*
* Rack elevation SVG styling
*/
svg {
// Light Mode Variables.
// Light mode values
--nbx-rack-bg: #{$gray-200};
--nbx-rack-border: #{$black};
--nbx-rack-slot-bg: #{$gray-200};
@ -12,9 +16,8 @@ svg {
--nbx-rack-link-color: #{$blue};
--nbx-rack-unit-color: #{$text-muted};
&[data-netbox-color-mode='dark'] {
// Dark Mode Variables.
// Note: only the `theme-light.scss` file is in-scope for simplicity.
&[data-bs-theme='dark'] {
// Dark mode values
--nbx-rack-bg: #{$gray-800};
--nbx-rack-border: #{$gray-600};
--nbx-rack-slot-bg: #{$gray-800};
@ -41,7 +44,7 @@ svg {
// Rack unit numbers along left side of rack elevation.
.unit {
margin: 0;
padding: 5px 0px;
padding: 5px 0;
// Rack unit text color.
fill: var(--nbx-rack-unit-color);
}