Erweiterungen
This commit is contained in:
17
src/main/java/de/assecutor/votianlt/model/Company.java
Normal file
17
src/main/java/de/assecutor/votianlt/model/Company.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package de.assecutor.votianlt.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.bson.types.ObjectId;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Company
|
||||||
|
{
|
||||||
|
public ObjectId id;
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
public String street;
|
||||||
|
public String houseNumber;
|
||||||
|
public String addressAddition;
|
||||||
|
public String zip;
|
||||||
|
public String city;
|
||||||
|
}
|
||||||
23
src/main/java/de/assecutor/votianlt/model/Customer.java
Normal file
23
src/main/java/de/assecutor/votianlt/model/Customer.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package de.assecutor.votianlt.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.bson.types.ObjectId;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Customer
|
||||||
|
{
|
||||||
|
private ObjectId id;
|
||||||
|
|
||||||
|
public String title;
|
||||||
|
public String companyName;
|
||||||
|
public String firstname;
|
||||||
|
public String lastName;
|
||||||
|
public String telephone;
|
||||||
|
public String fax;
|
||||||
|
public String mail;
|
||||||
|
public String street;
|
||||||
|
public String houseNumber;
|
||||||
|
public String addressAddition;
|
||||||
|
public String zip;
|
||||||
|
public String city;
|
||||||
|
}
|
||||||
28
src/main/java/de/assecutor/votianlt/model/User.java
Normal file
28
src/main/java/de/assecutor/votianlt/model/User.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package de.assecutor.votianlt.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class User
|
||||||
|
{
|
||||||
|
public int usrId;
|
||||||
|
public int hqId;
|
||||||
|
public short type;
|
||||||
|
public String title;
|
||||||
|
public String name;
|
||||||
|
public String firstname;
|
||||||
|
public java.sql.Date birthdate;
|
||||||
|
public String email;
|
||||||
|
public String invitationEmail;
|
||||||
|
public String phone;
|
||||||
|
public String phone2;
|
||||||
|
public String fax;
|
||||||
|
public String password;
|
||||||
|
public byte isActivated;
|
||||||
|
public String activationCode;
|
||||||
|
public byte isEmailConfirmed;
|
||||||
|
public byte isPasswordLost;
|
||||||
|
public String passwordCode;
|
||||||
|
public int passwordTimestamp;
|
||||||
|
public long activationDate;
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class address {
|
|
||||||
public int ad_id;
|
|
||||||
public String ad_street;
|
|
||||||
public String ad_add;
|
|
||||||
public String ad_zipcode;
|
|
||||||
public String ad_city;
|
|
||||||
public String ad_country;
|
|
||||||
public String ad_lat;
|
|
||||||
public String ad_lng;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class address_book {
|
|
||||||
public int adb_id;
|
|
||||||
public int usr_id;
|
|
||||||
public int ad_b_ad_id;
|
|
||||||
public String deliverHsno;
|
|
||||||
public String deliverCompany;
|
|
||||||
public String deliverTitle;
|
|
||||||
public String deliverFirstname;
|
|
||||||
public String deliverLastname;
|
|
||||||
public String deliverPhone;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class address_book_addresses
|
|
||||||
{
|
|
||||||
public int ad_b_ad_id;
|
|
||||||
public String deliverStreet;
|
|
||||||
public String deliverPlz;
|
|
||||||
public String deliverCity;
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class company
|
|
||||||
{
|
|
||||||
public int cmp_id;
|
|
||||||
public String cmp_comp;
|
|
||||||
public String cmp_comp2;
|
|
||||||
public String cmp_hsno;
|
|
||||||
public String cmp_Ustid;
|
|
||||||
public String cmp_Taxid;
|
|
||||||
public String cmp_Iban;
|
|
||||||
public String cmp_homepage;
|
|
||||||
public String votian_cmp_id;
|
|
||||||
public String votian_ad_id;
|
|
||||||
public String votian_tx_id;
|
|
||||||
public String votian_br_id;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class contractor
|
|
||||||
{
|
|
||||||
public int cr_id;
|
|
||||||
public int cmp_id;
|
|
||||||
public int usr_id;
|
|
||||||
public String votian_cr_id;
|
|
||||||
public String votian_cr_eid;
|
|
||||||
public String votian_hq_id;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class contractor_relation
|
|
||||||
{
|
|
||||||
public int cr_r_id;
|
|
||||||
public int usr_id;
|
|
||||||
public int cr_id;
|
|
||||||
public String cr_filter_json;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class costcenter
|
|
||||||
{
|
|
||||||
public int cs_id;
|
|
||||||
public int csc_id;
|
|
||||||
public String csc_comp;
|
|
||||||
public String csc_comp2;
|
|
||||||
public String csc_hsno;
|
|
||||||
public String csc_usr_name;
|
|
||||||
public String csc_usr_firstname;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class costcenter_address
|
|
||||||
{
|
|
||||||
public int csc_id;
|
|
||||||
public int ad_id;
|
|
||||||
public int adt_id;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class country
|
|
||||||
{
|
|
||||||
public String cou_iso_3;
|
|
||||||
public String cou_iso_no;
|
|
||||||
public String cou_mnemonic;
|
|
||||||
public String cou_name;
|
|
||||||
public String cou_iso_2;
|
|
||||||
public byte cou_continent;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class customer
|
|
||||||
{
|
|
||||||
public int cs_id;
|
|
||||||
public int cmp_id;
|
|
||||||
public int csc_id;
|
|
||||||
public int emp_id;
|
|
||||||
public String votian_cs_id;
|
|
||||||
public String votian_cs_eid;
|
|
||||||
public String votian_cs_admin;
|
|
||||||
public String votian_hq_id;
|
|
||||||
public String votian_cs_id_parent;
|
|
||||||
public String votian_cs_id_related;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class customer_relation
|
|
||||||
{
|
|
||||||
public int cs_r_id;
|
|
||||||
public int usr_id;
|
|
||||||
public int cr_id;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class device
|
|
||||||
{
|
|
||||||
public int d_id;
|
|
||||||
public int usr_id;
|
|
||||||
public int d_details;
|
|
||||||
public String d_name;
|
|
||||||
public int votian_dv_id;
|
|
||||||
public String device_name;
|
|
||||||
public String uuid;
|
|
||||||
public String code;
|
|
||||||
public int cust_id;
|
|
||||||
public int cust_acc_group;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class devices_invoice
|
|
||||||
{
|
|
||||||
public int d_i_id;
|
|
||||||
public String d_i_create;
|
|
||||||
public String d_i_delete;
|
|
||||||
public int d_id;
|
|
||||||
public int vlt_i_id;
|
|
||||||
public int usr_id;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class employee
|
|
||||||
{
|
|
||||||
public int emp_id;
|
|
||||||
public int usr_id;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class filter
|
|
||||||
{
|
|
||||||
public int f_id;
|
|
||||||
public int f_type;
|
|
||||||
public String f_short;
|
|
||||||
public String f_status;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class help
|
|
||||||
{
|
|
||||||
public int h_id;
|
|
||||||
public String h_language;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class invoice
|
|
||||||
{
|
|
||||||
public int i_id;
|
|
||||||
public int usr_id;
|
|
||||||
public int cr_id;
|
|
||||||
public String i_export_time;
|
|
||||||
public int i_create_date;
|
|
||||||
public String invoiceNumber;
|
|
||||||
public String fileName;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class invoice_credit
|
|
||||||
{
|
|
||||||
public int i_c_id;
|
|
||||||
public String i_c_date;
|
|
||||||
public int usr_id;
|
|
||||||
public double i_c_amount;
|
|
||||||
public String purpose;
|
|
||||||
public String iban;
|
|
||||||
public String currency;
|
|
||||||
public double diff;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class job
|
|
||||||
{
|
|
||||||
public int jb_id;
|
|
||||||
public int cs_id;
|
|
||||||
public int cr_id;
|
|
||||||
public int jb_votian_id;
|
|
||||||
public java.sql.Date jb_ordertime;
|
|
||||||
public int jb_status;
|
|
||||||
public int jb_type;
|
|
||||||
public int jb_invoice_data;
|
|
||||||
public String useApp;
|
|
||||||
public String customerID;
|
|
||||||
public String datepickerPickup;
|
|
||||||
public String timepickerPickup;
|
|
||||||
public String datepickerDel;
|
|
||||||
public String timepickerDel;
|
|
||||||
public String remark;
|
|
||||||
public String price;
|
|
||||||
public String submit;
|
|
||||||
public String appUserID;
|
|
||||||
public String cargo_type;
|
|
||||||
public String cargo_weight;
|
|
||||||
public String cargo_volume;
|
|
||||||
public String jobdetail_instruction;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class log
|
|
||||||
{
|
|
||||||
public int logo_id;
|
|
||||||
public String log_createtime;
|
|
||||||
public int hq_id;
|
|
||||||
public int jb_id;
|
|
||||||
public int usr_id;
|
|
||||||
public int cr_id;
|
|
||||||
public int cr_sid;
|
|
||||||
public int cs_id;
|
|
||||||
public int at_id;
|
|
||||||
public int pt_id;
|
|
||||||
public int emp_id;
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class log_invoice
|
|
||||||
{
|
|
||||||
public int l_i_id;
|
|
||||||
public int i_id;
|
|
||||||
public String i_date;
|
|
||||||
public int i_export_time_1;
|
|
||||||
public String i_export_time_2;
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class notification
|
|
||||||
{
|
|
||||||
public int n_id;
|
|
||||||
public String n_date;
|
|
||||||
public int n_info_id;
|
|
||||||
public int usr_id;
|
|
||||||
public byte n_new;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class notification_info
|
|
||||||
{
|
|
||||||
public int n_i_id;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class offer
|
|
||||||
{
|
|
||||||
public int o_id;
|
|
||||||
public int jb_id;
|
|
||||||
public int usr_id;
|
|
||||||
public int cr_id;
|
|
||||||
public java.sql.Date offer_time;
|
|
||||||
public String price;
|
|
||||||
public String remark;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class parameter
|
|
||||||
{
|
|
||||||
public int par_id;
|
|
||||||
public String par_key;
|
|
||||||
public int md_id;
|
|
||||||
public int hq_id;
|
|
||||||
public int emp_id;
|
|
||||||
public String par_value;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class price_table
|
|
||||||
{
|
|
||||||
public int pt_id;
|
|
||||||
public double pt_price;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class station
|
|
||||||
{
|
|
||||||
public int station_id;
|
|
||||||
public int jb_id;
|
|
||||||
public String station_type;
|
|
||||||
public int ad_id;
|
|
||||||
public int station_order;
|
|
||||||
public String station_name;
|
|
||||||
public String station_contact;
|
|
||||||
public String station_phone;
|
|
||||||
public java.sql.Date station_arrival_est;
|
|
||||||
public java.sql.Date station_departure_est;
|
|
||||||
public String instructions;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class transportorder
|
|
||||||
{
|
|
||||||
public int tr_id;
|
|
||||||
public int jb_id;
|
|
||||||
public int usr_id;
|
|
||||||
public String tr_comment;
|
|
||||||
public String tr_state;
|
|
||||||
public String tr_driver_lat;
|
|
||||||
public String tr_driver_lng;
|
|
||||||
public String tr_driver_accuracy;
|
|
||||||
public String tr_driver_last_update;
|
|
||||||
public String tr_created;
|
|
||||||
public String tr_updated;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class two_way
|
|
||||||
{
|
|
||||||
public int t_w_id;
|
|
||||||
public int usr_id;
|
|
||||||
public String t_w_secret;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class user
|
|
||||||
{
|
|
||||||
public int usr_id;
|
|
||||||
public int hq_id;
|
|
||||||
public short usr_type;
|
|
||||||
public String usr_title;
|
|
||||||
public String usr_name;
|
|
||||||
public String usr_firstname;
|
|
||||||
public java.sql.Date usr_birthdate;
|
|
||||||
public int ad_id;
|
|
||||||
public String usr_hsno;
|
|
||||||
public String usr_email;
|
|
||||||
public String usr_inv_email;
|
|
||||||
public String usr_phone;
|
|
||||||
public String usr_phone2;
|
|
||||||
public String usr_fax;
|
|
||||||
public String usr_account;
|
|
||||||
public String usr_password;
|
|
||||||
public String usr_modify;
|
|
||||||
public byte usr_is_activated;
|
|
||||||
public String usr_activation_code;
|
|
||||||
public byte usr_is_email_confirmed;
|
|
||||||
public String usr_code;
|
|
||||||
public int usr_code_timestamp;
|
|
||||||
public byte usr_is_password_lost;
|
|
||||||
public String usr_password_code;
|
|
||||||
public int usr_password_timestamp;
|
|
||||||
public byte usr_app;
|
|
||||||
public String votian_usr_id;
|
|
||||||
public String auth_customer;
|
|
||||||
public String auth_account;
|
|
||||||
public String auth_password;
|
|
||||||
public String auth_session_id;
|
|
||||||
public long activationDate;
|
|
||||||
public double balance;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class vehicle
|
|
||||||
{
|
|
||||||
public int vh_id;
|
|
||||||
public int usr_parent_id;
|
|
||||||
public int cr_id;
|
|
||||||
public int vh_details;
|
|
||||||
public int d_id;
|
|
||||||
public String title;
|
|
||||||
public String code;
|
|
||||||
public String votian_vht_id;
|
|
||||||
public String votian_vht_id_inv;
|
|
||||||
public String votian_cr_ar_jb_id;
|
|
||||||
public String votian_crvh_id;
|
|
||||||
public String votian_cr_id;
|
|
||||||
public String votian_crvh_sid;
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package de.assecutor.votianlt.model;
|
|
||||||
|
|
||||||
public class vlt_invoice
|
|
||||||
{
|
|
||||||
public int vlt_i_id;
|
|
||||||
public int usr_id;
|
|
||||||
public String vlt_i_price;
|
|
||||||
public String vlt_i_date;
|
|
||||||
public int vlt_i_status;
|
|
||||||
public String vlt_i_html;
|
|
||||||
public String totalPriceNet;
|
|
||||||
public String totalPrice;
|
|
||||||
public String payedDays;
|
|
||||||
public String daysInMonth;
|
|
||||||
public String devicePrice;
|
|
||||||
public String basePrice;
|
|
||||||
public String systemVat;
|
|
||||||
public String basePricePayed;
|
|
||||||
public String vatPrice;
|
|
||||||
public String invoiceNumber;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package de.assecutor.votianlt.pages.add_company.domain;
|
||||||
|
|
||||||
|
import de.assecutor.votianlt.model.Company;
|
||||||
|
import de.assecutor.votianlt.model.Customer;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
|
|
||||||
|
public interface AddCompanyRepository extends MongoRepository<Company, String> {
|
||||||
|
|
||||||
|
// If you don't need a total row count, Slice is better than Page.
|
||||||
|
Slice<Company> findAllBy(Pageable pageable);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package de.assecutor.votianlt.pages.add_company.service;
|
||||||
|
|
||||||
|
import de.assecutor.votianlt.model.Company;
|
||||||
|
import de.assecutor.votianlt.model.Customer;
|
||||||
|
import de.assecutor.votianlt.pages.add_company.domain.AddCompanyRepository;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
|
public class AddCompanyService {
|
||||||
|
private final AddCompanyRepository addCompanyRepository;
|
||||||
|
|
||||||
|
AddCompanyService(AddCompanyRepository addCompanyRepository) {
|
||||||
|
this.addCompanyRepository = addCompanyRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Company> list(Pageable pageable) {
|
||||||
|
return addCompanyRepository.findAllBy(pageable).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCompany(Company company) {
|
||||||
|
addCompanyRepository.save(company);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package de.assecutor.votianlt.pages.add_company.ui.view;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
|
import com.vaadin.flow.component.html.Main;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
|
import com.vaadin.flow.data.binder.ValidationException;
|
||||||
|
import com.vaadin.flow.router.Menu;
|
||||||
|
import com.vaadin.flow.router.PageTitle;
|
||||||
|
import com.vaadin.flow.router.Route;
|
||||||
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
|
import de.assecutor.votianlt.model.Company;
|
||||||
|
import de.assecutor.votianlt.pages.add_company.service.AddCompanyService;
|
||||||
|
import de.assecutor.votianlt.pages.base.ui.component.ViewToolbar;
|
||||||
|
|
||||||
|
import java.time.Clock;
|
||||||
|
|
||||||
|
@Route("add_company")
|
||||||
|
@PageTitle("Neuen Firma anlegen")
|
||||||
|
@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Neue Firma anlegen")
|
||||||
|
public class AddCompanyView extends Main {
|
||||||
|
private final AddCompanyService addCompanyService;
|
||||||
|
|
||||||
|
TextField companyName;
|
||||||
|
TextField firstName;
|
||||||
|
TextField lastName;
|
||||||
|
TextField telephone;
|
||||||
|
TextField fax;
|
||||||
|
TextField mail;
|
||||||
|
TextField street;
|
||||||
|
TextField houseNumber;
|
||||||
|
TextField addressAddition;
|
||||||
|
TextField zip;
|
||||||
|
TextField city;
|
||||||
|
final Button submitButton;
|
||||||
|
|
||||||
|
private final Binder<Company> binder = new Binder<>(Company.class); // Binder f
|
||||||
|
|
||||||
|
public AddCompanyView(AddCompanyService addCompanyService, Clock clock) {
|
||||||
|
this.addCompanyService = addCompanyService;
|
||||||
|
|
||||||
|
companyName = new TextField("Firmenname");
|
||||||
|
companyName.setRequiredIndicatorVisible(true);
|
||||||
|
binder.forField(companyName)
|
||||||
|
.asRequired("Firmenname ist ein Pflichtfeld") // Pflichtfeldmeldung
|
||||||
|
.bind(Company::getName, Company::setName);
|
||||||
|
|
||||||
|
firstName = new TextField("Vorname");
|
||||||
|
lastName = new TextField("Nachname");
|
||||||
|
telephone = new TextField("Telefonnummer");
|
||||||
|
fax = new TextField("Faxnummer");
|
||||||
|
mail = new TextField("E-Mail-Adresse");
|
||||||
|
street = new TextField("Straße");
|
||||||
|
houseNumber = new TextField("Hausnummer");
|
||||||
|
addressAddition = new TextField("Adresszusatz");
|
||||||
|
zip = new TextField("Postleitzahl");
|
||||||
|
city = new TextField("Stadt");
|
||||||
|
|
||||||
|
// Setze den Button als primär
|
||||||
|
submitButton = new Button("Kunden anlegen", event -> submit());
|
||||||
|
submitButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
|
|
||||||
|
// Erstelle ein Div als Container (oder direkt ein Layout)
|
||||||
|
VerticalLayout formLayout = new VerticalLayout();
|
||||||
|
formLayout.add(companyName, /*firstName, lastName, telephone, fax, mail, street, houseNumber, addressAddition, zip, city,*/ submitButton);
|
||||||
|
|
||||||
|
// Zentriere die Inhalte vertikal und horizontal
|
||||||
|
formLayout.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
|
||||||
|
formLayout.setSpacing(true);
|
||||||
|
formLayout.setSizeUndefined(); // Inhalt eng setzen
|
||||||
|
|
||||||
|
setSizeFull();
|
||||||
|
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN,
|
||||||
|
LumoUtility.Padding.MEDIUM, LumoUtility.Gap.SMALL);
|
||||||
|
|
||||||
|
add(new ViewToolbar("Neuen Kunden anlegen"));
|
||||||
|
add(formLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submit() {
|
||||||
|
Company company = new Company();
|
||||||
|
company.name = companyName.getValue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
binder.writeBean(company);
|
||||||
|
|
||||||
|
addCompanyService.addCompany(company);
|
||||||
|
|
||||||
|
} catch (ValidationException e) {
|
||||||
|
System.err.println("Validierungsfehler: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package de.assecutor.votianlt.pages.add_customer.domain;
|
||||||
|
|
||||||
|
import de.assecutor.votianlt.model.Customer;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
|
|
||||||
|
public interface AddCustomerRepository extends MongoRepository<Customer, String> {
|
||||||
|
|
||||||
|
// If you don't need a total row count, Slice is better than Page.
|
||||||
|
Slice<Customer> findAllBy(Pageable pageable);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package de.assecutor.votianlt.pages.add_customer.service;
|
||||||
|
|
||||||
|
import de.assecutor.votianlt.model.Customer;
|
||||||
|
import de.assecutor.votianlt.pages.add_customer.domain.AddCustomerRepository;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
|
public class AddCustomerService {
|
||||||
|
private final AddCustomerRepository addCustomerRepository;
|
||||||
|
|
||||||
|
AddCustomerService(AddCustomerRepository addCustomerRepository) {
|
||||||
|
this.addCustomerRepository = addCustomerRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Customer> list(Pageable pageable) {
|
||||||
|
return addCustomerRepository.findAllBy(pageable).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCustomer(Customer customer) {
|
||||||
|
addCustomerRepository.save(customer);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package de.assecutor.votianlt.pages.add_customer.ui.view;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
|
import com.vaadin.flow.component.html.Main;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
|
import com.vaadin.flow.data.binder.ValidationException;
|
||||||
|
import com.vaadin.flow.router.Menu;
|
||||||
|
import com.vaadin.flow.router.PageTitle;
|
||||||
|
import com.vaadin.flow.router.Route;
|
||||||
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
|
import de.assecutor.votianlt.model.Customer;
|
||||||
|
import de.assecutor.votianlt.pages.add_customer.service.AddCustomerService;
|
||||||
|
import de.assecutor.votianlt.pages.base.ui.component.ViewToolbar;
|
||||||
|
|
||||||
|
import java.time.Clock;
|
||||||
|
|
||||||
|
@Route("add_customer")
|
||||||
|
@PageTitle("Neuen Kunden anlegen")
|
||||||
|
@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Neuen Kunden anlegen")
|
||||||
|
public class AddCustomerView extends Main {
|
||||||
|
private final AddCustomerService addCustomerService;
|
||||||
|
|
||||||
|
TextField companyName;
|
||||||
|
TextField firstName;
|
||||||
|
TextField lastName;
|
||||||
|
TextField telephone;
|
||||||
|
TextField fax;
|
||||||
|
TextField mail;
|
||||||
|
TextField street;
|
||||||
|
TextField houseNumber;
|
||||||
|
TextField addressAddition;
|
||||||
|
TextField zip;
|
||||||
|
TextField city;
|
||||||
|
final Button submitButton;
|
||||||
|
|
||||||
|
private final Binder<Customer> binder = new Binder<>(Customer.class); // Binder f
|
||||||
|
|
||||||
|
public AddCustomerView(AddCustomerService todoService, Clock clock) {
|
||||||
|
this.addCustomerService = todoService;
|
||||||
|
|
||||||
|
companyName = new TextField("Firmenname");
|
||||||
|
companyName.setRequiredIndicatorVisible(true);
|
||||||
|
binder.forField(companyName)
|
||||||
|
.asRequired("Firmenname ist ein Pflichtfeld") // Pflichtfeldmeldung
|
||||||
|
.bind(Customer::getCompanyName, Customer::setCompanyName);
|
||||||
|
|
||||||
|
firstName = new TextField("Vorname");
|
||||||
|
lastName = new TextField("Nachname");
|
||||||
|
telephone = new TextField("Telefonnummer");
|
||||||
|
fax = new TextField("Faxnummer");
|
||||||
|
mail = new TextField("E-Mail-Adresse");
|
||||||
|
street = new TextField("Straße");
|
||||||
|
houseNumber = new TextField("Hausnummer");
|
||||||
|
addressAddition = new TextField("Adresszusatz");
|
||||||
|
zip = new TextField("Postleitzahl");
|
||||||
|
city = new TextField("Stadt");
|
||||||
|
|
||||||
|
// Setze den Button als primär
|
||||||
|
submitButton = new Button("Kunden anlegen", event -> submit());
|
||||||
|
submitButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
|
|
||||||
|
// Erstelle ein Div als Container (oder direkt ein Layout)
|
||||||
|
VerticalLayout formLayout = new VerticalLayout();
|
||||||
|
formLayout.add(companyName, /*firstName, lastName, telephone, fax, mail, street, houseNumber, addressAddition, zip, city,*/ submitButton);
|
||||||
|
|
||||||
|
// Zentriere die Inhalte vertikal und horizontal
|
||||||
|
formLayout.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
|
||||||
|
formLayout.setSpacing(true);
|
||||||
|
formLayout.setSizeUndefined(); // Inhalt eng setzen
|
||||||
|
|
||||||
|
setSizeFull();
|
||||||
|
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN,
|
||||||
|
LumoUtility.Padding.MEDIUM, LumoUtility.Gap.SMALL);
|
||||||
|
|
||||||
|
add(new ViewToolbar("Neuen Kunden anlegen"));
|
||||||
|
add(formLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submit() {
|
||||||
|
Customer customer = new Customer();
|
||||||
|
customer.companyName = companyName.getValue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
binder.writeBean(customer);
|
||||||
|
|
||||||
|
addCustomerService.addCustomer(customer);
|
||||||
|
|
||||||
|
} catch (ValidationException e) {
|
||||||
|
System.err.println("Validierungsfehler: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package de.assecutor.votianlt.pages.customers.domain;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
@Document(collection = "customer")
|
|
||||||
@Data
|
|
||||||
public class Customer {
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private Instant creationDate;
|
|
||||||
|
|
||||||
private LocalDate dueDate;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package de.assecutor.votianlt.pages.customers.domain;
|
package de.assecutor.votianlt.pages.customers.domain;
|
||||||
|
|
||||||
|
import de.assecutor.votianlt.model.Customer;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package de.assecutor.votianlt.pages.customers.service;
|
package de.assecutor.votianlt.pages.customers.service;
|
||||||
|
|
||||||
import de.assecutor.votianlt.pages.customers.domain.Customer;
|
import de.assecutor.votianlt.model.Customer;
|
||||||
import de.assecutor.votianlt.pages.customers.domain.CustomerRepository;
|
import de.assecutor.votianlt.pages.customers.domain.CustomerRepository;
|
||||||
import org.jspecify.annotations.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -30,9 +30,6 @@ public class CustomerService {
|
|||||||
throw new RuntimeException("This is for testing the error handler");
|
throw new RuntimeException("This is for testing the error handler");
|
||||||
}
|
}
|
||||||
var todo = new Customer();
|
var todo = new Customer();
|
||||||
todo.setDescription(description);
|
|
||||||
todo.setCreationDate(clock.instant());
|
|
||||||
todo.setDueDate(dueDate);
|
|
||||||
todoRepository.save(todo);
|
todoRepository.save(todo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
package de.assecutor.votianlt.pages.customers.ui.view;
|
package de.assecutor.votianlt.pages.customers.ui.view;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.UI;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.button.ButtonVariant;
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
import com.vaadin.flow.component.datepicker.DatePicker;
|
|
||||||
import com.vaadin.flow.component.grid.Grid;
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
import com.vaadin.flow.component.html.Main;
|
import com.vaadin.flow.component.html.Main;
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
|
||||||
import com.vaadin.flow.component.notification.NotificationVariant;
|
|
||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.router.Menu;
|
import com.vaadin.flow.router.Menu;
|
||||||
import com.vaadin.flow.router.PageTitle;
|
import com.vaadin.flow.router.PageTitle;
|
||||||
import com.vaadin.flow.router.Route;
|
import com.vaadin.flow.router.Route;
|
||||||
import com.vaadin.flow.theme.lumo.LumoUtility;
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
|
import de.assecutor.votianlt.model.Customer;
|
||||||
import de.assecutor.votianlt.pages.base.ui.component.ViewToolbar;
|
import de.assecutor.votianlt.pages.base.ui.component.ViewToolbar;
|
||||||
import de.assecutor.votianlt.pages.customers.domain.Customer;
|
|
||||||
import de.assecutor.votianlt.pages.customers.service.CustomerService;
|
import de.assecutor.votianlt.pages.customers.service.CustomerService;
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.format.FormatStyle;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static com.vaadin.flow.spring.data.VaadinSpringDataHelpers.toSpringPageRequest;
|
import static com.vaadin.flow.spring.data.VaadinSpringDataHelpers.toSpringPageRequest;
|
||||||
|
|
||||||
@@ -31,7 +26,6 @@ public class CustomersView extends Main {
|
|||||||
private final CustomerService todoService;
|
private final CustomerService todoService;
|
||||||
|
|
||||||
final TextField description;
|
final TextField description;
|
||||||
final DatePicker dueDate;
|
|
||||||
final Button createBtn;
|
final Button createBtn;
|
||||||
final Grid<Customer> todoGrid;
|
final Grid<Customer> todoGrid;
|
||||||
|
|
||||||
@@ -39,45 +33,27 @@ public class CustomersView extends Main {
|
|||||||
this.todoService = todoService;
|
this.todoService = todoService;
|
||||||
|
|
||||||
description = new TextField();
|
description = new TextField();
|
||||||
description.setPlaceholder("What do you want to do?");
|
description.setPlaceholder("Suche");
|
||||||
description.setAriaLabel("Task description");
|
|
||||||
description.setMaxLength(255);
|
description.setMaxLength(255);
|
||||||
description.setMinWidth("20em");
|
description.setMinWidth("20em");
|
||||||
|
|
||||||
dueDate = new DatePicker();
|
createBtn = new Button("Kunde anlegen", event -> addCustomer());
|
||||||
dueDate.setPlaceholder("Due date");
|
|
||||||
dueDate.setAriaLabel("Due date");
|
|
||||||
|
|
||||||
createBtn = new Button("Create", event -> createTodo());
|
|
||||||
createBtn.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
createBtn.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
|
|
||||||
var dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withZone(clock.getZone())
|
|
||||||
.withLocale(getLocale());
|
|
||||||
var dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(getLocale());
|
|
||||||
|
|
||||||
todoGrid = new Grid<>();
|
todoGrid = new Grid<>();
|
||||||
todoGrid.setItems(query -> todoService.list(toSpringPageRequest(query)).stream());
|
todoGrid.setItems(query -> todoService.list(toSpringPageRequest(query)).stream());
|
||||||
todoGrid.addColumn(Customer::getDescription).setHeader("Description");
|
todoGrid.addColumn(Customer::getCompanyName).setHeader("Firmenname");
|
||||||
todoGrid.addColumn(todo -> Optional.ofNullable(todo.getDueDate()).map(dateFormatter::format).orElse("Never"))
|
|
||||||
.setHeader("Due Date");
|
|
||||||
todoGrid.addColumn(todo -> dateTimeFormatter.format(todo.getCreationDate())).setHeader("Creation Date");
|
|
||||||
todoGrid.setSizeFull();
|
todoGrid.setSizeFull();
|
||||||
|
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN,
|
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN,
|
||||||
LumoUtility.Padding.MEDIUM, LumoUtility.Gap.SMALL);
|
LumoUtility.Padding.MEDIUM, LumoUtility.Gap.SMALL);
|
||||||
|
|
||||||
add(new ViewToolbar("Task List", ViewToolbar.group(description, dueDate, createBtn)));
|
add(new ViewToolbar("Kunden", ViewToolbar.group(description, createBtn)));
|
||||||
add(todoGrid);
|
add(todoGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTodo() {
|
private void addCustomer() {
|
||||||
todoService.createTodo(description.getValue(), dueDate.getValue());
|
UI.getCurrent().navigate("add_customer");
|
||||||
todoGrid.getDataProvider().refreshAll();
|
|
||||||
description.clear();
|
|
||||||
dueDate.clear();
|
|
||||||
Notification.show("Task added", 3000, Notification.Position.BOTTOM_END)
|
|
||||||
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package de.assecutor.votianlt.pages.login.domain;
|
||||||
|
|
||||||
|
import de.assecutor.votianlt.model.User;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface LoginRepository extends MongoRepository<User, String> {
|
||||||
|
|
||||||
|
// If you don't need a total row count, Slice is better than Page.
|
||||||
|
Slice<User> findAllBy(Pageable pageable);
|
||||||
|
|
||||||
|
Optional<User> findByEmailAndPassword(String email, String password);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package de.assecutor.votianlt.pages.login.service;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
|
import de.assecutor.votianlt.model.User;
|
||||||
|
import de.assecutor.votianlt.pages.login.domain.LoginRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.Clock;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
|
public class LoginService {
|
||||||
|
|
||||||
|
private final LoginRepository loginRepository;
|
||||||
|
|
||||||
|
LoginService(LoginRepository loginRepository, Clock clock) {
|
||||||
|
this.loginRepository = loginRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> findUser(String mail, String password) {
|
||||||
|
var user = loginRepository.findByEmailAndPassword(mail, password);
|
||||||
|
|
||||||
|
if (user.isEmpty()) {
|
||||||
|
Notification.show("Login failed", 3000, Notification.Position.BOTTOM_END);
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package de.assecutor.votianlt.pages.login.ui.view;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.UI;
|
||||||
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
|
import com.vaadin.flow.component.html.Main;
|
||||||
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
|
import com.vaadin.flow.component.notification.NotificationVariant;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
|
import com.vaadin.flow.router.PageTitle;
|
||||||
|
import com.vaadin.flow.router.Route;
|
||||||
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
|
import de.assecutor.votianlt.pages.login.service.LoginService;
|
||||||
|
import de.assecutor.votianlt.pages.register.service.RegisterService;
|
||||||
|
import de.assecutor.votianlt.util.Util;
|
||||||
|
|
||||||
|
import java.io.Console;
|
||||||
|
import java.time.Clock;
|
||||||
|
|
||||||
|
@Route("login")
|
||||||
|
@PageTitle("Bei VotianLT anmelden")
|
||||||
|
//@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Bei VotianLT registrieren")
|
||||||
|
public class LoginView extends Main {
|
||||||
|
private final LoginService loginService;
|
||||||
|
|
||||||
|
TextField usernameField = new TextField("E-Mail-Adresse");
|
||||||
|
TextField password1Field = new TextField("Passwort");
|
||||||
|
Button submitButton = new Button("Registrieren");
|
||||||
|
|
||||||
|
public LoginView(LoginService loginService, Clock clock) {
|
||||||
|
this.loginService = loginService;
|
||||||
|
|
||||||
|
// Setze den Button als primär
|
||||||
|
submitButton = new Button("Anmelden", event -> login());
|
||||||
|
submitButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
|
|
||||||
|
// Erstelle ein Div als Container (oder direkt ein Layout)
|
||||||
|
VerticalLayout formLayout = new VerticalLayout();
|
||||||
|
formLayout.add(usernameField, password1Field, submitButton);
|
||||||
|
|
||||||
|
// Zentriere die Inhalte vertikal und horizontal
|
||||||
|
formLayout.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
|
||||||
|
formLayout.setSpacing(true);
|
||||||
|
formLayout.setSizeUndefined(); // Inhalt eng setzen
|
||||||
|
|
||||||
|
setSizeFull();
|
||||||
|
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN,
|
||||||
|
LumoUtility.Padding.MEDIUM, LumoUtility.Gap.SMALL);
|
||||||
|
|
||||||
|
add(formLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void login() {
|
||||||
|
var user = loginService.findUser(usernameField.getValue(), password1Field.getValue());
|
||||||
|
|
||||||
|
if (user.isPresent()) {
|
||||||
|
UI.getCurrent().navigate("customer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submit() {
|
||||||
|
Util.changeDrawerState(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package de.assecutor.votianlt.pages.register.domain;
|
package de.assecutor.votianlt.pages.register.domain;
|
||||||
|
|
||||||
import de.assecutor.votianlt.pages.customers.domain.Customer;
|
import de.assecutor.votianlt.model.User;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
|
|
||||||
public interface RegisterRepository extends MongoRepository<Customer, String> {
|
public interface RegisterRepository extends MongoRepository<User, String> {
|
||||||
|
|
||||||
// If you don't need a total row count, Slice is better than Page.
|
// If you don't need a total row count, Slice is better than Page.
|
||||||
Slice<Order> findAllBy(Pageable pageable);
|
Slice<User> findAllBy(Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package de.assecutor.votianlt.pages.register.service;
|
package de.assecutor.votianlt.pages.register.service;
|
||||||
|
|
||||||
|
import de.assecutor.votianlt.model.User;
|
||||||
import de.assecutor.votianlt.pages.register.domain.RegisterRepository;
|
import de.assecutor.votianlt.pages.register.domain.RegisterRepository;
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
@@ -15,23 +14,10 @@ public class RegisterService {
|
|||||||
|
|
||||||
private final RegisterRepository registerRepository;
|
private final RegisterRepository registerRepository;
|
||||||
|
|
||||||
private final Clock clock;
|
RegisterService(RegisterRepository registerRepository) {
|
||||||
|
|
||||||
RegisterService(RegisterRepository registerRepository, Clock clock) {
|
|
||||||
this.registerRepository = registerRepository;
|
this.registerRepository = registerRepository;
|
||||||
this.clock = clock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerUser(String mail, String password) {
|
public void registerUser(User user) {
|
||||||
/*if ("fail".equals(description)) {
|
registerRepository.save(user);
|
||||||
throw new RuntimeException("This is for testing the error handler");
|
}}
|
||||||
}
|
|
||||||
var todo = new Todo();
|
|
||||||
todo.setDescription(description);
|
|
||||||
todo.setCreationDate(clock.instant());
|
|
||||||
todo.setDueDate(dueDate);
|
|
||||||
todoRepository.saveAndFlush(todo);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//public List<Order> list(Pageable pageable) { return todoRepository.findAllBy(pageable).toList();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,33 +1,28 @@
|
|||||||
package de.assecutor.votianlt.pages.register.ui.view;
|
package de.assecutor.votianlt.pages.register.ui.view;
|
||||||
|
|
||||||
import com.vaadin.flow.component.UI;
|
|
||||||
import com.vaadin.flow.component.applayout.AppLayout;
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.button.ButtonVariant;
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
import com.vaadin.flow.component.html.Main;
|
import com.vaadin.flow.component.html.Main;
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
|
||||||
import com.vaadin.flow.component.notification.NotificationVariant;
|
|
||||||
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.router.Menu;
|
|
||||||
import com.vaadin.flow.router.PageTitle;
|
import com.vaadin.flow.router.PageTitle;
|
||||||
import com.vaadin.flow.router.Route;
|
import com.vaadin.flow.router.Route;
|
||||||
import com.vaadin.flow.theme.lumo.LumoUtility;
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
import de.assecutor.votianlt.pages.base.ui.component.ViewToolbar;
|
import de.assecutor.votianlt.model.User;
|
||||||
import de.assecutor.votianlt.pages.register.service.RegisterService;
|
import de.assecutor.votianlt.pages.register.service.RegisterService;
|
||||||
import de.assecutor.votianlt.util.Util;
|
import de.assecutor.votianlt.util.Util;
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
|
|
||||||
@Route("register")
|
@Route("register")
|
||||||
@PageTitle("Bei VotianLT registrieren")
|
@PageTitle("Bei VotianLT anmelden")
|
||||||
//@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Bei VotianLT registrieren")
|
//@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Bei VotianLT registrieren")
|
||||||
public class RegisterView extends Main {
|
public class RegisterView extends Main {
|
||||||
|
|
||||||
private final RegisterService registerService;
|
private final RegisterService registerService;
|
||||||
|
|
||||||
TextField usernameField = new TextField("E-Mail-Adresse");
|
TextField mail = new TextField("E-Mail-Adresse");
|
||||||
TextField password1Field = new TextField("Passwort");
|
TextField password1Field = new TextField("Passwort");
|
||||||
TextField password2Field = new TextField("Passwort wiederholen");
|
TextField password2Field = new TextField("Passwort wiederholen");
|
||||||
Button submitButton = new Button("Registrieren");
|
Button submitButton = new Button("Registrieren");
|
||||||
@@ -36,12 +31,12 @@ public class RegisterView extends Main {
|
|||||||
this.registerService = registerService;
|
this.registerService = registerService;
|
||||||
|
|
||||||
// Setze den Button als primär
|
// Setze den Button als primär
|
||||||
submitButton = new Button("Create", event -> submit());
|
submitButton = new Button("Registrieren", event -> registerUser());
|
||||||
submitButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
submitButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
|
|
||||||
// Erstelle ein Div als Container (oder direkt ein Layout)
|
// Erstelle ein Div als Container (oder direkt ein Layout)
|
||||||
VerticalLayout formLayout = new VerticalLayout();
|
VerticalLayout formLayout = new VerticalLayout();
|
||||||
formLayout.add(usernameField, password1Field, password2Field, submitButton);
|
formLayout.add(mail, password1Field, password2Field, submitButton);
|
||||||
|
|
||||||
// Zentriere die Inhalte vertikal und horizontal
|
// Zentriere die Inhalte vertikal und horizontal
|
||||||
formLayout.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
|
formLayout.setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
|
||||||
@@ -49,18 +44,19 @@ public class RegisterView extends Main {
|
|||||||
formLayout.setSizeUndefined(); // Inhalt eng setzen
|
formLayout.setSizeUndefined(); // Inhalt eng setzen
|
||||||
|
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN,
|
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN, LumoUtility.Padding.MEDIUM, LumoUtility.Gap.SMALL);
|
||||||
LumoUtility.Padding.MEDIUM, LumoUtility.Gap.SMALL);
|
|
||||||
|
|
||||||
add(formLayout);
|
add(formLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submit() {
|
private void registerUser() {
|
||||||
Util.changeDrawerState(true);
|
var mail = this.mail.getValue();
|
||||||
}
|
var password = password1Field.getValue();
|
||||||
|
|
||||||
private void createTodo() {
|
User user = new User();
|
||||||
registerService.registerUser(usernameField.getValue(), password1Field.getValue());
|
user.setEmail(mail);
|
||||||
Notification.show("Benutzer registriert", 3000, Notification.Position.BOTTOM_END).addThemeVariants(NotificationVariant.LUMO_SUCCESS);
|
user.setPassword(password);
|
||||||
|
|
||||||
|
registerService.registerUser(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ import com.vaadin.flow.router.Route;
|
|||||||
import com.vaadin.flow.theme.lumo.LumoUtility;
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
|
|
||||||
@Route("")
|
@Route("")
|
||||||
@PageTitle("Start")
|
@PageTitle("Dummy")
|
||||||
@Menu(order = 0, icon = "vaadin:clipboard-check", title = "Start")
|
@Menu(order = 0, icon = "vaadin:clipboard-check", title = "DUMMY")
|
||||||
public class OrdersView extends Main {
|
public class StartView extends Main {
|
||||||
|
|
||||||
final Button registerBtn;
|
final Button registerBtn;
|
||||||
final Button loginBtn;
|
final Button loginBtn;
|
||||||
|
|
||||||
public OrdersView() {
|
public StartView() {
|
||||||
registerBtn = new Button("Registrieren", event -> register());
|
registerBtn = new Button("Registrieren", event -> register());
|
||||||
registerBtn.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
registerBtn.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
add(registerBtn);
|
add(registerBtn);
|
||||||
@@ -36,7 +36,5 @@ public class OrdersView extends Main {
|
|||||||
UI.getCurrent().navigate("register");
|
UI.getCurrent().navigate("register");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void login() {
|
private void login() { UI.getCurrent().navigate("login"); }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user