added website updates

This commit is contained in:
Lukas-Heiligenbrunner 2019-09-20 15:02:17 +02:00
parent 74fb1b504c
commit 079726fee6
21 changed files with 475 additions and 16 deletions

View File

@ -7,5 +7,7 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="org.eclipse.paho.client.mqttv3-1.2.1" level="project" />
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
</component> </component>
</module> </module>

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,3 @@
import javafx.scene.input.DataFormat;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.MalformedURLException; import java.net.MalformedURLException;

3
src/META-INF/MANIFEST.MF Normal file
View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: main

87
src/db/Database.java Executable file
View File

@ -0,0 +1,87 @@
package db;
import javax.swing.table.DefaultTableModel;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;
public abstract class Database {
protected String user;
protected String password;
protected String host;
protected int port;
protected String dbName;
public Database(String user, String password, String host, int port, String dbName) {
this.user = user;
this.password = password;
this.host = host;
this.port = port;
this.dbName = dbName;
}
public abstract Connection getConnection();
public static void logToConsole(ResultSet res) {
try {
ResultSetMetaData rsmd = res.getMetaData();
while (res.next()) {
String row = "";
for (int i = 1; i <= rsmd.getColumnCount(); ++i) {
if (row.length() > 0) {
row += ", ";
}
if (res.getObject(i) != null) {
row +=
rsmd.getColumnName(i) +
": " +
res.getObject(i).toString();
}
}
System.out.println(row);
}
} catch(SQLException e) {
}
}
public static DefaultTableModel logToTable(ResultSet res) {
try {
ResultSetMetaData rsmd = res.getMetaData();
Vector<String> columnNames = new Vector<>();
int columnCount = rsmd.getColumnCount();
for (int i = 1; i <= columnCount; ++i) {
columnNames.add(rsmd.getColumnName(i));
}
Vector<Vector<Object>> data = new Vector<>();
while(res.next()) {
Vector<Object> row = new Vector();
for (int i = 1; i <= columnCount; ++i) {
row.add(res.getObject(i));
}
data.add(row);
}
return new DefaultTableModel(data, columnNames);
} catch(SQLException e) {
e.printStackTrace();
}
return null;
}
}

37
src/db/MySQLConnector.java Executable file
View File

