Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions taccsite_cms/contrib/taccsite_sysmon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Sysmon

This is a _minimal_ conversion of the Frontera Sysmon snippet to a Django CMS plugin.

> There is a functionally more advanced plugin, [bitbucket:rochaa/tacc-sysmon](https://bitbucket.org/rochaa/tacc-sysmon), which allows:
>
> - server-side requests (Python) instead of client-side requests (JavaScript)
> - multi-system tables

## To Do

- [GH-295](https://github.com/TACC/Core-CMS/issues/295)
Empty file.
53 changes: 53 additions & 0 deletions taccsite_cms/contrib/taccsite_sysmon/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import gettext_lazy as _

from taccsite_cms.contrib.helpers import concat_classnames
from taccsite_cms.contrib.taccsite_offset.cms_plugins import get_direction_classname

from .models import TaccsiteSysmon

@plugin_pool.register_plugin
class TaccsiteSysmonPlugin(CMSPluginBase):
"""
Components > "System Monitor" Plugin
https://url.to/docs/components/sysmon/
"""
module = 'TACC Site'
model = TaccsiteSysmon
name = _('System Monitor')
render_template = 'sysmon.html'

cache = True
text_enabled = False
allow_children = False

fieldsets = [
(_('Single System'), {
# NOTE: Can GH-295 fix the reload caveat?
'description': 'Only a single system may be shown. After editing this plugin, reload the page to load system data.',
'fields': (
'system',
)
}),
(_('Advanced settings'), {
'classes': ('collapse',),
'fields': (
'attributes',
)
}),
]

# Render

def render(self, context, instance, placeholder):
context = super().render(context, instance, placeholder)
request = context['request']

classes = concat_classnames([
's-sysmon',
instance.attributes.get('class'),
])
instance.attributes['class'] = classes

return context
1 change: 1 addition & 0 deletions taccsite_cms/contrib/taccsite_sysmon/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_SYSTEM = 'frontera.tacc.utexas.edu'
29 changes: 29 additions & 0 deletions taccsite_cms/contrib/taccsite_sysmon/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 2.2.16 on 2021-07-30 22:21

from django.db import migrations, models
import django.db.models.deletion
import djangocms_attributes_field.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('cms', '0022_auto_20180620_1551'),
]

operations = [
migrations.CreateModel(
name='TaccsiteSysmon',
fields=[
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_sysmon_taccsitesysmon', serialize=False, to='cms.CMSPlugin')),
('system', models.CharField(choices=[('frontera.tacc.utexas.edu', 'Frontera'), ('stampede2.tacc.utexas.edu', 'Stampede2'), ('maverick2.tacc.utexas.edu', 'Maverick2'), ('longhorn.tacc.utexas.edu', 'Longhorn')], default='frontera.tacc.utexas.edu', max_length=255, verbose_name='System')),
('attributes', djangocms_attributes_field.fields.AttributesField(default=dict)),
],
options={
'abstract': False,
},
bases=('cms.cmsplugin',),
),
]
Empty file.
45 changes: 45 additions & 0 deletions taccsite_cms/contrib/taccsite_sysmon/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from cms.models.pluginmodel import CMSPlugin
from django.utils.translation import gettext_lazy as _

from django.db import models

from djangocms_attributes_field import fields

from taccsite_cms.contrib.helpers import get_choices

from .constants import DEFAULT_SYSTEM

# TODO: (Maybe in GH-295) Do not replicate `display_name` data from API
SYSTEM_DICT = {
'frontera.tacc.utexas.edu': {
'description': 'Frontera'
},
'stampede2.tacc.utexas.edu': {
'description': 'Stampede2'
},
'maverick2.tacc.utexas.edu': {
'description': 'Maverick2'
},
'longhorn.tacc.utexas.edu': {
'description': 'Longhorn'
},
}
SYSTEM_CHOICES = get_choices(SYSTEM_DICT)

class TaccsiteSysmon(CMSPlugin):
"""
Components > "System Monitor" Model
"""
system = models.CharField(
verbose_name=_('System'),
choices=SYSTEM_CHOICES,
blank=False,
max_length=255,
default=DEFAULT_SYSTEM,
)

attributes = fields.AttributesField()

def get_short_description(self):
system_choice = SYSTEM_DICT[self.system]
return system_choice['description']
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
System Monitor a.k.a. SysMon

Styles for the system monitor table that assumes external code:

- custom properties
(for `--global-...`)
- Bootstrap
(for badge)
- Iconworks
(for icon)

Styleguide Trumps.Scopes.SystemMonitor
*/

/* Container */

.s-sysmon {
font-size: 1.4rem;
min-width: 320px;
}

/* Table */

.s-sysmon table {
/* vert. `padding` + vert. `border-spacing` + `border-width` = 14px */
padding: 6px 0;

border: 1px solid var(--global-color-primary--xx-light);
border-radius: 9px;
border-spacing: 14px 7px; /* Overwrite Bootstrap 3 */
border-collapse: separate; /* Overwrite Bootstrap 4 */
}
.s-sysmon thead > tr {
margin-left: 5px;
margin-right: 5px;
}
.s-sysmon th {
font-weight: var(--bold);
}
.s-sysmon td {
font-weight: var(--medium);
}

/* Overwrite Bootstrap Class */
.s-sysmon .table {
margin-bottom: 0px;
}
.s-sysmon .table-dark {
color: var(--global-color-primary--normal);
background-color: var(--global-color-primary--xx-dark);
}
.s-sysmon .table thead th {
border-bottom: 1px solid var(--global-color-primary--dark);
}
.s-sysmon .table th,
.s-sysmon .table td {
vertical-align: middle;
border: none;
padding: 0 0 5px;
}
.s-sysmon .table td {
padding: 0;
}

/* Status Label */

.s-sysmon .badge {
font-family: Roboto;
}

/* Overwrite Bootstrap */
.s-sysmon .badge {
border-radius: 3px;
font-size: 1.3rem;
font-weight: normal;
}
.s-sysmon .badge-warning {
background-color: var(--global-color-warning--normal);
color: var(--global-color-primary--xx-light);
}

/* Overwrite IconWorks */
.s-sysmon .iconworks:before {
padding-right: 0.5em;
}
Loading