diff --git a/assets/assetpack.def b/assets/assetpack.def index 41dcab1af23..5f262f22a44 100644 --- a/assets/assetpack.def +++ b/assets/assetpack.def @@ -176,6 +176,9 @@ ! ws_console.js < javascripts/ws_console.js +! run_example.js +< javascripts/run_example.js + ! logo-16.png < images/logo-16.png diff --git a/assets/javascripts/run_example.js b/assets/javascripts/run_example.js new file mode 100644 index 00000000000..8d8967ed9ca --- /dev/null +++ b/assets/javascripts/run_example.js @@ -0,0 +1,29 @@ +function runExample(form) { + let data = $(form).serialize(); + console.log('Ser data ' + data + '<<'); + let postUrl = form.dataset.postUrl; + $.ajax({ + url: postUrl, + method: 'POST', + data: data, + success: function (response) { + console.log(response.ids); + for (newjobid in response.ids) { + console.log('id ' + response.ids[newjobid]); + alert('job runs on localhost/tests/' + response.ids[newjobid]); + } + //fetchHtmlEntry(rowUrl + response.id, targetElement); + }, + error: function (xhr, ajaxOptions, thrownError) { + console.log(ajaxOptions); + console.log(xhr); + + if (xhr.responseJSON.error) { + console.log(xhr.responseJSON.error); + } else { + console.log(thrownError); + } + } + }); + event.preventDefault(); +} diff --git a/assets/stylesheets/forms.scss b/assets/stylesheets/forms.scss index a2b48728afb..5220d0fa9a0 100644 --- a/assets/stylesheets/forms.scss +++ b/assets/stylesheets/forms.scss @@ -129,3 +129,7 @@ background-color: $default-bg-color-dark; } } + +label.form-label { + font-weight: bold; +} diff --git a/lib/OpenQA/WebAPI.pm b/lib/OpenQA/WebAPI.pm index 218995368dc..4f8184c5403 100644 --- a/lib/OpenQA/WebAPI.pm +++ b/lib/OpenQA/WebAPI.pm @@ -119,6 +119,9 @@ sub startup ($self) { $r->get('/search')->name('search')->to(template => 'search/search'); $r->get('/tests')->name('tests')->to('test#list'); + + $r->get('/run_test_case')->name('run_test_case')->to('NewJob#create'); + # we have to set this and some later routes up differently on Mojo # < 9 and Mojo >= 9.11 if ($Mojolicious::VERSION > 9.10) { diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm index b2e19fc8fda..2e576c8e621 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm @@ -99,8 +99,9 @@ created, their job ids and the information for jobs that could not be scheduled. sub create { my ($self) = @_; - my $params = $self->req->params->to_hash; + use Data::Dumper; + print(">>>>>> " . Dumper($params) . " <<<<<<<<<{async}; # whether to run the operation as a Minion job my $scheduled_product_clone_id = delete $params->{scheduled_product_clone_id}; # ID of a previous product to clone settings from diff --git a/lib/OpenQA/WebAPI/Controller/NewJob.pm b/lib/OpenQA/WebAPI/Controller/NewJob.pm index 5dbb372f842..0216035524d 100644 --- a/lib/OpenQA/WebAPI/Controller/NewJob.pm +++ b/lib/OpenQA/WebAPI/Controller/NewJob.pm @@ -4,32 +4,9 @@ package OpenQA::WebAPI::Controller::NewJob; use Mojo::Base 'Mojolicious::Controller', -signatures; -#use Cwd 'realpath'; -#use Encode 'decode_utf8'; -#use Mojo::File 'path'; -#use Mojo::URL; -#use Mojo::Util 'decode'; -# use OpenQA::Utils qw(ensure_timestamp_appended find_bug_number locate_needle needledir testcasedir); -# use OpenQA::Jobs::Constants; -# use File::Basename; -# use File::Which 'which'; -# use POSIX 'strftime'; -# use Mojo::JSON 'decode_json'; - sub create ($self) { - #my $self = shift; warn "route called"; - #$self->stash(msg => "Trigger job"); - $self->render(template => "NewJob/create", msg => "Trigger job"); - # openqa-cli schedule \ - # --monitor \ - # --host "${OPENQA_HOST:-https://openqa.opensuse.org}/" \ - # --apikey "$OPENQA_API_KEY" --apisecret "$OPENQA_API_SECRET" \ - # --param-file SCENARIO_DEFINITIONS_YAML=scenario-definitions.yaml \ - # DISTRI=example VERSION=0 FLAVOR=DVD ARCH=x86_64 TEST=simple_boot \ - # BUILD="$GH_REPO.git#$GH_REF" _GROUP_ID="0" \ - # CASEDIR="$GITHUB_SERVER_URL/$GH_REPO.git#$GH_REF" \ - # NEEDLES_DIR="%%CASEDIR%%/needles" + $self->render(template => "NewJob/create"); } diff --git a/templates/webapi/NewJob/create.html.ep b/templates/webapi/NewJob/create.html.ep index 07143282462..5c35910fba4 100644 --- a/templates/webapi/NewJob/create.html.ep +++ b/templates/webapi/NewJob/create.html.ep @@ -4,57 +4,75 @@ %= asset 'ace.css' % end -% title 'New job'; +% title 'Run a Job'; +

<%= title %>

%= include 'layouts/info' - -
+

Hint: Experimental form to trigger a test E.g. see <%= link_to 'this + link' => url_for('not_found') %>. +

+
+
- + + placeholder="example" value="example" name="DISTRI">
- - + +
- - + +
-
- - + +
- - + +
- - + +
-
- +
+
-
- - +
+ +
- +