nautobot 2.4.3__py3-none-any.whl → 2.4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nautobot/apps/filters.py +2 -0
- nautobot/circuits/filters.py +1 -1
- nautobot/circuits/tests/test_models.py +5 -3
- nautobot/cloud/filters.py +3 -6
- nautobot/cloud/tests/test_filters.py +21 -0
- nautobot/core/admin.py +2 -0
- nautobot/core/jobs/__init__.py +2 -1
- nautobot/core/management/commands/generate_performance_test_endpoints.py +9 -6
- nautobot/core/models/utils.py +6 -1
- nautobot/core/templates/inc/javascript.html +1 -0
- nautobot/core/templatetags/ui_framework.py +20 -4
- nautobot/core/testing/forms.py +1 -1
- nautobot/core/tests/test_api.py +1 -1
- nautobot/core/tests/test_graphql.py +3 -3
- nautobot/core/tests/test_jobs.py +4 -1
- nautobot/core/ui/object_detail.py +1 -1
- nautobot/dcim/api/serializers.py +36 -0
- nautobot/dcim/api/views.py +1 -1
- nautobot/dcim/elevations.py +17 -4
- nautobot/dcim/factory.py +9 -1
- nautobot/dcim/filters/__init__.py +27 -1
- nautobot/dcim/forms.py +13 -1
- nautobot/dcim/models/devices.py +11 -5
- nautobot/dcim/signals.py +26 -0
- nautobot/dcim/templates/dcim/virtualdevicecontext_retrieve.html +0 -62
- nautobot/dcim/templates/dcim/virtualdevicecontext_update.html +6 -0
- nautobot/dcim/tests/test_api.py +176 -0
- nautobot/dcim/tests/test_filters.py +56 -3
- nautobot/dcim/tests/test_models.py +40 -0
- nautobot/dcim/views.py +24 -14
- nautobot/extras/api/mixins.py +1 -1
- nautobot/extras/api/views.py +2 -2
- nautobot/extras/filters/__init__.py +4 -0
- nautobot/extras/models/datasources.py +7 -3
- nautobot/extras/plugins/__init__.py +26 -1
- nautobot/extras/templates/extras/inc/jobresult.html +12 -13
- nautobot/extras/templates/extras/objectchange.html +28 -12
- nautobot/extras/tests/test_api.py +16 -15
- nautobot/extras/tests/test_filters.py +2 -0
- nautobot/extras/tests/test_plugins.py +32 -1
- nautobot/extras/tests/test_views.py +12 -2
- nautobot/extras/views.py +3 -0
- nautobot/ipam/api/serializers.py +7 -8
- nautobot/ipam/api/views.py +2 -2
- nautobot/ipam/factory.py +27 -8
- nautobot/ipam/filters.py +67 -29
- nautobot/ipam/formfields.py +51 -0
- nautobot/ipam/forms.py +13 -1
- nautobot/ipam/migrations/0051_added_optional_vrf_relationship_to_vdc.py +41 -0
- nautobot/ipam/models.py +63 -5
- nautobot/ipam/tables.py +21 -7
- nautobot/ipam/tests/test_api.py +107 -66
- nautobot/ipam/tests/test_filters.py +145 -5
- nautobot/ipam/tests/test_views.py +15 -2
- nautobot/project-static/css/base.css +11 -0
- nautobot/project-static/css/dark.css +2 -1
- nautobot/project-static/docs/code-reference/nautobot/apps/filters.html +62 -0
- nautobot/project-static/docs/development/apps/api/configuration-view.html +0 -3
- nautobot/project-static/docs/development/apps/api/models/graphql.html +0 -4
- nautobot/project-static/docs/development/apps/api/platform-features/custom-validators.html +94 -1
- nautobot/project-static/docs/development/apps/api/platform-features/filter-extensions.html +0 -3
- nautobot/project-static/docs/development/apps/api/platform-features/jinja2-filters.html +0 -3
- nautobot/project-static/docs/development/apps/api/platform-features/populating-extensibility-features.html +0 -3
- nautobot/project-static/docs/development/apps/api/platform-features/secrets-providers.html +0 -3
- nautobot/project-static/docs/development/apps/api/prometheus.html +0 -3
- nautobot/project-static/docs/development/apps/api/testing.html +0 -6
- nautobot/project-static/docs/development/apps/api/ui-extensions/banners.html +0 -3
- nautobot/project-static/docs/development/apps/api/ui-extensions/home-page.html +0 -3
- nautobot/project-static/docs/development/apps/api/ui-extensions/object-views.html +0 -3
- nautobot/project-static/docs/development/apps/api/views/core-view-overrides.html +0 -3
- nautobot/project-static/docs/development/apps/api/views/nautobot-generic-views.html +1 -7
- nautobot/project-static/docs/development/apps/api/views/nautobotuiviewset.html +0 -7
- nautobot/project-static/docs/development/apps/api/views/nautobotuiviewsetrouter.html +0 -4
- nautobot/project-static/docs/development/apps/api/views/notes.html +0 -3
- nautobot/project-static/docs/development/apps/index.html +2 -35
- nautobot/project-static/docs/development/apps/migration/code-updates.html +1 -1
- nautobot/project-static/docs/development/core/application-registry.html +0 -6
- nautobot/project-static/docs/development/core/best-practices.html +0 -27
- nautobot/project-static/docs/development/core/docker-compose-advanced-use-cases.html +58 -4
- nautobot/project-static/docs/development/core/getting-started.html +12 -16
- nautobot/project-static/docs/development/core/homepage.html +0 -3
- nautobot/project-static/docs/development/core/style-guide.html +0 -5
- nautobot/project-static/docs/development/core/templates.html +0 -3
- nautobot/project-static/docs/development/core/testing.html +0 -9
- nautobot/project-static/docs/development/jobs/index.html +3 -29
- nautobot/project-static/docs/objects.inv +0 -0
- nautobot/project-static/docs/overview/application_stack.html +0 -18
- nautobot/project-static/docs/release-notes/version-2.4.html +191 -0
- nautobot/project-static/docs/requirements.txt +1 -1
- nautobot/project-static/docs/search/search_index.json +1 -1
- nautobot/project-static/docs/sitemap.xml +290 -290
- nautobot/project-static/docs/sitemap.xml.gz +0 -0
- nautobot/project-static/docs/user-guide/administration/configuration/settings.html +0 -10
- nautobot/project-static/docs/user-guide/administration/guides/docker.html +0 -15
- nautobot/project-static/docs/user-guide/administration/installation/index.html +0 -16
- nautobot/project-static/docs/user-guide/administration/installation/nautobot.html +1 -4
- nautobot/project-static/docs/user-guide/administration/installation/services.html +0 -11
- nautobot/project-static/docs/user-guide/administration/migration/migrating-from-postgresql.html +3 -3
- nautobot/project-static/docs/user-guide/administration/tools/nautobot-server.html +5 -35
- nautobot/project-static/docs/user-guide/administration/upgrading/from-v1/tables/v2-code-location-changes.yaml +1 -1
- nautobot/project-static/docs/user-guide/administration/upgrading/from-v1/upgrading-from-nautobot-v1.html +1 -1
- nautobot/project-static/docs/user-guide/administration/upgrading/upgrading.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/circuits/providernetwork.html +0 -3
- nautobot/project-static/docs/user-guide/core-data-model/dcim/consoleport.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/consoleporttemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/consoleserverport.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/consoleserverporttemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/devicebay.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/devicebaytemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/deviceredundancygroup.html +0 -3
- nautobot/project-static/docs/user-guide/core-data-model/dcim/devicetype.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/frontport.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/frontporttemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/interface.html +1 -17
- nautobot/project-static/docs/user-guide/core-data-model/dcim/interfaceredundancygroup.html +0 -3
- nautobot/project-static/docs/user-guide/core-data-model/dcim/interfacetemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/inventoryitem.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/location.html +0 -3
- nautobot/project-static/docs/user-guide/core-data-model/dcim/locationtype.html +1 -7
- nautobot/project-static/docs/user-guide/core-data-model/dcim/platform.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/poweroutlet.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/poweroutlettemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/powerport.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/powerporttemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/rearport.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/dcim/rearporttemplate.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/extras/configcontext.html +0 -6
- nautobot/project-static/docs/user-guide/core-data-model/extras/configcontextschema.html +0 -3
- nautobot/project-static/docs/user-guide/core-data-model/ipam/ipaddress.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/ipam/vlan.html +0 -4
- nautobot/project-static/docs/user-guide/core-data-model/virtualization/vminterface.html +0 -8
- nautobot/project-static/docs/user-guide/feature-guides/custom-fields.html +3 -3
- nautobot/project-static/docs/user-guide/feature-guides/graphql.html +0 -6
- nautobot/project-static/docs/user-guide/platform-functionality/computedfield.html +0 -3
- nautobot/project-static/docs/user-guide/platform-functionality/customfield.html +3 -15
- nautobot/project-static/docs/user-guide/platform-functionality/dynamicgroup.html +0 -26
- nautobot/project-static/docs/user-guide/platform-functionality/gitrepository.html +0 -8
- nautobot/project-static/docs/user-guide/platform-functionality/graphql.html +0 -3
- nautobot/project-static/docs/user-guide/platform-functionality/jobs/index.html +0 -8
- nautobot/project-static/docs/user-guide/platform-functionality/jobs/job-scheduling-and-approvals.html +0 -7
- nautobot/project-static/docs/user-guide/platform-functionality/jobs/jobbutton.html +0 -3
- nautobot/project-static/docs/user-guide/platform-functionality/jobs/jobhook.html +0 -3
- nautobot/project-static/docs/user-guide/platform-functionality/jobs/models.html +0 -14
- nautobot/project-static/docs/user-guide/platform-functionality/note.html +0 -3
- nautobot/project-static/docs/user-guide/platform-functionality/relationship.html +1 -10
- nautobot/project-static/docs/user-guide/platform-functionality/rest-api/authentication.html +0 -3
- nautobot/project-static/docs/user-guide/platform-functionality/rest-api/filtering.html +0 -14
- nautobot/project-static/docs/user-guide/platform-functionality/rest-api/overview.html +0 -19
- nautobot/project-static/docs/user-guide/platform-functionality/secret.html +3 -9
- nautobot/project-static/docs/user-guide/platform-functionality/status.html +0 -8
- nautobot/project-static/docs/user-guide/platform-functionality/tag.html +0 -4
- nautobot/project-static/docs/user-guide/platform-functionality/template-filters.html +1 -13
- nautobot/project-static/docs/user-guide/platform-functionality/webhook.html +0 -5
- nautobot/project-static/js/editor.js +292 -0
- nautobot/project-static/monaco-editor-0.52.2/README.md +81 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/base/worker/workerMain.js +31 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/basic-languages/xml/xml.js +10 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/basic-languages/yaml/yaml.js +10 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/editor/editor.main.css +8 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/editor/editor.main.js +798 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/language/json/jsonMode.js +19 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/language/json/jsonWorker.js +42 -0
- nautobot/project-static/monaco-editor-0.52.2/vs/loader.js +11 -0
- nautobot/tenancy/filters/__init__.py +3 -5
- nautobot/tenancy/tests/test_filters.py +10 -0
- nautobot/virtualization/views.py +0 -1
- nautobot/wireless/tables.py +9 -4
- nautobot/wireless/tests/test_api.py +0 -9
- {nautobot-2.4.3.dist-info → nautobot-2.4.4.dist-info}/METADATA +2 -2
- {nautobot-2.4.3.dist-info → nautobot-2.4.4.dist-info}/RECORD +175 -163
- {nautobot-2.4.3.dist-info → nautobot-2.4.4.dist-info}/LICENSE.txt +0 -0
- {nautobot-2.4.3.dist-info → nautobot-2.4.4.dist-info}/NOTICE +0 -0
- {nautobot-2.4.3.dist-info → nautobot-2.4.4.dist-info}/WHEEL +0 -0
- {nautobot-2.4.3.dist-info → nautobot-2.4.4.dist-info}/entry_points.txt +0 -0
|
@@ -9497,10 +9497,7 @@
|
|
|
9497
9497
|
<p>Each attribute of the IP address is expressed as an attribute of the JSON object. Related objects are identified by their own URLs that may be accessed to retrieve more details of the related object, as in the case of the <code>role</code> and <code>status</code> fields above. Every object includes a primary key named <code>id</code> which uniquely identifies it in the database.</p>
|
|
9498
9498
|
<h2 id="interactive-documentation">Interactive Documentation<a class="headerlink" href="#interactive-documentation" title="Permanent link">¶</a></h2>
|
|
9499
9499
|
<p>Comprehensive, interactive documentation of all REST API endpoints is available on a running Nautobot instance at <code>/api/docs/</code>. This interface provides a convenient sandbox for researching and experimenting with specific endpoints and request types. The API itself can also be explored using a web browser by navigating to its root at <code>/api/</code>.</p>
|
|
9500
|
-
<details class="version-added">
|
|
9501
|
-
<summary>Added in version 1.3.0</summary>
|
|
9502
9500
|
<p>You can view or explore a specific REST API <a href="#versioning">version</a> by adding the API version as a query parameter, for example <code>/api/docs/?api_version=2.0</code> or <code>/api/?api_version=2.0</code></p>
|
|
9503
|
-
</details>
|
|
9504
9501
|
<h2 id="endpoint-hierarchy">Endpoint Hierarchy<a class="headerlink" href="#endpoint-hierarchy" title="Permanent link">¶</a></h2>
|
|
9505
9502
|
<p>Nautobot's entire REST API is housed under the API root at <code>https://<hostname>/api/</code>. The URL structure is divided at the root level by application: circuits, DCIM, extras, IPAM, plugins, tenancy, users, and virtualization. Within each application exists a separate path for each model. For example, the provider and circuit objects are located under the "circuits" application:</p>
|
|
9506
9503
|
<ul>
|
|
@@ -9524,9 +9521,6 @@
|
|
|
9524
9521
|
</code></pre></div>
|
|
9525
9522
|
<p>See the <a href="filtering.html">filtering documentation</a> for more details.</p>
|
|
9526
9523
|
<h2 id="versioning">Versioning<a class="headerlink" href="#versioning" title="Permanent link">¶</a></h2>
|
|
9527
|
-
<details class="version-added">
|
|
9528
|
-
<summary>Added in version 1.3.0</summary>
|
|
9529
|
-
</details>
|
|
9530
9524
|
<p>As of Nautobot 1.3, the REST API supports multiple versions. A REST API client may request a given API version by including a <code>major.minor</code> Nautobot version number in its request in one of two ways:</p>
|
|
9531
9525
|
<ol>
|
|
9532
9526
|
<li>A client may include a <code>version</code> in its HTTP Accept header, for example <code>Accept: application/json; version=2.0</code></li>
|
|
@@ -9535,10 +9529,6 @@
|
|
|
9535
9529
|
<p>Generally the former approach is recommended when writing automated API integrations, as it can be set as a general request header alongside the <a href="authentication.html">authentication token</a> and re-used across a series of REST API interactions, while the latter approach may be more convenient when initially exploring the REST API via the interactive documentation as described above.</p>
|
|
9536
9530
|
<h3 id="default-versions">Default Versions<a class="headerlink" href="#default-versions" title="Permanent link">¶</a></h3>
|
|
9537
9531
|
<p>By default, a REST API request that does not specify an API version number will default to compatibility with the current Nautobot version.</p>
|
|
9538
|
-
<details class="version-added">
|
|
9539
|
-
<summary>Added in version 1.3.0</summary>
|
|
9540
|
-
<p>For Nautobot 1.x, the default API behavior is to be compatible with the REST API of Nautobot version 1.2, in other words, for all Nautobot 1.x versions (beginning with Nautobot 1.2.0), <code>Accept: application/json</code> is functionally equivalent to <code>Accept: application/json; version=1.2</code>.</p>
|
|
9541
|
-
</details>
|
|
9542
9532
|
<details class="version-changed">
|
|
9543
9533
|
<summary>Changed in version 2.0.0</summary>
|
|
9544
9534
|
<p>As of Nautobot 2.0, the default API behavior is changed to use the latest available REST API version. In other words, the default REST API version for Nautobot 2.0.y will be <code>2.0</code>, for Nautobot 2.1.y will be <code>2.1</code>, etc. This means that REST API clients that do not explicitly request a particular REST API version may encounter potentially <a href="#breaking-changes">breaking changes</a> in the REST API when Nautobot is upgraded to a new minor or major version.</p>
|
|
@@ -9660,9 +9650,6 @@
|
|
|
9660
9650
|
</tbody>
|
|
9661
9651
|
</table>
|
|
9662
9652
|
<h3 id="apiselect-with-versioning-capability">APISelect with versioning capability<a class="headerlink" href="#apiselect-with-versioning-capability" title="Permanent link">¶</a></h3>
|
|
9663
|
-
<details class="version-added">
|
|
9664
|
-
<summary>Added in version 1.3.0</summary>
|
|
9665
|
-
</details>
|
|
9666
9653
|
<p>The constructor for Nautobot's <code>APISelect</code>/<code>APISelectMultiple</code> UI widgets now includes an optional <code>api_version</code> argument which if set overrides the default API version of the request.</p>
|
|
9667
9654
|
<h2 id="serialization">Serialization<a class="headerlink" href="#serialization" title="Permanent link">¶</a></h2>
|
|
9668
9655
|
<p>The REST API employs "serializers" to represent model data. The representation produced by a serializer typically includes all relevant database table fields which comprise the model, and may also include additional metadata such as information about other relevant objects in the database. Much like the database model itself, a serializer typically will represent information about "parent" objects (those objects that needed to exist in order to define the current object, such as <code>DeviceType</code> and <code>Location</code> for a <code>DeviceSerializer</code>) but typically will not include information about "child" objects (those objects that depend on the current object in order to be defined, such as <code>Interface</code> objects for a <code>DeviceSerializer</code>).</p>
|
|
@@ -10174,9 +10161,6 @@ This parameter is an positive integer value that can range from 0 to 10. In most
|
|
|
10174
10161
|
<a id="__codelineno-23-79" name="__codelineno-23-79" href="#__codelineno-23-79"></a><span class="p">}</span>
|
|
10175
10162
|
</code></pre></div>
|
|
10176
10163
|
<h3 id="retrieving-object-relationships-and-relationship-associations">Retrieving Object Relationships and Relationship Associations<a class="headerlink" href="#retrieving-object-relationships-and-relationship-associations" title="Permanent link">¶</a></h3>
|
|
10177
|
-
<details class="version-added">
|
|
10178
|
-
<summary>Added in version 1.4.0</summary>
|
|
10179
|
-
</details>
|
|
10180
10164
|
<p>Objects that are associated with another object by a custom <a href="../relationship.html">Relationship</a> are also retrievable and modifiable via the REST API. Due to the additional processing overhead involved in retrieving and representing these relationships, they are <em>not</em> included in default REST API <code>GET</code> responses. To include relationships data, pass <code>include=relationships</code> as a query parameter; in this case an additional key, <code>"relationships"</code>, will be included in the API response, as seen below:</p>
|
|
10181
10165
|
<div class="highlight"><pre><span></span><code><a id="__codelineno-24-1" name="__codelineno-24-1" href="#__codelineno-24-1"></a>GET /api/dcim/locations/f472bb77-7f56-4e79-ac25-2dc73eb63924/?include=relationships
|
|
10182
10166
|
</code></pre></div>
|
|
@@ -10362,9 +10346,6 @@ This parameter is an positive integer value that can range from 0 to 10. In most
|
|
|
10362
10346
|
<p>The Nautobot REST API support the use of either <code>PUT</code> or <code>PATCH</code> to modify an existing object. The difference is that a <code>PUT</code> request requires the user to specify a <em>complete</em> representation of the object being modified, whereas a <code>PATCH</code> request need include only the attributes that are being updated. For most purposes, using <code>PATCH</code> is recommended.</p>
|
|
10363
10347
|
</div>
|
|
10364
10348
|
<h4 id="updating-relationship-associations">Updating Relationship Associations<a class="headerlink" href="#updating-relationship-associations" title="Permanent link">¶</a></h4>
|
|
10365
|
-
<details class="version-added">
|
|
10366
|
-
<summary>Added in version 1.4.0</summary>
|
|
10367
|
-
</details>
|
|
10368
10349
|
<p>It is possible to modify the objects associated via Relationship with an object as part of a REST API <code>PATCH</code> request by specifying the <code>"relationships"</code> key, any or all of the relevant Relationships, and the list of desired related objects for each such Relationship. Since nested serializers are used for the related objects, they can be identified by ID (primary key) or by one or more attributes in a dictionary. For example, either of the following requests would be valid:</p>
|
|
10369
10350
|
<div class="highlight"><pre><span></span><code><a id="__codelineno-33-1" name="__codelineno-33-1" href="#__codelineno-33-1"></a><span class="p">{</span>
|
|
10370
10351
|
<a id="__codelineno-33-2" name="__codelineno-33-2" href="#__codelineno-33-2"></a><span class="w"> </span><span class="nt">"relationships"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
|
|
@@ -9296,16 +9296,10 @@
|
|
|
9296
9296
|
|
|
9297
9297
|
|
|
9298
9298
|
<h1 id="secrets">Secrets<a class="headerlink" href="#secrets" title="Permanent link">¶</a></h1>
|
|
9299
|
-
<details class="version-added">
|
|
9300
|
-
<summary>Added in version 1.2.0</summary>
|
|
9301
|
-
</details>
|
|
9302
9299
|
<p>For security reasons, Nautobot generally does not store sensitive secrets (device access credentials, systems-integration API tokens, etc.) in its own database. There are other approaches and systems better suited to this purpose, ranging from simple solutions such as process-specific environment variables or restricted-access files on disk, all the way through to dedicated systems such as Hashicorp Vault or AWS Secrets Manager.</p>
|
|
9303
9300
|
<p>However, any number of Nautobot features (including, but not limited to, device access via NAPALM, Git repository access, custom Jobs, and various Apps seeking to integrate with third-party systems) do need the ability to retrieve and make use of such secrets. Towards that end, Nautobot provides a <code>Secret</code> database model. This model does <strong>not</strong> store the secret value itself, but instead defines <strong>how</strong> Nautobot can retrieve the secret value as and when it is needed. By using this model as an abstraction of the underlying secrets storage implementation, this makes it possible for any Nautobot feature to make use of secret values without needing to know or care where or how the secret is actually stored.</p>
|
|
9304
9301
|
<p>Secrets can be grouped and assigned a specific purpose as members of a Secrets Group, which can then be attached to a Git repository, device, or other data model as needed for a given purpose.</p>
|
|
9305
9302
|
<h2 id="secrets-groups">Secrets Groups<a class="headerlink" href="#secrets-groups" title="Permanent link">¶</a></h2>
|
|
9306
|
-
<details class="version-added">
|
|
9307
|
-
<summary>Added in version 1.2.0</summary>
|
|
9308
|
-
</details>
|
|
9309
9303
|
<p>A Secrets Group provides a way to collect and assign a purpose to one or more Secrets. The Secrets Group can then be attached to any object that needs to reference and make use of these Secrets, such as a Git repository needing a username/token to authenticate to a private GitHub repository, or a device using a group of Secrets to drive its NAPALM integration.</p>
|
|
9310
9304
|
<p>When creating or editing a Secrets Group, you can assign any number of defined Secrets to this group, assigning each secret an <em>access type</em> and a <em>secret type</em> that are unique within the context of this group. Some examples of how a Secrets Group might be populated for use by a given feature:</p>
|
|
9311
9305
|
<table>
|
|
@@ -9336,10 +9330,10 @@
|
|
|
9336
9330
|
<li><em>Environment Variable</em> - for retrieving a secret value defined in an environment variable; Secrets using this provider must specify the <code>variable</code> name to retrieve.</li>
|
|
9337
9331
|
<li><em>Text File</em> - for retrieving a secret value stored in a text file; Secrets using this provider must specify the absolute <code>path</code> of the file to retrieve.</li>
|
|
9338
9332
|
</ul>
|
|
9339
|
-
<
|
|
9340
|
-
<
|
|
9333
|
+
<div class="admonition tip">
|
|
9334
|
+
<p class="admonition-title">Tip</p>
|
|
9341
9335
|
<p>When using the Text File secrets provider, any leading and trailing whitespace or newlines will be stripped.</p>
|
|
9342
|
-
</
|
|
9336
|
+
</div>
|
|
9343
9337
|
<p>When defining a new Secret, you will need to select the desired secrets provider and then fill in the specific parameters required by that provider in order to have a completely specified, usable Secret record.</p>
|
|
9344
9338
|
<div class="admonition tip">
|
|
9345
9339
|
<p class="admonition-title">Tip</p>
|
|
@@ -9468,10 +9468,6 @@ own risk!</p>
|
|
|
9468
9468
|
<li><code>nautobot.extras.forms.StatusModelFilterFormMixin</code> should be used to add a non-required, multiple-choice <code>status</code> filter field to UI filter forms. This multiple-choice field allows for multiple status values to be selected for filtering objects in list views in the web UI.</li>
|
|
9469
9469
|
<li><code>nautobot.extras.forms.StatusModelBulkEditFormMixin</code> should be used to add a non-required <code>status</code> form field to a an object's model form. This field constrains status choices eligible to the object type being edited.</li>
|
|
9470
9470
|
</ul>
|
|
9471
|
-
<details class="version-changed">
|
|
9472
|
-
<summary>Changed in version 1.4.0</summary>
|
|
9473
|
-
<p>In prior Nautobot versions these mixins were named <code>StatusFilterFormMixin</code> and <code>StatusBulkEditFormMixin</code>; the old names are still available as aliases but will be removed in a future major release.</p>
|
|
9474
|
-
</details>
|
|
9475
9471
|
<h3 id="table-field">Table field<a class="headerlink" href="#table-field" title="Permanent link">¶</a></h3>
|
|
9476
9472
|
<p>If you wish for a table to include a <code>status</code> field, your table must inherit from <code>nautobot.extras.tables.StatusTableMixin</code>. This includes a <code>ColorColumn</code> on the table.</p>
|
|
9477
9473
|
<h2 id="status-object-integrations">Status object integrations<a class="headerlink" href="#status-object-integrations" title="Permanent link">¶</a></h2>
|
|
@@ -9487,10 +9483,6 @@ own risk!</p>
|
|
|
9487
9483
|
<li>Bulk edit model forms must inherit from <code>nautobot.extras.forms.StatusModelBulkEditFormMixin</code></li>
|
|
9488
9484
|
<li>Filter forms must inherit from <code>nautobot.extras.forms.StatusModelFilterFormMixin</code></li>
|
|
9489
9485
|
</ul>
|
|
9490
|
-
<details class="version-changed">
|
|
9491
|
-
<summary>Changed in version 1.4.0</summary>
|
|
9492
|
-
<p>In prior Nautobot releases the latter two mixins were named <code>StatusBulkEditFormMixin</code> and <code>StatusFilterFormMixin</code> respectively; the old names are still available as aliases but will be removed in a future major release.</p>
|
|
9493
|
-
</details>
|
|
9494
9486
|
<h3 id="filters">Filters<a class="headerlink" href="#filters" title="Permanent link">¶</a></h3>
|
|
9495
9487
|
<ul>
|
|
9496
9488
|
<li>Filtersets for your model must inherit from <code>nautobot.extras.filters.StatusModelFilterSetMixin</code></li>
|
|
@@ -9121,10 +9121,6 @@
|
|
|
9121
9121
|
|
|
9122
9122
|
<h1 id="tags">Tags<a class="headerlink" href="#tags" title="Permanent link">¶</a></h1>
|
|
9123
9123
|
<p>Tags are user-defined labels which can be applied to a variety of objects within Nautobot. They can be used to establish dimensions of organization beyond the relationships built into Nautobot. For example, you might create a tag to identify a particular ownership or condition across several types of objects.</p>
|
|
9124
|
-
<details class="version-added">
|
|
9125
|
-
<summary>Added in version 1.3.0</summary>
|
|
9126
|
-
<p>When created, a <code>Tag</code> can be associated to one or more model content-types using a many-to-many relationship. The tag will then apply only to models belonging to those associated content-types.</p>
|
|
9127
|
-
</details>
|
|
9128
9124
|
<p>Each tag has a name, label, color, and permitted content-types. Each tag can also be assigned a description indicating its purpose.</p>
|
|
9129
9125
|
<p>Objects can be filtered by the tags they have applied. For example, the following API request will retrieve all devices tagged as "monitored":</p>
|
|
9130
9126
|
<div class="highlight"><pre><span></span><code><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a>GET /api/dcim/devices/?tag=monitored
|
|
@@ -9802,16 +9802,10 @@
|
|
|
9802
9802
|
</div>
|
|
9803
9803
|
<p>Both Django Template and Jinja2 can be extended with a library of functions, called <code>filters</code>, that apply formatting or transformations to a provided input. Nautobot provides many built-in <code>filters</code>, including network specific <code>filters</code> from the <a href="https://netutils.readthedocs.io/en/latest/">netutils library</a>.</p>
|
|
9804
9804
|
<h2 id="netutils-filters">Netutils Filters<a class="headerlink" href="#netutils-filters" title="Permanent link">¶</a></h2>
|
|
9805
|
-
<details class="version-added">
|
|
9806
|
-
<summary>Added in version 1.2.0</summary>
|
|
9807
|
-
</details>
|
|
9808
9805
|
<p><a href="https://netutils.readthedocs.io/en/latest/">Netutils</a> is an external library, maintained by Network to Code, that is focusing on providing a collection of functions for common network automation tasks. Please <a href="https://netutils.readthedocs.io/en/latest/">check the netutils documentation</a> to see the list of available functions.</p>
|
|
9809
9806
|
<p>These functions are available automatically in Jinja2 rendered by Nautobot. For example you could define a <a href="computedfield.html">computed field</a> on Circuit objects, using the Netutils <code>bits_to_name</code> function, to display the "Commit Rate" as a human-readable value by using the template code <code>{{ (obj.commit_rate * 1000) | bits_to_name }}</code>. (This particular example is contrived, as the Nautobot UI already humanizes the raw <code>commit_rate</code> value for display, but it demonstrates the kinds of things that these filters can be used for.)</p>
|
|
9810
9807
|
<p>In general the syntax for using a netutils filter in a Jinja2 template is something like <code>{{ arg1 | function_name }}</code> for functions that take a single argument, and <code>{{ arg1 | function_name(arg_name2=arg2, arg_name3=arg3) }}</code> for functions that take multiple arguments.</p>
|
|
9811
|
-
<details class="version-added">
|
|
9812
|
-
<summary>Added in version 1.5.11</summary>
|
|
9813
9808
|
<p>Netutils functions are also available in Django templates after using the <code>{% load netutils %}</code> directive in a template. The syntax to use these functions is then generally <code>{% function_name arg_name1=arg1 arg_name2=arg2 %}</code>.</p>
|
|
9814
|
-
</details>
|
|
9815
9809
|
<h2 id="nautobot-built-in-filters">Nautobot Built-In Filters<a class="headerlink" href="#nautobot-built-in-filters" title="Permanent link">¶</a></h2>
|
|
9816
9810
|
<p>The Nautobot project also provides the following built-in <code>filters</code> that can be used in both Jinja2 and Django Template.</p>
|
|
9817
9811
|
<h3 id="as_range">as_range<a class="headerlink" href="#as_range" title="Permanent link">¶</a></h3>
|
|
@@ -9889,25 +9883,19 @@
|
|
|
9889
9883
|
</details>
|
|
9890
9884
|
<p>Render a phone number string, if any, as a <code>tel:</code> hyperlink, or render a placeholder if no phone number is given.</p>
|
|
9891
9885
|
<h3 id="hyperlinked_object">hyperlinked_object<a class="headerlink" href="#hyperlinked_object" title="Permanent link">¶</a></h3>
|
|
9892
|
-
<details class="version-added">
|
|
9893
|
-
<summary>Added in version 1.4.0</summary>
|
|
9894
|
-
</details>
|
|
9895
9886
|
<p>Render and link to a Django model instance, if any, or render a placeholder if not.</p>
|
|
9896
9887
|
<p>Uses <code>object.display</code> if available, otherwise uses the string representation of the object.
|
|
9897
9888
|
If the object defines <code>get_absolute_url()</code> this will be used to hyperlink the displayed object;
|
|
9898
9889
|
additionally if there is an <code>object.description</code> this will be used as the title of the hyperlink.</p>
|
|
9899
9890
|
<div class="highlight"><pre><span></span><code><a id="__codelineno-10-1" name="__codelineno-10-1" href="#__codelineno-10-1"></a><span class="cp">{{</span> <span class="nv">device</span><span class="o">|</span><span class="nf">hyperlinked_object</span> <span class="cp">}}</span>
|
|
9900
9891
|
</code></pre></div>
|
|
9901
|
-
<
|
|
9902
|
-
<summary>Added in version 1.5.0</summary>
|
|
9903
|
-
<p>This filter now accepts an optional <code>field</code> parameter, which allows you to use a field other than <code>object.display</code> for the object representation if desired. For example, to display the object's <code>name</code> field instead:</p>
|
|
9892
|
+
<p>This filter also accepts an optional <code>field</code> parameter, which allows you to use a field other than <code>object.display</code> for the object representation if desired. For example, to display the object's <code>name</code> field instead:</p>
|
|
9904
9893
|
<div class="highlight"><pre><span></span><code><a id="__codelineno-11-1" name="__codelineno-11-1" href="#__codelineno-11-1"></a><span class="x"># Django Template</span>
|
|
9905
9894
|
<a id="__codelineno-11-2" name="__codelineno-11-2" href="#__codelineno-11-2"></a><span class="cp">{{</span> <span class="nv">location</span><span class="o">|</span><span class="nf">hyperlinked_object</span><span class="s2">:"name"</span> <span class="cp">}}</span>
|
|
9906
9895
|
<a id="__codelineno-11-3" name="__codelineno-11-3" href="#__codelineno-11-3"></a>
|
|
9907
9896
|
<a id="__codelineno-11-4" name="__codelineno-11-4" href="#__codelineno-11-4"></a><span class="x"># Jinja</span>
|
|
9908
9897
|
<a id="__codelineno-11-5" name="__codelineno-11-5" href="#__codelineno-11-5"></a><span class="cp">{{</span> <span class="nv">location</span><span class="o">|</span><span class="nf">hyperlinked_object</span><span class="o">(</span><span class="s2">"name"</span><span class="o">)</span> <span class="cp">}}</span>
|
|
9909
9898
|
</code></pre></div>
|
|
9910
|
-
</details>
|
|
9911
9899
|
<h3 id="meta">meta<a class="headerlink" href="#meta" title="Permanent link">¶</a></h3>
|
|
9912
9900
|
<p>Return the specified Meta attribute of a model.</p>
|
|
9913
9901
|
<div class="highlight"><pre><span></span><code><a id="__codelineno-12-1" name="__codelineno-12-1" href="#__codelineno-12-1"></a><span class="cp">{{</span> <span class="nv">obj</span> <span class="o">|</span> <span class="nf">meta</span><span class="o">(</span><span class="s1">'app_label'</span><span class="o">)</span> <span class="cp">}}</span>
|
|
@@ -9313,13 +9313,8 @@
|
|
|
9313
9313
|
<li><code>username</code> - The name of the user account associated with the change.</li>
|
|
9314
9314
|
<li><code>request_id</code> - The unique request ID. This may be used to correlate multiple changes associated with a single request.</li>
|
|
9315
9315
|
<li><code>data</code> - A serialized representation of the object <em>after</em> the change was made. This is typically equivalent to the model's representation in Nautobot's REST API.</li>
|
|
9316
|
-
</ul>
|
|
9317
|
-
<details class="version-added">
|
|
9318
|
-
<summary>Added in version 1.3.0</summary>
|
|
9319
|
-
<ul>
|
|
9320
9316
|
<li><code>snapshots</code> - snapshots of the serialized object state both before and after the change was made; provided as a dictionary with keys named <code>prechange</code>, <code>postchange</code> and <code>differences</code>.</li>
|
|
9321
9317
|
</ul>
|
|
9322
|
-
</details>
|
|
9323
9318
|
<h3 id="default-request-body">Default Request Body<a class="headerlink" href="#default-request-body" title="Permanent link">¶</a></h3>
|
|
9324
9319
|
<p>If no body template is specified, the request body will be populated with a JSON object containing the context data. For example, a newly created Location might appear as follows:</p>
|
|
9325
9320
|
<div class="highlight"><pre><span></span><code><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a>{
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monaco Editor wrapper for embedding in any page.
|
|
3
|
+
*
|
|
4
|
+
* Configuration via data attributes:
|
|
5
|
+
* @param {string} data-mode - Set to 'diff' for diff viewer, omit for standard editor
|
|
6
|
+
* @param {string} data-lang - Language syntax (json, yaml, xml, text)
|
|
7
|
+
* @param {string} data-value - Initial content for standard editor
|
|
8
|
+
* @param {string} data-original - Original content for diff viewer (requires data-mode="diff")
|
|
9
|
+
* @param {string} data-modified - Modified content for diff viewer (requires data-mode="diff")
|
|
10
|
+
* @param {string} data-options - JSON string of Monaco editor options to merge with base config
|
|
11
|
+
*
|
|
12
|
+
* Example Usage:
|
|
13
|
+
*
|
|
14
|
+
* Diff Viewer:
|
|
15
|
+
* <div class="editor-container"
|
|
16
|
+
* data-mode="diff"
|
|
17
|
+
* data-original="{{ diff_removed }}"
|
|
18
|
+
* data-modified="{{ diff_added }}"
|
|
19
|
+
* data-lang="json">
|
|
20
|
+
* </div>
|
|
21
|
+
*
|
|
22
|
+
* Standard Editor:
|
|
23
|
+
* <div class="editor-container"
|
|
24
|
+
* data-lang="yaml"
|
|
25
|
+
* data-value="key: value"
|
|
26
|
+
* data-options='{"readOnly": false}'>
|
|
27
|
+
* </div>
|
|
28
|
+
*/
|
|
29
|
+
;(function(window, document, undefined) {
|
|
30
|
+
'use strict';
|
|
31
|
+
|
|
32
|
+
const MONACO_BASE = window.nautobot_static_url + 'monaco-editor-0.52.2';
|
|
33
|
+
|
|
34
|
+
class Editor {
|
|
35
|
+
// Base configuration for all editor instances
|
|
36
|
+
static BASE_COMMON = {
|
|
37
|
+
automaticLayout: true,
|
|
38
|
+
scrollBeyondLastLine: false,
|
|
39
|
+
lineDecorationsWidth: 0,
|
|
40
|
+
lineNumbers: 'off',
|
|
41
|
+
wordWrap: 'off',
|
|
42
|
+
renderWhitespace: 'none',
|
|
43
|
+
guides: {
|
|
44
|
+
indentation: false,
|
|
45
|
+
highlightActiveIndentation: false,
|
|
46
|
+
bracketPairs: false
|
|
47
|
+
},
|
|
48
|
+
readOnly: true,
|
|
49
|
+
contextmenu: false,
|
|
50
|
+
matchBrackets: 'never',
|
|
51
|
+
accessibilitySupport: 'auto',
|
|
52
|
+
minimap: { enabled: false },
|
|
53
|
+
renderLineHighlight: 'none',
|
|
54
|
+
hideCursorInOverviewRuler: true,
|
|
55
|
+
overviewRuler: {
|
|
56
|
+
border: false,
|
|
57
|
+
lanes: 0,
|
|
58
|
+
renderOverviewRuler: false
|
|
59
|
+
},
|
|
60
|
+
scrollbar: {
|
|
61
|
+
useShadows: false,
|
|
62
|
+
verticalScrollbarSize: 8,
|
|
63
|
+
horizontalScrollbarSize: 8,
|
|
64
|
+
alwaysConsumeMouseWheel: false,
|
|
65
|
+
arrowSize: 0,
|
|
66
|
+
handleMouseWheel: true
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Additional configuration for diff viewer mode
|
|
71
|
+
static BASE_DIFF = {
|
|
72
|
+
enableSplitViewResizing: false,
|
|
73
|
+
renderSideBySide: true,
|
|
74
|
+
useInlineViewWhenSpaceIsLimited: false
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Creates a new Editor instance, ensuring Monaco is loaded before initialization. */
|
|
78
|
+
static async create(host) {
|
|
79
|
+
await Editor.loadMonaco();
|
|
80
|
+
return new Editor(host);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Initializes shared Monaco Editor environment, ensuring only one initialization occurs. */
|
|
84
|
+
static async loadMonaco() {
|
|
85
|
+
if (window.monaco) return;
|
|
86
|
+
|
|
87
|
+
// Create worker environment with blob URL wrapper for CORS
|
|
88
|
+
const createWorkerEnv = () => {
|
|
89
|
+
const workerPath = `${MONACO_BASE}/vs/base/worker/workerMain.js`;
|
|
90
|
+
const absoluteWorkerPath = new URL(workerPath, window.location.origin).href;
|
|
91
|
+
|
|
92
|
+
// Create cached blob URL for all workers
|
|
93
|
+
if (!window._monacoWorkerUrl) {
|
|
94
|
+
const workerCode = `
|
|
95
|
+
self.MonacoEnvironment = {
|
|
96
|
+
baseUrl: '${new URL(MONACO_BASE, window.location.origin).href}'
|
|
97
|
+
};
|
|
98
|
+
importScripts('${absoluteWorkerPath}');
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
window._monacoWorkerUrl = URL.createObjectURL(
|
|
102
|
+
new Blob([workerCode], { type: 'text/javascript' })
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
getWorkerUrl: () => window._monacoWorkerUrl
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// Load Monaco via AMD, reusing existing promise if pending
|
|
112
|
+
window._monacoLoaderPromise ||= new Promise((resolve, reject) => {
|
|
113
|
+
const script = document.createElement('script');
|
|
114
|
+
script.src = `${MONACO_BASE}/vs/loader.js`;
|
|
115
|
+
script.crossOrigin = 'anonymous';
|
|
116
|
+
|
|
117
|
+
script.onload = () => {
|
|
118
|
+
require.config({
|
|
119
|
+
paths: {
|
|
120
|
+
vs: `${MONACO_BASE}/vs`
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
window.MonacoEnvironment = createWorkerEnv();
|
|
125
|
+
require(['vs/editor/editor.main'], resolve, reject);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
script.onerror = reject;
|
|
129
|
+
document.head.appendChild(script);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
await window._monacoLoaderPromise;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Constructs a new Editor instance with configuration from host element. */
|
|
136
|
+
constructor(host) {
|
|
137
|
+
this._host = host;
|
|
138
|
+
this._editor = null;
|
|
139
|
+
this._resizeObserver = null;
|
|
140
|
+
|
|
141
|
+
// Destructure with safety
|
|
142
|
+
const { mode, lang, value, original, modified, options } = host.dataset;
|
|
143
|
+
|
|
144
|
+
this._config = {
|
|
145
|
+
isDiff: mode === 'diff',
|
|
146
|
+
language: lang || 'text',
|
|
147
|
+
theme: document.documentElement.dataset.theme === 'dark' ? 'vs-dark' : 'vs',
|
|
148
|
+
value: value || '',
|
|
149
|
+
original: original || '',
|
|
150
|
+
modified: modified || '',
|
|
151
|
+
options: {
|
|
152
|
+
...JSON.parse(options || '{}') // User overrides
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
this.init();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Initializes editor with configured options and sets up event listeners. */
|
|
160
|
+
init() {
|
|
161
|
+
const { theme, language, isDiff, options } = this._config;
|
|
162
|
+
|
|
163
|
+
const editorOptions = {
|
|
164
|
+
...Editor.BASE_COMMON, // Use static property
|
|
165
|
+
...(isDiff ? Editor.BASE_DIFF : {}), // Use static property
|
|
166
|
+
...options
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
if (this._config.isDiff) {
|
|
170
|
+
this._createDiffEditor({ theme, language, ...editorOptions });
|
|
171
|
+
} else {
|
|
172
|
+
this._createStandardEditor({ theme, language, ...editorOptions });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this._setupResize();
|
|
176
|
+
this._setupContentHeightListener();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Creates a standard Monaco editor with the configured value and options. */
|
|
180
|
+
_createStandardEditor(options) {
|
|
181
|
+
this._editor = monaco.editor.create(this._host, {
|
|
182
|
+
...options,
|
|
183
|
+
value: this._config.value
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Creates a Monaco diff editor with original and modified content models. */
|
|
188
|
+
_createDiffEditor(options) {
|
|
189
|
+
this._editor = monaco.editor.createDiffEditor(this._host, options);
|
|
190
|
+
const { language, original, modified } = this._config;
|
|
191
|
+
this._editor.setModel({
|
|
192
|
+
original: monaco.editor.createModel(original, language),
|
|
193
|
+
modified: monaco.editor.createModel(modified, language)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Sets up a debounced resize observer to update editor layout. */
|
|
198
|
+
_setupResize() {
|
|
199
|
+
let resizeTimeout;
|
|
200
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
201
|
+
// Add debouncing for better performance with multiple editors
|
|
202
|
+
if (resizeTimeout) clearTimeout(resizeTimeout);
|
|
203
|
+
resizeTimeout = setTimeout(() => {
|
|
204
|
+
this._editor?.layout();
|
|
205
|
+
this._updateEditorHeight();
|
|
206
|
+
}, 100);
|
|
207
|
+
});
|
|
208
|
+
this._resizeObserver.observe(this._host);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Registers listeners to update editor height when content size changes. */
|
|
212
|
+
_setupContentHeightListener() {
|
|
213
|
+
// Store listeners for cleanup
|
|
214
|
+
this._contentListeners = [];
|
|
215
|
+
const update = () => this._updateEditorHeight();
|
|
216
|
+
|
|
217
|
+
if (this._config.isDiff) {
|
|
218
|
+
this._contentListeners.push(
|
|
219
|
+
this._editor.getOriginalEditor().onDidContentSizeChange(update),
|
|
220
|
+
this._editor.getModifiedEditor().onDidContentSizeChange(update)
|
|
221
|
+
);
|
|
222
|
+
} else {
|
|
223
|
+
this._contentListeners.push(
|
|
224
|
+
this._editor.onDidContentSizeChange(update)
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Updates editor container height based on content and max-height constraints. */
|
|
230
|
+
_updateEditorHeight() {
|
|
231
|
+
if (!this._editor) return;
|
|
232
|
+
|
|
233
|
+
const getHeight = e => e.getContentHeight() + 5;
|
|
234
|
+
let contentHeight;
|
|
235
|
+
|
|
236
|
+
if (this._config.isDiff) {
|
|
237
|
+
contentHeight = Math.max(
|
|
238
|
+
getHeight(this._editor.getOriginalEditor()),
|
|
239
|
+
getHeight(this._editor.getModifiedEditor())
|
|
240
|
+
);
|
|
241
|
+
} else {
|
|
242
|
+
contentHeight = getHeight(this._editor);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Get max-height from CSS (if set)
|
|
246
|
+
const maxHeight = parseInt(getComputedStyle(this._host).maxHeight, 10);
|
|
247
|
+
if (!isNaN(maxHeight)) {
|
|
248
|
+
contentHeight = Math.min(contentHeight, maxHeight);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
this._host.style.height = `${contentHeight}px`;
|
|
252
|
+
this._editor.layout();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Cleans up editor instance, models, and event listeners. */
|
|
256
|
+
dispose() {
|
|
257
|
+
if (!this._editor) return;
|
|
258
|
+
|
|
259
|
+
// Dispose content size listeners
|
|
260
|
+
this._contentListeners?.forEach(listener => listener.dispose());
|
|
261
|
+
this._contentListeners = null;
|
|
262
|
+
|
|
263
|
+
// Dispose models safely
|
|
264
|
+
const model = this._editor.getModel();
|
|
265
|
+
if (this._config.isDiff) {
|
|
266
|
+
model?.original?.dispose();
|
|
267
|
+
model?.modified?.dispose();
|
|
268
|
+
} else {
|
|
269
|
+
model?.dispose();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Cleanup editor
|
|
273
|
+
this._editor.dispose();
|
|
274
|
+
this._resizeObserver?.disconnect();
|
|
275
|
+
|
|
276
|
+
// Clear references
|
|
277
|
+
[this._editor, this._resizeObserver, this._host, this._config] = [];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Initialize editors with error handling
|
|
282
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
283
|
+
const containers = Array.from(document.querySelectorAll('.editor-container'));
|
|
284
|
+
Promise.allSettled(containers.map(host => Editor.create(host)))
|
|
285
|
+
.then(results => results.forEach((result, i) => {
|
|
286
|
+
if (result.status === 'rejected') {
|
|
287
|
+
containers[i].textContent = 'Editor initialization failed';
|
|
288
|
+
console.error('Monaco error:', result.reason);
|
|
289
|
+
}
|
|
290
|
+
}));
|
|
291
|
+
});
|
|
292
|
+
})(window, document);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Monaco Editor Custom Build
|
|
2
|
+
|
|
3
|
+
Minimal Monaco Editor distribution optimized for JSON, YAML, and XML. Built for reduced bundle size while maintaining core functionality.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
nautobot/project-static/monaco-editor-[VERSION]/
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Full Monaco editing experience
|
|
14
|
+
- JSON with language server support
|
|
15
|
+
- YAML and XML syntax support
|
|
16
|
+
- Core UI components and Codicon font
|
|
17
|
+
- Modern browser support
|
|
18
|
+
|
|
19
|
+
## Build
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Get latest version
|
|
23
|
+
VERSION=$(curl -s https://registry.npmjs.org/monaco-editor | jq -r '."dist-tags".latest')
|
|
24
|
+
|
|
25
|
+
# Download and extract
|
|
26
|
+
curl -O -L "https://registry.npmjs.org/monaco-editor/-/monaco-editor-$VERSION.tgz"
|
|
27
|
+
tar -xzf monaco-editor-*.tgz
|
|
28
|
+
|
|
29
|
+
# Setup directories
|
|
30
|
+
mkdir -p nautobot/project-static/monaco-editor-$VERSION/vs/{editor,language,basic-languages}
|
|
31
|
+
mkdir -p nautobot/project-static/monaco-editor-$VERSION/vs/base/{worker,browser/ui}
|
|
32
|
+
|
|
33
|
+
# Copy core files
|
|
34
|
+
cp package/min/vs/loader.js nautobot/project-static/monaco-editor-$VERSION/vs/
|
|
35
|
+
cp package/min/vs/editor/editor.main.js nautobot/project-static/monaco-editor-$VERSION/vs/editor/
|
|
36
|
+
cp package/min/vs/editor/editor.main.css nautobot/project-static/monaco-editor-$VERSION/vs/editor/
|
|
37
|
+
|
|
38
|
+
# Copy language files
|
|
39
|
+
mkdir -p nautobot/project-static/monaco-editor-$VERSION/vs/language/json
|
|
40
|
+
mkdir -p nautobot/project-static/monaco-editor-$VERSION/vs/basic-languages/{yaml,xml}
|
|
41
|
+
cp -r package/min/vs/language/json/* nautobot/project-static/monaco-editor-$VERSION/vs/language/json/
|
|
42
|
+
cp -r package/min/vs/basic-languages/yaml/* nautobot/project-static/monaco-editor-$VERSION/vs/basic-languages/yaml/
|
|
43
|
+
cp -r package/min/vs/basic-languages/xml/* nautobot/project-static/monaco-editor-$VERSION/vs/basic-languages/xml/
|
|
44
|
+
|
|
45
|
+
# Copy worker and UI
|
|
46
|
+
cp -r package/min/vs/base/worker nautobot/project-static/monaco-editor-$VERSION/vs/base/
|
|
47
|
+
mkdir -p nautobot/project-static/monaco-editor-$VERSION/vs/base/browser/ui/codicons/codicon
|
|
48
|
+
cp -r package/min/vs/base/browser/ui/codicons/codicon/* nautobot/project-static/monaco-editor-$VERSION/vs/base/browser/ui/codicons/codicon/
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Structure
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
nautobot/project-static/monaco-editor-0.52.2/
|
|
55
|
+
├── vs/
|
|
56
|
+
│ ├── base/
|
|
57
|
+
│ │ ├── worker/
|
|
58
|
+
│ │ │ └── workerMain.js
|
|
59
|
+
│ │ └── browser/ui/codicons/
|
|
60
|
+
│ ├── basic-languages/
|
|
61
|
+
│ │ ├── xml/
|
|
62
|
+
│ │ └── yaml/
|
|
63
|
+
│ ├── editor/
|
|
64
|
+
│ │ ├── editor.main.css
|
|
65
|
+
│ │ └── editor.main.js
|
|
66
|
+
│ ├── language/
|
|
67
|
+
│ │ └── json/
|
|
68
|
+
│ └── loader.js
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
|
|
73
|
+
- MIT License
|
|
74
|
+
- Supports Chrome, Firefox, Safari, Edge
|
|
75
|
+
- Externally maintained build
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
|
|
79
|
+
1. Update version numbers in README and paths
|
|
80
|
+
2. Test in target application
|
|
81
|
+
3. Verify language services work
|