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";
41 public static final String INPUT = "input";
42 public static final String TYPE_BUTTON = "type=button";
44 public WebCommand(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
45 super(gui.env, "Web Command Client",HREF, NO_FIELDS,
46 new BreadCrumbs(breadcrumbs),
47 new NamedCode(true, "content") {
48 StaticSlot sThemeWebPath = gui.env.staticSlot(CachingFileAccess.CFA_WEB_PATH);
49 StaticSlot sTheme = gui.env.staticSlot(AAF_GUI.AAF_GUI_THEME);
51 public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
52 hgen.leaf("p","id=help_msg")
53 .text("Questions about this page? ")
54 .leaf("a", "href="+gui.env.getProperty(AAF_URL_CUIGUI,""), "target=_blank")
57 .text(". Type 'help' below for a list of AAF commands")
60 .divID("console_and_options");
61 hgen.divID("console_area");
62 hgen.end(); //console_area
64 hgen.divID("options_link", "class=closed");
65 cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
67 public void code(AAF_GUI state, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen xgen)
68 throws APIException, IOException {
69 String imageRoot = "src=../../"+state.env.get(sThemeWebPath).toString() + '/' + state.env.get(sTheme) + "/images/icons";
70 hgen.img(imageRoot + "/options_down.png", "onclick=handleDivHiding('options',this);",
71 "id=options_img", "alt=Options", "title=Options")
72 .end(); //options_link
74 hgen.divID("options");
76 switch(browser(trans,trans.env().slot(getBrowserType()))) {
79 // IE doesn't support file save
82 xgen.img(imageRoot+"/AAF_download.png", "onclick=saveToFile();",
83 "alt=Save log to file", "title=Save log to file");
85 xgen.img(imageRoot+"/AAF_font_size.png", "onclick=handleDivHiding('text_slider',this);",
86 "id=fontsize_img", "alt=Change text size", "title=Change text size");
87 xgen.img(imageRoot+"/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(imageRoot+"/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);")