Improved UI and added response beautification for JSON and XML
This commit is contained in:
parent
0d1ea2284f
commit
932ceab72b
13 changed files with 132 additions and 28 deletions
BIN
docs/Credits.odt
Normal file
BIN
docs/Credits.odt
Normal file
Binary file not shown.
17
nbactions.xml
Normal file
17
nbactions.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>run</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath com.rohitawate.restaurant.main.Main</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
13
pom.xml
13
pom.xml
|
@ -34,6 +34,17 @@
|
|||
<artifactId>jersey-hk2</artifactId>
|
||||
<version>2.26</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -76,10 +76,8 @@ public class DashboardController implements Initializable {
|
|||
}
|
||||
responseArea.setText(response);
|
||||
} catch (MalformedURLException ex) {
|
||||
Logger.getLogger(DashboardController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
snackBar.show("Server did not respond", 7000);
|
||||
snackBar.show("Invalid URL. Please verify and try again.", 7000);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DashboardController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
snackBar.show("Server did not respond", 7000);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package com.rohitawate.restaurant.requests;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
@ -28,19 +31,35 @@ import javax.ws.rs.core.Response;
|
|||
* @author Rohit Awate
|
||||
*/
|
||||
public class RequestManager {
|
||||
|
||||
private final Client client;
|
||||
|
||||
public RequestManager() {
|
||||
client = ClientBuilder.newClient();
|
||||
}
|
||||
|
||||
|
||||
public String get(URL url) throws MalformedURLException, IOException {
|
||||
String responseBody;
|
||||
WebTarget target = client.target(url.toString());
|
||||
|
||||
|
||||
Response response = target.request().get();
|
||||
String type = (String) response.getHeaders().getFirst("Content-type");
|
||||
System.out.println(type);
|
||||
responseBody = response.readEntity(String.class);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
|
||||
|
||||
switch (type) {
|
||||
case "application/json":
|
||||
JsonNode node = mapper.readTree(responseBody);
|
||||
responseBody = mapper.writeValueAsString(node);
|
||||
break;
|
||||
case "application/xml":
|
||||
responseBody = mapper.writeValueAsString(responseBody);
|
||||
break;
|
||||
}
|
||||
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
|
|
BIN
src/main/resources/assets/LogoWithName.png
Normal file
BIN
src/main/resources/assets/LogoWithName.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
BIN
src/main/resources/assets/RoundLogo_Black.png
Normal file
BIN
src/main/resources/assets/RoundLogo_Black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
src/main/resources/assets/RoundLogo_White.png
Normal file
BIN
src/main/resources/assets/RoundLogo_White.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
src/main/resources/assets/editables/LogoWithName.xcf
Normal file
BIN
src/main/resources/assets/editables/LogoWithName.xcf
Normal file
Binary file not shown.
1
src/main/resources/assets/editables/RoundLogo.svg
Normal file
1
src/main/resources/assets/editables/RoundLogo.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 125" enable-background="new 0 0 100 100" xml:space="preserve"><path d="M99.207,50.077c0,27.06-21.934,49.001-49.001,49.001c-27.064,0-48.995-21.941-48.995-49.001 C1.211,23.02,23.142,1.08,50.206,1.08C77.273,1.08,99.207,23.02,99.207,50.077L99.207,50.077z M35.417,19.477 c0-0.438-0.349-0.804-0.8-0.804h-0.358c-0.438,0-0.801,0.365-0.801,0.804v16.077c0,1.822,1.475,3.304,3.304,3.304 c0.685,0,1.245,0.551,1.245,1.238v42.3c0,0.688,0.555,1.248,1.249,1.248h3.077c0.685,0,1.242-0.561,1.242-1.248v-42.3 c0-0.688,0.558-1.238,1.248-1.238c1.82,0,3.308-1.481,3.308-3.304V19.477c0-0.438-0.358-0.804-0.801-0.804h-0.371 c-0.436,0-0.791,0.365-0.791,0.804v9.124c0,0.448-0.361,0.801-0.8,0.801h-0.671c-0.451,0-0.804-0.353-0.804-0.801v-9.124 c0-0.438-0.361-0.804-0.8-0.804h-0.362c-0.448,0-0.8,0.365-0.8,0.804v9.124c0,0.448-0.362,0.801-0.797,0.801h-0.678 c-0.438,0-0.803-0.353-0.803-0.801v-9.124c0-0.438-0.362-0.804-0.801-0.804h-0.361c-0.448,0-0.797,0.365-0.797,0.804v9.124 c0,0.448-0.365,0.801-0.801,0.801h-0.677c-0.436,0-0.801-0.353-0.801-0.801V19.477 M57.132,26.679 c-0.136,0.202-0.209,0.441-0.209,0.687v32.589c0,0.68,0.564,1.242,1.245,1.242h1.026v21.199c0,0.688,0.558,1.248,1.241,1.248h3.085 c0.688,0,1.248-0.561,1.248-1.248V17.76c0-0.441-0.361-0.793-0.8-0.793c-0.27,0-0.524,0.129-0.671,0.358L57.132,26.679"/><text x="0" y="115" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">Created by Aldric Rodríguez</text><text x="0" y="120" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">from the Noun Project</text></svg>
|
After Width: | Height: | Size: 1.7 KiB |
|
@ -5,34 +5,54 @@
|
|||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<BorderPane fx:id="dashboard" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="720.0" prefWidth="1280.0" stylesheets="@../styles/dashboard.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.rohitawate.restaurant.dashboard.DashboardController">
|
||||
<BorderPane fx:id="dashboard" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="720.0" prefWidth="1280.0" stylesheets="@../styles/Default.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.rohitawate.restaurant.dashboard.DashboardController">
|
||||
<center>
|
||||
<VBox prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField fx:id="addressField" maxWidth="500.0" promptText="URL" HBox.hgrow="ALWAYS">
|
||||
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../assets/LogoWithName.png" />
|
||||
</image>
|
||||
<HBox.margin>
|
||||
<Insets right="5.0" />
|
||||
</HBox.margin>
|
||||
</ImageView>
|
||||
<TextField fx:id="addressField" maxWidth="800.0" promptText="URL" HBox.hgrow="ALWAYS">
|
||||
<HBox.margin>
|
||||
<Insets right="20.0" />
|
||||
</HBox.margin>
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<ComboBox fx:id="httpMethodBox" prefWidth="150.0">
|
||||
<ComboBox fx:id="httpMethodBox" prefHeight="39.0" prefWidth="150.0">
|
||||
<HBox.margin>
|
||||
<Insets right="20.0" />
|
||||
</HBox.margin>
|
||||
</ComboBox>
|
||||
<JFXButton fx:id="sendButton" buttonType="RAISED" defaultButton="true" onAction="#sendAction" prefWidth="100.0" text="SEND" textFill="WHITE">
|
||||
<JFXButton fx:id="sendButton" buttonType="RAISED" defaultButton="true" onAction="#sendAction" prefHeight="39.0" prefWidth="80.0" text="SEND" textFill="WHITE" HBox.hgrow="ALWAYS">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="20.0" right="20.0" top="10.0" />
|
||||
<Insets bottom="5.0" left="15.0" right="15.0" top="5.0" />
|
||||
</padding>
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</JFXButton>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||
<Insets bottom="20.0" top="20.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
<TextArea fx:id="responseArea" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
|
||||
|
|
54
src/main/resources/styles/Default.css
Normal file
54
src/main/resources/styles/Default.css
Normal file
|
@ -0,0 +1,54 @@
|
|||
#dashboard {
|
||||
-fx-background-color: #505050;
|
||||
}
|
||||
|
||||
#addressField {
|
||||
-fx-background-color: #6e6e6e;
|
||||
-fx-text-fill: white;
|
||||
}
|
||||
|
||||
#httpMethodBox {
|
||||
-fx-background-color: #494949;
|
||||
}
|
||||
|
||||
#httpMethodBox .list-cell {
|
||||
-fx-background-color: #494949;
|
||||
-fx-pref-height: 39px;
|
||||
-fx-font-size: 20px;
|
||||
-fx-text-fill: #acacac;
|
||||
}
|
||||
|
||||
#httpMethodBox .list-view {
|
||||
-fx-border-style: none;
|
||||
}
|
||||
|
||||
#httpMethodBox .list-cell:hover {
|
||||
-fx-background-color: orangered;
|
||||
-fx-text-fill: white;
|
||||
}
|
||||
|
||||
#sendButton {
|
||||
-fx-background-color: #c45015;
|
||||
}
|
||||
|
||||
#responseArea .content {
|
||||
-fx-font-family: 'Liberation Mono';
|
||||
-fx-background-color: #ababab;
|
||||
}
|
||||
|
||||
#responseArea {
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
-fx-background-color: #8b8b8b;
|
||||
}
|
||||
|
||||
.jfx-snackbar-content {
|
||||
-fx-background-color: darkslategray;
|
||||
}
|
||||
|
||||
.jfx-snackbar-toast {
|
||||
-fx-text-fill: lightgray;
|
||||
-fx-alignment: center;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
#sendButton {
|
||||
-fx-background-color: lightslategray;
|
||||
}
|
||||
|
||||
#responseArea {
|
||||
-fx-font-family: 'Liberation Mono';
|
||||
}
|
||||
|
||||
.jfx-snackbar-content {
|
||||
-fx-background-color: darkslategray;
|
||||
}
|
||||
|
||||
.jfx-snackbar-toast {
|
||||
-fx-text-fill: lightgray;
|
||||
-fx-alignment: center;
|
||||
}
|
Loading…
Reference in a new issue