How to add a launch page » History » Version 15
Amber Herold, 02/05/2014 04:46 PM
1 | 1 | Amber Herold | h1. How to add a job launch page to the Appion pipeline |
---|---|---|---|
2 | |||
3 | 15 | Amber Herold | If you are adding a GUI to launch a python script that is based on the AppionLoop class found in appionLoop2.py, follow the [[directions for adding an AppionLoop GUI page]]. |
4 | |||
5 | 4 | Amber Herold | # *Add a php page with the basic appion template* |
6 | 5 | Amber Herold | |
7 | 10 | Neil Voss | Most of our launch pages are php files with at leat 2 functions, one to create a form for the user to fill out, and another to build a job command when the user submits the form. You can copy an existing PHP file such as runSimple.php to create your new launch page. To give your page the Appion processing page look and feel with the header and side menu, be sure the functions processing_header($title,$heading,$javascript) and processing_footer() are called. |
8 | 11 | Neil Voss | |
9 | 14 | Neil Voss | A starting template with documentation is available here to get you started: |
10 | <pre> |
||
11 | cp -v runAppionScript.php.template runMyProgram.php |
||
12 | </pre> |
||
13 | 4 | Amber Herold | # *Add a link to your page in the menuprocessing.php file or from another page* |
14 | 5 | Amber Herold | |
15 | 4 | Amber Herold | The menuprocessing file is a bit tricky to work with. |
16 | 5 | Amber Herold | |
17 | 4 | Amber Herold | # *Create a new form class for your package specific parameters* |
18 | 5 | Amber Herold | |
19 | 4 | Amber Herold | You can copy simpleParamsForm.inc as a template for your own form parameters. There are 2 primary functions to define. |
20 | ## Define the constructor |
||
21 | This is where all your parameters are listed. Values passed into the constructor become default values. Validations can be added to any of the parameters. |
||
22 | ## Define the generateForm() function |
||
23 | This function outputs html. There are many predefined parameter fields that can be used to build your form. |
||
24 | 5 | Amber Herold | |
25 | 4 | Amber Herold | # *Add pop-up help messages to help.js* |
26 | 5 | Amber Herold | |
27 | 4 | Amber Herold | Located at myami/myamiweb/processing/js/help.js. |
28 | ## Add a new namespace for your form, you can copy the 'simple' section. Don't forget any commas. |
||
29 | ## add a help string for each of the parameter keys in your form |
||
30 | ## make sure $javascript .= writeJavaPopupFunctions(); is in your createForm() function in your php launch page prior to the processing header function. |
||
31 | 5 | Amber Herold | |
32 | 4 | Amber Herold | # *Add a publication reference for the package you are using* |
33 | 5 | Amber Herold | |
34 | 4 | Amber Herold | ## Edit /myami/myamiweb/processing/inc/publicationList.inc to include an entry for any references you need to add to your launch page. |
35 | ## publications can be added to a page with the following code: |
||
36 | 3 | Amber Herold | <pre> |
37 | 4 | Amber Herold | $pub = new Publication('appion'); |
38 | echo $pub->getHtmlTable(); //returns the html reference to the "appion" publication |
||
39 | 3 | Amber Herold | </pre> |
40 | 6 | Amber Herold | |
41 | # *Use your new form class in your launch page* |
||
42 | 1 | Amber Herold | |
43 | 8 | Amber Herold | ## Modify the launch page *createForm()* function |
44 | 9 | Amber Herold | The create form function outputs the html needed for your form. The myami/myamiweb/processing/inc/forms directory holds reusable form classes based on the basicForm.inc class. Any combination of these can be used to add parameters to your form with little knowlege of html. You may also create a new form class to define the parameters specific to your job command. |
45 | 6 | Amber Herold | ### Add a call to your form class generateForm() function, adding default values in the constructor. |
46 | <pre> |
||
47 | $simpleParamsForm = new SimpleParamsForm('','','','CHECKED','','','10','30','','20','100','2','2','10','','0.8','40','3','3'); |
||
48 | echo $simpleParamsForm->generateForm(); |
||
49 | </pre> |
||
50 | ### Add a reference to your publication |
||
51 | <pre> |
||
52 | $pub = new Publication('appion'); |
||
53 | echo $pub->getHtmlTable(); |
||
54 | </pre> |
||
55 | 8 | Amber Herold | ## Modify the launch page *createCommand()* function |
56 | 6 | Amber Herold | ### instantiate and validate your form parameters |
57 | <pre> |
||
58 | $simpleParamsForm = new SimpleParamsForm(); |
||
59 | $errorMsg .= $simpleParamsForm->validate( $_POST ); |
||
60 | </pre> |
||
61 | ### Create your new command |
||
62 | <pre> |
||
63 | /* ******************* |
||
64 | PART 2: Create program command |
||
65 | ******************** */ |
||
66 | $command = "runSimpleCluster.py "; |
||
67 | |||
68 | // add run parameters |
||
69 | $command .= $runParametersForm->buildCommand( $_POST ); |
||
70 | |||
71 | // add simple parameters |
||
72 | $command .= $simpleParamsForm->buildCommand( $_POST ); |
||
73 | </pre> |
||
74 | ### Add a reference to your publication in the header info |
||
75 | ### Change the jobtype passed in showOrSubmitCommand() |