Skip to content

Commit

Permalink
#271 fixed web GUI according to changes in soma-base
Browse files Browse the repository at this point in the history
  • Loading branch information
sapetnioc committed Sep 27, 2023
1 parent d35a7af commit eeffa26
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
26 changes: 6 additions & 20 deletions capsul/ui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
# -*- coding: utf-8 -*-

from capsul.api import Capsul
from capsul.web import WebRoutes, WebBackend

from soma.qt_gui.qt_backend import Qt
from soma.web import WebRoutes, WebBackend


class CapsulRoutes(WebRoutes):
_templates = {
'qt_backend.js',
'html_backend.js'
}
def dashboard(self):
return self._result('dashboard.html')



def engine(self, engine_label):
engine = self.handler.jinja_kwargs['capsul'].engine(engine_label)
engine = self._handler['capsul'].engine(engine_label)
if engine:
return self._result('engine.html', engine=engine)

Expand All @@ -29,28 +21,22 @@ def execution(self, engine_label, execution_id):


class CapsulBackend(WebBackend):

def capsul(self):
if not hasattr(self, '_capsul'):
self._capsul = Capsul()
return self._capsul

def engines(self) -> list:
return [engine.engine_status() for engine in self.capsul().engines()]
return [engine.engine_status() for engine in self._handler['capsul'].engines()]


def engine_status(self, engine_label: str) -> dict:
try:
engine = self.capsul().engine(engine_label)
engine = self._handler['capsul'].engine(engine_label)
except ValueError:
return {}
return engine.engine_status()


def executions_summary(self, engine_label: str) -> list:
return self.capsul().engine(engine_label).executions_summary()
return self._handler['capsul'].engine(engine_label).executions_summary()


def execution_report(self, engine_label: str, execution_id: str) -> dict:
with self.capsul().engine(engine_label) as engine:
with self._handler['capsul'].engine(engine_label) as engine:
return engine.database.execution_report_json(engine.engine_id, execution_id)
1 change: 1 addition & 0 deletions capsul/ui/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h1>Capsul engines</h1>
{% block script %}
<script>
function set_engines(engines_status) {
console.log('!1!', engines_status)
let engines_table = document.getElementById("engines_table");
engines_status.forEach(engine_status => {
let tr = document.createElement("tr");
Expand Down
2 changes: 1 addition & 1 deletion capsul/ui/templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'soma_layout.html' %}
{%- block head%}
{%- block head %}
<link rel="icon" href="{{base_url}}/static/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="{{base_url}}/static/capsul.css">
{%- endblock %}
Expand Down

0 comments on commit eeffa26

Please sign in to comment.