Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4fc650c
fix duplicate gid : null by filling in gid
dragonpoo Oct 11, 2024
f1bedbf
add theme to snapshot list api
dragonpoo Oct 9, 2024
6fece96
add range to snapshot list api
dragonpoo Oct 9, 2024
449f1fd
convert to time-series collection
dragonpoo Oct 10, 2024
4d8ac38
add new endpoint to retrieve archived snapshot list
dragonpoo Oct 11, 2024
38a32d5
Add name param to application list endpoint
goldants Oct 1, 2024
0ad8fef
Add name param to folder list endpoint
goldants Oct 1, 2024
fbfa78b
Add name param to folder list endpoint
goldants Oct 1, 2024
7d5fb6b
Add name param to datasource, libraryquery list endpoint
goldants Oct 2, 2024
9541784
Refactor code to use StringUtils
dragonpoo Oct 17, 2024
172be23
sync style property views with applied comp styles + added useThemeSt…
raheeliftikhar5 Oct 17, 2024
60609a1
added showValidationMessageOnEmptyInput flag in input fields
raheeliftikhar5 Oct 17, 2024
dd36801
Fix required issue
dragonpoo Oct 17, 2024
49a4a61
Add authorization check to Extension Endpoint
dragonpoo Oct 22, 2024
1ff153e
Fix org list by email
dragonpoo Oct 23, 2024
1616232
theme canvas settings
raheeliftikhar5 Oct 8, 2024
420c56f
set default values for canvas settings
raheeliftikhar5 Oct 8, 2024
dba9097
theme canvas settings
raheeliftikhar5 Oct 10, 2024
e76ef90
canvas setting in theme and app
raheeliftikhar5 Oct 10, 2024
81a55be
small fix
raheeliftikhar5 Oct 10, 2024
21ced62
add rowCount in readonly view
raheeliftikhar5 Oct 11, 2024
9c11938
replaced color picker to allow gradient selection
raheeliftikhar5 Oct 15, 2024
c459d56
Timeline: added gradient
raheeliftikhar5 Oct 16, 2024
1c33fd0
added canvas bg color option in app Settings
raheeliftikhar5 Oct 16, 2024
4f19e7b
added background style utility
raheeliftikhar5 Oct 16, 2024
419c11c
ShapeComp: added gradient
raheeliftikhar5 Oct 16, 2024
aba86a6
Containers: added gradient
raheeliftikhar5 Oct 16, 2024
91d8e3a
List/GridView: added gradient
raheeliftikhar5 Oct 16, 2024
f462970
Modal/Drawer: added gradients
raheeliftikhar5 Oct 16, 2024
92292c3
added gradient
raheeliftikhar5 Oct 16, 2024
0d4b64d
Table: added gradient
raheeliftikhar5 Oct 17, 2024
f560a9a
Table: added gradients
raheeliftikhar5 Oct 18, 2024
557407f
fixed canvas settings
raheeliftikhar5 Oct 18, 2024
2f0a51a
set app default canvas settings
raheeliftikhar5 Oct 18, 2024
6c16141
show theme colors in preset colors for color picker
raheeliftikhar5 Oct 21, 2024
b09e024
separate app settings, canvas settings and js settings
raheeliftikhar5 Oct 21, 2024
89aa5d0
move theme selection in color settings
raheeliftikhar5 Oct 22, 2024
bd028f3
fix opacity not working
raheeliftikhar5 Oct 25, 2024
dd50f07
hide gradient selection in color picker for text/border colors
raheeliftikhar5 Oct 25, 2024
23ba36e
Merge pull request #1247 from lowcoder-org/theme_canvas_settings
FalkWolsky Oct 25, 2024
3c8bc96
Small branding changes in Seletable
Oct 25, 2024
861e472
fix canvas setting issues
raheeliftikhar5 Oct 28, 2024
3a95a7f
refresh oauth issue - invalid workspace id
dragonpoo Oct 25, 2024
b7277b0
disable email and providers based on workspace
dragonpoo Oct 25, 2024
f243dcc
Update Firebase Query to accept paging parameter
Oct 28, 2024
6ea831c
Updating Firestore Query to accept "startAt" for Pagination, Adapting…
Oct 28, 2024
e81a571
Updating yarn lock file for Node-Service
Oct 28, 2024
f5d21fa
Merge branch 'main' into dev
FalkWolsky Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add new endpoint to retrieve archived snapshot list
  • Loading branch information
