AT&T 2.0.19 Code drop, stage 4
[aaf/authz.git] / authz-gui / src / main / java / com / att / authz / gui / pages / WebCommand.java
1 /*******************************************************************************
2  * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
3  *******************************************************************************/
4 package com.att.authz.gui.pages;
5
6 import java.io.IOException;
7
8 import com.att.authz.env.AuthzTrans;
9 import com.att.authz.gui.AuthGUI;
10 import com.att.authz.gui.BreadCrumbs;
11 import com.att.authz.gui.NamedCode;
12 import com.att.authz.gui.Page;
13 import org.onap.aaf.inno.env.APIException;
14 import com.att.xgen.Cache;
15 import com.att.xgen.DynamicCode;
16 import com.att.xgen.Mark;
17 import com.att.xgen.html.HTMLGen;
18
19 public class WebCommand extends Page {
20         public static final String HREF = "/gui/cui";
21         
22         public WebCommand(final AuthGUI gui, final Page ... breadcrumbs) throws APIException, IOException {
23                 super(gui.env, "Web Command Client",HREF, NO_FIELDS,
24                                 new BreadCrumbs(breadcrumbs),
25                                 new NamedCode(true, "content") {
26                         @Override
27                         public void code(Cache<HTMLGen> cache, HTMLGen hgen) throws APIException, IOException {
28                                 hgen.leaf("p","id=help_msg")
29                                         .text("Questions about this page? ")
30                                         .leaf("a", "href=http://wiki.web.att.com/display/aaf/Web+CUI+Usage", "target=_blank")
31                                         .text("Click here")
32                                         .end()
33                                         .text(". Type 'help' below for a list of AAF commands")
34                                         .end()
35                                         
36                                         .divID("console_and_options");
37                                 hgen.divID("console_area");                             
38                                 hgen.end(); //console_area
39                                 
40                                 hgen.divID("options_link", "class=closed");
41                                 hgen.img("src=../../theme/options_down.png", "onclick=handleDivHiding('options',this);", 
42                                                 "id=options_img", "alt=Options", "title=Options")                                       
43                                         .end(); //options_link
44                                 
45                                 hgen.divID("options");
46                                 cache.dynamic(hgen, new DynamicCode<HTMLGen,AuthGUI,AuthzTrans>() {
47                                         @Override
48                                         public void code(AuthGUI state, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen xgen)
49                                                         throws APIException, IOException {
50                                                 switch(browser(trans,trans.env().slot(getBrowserType()))) {
51                                                         case ie:
52                                                         case ieOld:
53                                                                 // IE doesn't support file save
54                                                                 break;
55                                                         default:
56                                                                 xgen.img("src=../../theme/AAFdownload.png", "onclick=saveToFile();",
57                                                                                 "alt=Save log to file", "title=Save log to file");
58                                                 }
59 //                                              xgen.img("src=../../theme/AAFemail.png", "onclick=emailLog();",
60 //                                                              "alt=Email log to me", "title=Email log to me");
61                                                 xgen.img("src=../../theme/AAF_font_size.png", "onclick=handleDivHiding('text_slider',this);", 
62                                                                 "id=fontsize_img", "alt=Change text size", "title=Change text size");
63                                                 xgen.img("src=../../theme/AAF_details.png", "onclick=selectOption(this,0);", 
64                                                                 "id=details_img", "alt=Turn on/off details mode", "title=Turn on/off details mode");
65                                                 xgen.img("src=../../theme/AAF_maximize.png", "onclick=maximizeConsole(this);",
66                                                                 "id=maximize_img", "alt=Maximize Console Window", "title=Maximize Console Window");
67                                         }       
68                                 });
69
70                                 hgen.divID("text_slider");
71                                 hgen.tagOnly("input", "type=button", "class=change_font", "onclick=buttonChangeFontSize('dec')", "value=-")
72                                         .tagOnly("input", "id=text_size_slider", "type=range", "min=75", "max=200", "value=100", 
73                                                 "oninput=changeFontSize(this.value)", "onchange=changeFontSize(this.value)", "title=Change Text Size")
74                                         .tagOnly("input", "type=button", "class=change_font", "onclick=buttonChangeFontSize('inc')", "value=+")                         
75                                         .end(); //text_slider
76
77                                 hgen.end(); //options
78                                 hgen.end(); //console_and_options
79                                 
80                                 hgen.divID("input_area");
81                                 hgen.tagOnly("input", "type=text", "id=command_field", 
82                                                 "autocomplete=off", "autocorrect=off", "autocapitalize=off", "spellcheck=false",
83                                                 "onkeypress=keyPressed()", "placeholder=Type your AAFCLI commands here", "autofocus")
84                                         .tagOnly("input", "id=submit", "type=button", "value=Submit", 
85                                                         "onclick=http('put','../../gui/cui',getCommand(),callCUI);")
86                                         .end();
87
88                                 Mark callCUI = new Mark();
89                                 hgen.js(callCUI);
90                                 hgen.text("function callCUI(resp) {")
91                                         .text("moveCommandToDiv();")
92                                         .text("printResponse(resp);") 
93                                         .text("}");
94                                 hgen.end(callCUI);      
95                         
96                         }
97                 });
98
99         }
100
101 }