Mercurial > sci
changeset 48:3cf148705724
scid: refactor status classes in bulma
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 16 Aug 2022 18:40:01 +0200 |
parents | e8f24896b484 |
children | 9d8df0c1db63 |
files | scid/page-index.c scid/page-workers.c sql/jobresult-list-by-worker.sql themes/bulma/index.mustache themes/bulma/jobresults.mustache themes/bulma/theme.js themes/bulma/worker.mustache |
diffstat | 7 files changed, 17 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/scid/page-index.c Tue Aug 16 18:29:08 2022 +0200 +++ b/scid/page-index.c Tue Aug 16 18:40:01 2022 +0200 @@ -28,10 +28,11 @@ static void set_job_status(json_t *project, json_t *job, json_t *jobresults) { - json_t *iter, *status; + json_t *iter; int exitcode, sigcode; size_t i, ns = 0, nf = 0; + /* Compute number of failures and number of success. */ json_array_foreach(jobresults, i, iter) { json_unpack(iter, "{si si}", "exitcode", &exitcode, "sigcode", &sigcode); @@ -39,14 +40,12 @@ ns++; else nf++; + + /* Also add exitcode and sigcode to the job object. */ + json_object_set_new(job, "exitcode", json_integer(exitcode)); + json_object_set_new(job, "sigcode", json_integer(sigcode)); } - if (nf) - status = json_string("failed"); - else - status = json_string("success"); - - json_object_set_new(job, "status", status); json_object_set_new(project, "n-failed", json_integer(nf)); json_object_set_new(project, "n-success", json_integer(ns)); }
--- a/scid/page-workers.c Tue Aug 16 18:29:08 2022 +0200 +++ b/scid/page-workers.c Tue Aug 16 18:40:01 2022 +0200 @@ -39,7 +39,6 @@ if ((jobs = db_jobresult_list_by_worker(r->path))) json_object_set_new(worker, "jobs", jobs); - //printf("worker=%s\n", json_dumps(worker, JSON_INDENT(4))); body = theme_render("onPageWorker", worker); pageutil_render(r, KHTTP_200, KMIME_TEXT_HTML, body); free(body);
--- a/sql/jobresult-list-by-worker.sql Tue Aug 16 18:29:08 2022 +0200 +++ b/sql/jobresult-list-by-worker.sql Tue Aug 16 18:40:01 2022 +0200 @@ -1,4 +1,5 @@ - SELECT * + SELECT rowid + , * FROM `jobresult` WHERE `worker_name` = ? ORDER BY `job_id` ASC
--- a/themes/bulma/index.mustache Tue Aug 16 18:29:08 2022 +0200 +++ b/themes/bulma/index.mustache Tue Aug 16 18:40:01 2022 +0200 @@ -24,7 +24,7 @@ <tr> <td><a href="jobresults/{{id}}">{{id}}</a></td> <td>{{tag}}</td> - <td><span class="tag {{classname}} is-light">{{status}}</span></td> + <td><span class="tag {{textcolor}} is-light">{{status}}</span></td> </tr> {{/jobs}} </table>
--- a/themes/bulma/jobresults.mustache Tue Aug 16 18:29:08 2022 +0200 +++ b/themes/bulma/jobresults.mustache Tue Aug 16 18:40:01 2022 +0200 @@ -15,7 +15,7 @@ <td><a href="/workers/{{worker_name}}">{{worker_name}}</a></td> <td>{{exitcode}}</td> <td>{{sigcode}}</td> - <td class="{{classname}}">{{status}}</td> + <td class="{{textcolor}}">{{status}}</td> <td><button class="button is-light is-info is-small js-modal-trigger" data-target="console-{{job_id}}">view log</button></td> </tr> {{/jobresults}}
--- a/themes/bulma/theme.js Tue Aug 16 18:29:08 2022 +0200 +++ b/themes/bulma/theme.js Tue Aug 16 18:40:01 2022 +0200 @@ -31,12 +31,12 @@ for (var j = 0; j < jobs.length; ++j) { if (jobs[j].exitcode !== 0 || jobs[j].sigcode !== 0) { jobs[j].color = "is-danger"; - jobs[j].classname = "has-text-success"; - jobs[j].status = "success"; + jobs[j].textcolor = "has-text-danger"; + jobs[j].status = "failed"; } else { jobs[j].color = "is-success"; - jobs[j].textcolor = "has-text-danger"; - jobs[j].status = "failed"; + jobs[j].textcolor = "has-text-success"; + jobs[j].status = "success"; } } } @@ -58,16 +58,7 @@ /* * Add a status on failed/successful tasks. */ - for (var i = 0; i < data.jobresults.length; ++i) { - if (data.jobresults[i].exitcode !== 0 || data.jobresults[i].sigcode !== 0) { - data.jobresults[i].status = "failed"; - data.jobresults[i].classname = "has-text-danger"; - } else { - data.jobresults[i].status = "passed"; - data.jobresults[i].classname = "has-text-success"; - } - } - + addStatusClasses(data.jobresults); render(rdr, "jobresults.mustache", "sci -- job results", data); } @@ -79,6 +70,7 @@ function onPageWorker(rdr, data) { /* Similar to index page, add classes. */ + Scid.print(JSON.stringify(data, null, 4)); if (typeof (data.jobs) === "object") addStatusClasses(data.jobs);
--- a/themes/bulma/worker.mustache Tue Aug 16 18:29:08 2022 +0200 +++ b/themes/bulma/worker.mustache Tue Aug 16 18:40:01 2022 +0200 @@ -28,7 +28,7 @@ {{#jobs}} <tr> <td><a href="/jobresults/{{id}}">{{id}}</a></td> - <td><span class="tag {{classname}} is-light">{{status}}</span></td> + <td><span class="tag {{textcolor}} is-light">{{status}}</span></td> </tr> {{/jobs}} </table>