Skip to content

Commit

Permalink
🚧 #80 Added gif, resolve #86, Wip #85
Browse files Browse the repository at this point in the history
* Change some icons
  • Loading branch information
rucko24 committed Nov 18, 2024
1 parent dac38f4 commit 82c0116
Show file tree
Hide file tree
Showing 59 changed files with 1,681 additions and 1,025 deletions.
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<properties>
<java.version>21</java.version>
<vaadin.version>24.5.4</vaadin.version>
<org.projectlombok.version>1.18.32</org.projectlombok.version>
</properties>

<parent>
Expand Down Expand Up @@ -121,6 +122,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -198,6 +200,17 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>21</source> <!-- depending on your project -->
<target>21</target> <!-- depending on your project -->
</configuration>
</plugin>

</plugins>
</build>

Expand Down
Binary file modified src/main/bundles/prod.bundle
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/frontend/themes/espflow/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//@import url('components/border.css');*/
@import url('components/layout.css');
@import url('./views/readflash/esp-device-info.css');
@import url('./views/flash-view/wizard-dialog/wizard-dialog.css');
@import url('./views/settings-dialog/settings-dialog.css');
@import url('./fonts/stylesheet.css');

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.avatar-step-inactive {
color: black;
border: 1px solid black;
background-color: white;
}

