forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API for application themes (appsmithorg#9449)
- Loading branch information
1 parent
2138229
commit 1fad719
Showing
41 changed files
with
2,615 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...server/appsmith-server/src/main/java/com/appsmith/server/controllers/ThemeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.appsmith.server.controllers; | ||
|
||
import com.appsmith.server.constants.Url; | ||
import com.appsmith.server.controllers.ce.ThemeControllerCE; | ||
import com.appsmith.server.services.ThemeService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping(Url.THEME_URL) | ||
public class ThemeController extends ThemeControllerCE { | ||
|
||
public ThemeController(ThemeService themeService) { | ||
super(themeService); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...r/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ThemeControllerCE.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.appsmith.server.controllers.ce; | ||
|
||
import com.appsmith.server.constants.Url; | ||
import com.appsmith.server.domains.ApplicationMode; | ||
import com.appsmith.server.domains.Theme; | ||
import com.appsmith.server.dtos.ResponseDTO; | ||
import com.appsmith.server.services.ThemeService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import reactor.core.publisher.Mono; | ||
|
||
import javax.validation.Valid; | ||
|
||
@Slf4j | ||
@RequestMapping(Url.THEME_URL) | ||
public class ThemeControllerCE extends BaseController<ThemeService, Theme, String> { | ||
public ThemeControllerCE(ThemeService themeService) { | ||
super(themeService); | ||
} | ||
|
||
@GetMapping("applications/{applicationId}") | ||
public Mono<ResponseDTO<Theme>> getThemes(@PathVariable String applicationId, @RequestParam(required = false, defaultValue = "EDIT") ApplicationMode mode) { | ||
return service.getApplicationTheme(applicationId, mode) | ||
.map(theme -> new ResponseDTO<>(HttpStatus.OK.value(), theme, null)); | ||
} | ||
|
||
@PostMapping("applications/{applicationId}") | ||
public Mono<ResponseDTO<Theme>> updateTheme(@PathVariable String applicationId, @Valid @RequestBody Theme resource) { | ||
return service.updateTheme(applicationId, resource) | ||
.map(theme -> new ResponseDTO<>(HttpStatus.OK.value(), theme, null)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../appsmith/server/domains/CommentMode.java → ...smith/server/domains/ApplicationMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.appsmith.server.domains; | ||
|
||
public enum CommentMode { | ||
public enum ApplicationMode { | ||
EDIT, PUBLISHED | ||
} |
133 changes: 133 additions & 0 deletions
133
app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Theme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package com.appsmith.server.domains; | ||
|
||
import com.appsmith.external.models.BaseDomain; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Getter | ||
@Setter | ||
@Document | ||
public class Theme extends BaseDomain { | ||
public static final String LEGACY_THEME_NAME = "classic"; | ||
public static final String DEFAULT_THEME_NAME = "classic"; | ||
|
||
@NotNull | ||
private String name; | ||
private Config config; | ||
private Properties properties; | ||
private Map<String, WidgetStyle> stylesheet; | ||
|
||
@JsonProperty("isSystemTheme") // manually setting property name to make sure it's compatible with Gson | ||
private boolean isSystemTheme = false; // should be false by default | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class Properties { | ||
private Colors colors; | ||
private BorderRadiusProperties borderRadius; | ||
private BoxShadowProperties boxShadow; | ||
private FontFamilyProperties fontFamily; | ||
} | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class Colors { | ||
private String primaryColor; | ||
private String backgroundColor; | ||
} | ||
|
||
@Data | ||
public static class Config { | ||
private Colors colors; | ||
private BorderRadius borderRadius; | ||
private BoxShadow boxShadow; | ||
private FontFamily fontFamily; | ||
} | ||
|
||
@Data | ||
public static class ResponsiveAttributes { | ||
@JsonProperty("none") | ||
@SerializedName("none") | ||
private String noneValue; | ||
|
||
@JsonProperty("DEFAULT") | ||
@SerializedName("DEFAULT") | ||
private String defaultValue; | ||
|
||
@JsonProperty("md") | ||
@SerializedName("md") | ||
private String mdValue; | ||
|
||
@JsonProperty("lg") | ||
@SerializedName("lg") | ||
private String lgValue; | ||
|
||
@JsonProperty("xl") | ||
@SerializedName("xl") | ||
private String xlValue; | ||
|
||
@JsonProperty("2xl") | ||
@SerializedName("2xl") | ||
private String doubleXlValue; | ||
|
||
@JsonProperty("3xl") | ||
@SerializedName("3xl") | ||
private String tripleXlValue; | ||
|
||
@JsonProperty("full") | ||
@SerializedName("full") | ||
private String fullValue; | ||
} | ||
|
||
@Data | ||
public static class BorderRadius { | ||
private ResponsiveAttributes appBorderRadius; | ||
} | ||
|
||
@Data | ||
public static class BoxShadow { | ||
private ResponsiveAttributes appBoxShadow; | ||
} | ||
|
||
@Data | ||
public static class FontFamily { | ||
private List<String> appFont; | ||
} | ||
|
||
@Data | ||
public static class FontFamilyProperties { | ||
private String appFont; | ||
} | ||
|
||
@Data | ||
public static class WidgetStyle { | ||
private String backgroundColor; | ||
private String borderRadius; | ||
private String boxShadow; | ||
private String primaryColor; | ||
private String menuColor; | ||
private String buttonColor; | ||
} | ||
|
||
@Data | ||
public static class BorderRadiusProperties { | ||
private String appBorderRadius; | ||
} | ||
|
||
@Data | ||
public static class BoxShadowProperties { | ||
private String appBoxShadow; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.