Commit 7a39c212 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Add all jobs to menu in standalone mode, sorted alphabetically, Implements #119

parent efd11bcd
......@@ -237,7 +237,7 @@ class Functions:
return items
@staticmethod
def is_in_gallery(id_job, mode):
def is_in_gallery(id_job, mode="webserver"):
if mode == "webserver":
from dgenies.database import Gallery, Job
from peewee import DoesNotExist
......@@ -246,3 +246,12 @@ class Functions:
except DoesNotExist:
return False
return False
@staticmethod
def get_list_all_jobs(mode="webserver"):
if mode == "webserver":
return [] # Don't give the list in webserver as it's multi-user
all_jobs = os.listdir(Functions.config.app_data)
if "gallery" in all_jobs:
all_jobs.remove("gallery")
return sorted(all_jobs, key=lambda x: x.lower())
dgenies = {};
dgenies.loading = "#loading";
dgenies.noise = true;
dgenies.mode = "webserver";
dgenies.init = function() {
dgenies.init = function(all_jobs, mode) {
dgenies.mode = mode;
let cookies = $.cookie("results");
cookies = (cookies !== undefined && cookies.length > 0) ? cookies.split("|") : [];
if (mode === "webserver") {
cookies = (cookies !== undefined && cookies.length > 0) ? cookies.split("|") : [];
}
else {
cookies = all_jobs;
dgenies.save_cookies(cookies);
}
dgenies.update_results(cookies);
};
dgenies.save_cookies = function(cookies) {
$.cookie("results", cookies.join("|"), {path: '/'});
}
dgenies.update_results = function(results) {
let job_list_item = $("ul.nav li.result ul");
job_list_item.html("");
......
......@@ -8,25 +8,9 @@ dgenies.result.id_res = null;
dgenies.result.init = function(id_res) {
dgenies.result.id_res = id_res;
dgenies.result.update_cookies();
d3.boxplot.init();
};
dgenies.result.update_cookies = function () {
let cookies = $.cookie("results");
cookies = (cookies !== undefined && cookies.length > 0) ? cookies.split("|") : [];
let index = cookies.indexOf(dgenies.result.id_res);
let need_update = false;
if (index === -1) {
need_update = true;
cookies.unshift(dgenies.result.id_res)
}
$.cookie("results", cookies.join("|"), {path: '/'});
if (need_update) {
dgenies.update_results(cookies);
}
};
dgenies.result.remove_job_from_cookie = function(job) {
let cookies = $.cookie("results");
cookies = cookies !== undefined ? cookies.split("|") : [];
......
......@@ -10,16 +10,14 @@ dgenies.run.max_upload_file_size = -1
dgenies.run.files = [undefined, undefined];
dgenies.run.allow_upload = false;
dgenies.run.ping_interval = null;
dgenies.run.mode = "webserver"
dgenies.run.init = function (s_id, allowed_ext, max_upload_file_size=1073741824, mode="webserver") {
dgenies.run.init = function (s_id, allowed_ext, max_upload_file_size=1073741824) {
dgenies.run.s_id = s_id;
dgenies.run.allowed_ext = allowed_ext;
dgenies.run.max_upload_file_size = max_upload_file_size
dgenies.run.restore_form();
dgenies.run.set_events();
dgenies.run.init_fileuploads();
dgenies.run.mode = mode;
};
dgenies.run.restore_form = function () {
......@@ -257,7 +255,7 @@ dgenies.run.do_submit = function () {
dgenies.post("/launch_analysis",
{
"id_job": $("input#id_job").val(),
"email": dgenies.run.mode === "webserver" ? $("input#email").val() : "",
"email": dgenies.mode === "webserver" ? $("input#email").val() : "",
"query": $("input#query").val(),
"query_type": $("select.query").find(":selected").text().toLowerCase(),
"target": $("input#target").val(),
......@@ -302,7 +300,7 @@ dgenies.run.valid_form = function () {
}
// Check mail:
if (dgenies.run.mode === "webserver") {
if (dgenies.mode === "webserver") {
let email = $("input#email").val();
let mail_re = /^.+@.+\..+$/;
if (email.match(mail_re) === null) {
......
......@@ -20,7 +20,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css">
<link rel="shortcut icon" href="{{ url_for('static', filename='images/favicon.ico') }}">
</head>
<body role="document" onload="{% block onload %}dgenies.init();{% endblock %}">
<body role="document" onload="{% block onload %}dgenies.init({{ all_jobs}}, '{{ mode }}');{% endblock %}">
{% block body %}
<div id="main-wrapper">
<!-- Fixed navbar -->
......
......@@ -11,7 +11,7 @@
{% endblock %}
{% block onload %}
{{ super() }}
dgenies.run.init('{{ s_id }}',{{ allowed_ext }}, {{ max_upload_file_size }}, '{{ mode }}');
dgenies.run.init('{{ s_id }}',{{ allowed_ext }}, {{ max_upload_file_size }});
{% endblock %}
{% block content %}
<form id="submit_minimap" method=post action="#">
......
......@@ -24,7 +24,8 @@ if MODE == "webserver":
def global_templates_variables():
return {
"title": app_title,
"mode": MODE
"mode": MODE,
"all_jobs": Functions.get_list_all_jobs(MODE)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment