This commit is contained in:
Magnus Åhall 2025-07-16 10:50:31 +02:00
parent b7fa4c5c94
commit ba7375fe15
2 changed files with 53 additions and 0 deletions

18
sql/0010.sql Normal file
View file

@ -0,0 +1,18 @@
CREATE TABLE public.script (
id serial NOT NULL,
name varchar NOT NULL,
"source" text NOT NULL,
updated timestamptz DEFAULT NOW() NOT NULL,
CONSTRAINT script_pk PRIMARY KEY (id),
CONSTRAINT script_unique_name UNIQUE (name)
);
CREATE TABLE public."execute" (
id serial NOT NULL,
node_id int4 NOT NULL,
script_id int4 NOT NULL,
ssh varchar DEFAULT '' NOT NULL,
CONSTRAINT execute_pk PRIMARY KEY (id),
CONSTRAINT execute_node_fk FOREIGN KEY (node_id) REFERENCES public.node(id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT execute_script_fk FOREIGN KEY (script_id) REFERENCES public.script(id) ON DELETE CASCADE ON UPDATE CASCADE
);

35
static/js/component.mjs Normal file
View file

@ -0,0 +1,35 @@
export class Component {
constructor() {
this._component_name = Object.getPrototypeOf(this).constructor.name
this._template = document.createElement('template')
this._debug = (sessionStorage.getItem('debug') === 'true')
}
render() {
const component = this.renderComponent()
this._template.content.appendChild(component)
for (const e of this._template.content.children) {
e.setAttribute('data-component-name', this._component_name)
if (this._debug) {
e.setAttribute('data-tooltip', this._component_name)
e.classList.add('tooltip')
e.classList.add('left')
e.addEventListener('mouseover', event=>{
if (event.target !== e)
return
e.style.border = '1px solid #f0f';
})
e.addEventListener('mouseout', event=>{
if (event.target !== e)
return
e.style.border = 'none';
})
}
}
return this._template.content
}
}