Thomasr authored and ludomikula committed Oct 17, 2024
commit 4d8ac381fd918dd4241ec8425f520f36dfff54b4
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.lowcoder.domain.application.repository;

import org.lowcoder.domain.application.model.ApplicationHistorySnapshot;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.time.Instant;

@Repository
public interface ApplicationHistoryArchivedSnapshotRepository extends ReactiveMongoRepository<ApplicationHistorySnapshot, String> {

@Query(value = "{ 'applicationId': ?0, $and: [" +
"{$or: [ { 'context.operations': { $elemMatch: { 'compName': ?1 } } }, { $expr: { $eq: [?1, null] } } ]}, " +
"{$or: [ { 'dsl.settings.themeId': ?2 }, { $expr: { $eq: [?2, null] } } ] }, " +
"{$or: [ { 'createdAt': { $gte: ?3} }, { $expr: { $eq: [?3, null] } } ] }, " +
"{$or: [ { 'createdAt': { $lte: ?4} }, { $expr: { $eq: [?4, null] } } ] } " +
"]}",
fields = "{applicationId : 1, context: 1, createdBy : 1, createdAt : 1}")
Flux<ApplicationHistorySnapshot> findAllByApplicationId(String applicationId, String compName, String theme, Instant createdAtFrom, Instant createdAtTo, Pageable pageable);

Mono<Long> countByApplicationId(String applicationId);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.lowcoder.domain.application.service;

import org.lowcoder.domain.application.model.ApplicationHistorySnapshot;
import org.lowcoder.domain.application.model.ApplicationHistorySnapshotTS;
import org.springframework.data.domain.PageRequest;
import reactor.core.publisher.Mono;
Expand All @@ -13,8 +14,11 @@ public interface ApplicationHistorySnapshotService {
Mono<Boolean> createHistorySnapshot(String applicationId, Map<String, Object> dsl, Map<String, Object> context, String userId);

Mono<List<ApplicationHistorySnapshotTS>> listAllHistorySnapshotBriefInfo(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest);
Mono<List<ApplicationHistorySnapshot>> listAllHistorySnapshotBriefInfoArchived(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest);

Mono<Long> countByApplicationId(String applicationId);

Mono<ApplicationHistorySnapshotTS> getHistorySnapshotDetail(String historySnapshotId);

Mono<ApplicationHistorySnapshot> getHistorySnapshotDetailArchived(String historySnapshotId);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.lowcoder.domain.application.service.impl;

import lombok.RequiredArgsConstructor;
import org.lowcoder.domain.application.model.ApplicationHistorySnapshot;
import org.lowcoder.domain.application.model.ApplicationHistorySnapshotTS;
import org.lowcoder.domain.application.repository.ApplicationHistoryArchivedSnapshotRepository;
import org.lowcoder.domain.application.repository.ApplicationHistorySnapshotRepository;
import org.lowcoder.domain.application.service.ApplicationHistorySnapshotService;
import org.lowcoder.sdk.exception.BizError;
Expand All @@ -23,6 +25,7 @@
public class ApplicationHistorySnapshotServiceImpl implements ApplicationHistorySnapshotService {

private final ApplicationHistorySnapshotRepository repository;
private final ApplicationHistoryArchivedSnapshotRepository repositoryArchived;

@Override
public Mono<Boolean> createHistorySnapshot(String applicationId, Map<String, Object> dsl, Map<String, Object> context, String userId) {
Expand All @@ -42,6 +45,13 @@ public Mono<List<ApplicationHistorySnapshotTS>> listAllHistorySnapshotBriefInfo(
.onErrorMap(Exception.class, e -> ofException(BizError.FETCH_HISTORY_SNAPSHOT_FAILURE, "FETCH_HISTORY_SNAPSHOT_FAILURE"));
}

@Override
public Mono<List<ApplicationHistorySnapshot>> listAllHistorySnapshotBriefInfoArchived(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest) {
return repositoryArchived.findAllByApplicationId(applicationId, compName, theme, from, to, pageRequest.withSort(Direction.DESC, "id"))
.collectList()
.onErrorMap(Exception.class, e -> ofException(BizError.FETCH_HISTORY_SNAPSHOT_FAILURE, "FETCH_HISTORY_SNAPSHOT_FAILURE"));
}

@Override
public Mono<Long> countByApplicationId(String applicationId) {
return repository.countByApplicationId(applicationId)
Expand All @@ -55,4 +65,11 @@ public Mono<ApplicationHistorySnapshotTS> getHistorySnapshotDetail(String histor
return repository.findById(historySnapshotId)
.switchIfEmpty(deferredError(INVALID_HISTORY_SNAPSHOT, "INVALID_HISTORY_SNAPSHOT", historySnapshotId));
}


@Override
public Mono<ApplicationHistorySnapshot> getHistorySnapshotDetailArchived(String historySnapshotId) {
return repositoryArchived.findById(historySnapshotId)
.switchIfEmpty(deferredError(INVALID_HISTORY_SNAPSHOT, "INVALID_HISTORY_SNAPSHOT", historySnapshotId));
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package org.lowcoder.api.application;

import static org.lowcoder.api.util.ViewBuilder.multiBuild;

import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableMap;
import lombok.RequiredArgsConstructor;
import org.lowcoder.api.application.view.HistorySnapshotDslView;
import org.lowcoder.api.framework.view.ResponseView;
import org.lowcoder.api.home.SessionUserService;
import org.lowcoder.api.util.Pagination;
import org.lowcoder.domain.application.model.Application;
import org.lowcoder.domain.application.model.ApplicationHistorySnapshot;
import org.lowcoder.domain.application.model.ApplicationHistorySnapshotTS;
import org.lowcoder.domain.application.service.ApplicationHistorySnapshotService;
import org.lowcoder.domain.application.service.ApplicationService;
Expand All @@ -22,11 +18,14 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import com.google.common.collect.ImmutableMap;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
import reactor.core.publisher.Mono;
import static org.lowcoder.api.util.ViewBuilder.multiBuild;

@RequiredArgsConstructor
@RestController
Expand Down Expand Up @@ -90,6 +89,43 @@ public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfo(@
.map(ResponseView::success);
}

@Override
public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfoArchived(@PathVariable String applicationId,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam String compName,
@RequestParam String theme,
@RequestParam Instant from,
@RequestParam Instant to) {

Pagination pagination = Pagination.of(page, size).check();

return sessionUserService.getVisitorId()
.delayUntil(visitor -> resourcePermissionService.checkResourcePermissionWithError(visitor, applicationId,
ResourceAction.EDIT_APPLICATIONS))
.flatMap(__ -> applicationHistorySnapshotService.listAllHistorySnapshotBriefInfoArchived(applicationId, compName, theme, from, to, pagination.toPageRequest()))
.flatMap(snapshotList -> {
Mono<List<ApplicationHistorySnapshotBriefInfo>> snapshotBriefInfoList = multiBuild(snapshotList,
ApplicationHistorySnapshot::getCreatedBy,
userService::getByIds,
(applicationHistorySnapshot, user) -> new ApplicationHistorySnapshotBriefInfo(
applicationHistorySnapshot.getId(),
applicationHistorySnapshot.getContext(),
applicationHistorySnapshot.getCreatedBy(),
user.getName(),
user.getAvatarUrl(),
applicationHistorySnapshot.getCreatedAt().toEpochMilli()
)
);

Mono<Long> applicationHistorySnapshotCount = applicationHistorySnapshotService.countByApplicationId(applicationId);

return Mono.zip(snapshotBriefInfoList, applicationHistorySnapshotCount)
.map(tuple -> ImmutableMap.of("list", tuple.getT1(), "count", tuple.getT2()));
})
.map(ResponseView::success);
}

@Override
public Mono<ResponseView<HistorySnapshotDslView>> getHistorySnapshotDsl(@PathVariable String applicationId,
@PathVariable String snapshotId) {
Expand All @@ -98,7 +134,29 @@ public Mono<ResponseView<HistorySnapshotDslView>> getHistorySnapshotDsl(@PathVar
ResourceAction.EDIT_APPLICATIONS))
.flatMap(__ -> applicationHistorySnapshotService.getHistorySnapshotDetail(snapshotId))
.map(ApplicationHistorySnapshotTS::getDsl)
.zipWhen(dsl -> applicationService.getAllDependentModulesFromDsl(dsl))
.zipWhen(applicationService::getAllDependentModulesFromDsl)
.map(tuple -> {
Map<String, Object> applicationDsl = tuple.getT1();
List<Application> dependentModules = tuple.getT2();
Map<String, Map<String, Object>> dependentModuleDsl = dependentModules.stream()
.collect(Collectors.toMap(Application::getId, Application::getLiveApplicationDsl, (a, b) -> b));
return HistorySnapshotDslView.builder()
.applicationsDsl(applicationDsl)
.moduleDSL(dependentModuleDsl)
.build();
})
.map(ResponseView::success);
}

@Override
public Mono<ResponseView<HistorySnapshotDslView>> getHistorySnapshotDslArchived(@PathVariable String applicationId,
@PathVariable String snapshotId) {
return sessionUserService.getVisitorId()
.delayUntil(visitor -> resourcePermissionService.checkResourcePermissionWithError(visitor, applicationId,
ResourceAction.EDIT_APPLICATIONS))
.flatMap(__ -> applicationHistorySnapshotService.getHistorySnapshotDetailArchived(snapshotId))
.map(ApplicationHistorySnapshot::getDsl)
.zipWhen(applicationService::getAllDependentModulesFromDsl)
.map(tuple -> {
Map<String, Object> applicationDsl = tuple.getT1();
List<Application> dependentModules = tuple.getT2();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfo(@
@RequestParam(required = false ) @Nullable Instant from,
@RequestParam(required = false ) @Nullable Instant to);

@Operation(
tags = TAG_APPLICATION_HISTORY_MANAGEMENT,
operationId = "listApplicationSnapshotsArchived",
summary = "List Archived Application Snapshots",
description = "Retrieve a list of Archived Snapshots associated with a specific Application within Lowcoder."
)
@GetMapping("/archive/{applicationId}")
public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfoArchived(@PathVariable String applicationId,
@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size,
@RequestParam(required = false ) @Nullable String compName, @RequestParam(required = false ) @Nullable String theme,
@RequestParam(required = false ) @Nullable Instant from,
@RequestParam(required = false ) @Nullable Instant to);

@Operation(
tags = TAG_APPLICATION_HISTORY_MANAGEMENT,
operationId = "getApplicationSnapshot",
Expand All @@ -56,6 +69,16 @@ public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfo(@
public Mono<ResponseView<HistorySnapshotDslView>> getHistorySnapshotDsl(@PathVariable String applicationId,
@PathVariable String snapshotId);

@Operation(
tags = TAG_APPLICATION_HISTORY_MANAGEMENT,
operationId = "getApplicationSnapshotArchived",
summary = "Retrieve Archived Application Snapshot",
description = "Retrieve a specific Archived Application Snapshot within Lowcoder using the Application and Snapshot IDs."
)
@GetMapping("/archive/{applicationId}/{snapshotId}")
public Mono<ResponseView<HistorySnapshotDslView>> getHistorySnapshotDslArchived(@PathVariable String applicationId,
@PathVariable String snapshotId);

public record ApplicationHistorySnapshotBriefInfo(String snapshotId, Map<String, Object> context,
String userId, String userName,
String userAvatar, long createTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ common:
cookie:
max-age-in-hours: ${LOWCODER_COOKIE_MAX_AGE:24}
query:
app-snapshot-keep-duration: ${LOWCODER_QUERY_SNAPSHOT_ACTIVE_DURATION:30}
app-snapshot-keep-duration: ${LOWCODER_APP_SNAPSHOT_RETENTIONTIME:30}

debug: true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ common:
cookie:
max-age-in-hours: ${LOWCODER_COOKIE_MAX_AGE:24}
query:
app-snapshot-keep-duration: ${LOWCODER_QUERY_SNAPSHOT_ACTIVE_DURATION:30}
app-snapshot-keep-duration: ${LOWCODER_APP_SNAPSHOT_RETENTIONTIME:30}

material:
mongodb-grid-fs:
Expand Down
Loading