@ -0,0 +1,37 @@
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MySQLConnector extends Database {
static {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
public MySQLConnector(String user, String password, String host, int port, String dbName) {
super(user, password, host, port, dbName);
}
public Connection getConnection() {
Connection con = null;
try {
con = DriverManager.getConnection(
"jdbc:mysql://" + host + ":" + port + "/" + dbName + "?useSSL=false",
user,
password);
} catch (SQLException e) {
e.printStackTrace();
}
return con;
}
}

37
src/db/PostgreSQLConnector.java Executable file
View File

@ -0,0 +1,37 @@
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class PostgreSQLConnector extends Database {
static {
try {
Class.forName("org.postgresql.Driver").newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
public PostgreSQLConnector(String user, String password, String host, int port, String dbName) {
super(user, password, host, port, dbName);
}
@Override
public Connection getConnection() {
Connection con = null;
try {
con = DriverManager.getConnection(
"jdbc:postgresql://" + host + ":" + port + "/" + dbName,
user,
password);
} catch (SQLException e) {
e.printStackTrace();
}
return con;
}
}

33
src/db/jdcb.java Normal file
View File

@ -0,0 +1,33 @@
package db;
import javax.swing.table.DefaultTableModel;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class jdcb {
public void executeQuery(String sql) {
Database db = new MySQLConnector(
"users",
"kOpaIJUjkgb9ur6S",
"127.0.0.1",
3306,
"wasteinformation");
Connection c = db.getConnection();
try {
PreparedStatement stmt =
c.prepareStatement(sql);
ResultSet r = stmt.executeQuery();
DefaultTableModel model = Database.logToTable(r);
// this.resultTable.setModel(model);
} catch (SQLException e) {
e.printStackTrace();
}
}
}

View File

@ -1,14 +1,18 @@
import db.jdcb;
public class main { public class main {
public static void main(String[] args) { public static void main(String[] args) {
/*
Date D=new Date(); Date D=new Date();
D.getdata(); D.getdata();
D.printList(); D.printList();
/* */
Thread mythread = new Thread(() -> new Webserver().startserver()); // Thread mythread = new Thread(() -> new Webserver().startserver());
mythread.start(); // mythread.start();
//
//
// System.out.println("thread started");
new jdcb().executeQuery("select * from user");
System.out.println("thread started");*/
} }
} }

40
src/mqtt.java Normal file
View File

@ -0,0 +1,40 @@
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
public class mqtt {
public mqtt() {
String topic = "MQTT Examples";
String content = "Message from MqttPublishSample";
int qos = 2;
String broker = "tcp://iot.eclipse.org:1883";
String clientId = "JavaSample";
MemoryPersistence persistence = new MemoryPersistence();
try {
MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(true);
System.out.println("Connecting to broker: "+broker);
sampleClient.connect(connOpts);
System.out.println("Connected");
System.out.println("Publishing message: "+content);
MqttMessage message = new MqttMessage(content.getBytes());
message.setQos(qos);
sampleClient.publish(topic, message);
System.out.println("Message published");
sampleClient.disconnect();
System.out.println("Disconnected");
System.exit(0);
} catch(MqttException me) {
System.out.println("reason "+me.getReasonCode());
System.out.println("msg "+me.getMessage());
System.out.println("loc "+me.getLocalizedMessage());
System.out.println("cause "+me.getCause());
System.out.println("excep "+me);
me.printStackTrace();
}
}
}

View File

@ -1,3 +1,8 @@
.test{ .test{
background-color: #FF0000; background-color: #7F7F7F;
} }
.optionsarray{
margin-left: 20mm;
margin-top: 20mm;
}

89
wwwroot/css/login.css Normal file
View File

@ -0,0 +1,89 @@
/* Made with love by Mutiullah Samim*/
@import url('https://fonts.googleapis.com/css?family=Numans');
html,body{
background-image: url('../rsc/login2.jpg');
background-size: cover;
background-repeat: no-repeat;
height: 100%;
font-family: 'Numans', sans-serif;
}
.container{
height: 100%;
align-content: center;
}
.card{
height: 370px;
margin-top: auto;
margin-bottom: auto;
width: 400px;
background-color: rgba(0,0,0,0.5) !important;
}
.social_icon span{
font-size: 60px;
margin-left: 10px;
color: #FFC312;
}
.social_icon span:hover{
color: white;
cursor: pointer;
}
.card-header h3{
color: white;
}
.social_icon{
position: absolute;
right: 20px;
top: -45px;
}
.input-group-prepend span{
width: 50px;
background-color: #FFC312;
color: black;
border:0 !important;
}
input:focus{
outline: 0 0 0 0 !important;
box-shadow: 0 0 0 0 !important;
}
.remember{
color: white;
}
.remember input
{
width: 20px;
height: 20px;
margin-left: 15px;
margin-right: 5px;
}
.login_btn{
color: black;
background-color: #FFC312;
width: 100px;
}
.login_btn:hover{
color: black;
background-color: white;
}
.links{
color: white;
}
.links a{
margin-left: 4px;
}

View File

@ -4,15 +4,51 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title></title> <title></title>
<script <!-- Latest compiled and minified CSS -->
src="https://code.jquery.com/jquery-3.4.1.slim.min.js" <link rel="stylesheet" href="lib/bootstrap.min.css">
integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8="
crossorigin="anonymous"></script> <!-- jQuery library -->
<script src="lib/jquery.min.js"></script>
<!-- Popper JS -->
<script src="lib/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="lib/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/index.css"> <link rel="stylesheet" type="text/css" href="css/index.css">
<script type="text/javascript" src="js/index.js"> </script> <script type="text/javascript" src="js/index.js"> </script>
</head> </head>
<body class="test"> <body>
hello there <!-- Grey with black text -->
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</nav>
<div class="optionsarray">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="customSwitch1">
<label class="custom-control-label" for="customSwitch1">Setting 1</label>
</div>
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="customSwitch2">
<label class="custom-control-label" for="customSwitch2">Setting 2</label>
</div>
</div>
</body> </body>
</html> </html>

7
wwwroot/lib/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

7
wwwroot/lib/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
wwwroot/lib/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

5
wwwroot/lib/popper.min.js vendored Normal file

File diff suppressed because one or more lines are too long

67
wwwroot/login.html Normal file
View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<!--Made with love by Mutiullah Samim -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="lib/bootstrap.min.css">
<!-- jQuery library -->
<script src="lib/jquery.min.js"></script>
<!-- Popper JS -->
<script src="lib/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="lib/bootstrap.min.js"></script>
<!--Fontawesome CDN-->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<!--Custom styles-->
<link rel="stylesheet" type="text/css" href="css/login.css">
</head>
<body>
<div class="container">
<div class="d-flex justify-content-center h-100">
<div class="card">
<div class="card-header">
<h3>Sign In</h3>
</div>
<div class="card-body">
<form>
<div class="input-group form-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" class="form-control" placeholder="username">
</div>
<div class="input-group form-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-key"></i></span>
</div>
<input type="password" class="form-control" placeholder="password">
</div>
<div class="row align-items-center remember">
<input type="checkbox">Remember Me
</div>
<div class="form-group">
<input type="submit" value="Login" class="btn float-right login_btn">
</div>
</form>
</div>
<div class="card-footer">
<div class="d-flex justify-content-center links">
Don't have an account?<a href="#">Sign Up</a>
</div>
<div class="d-flex justify-content-center">
<a href="#">Forgot your password?</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

BIN
wwwroot/rsc/login.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

BIN
wwwroot/rsc/login2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB