2 * ============LICENSE_START====================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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====================================================
22 package org.onap.aaf.auth.gui.pages;
24 import java.io.IOException;
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;
37 public class WebCommand extends Page {
38 public static final String HREF = "/gui/cui";
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") {
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")
51 .text(". Type 'help' below for a list of AAF commands")
54 .divID("console_and_options");
55 hgen.divID("console_area");
56 hgen.end(); //console_area
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
63 hgen.divID("options");
64 cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
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()))) {
71 // IE doesn't support file save
74 xgen.img("src=../../"+gui.theme+"/AAFdownload.png", "onclick=saveToFile();",
75 "alt=Save log to file", "title=Save log to file");
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");
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=+")
95 hgen.end(); //console_and_options
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);")
105 Mark callCUI = new Mark();
107 hgen.text("function callCUI(resp) {")
108 .text("moveCommandToDiv();")
109 .text("printResponse(resp);")