Mass removal of all Tabs (Style Warnings)
[aaf/authz.git] / auth / auth-gui / src / main / java / org / onap / aaf / auth / gui / pages / WebCommand.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.auth.gui.pages;
23
24 import java.io.IOException;
25
26 import org.onap.aaf.auth.env.AuthzTrans;
27 import org.onap.aaf.auth.gui.AAF_GUI;
28 import org.onap.aaf.auth.gui.BreadCrumbs;
29 import org.onap.aaf.auth.gui.NamedCode;
30 import org.onap.aaf.auth.gui.Page;
31 import org.onap.aaf.misc.env.APIException;
32 import org.onap.aaf.misc.xgen.Cache;
33 import org.onap.aaf.misc.xgen.DynamicCode;
34 import org.onap.aaf.misc.xgen.Mark;
35 import org.onap.aaf.misc.xgen.html.HTMLGen;
36
37 public class WebCommand extends Page {
38     public static final String HREF = "/gui/cui";
39     
40     public WebCommand(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
41         super(gui.env, "Web Command Client",HREF, NO_FIELDS,
42                 new BreadCrumbs(breadcrumbs),
43                 new NamedCode(true, "content") {
44             @Override
45             public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
46                 hgen.leaf("p","id=help_msg")
47                     .text("Questions about this page? ")
48                     .leaf("a", "href="+gui.env.getProperty(AAF_URL_CUIGUI,""), "target=_blank")
49                     .text("Click here")
50                     .end()
51                     .text(". Type 'help' below for a list of AAF commands")
52                     .end()
53                     
54                     .divID("console_and_options");
55                 hgen.divID("console_area");                
56                 hgen.end(); //console_area
57                 
58                 hgen.divID("options_link", "class=closed");
59                 hgen.img("src=../../"+gui.theme + "/options_down.png", "onclick=handleDivHiding('options',this);", 
60                         "id=options_img", "alt=Options", "title=Options")                    
61                     .end(); //options_link
62                 
63                 hgen.divID("options");
64                 cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
65                     @Override
66                     public void code(AAF_GUI state, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen xgen)
67                             throws APIException, IOException {
68                         switch(browser(trans,trans.env().slot(getBrowserType()))) {
69                             case ie:
70                             case ieOld:
71                                 // IE doesn't support file save
72                                 break;
73                             default:
74                                 xgen.img("src=../../"+gui.theme+"/AAFdownload.png", "onclick=saveToFile();",
75                                         "alt=Save log to file", "title=Save log to file");
76                         }
77 //                        xgen.img("src=../../"+gui.theme+"/AAFemail.png", "onclick=emailLog();",
78 //                                "alt=Email log to me", "title=Email log to me");
79                         xgen.img("src=../../"+gui.theme+"/AAF_font_size.png", "onclick=handleDivHiding('text_slider',this);", 
80                                 "id=fontsize_img", "alt=Change text size", "title=Change text size");
81                         xgen.img("src=../../"+gui.theme+"/AAF_details.png", "onclick=selectOption(this,0);", 
82                                 "id=details_img", "alt=Turn on/off details mode", "title=Turn on/off details mode");
83                         xgen.img("src=../../"+gui.theme+"/AAF_maximize.png", "onclick=maximizeConsole(this);",
84                                 "id=maximize_img", "alt=Maximize Console Window", "title=Maximize Console Window");
85                     }    
86                 });
87                 hgen.divID("text_slider");
88                 hgen.tagOnly("input", "type=button", "class=change_font", "onclick=buttonChangeFontSize('dec')", "value=-")
89                     .tagOnly("input", "id=text_size_slider", "type=range", "min=75", "max=200", "value=100", 
90                         "oninput=changeFontSize(this.value)", "onchange=changeFontSize(this.value)", "title=Change Text Size")
91                     .tagOnly("input", "type=button", "class=change_font", "onclick=buttonChangeFontSize('inc')", "value=+")                
92                     .end(); //text_slider
93
94                 hgen.end(); //options
95                 hgen.end(); //console_and_options
96                 
97                 hgen.divID("input_area");
98                 hgen.tagOnly("input", "type=text", "id=command_field", 
99                         "autocomplete=off", "autocorrect=off", "autocapitalize=off", "spellcheck=false",
100                         "onkeypress=keyPressed()", "placeholder=Type your AAFCLI commands here", "autofocus")
101                     .tagOnly("input", "id=submit", "type=button", "value=Submit", 
102                             "onclick=http('put','../../gui/cui',getCommand(),callCUI);")
103                     .end();
104
105                 Mark callCUI = new Mark();
106                 hgen.js(callCUI);
107                 hgen.text("function callCUI(resp) {")
108                     .text("moveCommandToDiv();")
109                     .text("printResponse(resp);") 
110                     .text("}");
111                 hgen.end(callCUI);    
112             
113             }
114         });
115
116     }
117
118 }