.avatar-step-active {
background: var(--lumo-primary-color);
color: var(--lumo-primary-contrast-color);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.esp.espflow.configuration;

import com.vaadin.flow.component.messages.MessageListItem;
import com.esp.espflow.entity.event.EspMessageListItemEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Flux;
Expand All @@ -17,15 +17,15 @@
public class EspMessageListItemReactivePublisher {

@Bean(value = "publishMessageListItem")
public Sinks.Many<MessageListItem> publisher() {
public Sinks.Many<EspMessageListItemEvent> publisher() {
return Sinks
.many()
.multicast()
.onBackpressureBuffer();
}

@Bean(value = "subscribersMessageListItems")
public Flux<MessageListItem> subscribers(Sinks.Many<MessageListItem> publisher) {
public Flux<EspMessageListItemEvent> subscribers(Sinks.Many<EspMessageListItemEvent> publisher) {
return publisher
.asFlux();
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/esp/espflow/entity/WizardEspEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.esp.espflow.entity;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

@Data
@Entity
@Table(name = "wizard_flashesp")
public class WizardEspEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private boolean isWizardEnabled;
private String name;

}
9 changes: 9 additions & 0 deletions src/main/java/com/esp/espflow/entity/dto/WizardEspDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.esp.espflow.entity.dto;

import lombok.Builder;

/**
* @author rub'n
*/
@Builder
public record WizardEspDto(boolean isWizardEnabled, String name) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.esp.espflow.entity.event;

public enum DialogHideEvent {
HIDE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.esp.espflow.entity.event;

import com.esp.espflow.util.svgfactory.SvgFactory;
import com.vaadin.flow.component.messages.MessageListItem;
import com.vaadin.flow.server.StreamResource;
import lombok.extern.log4j.Log4j2;

import java.security.SecureRandom;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Arrays;

import static com.esp.espflow.util.EspFlowConstants.FRONTEND_IMAGES_SVG_ICONS;

/**
* @author rub'n
*/
@Log4j2
public class EspMessageListItemEvent extends MessageListItem {
/*
* For Custom colors
*/
private static final SecureRandom SECURE_RANDOM = new SecureRandom();

public EspMessageListItemEvent(String operation, String port) {
super.setText(operation);
super.setTime(LocalDateTime.now().toInstant(ZoneOffset.UTC));
super.setUserName(port);
this.setCustomImage();
var colors = Arrays.asList(0, 1, 2, 3, 4, 5, 6);
super.setUserColorIndex(colors.get(SECURE_RANDOM.nextInt(colors.size())));
}

private void setCustomImage() {
final StreamResource resource = new StreamResource("usb-port-black.svg",
() -> SvgFactory.class.getResourceAsStream(FRONTEND_IMAGES_SVG_ICONS + "usb-port-black.svg"));
super.setUserImageResource(resource);
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/esp/espflow/generator/DataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.esp.espflow.entity.User;
import com.esp.espflow.enums.Role;
import com.esp.espflow.service.UserRepository;
import com.esp.espflow.service.respository.UserRepository;
import com.vaadin.flow.spring.annotation.SpringComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/esp/espflow/mappers/WizardEspMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.esp.espflow.mappers;

import com.esp.espflow.entity.WizardEspEntity;
import com.esp.espflow.entity.dto.WizardEspDto;

/**
* @author rub'n
*/
public class WizardEspMapper {

public static final WizardEspMapper INSTANCE = new WizardEspMapper();

private WizardEspMapper() {
}

public WizardEspEntity dtoToEntity(final WizardEspDto dto) {
final WizardEspEntity entity = new WizardEspEntity();
entity.setName(dto.name());
entity.setWizardEnabled(dto.isWizardEnabled());
return entity;
}

public WizardEspDto entityToDto(final WizardEspEntity entity) {
return WizardEspDto.builder()
.name(entity.getName())
.isWizardEnabled(entity.isWizardEnabled())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.esp.espflow.security;

import com.esp.espflow.entity.User;
import com.esp.espflow.service.UserRepository;
import com.esp.espflow.service.respository.UserRepository;
import com.vaadin.flow.spring.security.AuthenticationContext;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.esp.espflow.security;

import com.esp.espflow.entity.User;
import com.esp.espflow.service.UserRepository;
import com.esp.espflow.service.respository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/esp/espflow/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.esp.espflow.service;

import com.esp.espflow.entity.User;
import com.esp.espflow.service.respository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.esp.espflow.service;
package com.esp.espflow.service.respository;


import com.esp.espflow.entity.User;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.esp.espflow.service.respository;

import com.esp.espflow.entity.WizardEspEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface WizardEspRepository extends JpaRepository<WizardEspEntity, Long> {

Optional<WizardEspEntity> findByName(String name);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.esp.espflow.service.respository.impl;

import com.esp.espflow.entity.WizardEspEntity;
import com.esp.espflow.entity.dto.WizardEspDto;
import com.esp.espflow.mappers.WizardEspMapper;
import com.esp.espflow.service.respository.WizardEspRepository;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
* @author rub'n
*/
@Log4j2
@Service
@RequiredArgsConstructor
public class WizardEspService {

private final WizardEspRepository wizardEspRepository;

/**
* @param wizardEspDto
*/
public void save(WizardEspDto wizardEspDto) {
var entity = WizardEspMapper.INSTANCE.dtoToEntity(wizardEspDto);
this.wizardEspRepository.findByName(entity.getName())
.ifPresentOrElse(currentEntity -> {
currentEntity.setWizardEnabled(entity.isWizardEnabled());
wizardEspRepository.save(currentEntity);
log.info("Entity updated {}", currentEntity);
}, () -> {
wizardEspRepository.save(entity);
log.info("Entity saved {}", entity);
});
}

/**
*
* @param name of this Wizard
*
* @return A {@link Optional< WizardEspEntity >}
*/
@Transactional
public Optional<WizardEspDto> findWizardFlashEsp(String name) {
return this.wizardEspRepository.findByName(name)
.map(WizardEspMapper.INSTANCE::entityToDto);
}

}
7 changes: 6 additions & 1 deletion src/main/java/com/esp/espflow/util/EspFlowConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class EspFlowConstants {
public static final String DIALOG_DISABLED = "Hide";
public static final String INFORMATION = "Information";
public static final String WARNING = "Warning";

public static final String FRONTEND_ICON = "icons/icon.png";
public static final String FRONTEND_IMAGES_ESPDEVICES = "frontend/images/espdevices/";
public static final String FRONTEND_IMAGES_LOGO = "frontend/images/logo/";
public static final String FRONTEND_IMAGES_AVATAR_USER = "frontend/images/avatar-user/";
Expand Down Expand Up @@ -92,4 +92,9 @@ public class EspFlowConstants {
public static final String MACOS_ICON = "mac.svg";
public static final String FREE_BSD_ICON = "freebsd.svg";
public static final String NO_OS_ICON = "no-os.svg";
public static final String ESPFLOW_SOURCE_CODE = "https://github.com/rucko24/EspFlow";
public static final String WIZARD_FLASHESP_VIEW = "wizardFlashEspView";
public static final String WIZARD_READ_FLASH_ESP_VIEW = "wizardReadFlashEspView";
public static final String INNER_HTML = "innerHTML";

}
Loading

0 comments on commit 82c0116

Please sign in to comment.