aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-05-06 16:00:59 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-05-06 16:00:59 -0400
commit55870299e41492ee8ab6c50116061f48f06fcd7d (patch)
tree046ea3e9d4dffe186dff78c3b5fb7d87aca9d08c
parenta67622fdc0dbe7f6be04667663f58b31fbf30a8d (diff)
downloadlevitating-55870299e41492ee8ab6c50116061f48f06fcd7d.tar.gz
levitating-55870299e41492ee8ab6c50116061f48f06fcd7d.zip
Individual job results can now be displayed via CGI
-rw-r--r--captain/external.f9027
-rw-r--r--captain/requtils.f9026
-rw-r--r--captain/web.f9092
3 files changed, 115 insertions, 30 deletions
diff --git a/captain/external.f90 b/captain/external.f90
index 49331ba..8ca5c97 100644
--- a/captain/external.f90
+++ b/captain/external.f90
@@ -142,32 +142,6 @@ contains
end function generate_one_job_gemini
-
- subroutine get_job_page_title(req, title)
- use captain_db
- use server_response
- implicit none
-
- type(request), intent(in)::req
- character(*), intent(out)::title
-
- integer::job_id, i
- character(32)::job_text
- character(PLAYER_NAME_LENGTH)::instruction_name
-
- ! All this to get the job id
- call req%last_component(job_text)
- i = index(job_text, ".")
- job_text(i:len(job_text)) = " "
- read(job_text, '(I8)') job_id
-
- ! Request instruction name
- i = get_job_instruction(job_id)
- call get_instruction_name(i, instruction_name)
-
- title = "Job "//trim(job_text)//" - "//trim(instruction_name)
-
- end subroutine get_job_page_title
function generate_releases_gemini(req) result(res)
use utilities
@@ -606,6 +580,7 @@ contains
use config, only: template_filepath, project
use logging
use server_response
+ use request_utils, only: get_job_page_title
implicit none
class(request), intent(in)::req
diff --git a/captain/requtils.f90 b/captain/requtils.f90
index 742f8ac..b28500e 100644
--- a/captain/requtils.f90
+++ b/captain/requtils.f90
@@ -283,4 +283,30 @@ contains
end function render_jobs_links
+ subroutine get_job_page_title(req, title)
+ use captain_db
+ use server_response
+ implicit none
+
+ type(request), intent(in)::req
+ character(*), intent(out)::title
+
+ integer::job_id, i
+ character(32)::job_text
+ character(PLAYER_NAME_LENGTH)::instruction_name
+
+ ! All this to get the job id
+ call req%last_component(job_text)
+ i = index(job_text, ".")
+ job_text(i:len(job_text)) = " "
+ read(job_text, '(I8)') job_id
+
+ ! Request instruction name
+ i = get_job_instruction(job_id)
+ call get_instruction_name(i, instruction_name)
+
+ title = "Job "//trim(job_text)//" - "//trim(instruction_name)
+
+ end subroutine get_job_page_title
+
end module request_utils \ No newline at end of file
diff --git a/captain/web.f90 b/captain/web.f90
index e232e2d..3ac260a 100644
--- a/captain/web.f90
+++ b/captain/web.f90
@@ -64,6 +64,88 @@ contains
end function html_link
+ function generate_one_job_html(req) result(res)
+ use captain_db
+ use server_response
+ use special_filenames, only: get_task_result_static_filename
+ use request_utils, only: get_status_utf8
+ implicit none
+
+ type(request), intent(in)::req
+ character(len=:), pointer::res
+
+ character(4)::status
+ integer::i, j, job_id
+ type(job)::one_job
+
+ character(PLAYER_NAME_LENGTH)::player
+ character(1)::nl = new_line(' ')
+
+ type(task), dimension(:), pointer::tasks
+ character(32)::task_text, job_text
+ character(len=:), pointer::task_results_filename, one_link
+
+ logical::file_exists
+
+ res => null()
+
+ ! Ugh, all this nonsense
+ call req%last_component(job_text)
+ j = index(job_text, ".", back=.true.)
+ job_text(j:len(job_text)) = " "
+ read(job_text, '(I8)') job_id
+ one_job = get_job(job_id)
+
+ if(one_job%id >= 0) then
+ allocate(character(len=1024) :: res)
+
+ status = get_status_utf8(one_job%status)
+ res = "<h2>Status - "//status//"</h2>"
+
+ call get_player_name(one_job%player, player)
+ res = trim(res)//nl//nl//"<p><em>Running on "//trim(player)//nl// &
+ "Last update at: "//one_job%time//"</em></p>"
+
+ res = trim(res)//nl//nl//"<h3>Task Results</h3>"
+
+ tasks => get_job_tasks(job_id)
+ if(associated(tasks)) then
+ res = trim(res)//nl//"<ul>"
+ do i = 1, size(tasks)
+ status = get_status_utf8(tasks(i)%status)
+ task_results_filename => get_task_result_static_filename(one_job%id, i, no_path=.true.)
+
+ inquire(file=task_results_filename, exist=file_exists)
+
+ write(task_text, '(I8)') i
+
+ if(file_exists) then
+ one_link => html_link("../results/"//task_results_filename, &
+ trim(status)//" - Task "//trim(adjustl(task_text)))
+
+ res = trim(res)//nl//" <li>"//trim(one_link)//"</li>"
+ deallocate(one_link)
+ else
+ res = trim(res)//nl//" <li>"//trim(status)//" - Task "//trim(adjustl(task_text))//"</li>"
+ end if
+
+ deallocate(task_results_filename)
+ end do
+ res = trim(res)//nl//"</ul>"
+ deallocate(tasks)
+ else
+ res = trim(res)//nl//nl//"<p><strong>None reported yet</strong></p>"
+ end if
+
+ else
+
+ allocate(character(len=64) :: res)
+ write(res, '(A20, 1X, I5)') "No record of:", job_id
+
+ end if
+
+ end function generate_one_job_html
+
function generate_releases_html(req) result(res)
use utilities
use server_response
@@ -232,6 +314,7 @@ contains
use logging
use server_response, only:request, response
use http, only: HTTP_CODE_SUCCESS, HTTP_CODE_NOTFOUND
+ use request_utils, only: get_job_page_title
implicit none
type(request), intent(in)::req
@@ -242,6 +325,7 @@ contains
character(64)::first
character(len=:), pointer::contents
+ character(128)::job_page_title
call template_filepath("index.html", template_file)
call page%init(trim(template_file))
@@ -293,10 +377,10 @@ contains
else if(trim(first) == "jobs") then
- !call get_job_page_title(req, job_page_title)
- !call page%assign('title', trim(job_page_title))
- !contents => generate_one_job_gemini(req)
- !call page%assign('contents', contents)
+ call get_job_page_title(req, job_page_title)
+ call page%assign('title', trim(job_page_title))
+ contents => generate_one_job_html(req)
+ call page%assign('contents', contents)
else