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.auth.rserv.CachingFileAccess;
32 import org.onap.aaf.misc.env.APIException;
33 import org.onap.aaf.misc.env.StaticSlot;
34 import org.onap.aaf.misc.xgen.Cache;
35 import org.onap.aaf.misc.xgen.DynamicCode;
36 import org.onap.aaf.misc.xgen.Mark;
37 import org.onap.aaf.misc.xgen.html.HTMLGen;
39 public class WebCommand extends Page {
40 public static final String HREF = "/gui/cui";
42 public WebCommand(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
43 super(gui.env, "Web Command Client",HREF, NO_FIELDS,
44 new BreadCrumbs(breadcrumbs),
45 new NamedCode(true, "content") {
46 StaticSlot sThemeWebPath = gui.env.staticSlot(CachingFileAccess.CFA_WEB_PATH);
47 StaticSlot sTheme = gui.env.staticSlot(AAF_GUI.AAF_GUI_THEME);
49 public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
50 hgen.leaf("p","id=help_msg")
51 .text("Questions about this page? ")
52 .leaf("a", "href="+gui.env.getProperty(AAF_URL_CUIGUI,""), "target=_blank")
55 .text(". Type 'help' below for a list of AAF commands")
58 .divID("console_and_options");
59 hgen.divID("console_area");
60 hgen.end(); //console_area
62 hgen.divID("options_link", "class=closed");
63 cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
65 public void code(AAF_GUI state, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen xgen)
66 throws APIException, IOException {
67 String image_root = "src=../../"+state.env.get(sThemeWebPath).toString() + '/' + state.env.get(sTheme) + "/images/icons";
68 hgen.img(image_root + "/options_down.png", "onclick=handleDivHiding('options',this);",
69 "id=options_img", "alt=Options", "title=Options")
70 .end(); //options_link
72 hgen.divID("options");
74 switch(browser(trans,trans.env().slot(getBrowserType()))) {
77 // IE doesn't support file save
80 xgen.img(image_root+"/AAF_download.png", "onclick=saveToFile();",
81 "alt=Save log to file", "title=Save log to file");
83 // xgen.img("src=../../"+gui.theme+"/AAF_email.png", "onclick=emailLog();",
84 // "alt=Email log to me", "title=Email log to me");
85 xgen.img(image_root+"/AAF_font_size.png", "onclick=handleDivHiding('text_slider',this);",
86 "id=fontsize_img", "alt=Change text size", "title=Change text size");
87 xgen.img(image_root+"/AAF_details.png", "onclick=selectOption(this,0);",
88 "id=details_img", "alt=Turn on/off details mode", "title=Turn on/off details mode");
89 xgen.img(image_root+"/AAF_maximize.png", "onclick=maximizeConsole(this);",
90 "id=maximize_img", "alt=Maximize Console Window", "title=Maximize Console Window");
93 hgen.divID("text_slider");
94 hgen.tagOnly("input", "type=button", "class=change_font", "onclick=buttonChangeFontSize('dec')", "value=-")
95 .tagOnly("input", "id=text_size_slider", "type=range", "min=75", "max=200", "value=100",
96 "oninput=changeFontSize(this.value)", "onchange=changeFontSize(this.value)", "title=Change Text Size")
97 .tagOnly("input", "type=button", "class=change_font", "onclick=buttonChangeFontSize('inc')", "value=+")
100 hgen.end(); //options
101 hgen.end(); //console_and_options
103 hgen.divID("input_area");
104 hgen.tagOnly("input", "type=text", "id=command_field",
105 "autocomplete=off", "autocorrect=off", "autocapitalize=off", "spellcheck=false",
106 "onkeypress=keyPressed()", "placeholder=Type your AAFCLI commands here", "autofocus")
107 .tagOnly("input", "id=submit", "type=button", "value=Submit",
108 "onclick=http('put','../../gui/cui',getCommand(),callCUI);")
111 Mark callCUI = new Mark();
113 hgen.text("function callCUI(resp) {")
114 .text("moveCommandToDiv();")
115 .text("printResponse(resp);")