Skip to content

Commit

Permalink
feat(#3156): Add asset browser to overview pages (#3159)
Browse files Browse the repository at this point in the history
* feat(#3156): Add asset browser to adapters and pipelines

* Move asset browser to shared-ui module

* Improve rendering of asset browser

* Fix imports

* Add header

* Improve asset viewer, add migrations

* Add headers

* Fix checkstyle

* Fix creation of asset link types

* Fix bugs

* feat(#3176): Move adapter preview to details view (#3177)

* feat(#3176): Move adapter preview to details view

* Modify tests
  • Loading branch information
dominikriemer authored Aug 27, 2024
1 parent 22ac222 commit 54b3f3a
Show file tree
Hide file tree
Showing 110 changed files with 3,615 additions and 872 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class AssetLinkType {
@JsonProperty("_id")
private @SerializedName("_id") String id;

@JsonProperty("_rev")
private @SerializedName("_rev") String rev;

private String linkType;
private String linkLabel;
private String linkColor;
Expand Down Expand Up @@ -128,4 +131,12 @@ public boolean isNavigationActive() {
public void setNavigationActive(boolean navigationActive) {
this.navigationActive = navigationActive;
}

public String getRev() {
return rev;
}

public void setRev(String rev) {
this.rev = rev;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,31 @@

public class CreateAssetLinkTypeTask implements InstallationTask {

private List<AssetLinkType> defaultLinkTypes = Arrays.asList(
new AssetLinkType("data-view", "Data View", "var(--color-data-view)", "search", "data-view",
List.of("dataexplorer"), true),
private final List<AssetLinkType> defaultLinkTypes = Arrays.asList(
new AssetLinkType(
"data-view",
"Data View",
"var(--color-data-view)",
"search",
"data-view",
List.of("dataexplorer", "dashboard"),
true
),
new AssetLinkType("dashboard", "Dashboard", "var(--color-dashboard)", "insert_chart", "dashboard",
List.of("dashboard"), true),
new AssetLinkType("adapter", "Adapter", "var(--color-adapter)", "power", "adapter", List.of("connect"), true),
new AssetLinkType(
"adapter",
"Adapter",
"var(--color-adapter)",
"power",
"adapter",
List.of("connect", "details"),
true
),
new AssetLinkType("data-source", "Data Source", "var(--color-data-source)", "dataset", "data-source", List.of(),
false),
new AssetLinkType("pipeline", "Pipeline", "var(--color-pipeline)", "play_arrow", "pipeline",
List.of("pipeline", "details"), true),
List.of("pipelines", "details"), true),
new AssetLinkType("measurement", "Data Lake Storage", "var(--color-measurement)", "folder", "measurement",
List.of(), false),
new AssetLinkType("file", "File", "var(--color-file)", "draft", "file", List.of(), false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.streampipes.service.core.migrations.v095.MergeFilenamesAndRenameDuplicatesMigration;
import org.apache.streampipes.service.core.migrations.v970.AddLinkSettingsMigration;
import org.apache.streampipes.service.core.migrations.v970.DataExplorerDataViewMigration;
import org.apache.streampipes.service.core.migrations.v970.ModifyAssetLinkTypeMigration;

import java.util.Arrays;
import java.util.List;
Expand All @@ -44,7 +45,8 @@ public List<Migration> getAvailableMigrations() {
new StoreEmailTemplatesMigration(),
new MergeFilenamesAndRenameDuplicatesMigration(),
new AddLinkSettingsMigration(),
new DataExplorerDataViewMigration()
new DataExplorerDataViewMigration(),
new ModifyAssetLinkTypeMigration()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.streampipes.service.core.migrations.v970;

import org.apache.streampipes.commons.constants.GenericDocTypes;
import org.apache.streampipes.model.assets.AssetLinkType;
import org.apache.streampipes.service.core.migrations.Migration;
import org.apache.streampipes.storage.api.IGenericStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public class ModifyAssetLinkTypeMigration implements Migration {

private static final Logger LOG = LoggerFactory.getLogger(ModifyAssetLinkTypeMigration.class);

private final IGenericStorage genericStorage = StorageDispatcher.INSTANCE.getNoSqlStore().getGenericStorage();
private final ObjectMapper objectMapper = new ObjectMapper();

public ModifyAssetLinkTypeMigration() {

}

@Override
public boolean shouldExecute() {
return true;
}

@Override
public void executeMigration() throws IOException {
getAssetLinkTypes().stream()
.filter(assetLinkType -> switch (assetLinkType.getLinkType()) {
case "data-view", "adapter", "pipeline" -> true;
default -> false;
})
.forEach(assetLinkType -> {
assetLinkType.setNavPaths(switch (assetLinkType.getLinkType()) {
case "data-view" -> List.of("dataexplorer", "dashboard");
case "adapter" -> List.of("connect", "details");
case "pipeline" -> List.of("pipelines", "details");
default -> throw new IllegalStateException("Unexpected value: " + assetLinkType.getLinkType());
});
updateLinkType(assetLinkType);
});
}

@Override
public String getDescription() {
return "Modifying navigation targets of asset link types";
}

private void updateLinkType(AssetLinkType assetLinkType) {
try {
this.genericStorage.update(assetLinkType.getId(), objectMapper.writeValueAsString(assetLinkType));
} catch (IOException e) {
LOG.warn("Could not update asset link type {}", assetLinkType, e);
}
}

private List<AssetLinkType> getAssetLinkTypes() {
try {
return deserialize(genericStorage.findAll(GenericDocTypes.DOC_ASSET_LINK_TYPE));
} catch (IOException e) {
return List.of();
}
}

private List<AssetLinkType> deserialize(List<Map<String, Object>> list) {
CollectionType listType = objectMapper.getTypeFactory()
.constructCollectionType(List.class, AssetLinkType.class);

return objectMapper.convertValue(list, listType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.streampipes.storage.couchdb.constants.GenericCouchDbConstants;
import org.apache.streampipes.storage.couchdb.utils.Utils;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
Expand Down Expand Up @@ -50,7 +51,9 @@ public class GenericStorageImpl implements IGenericStorage {

public GenericStorageImpl() {
this.mapper = new ObjectMapper();
this.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.mapper
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions ui/cypress/support/utils/connect/ConnectBtns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
*/
export class ConnectBtns {
public static infoAdapter() {
return cy.dataCy('info-adapter');
public static detailsAdapter() {
return cy.dataCy('details-adapter');
}

public static editAdapter() {
Expand Down
6 changes: 2 additions & 4 deletions ui/cypress/support/utils/connect/ConnectUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,16 @@ export class ConnectUtils {

public static validateEventsInPreview(amountOfProperties: number) {
// View data
ConnectBtns.infoAdapter().click();
cy.get('div').contains('Values').parent().click();
ConnectBtns.detailsAdapter().click();

// Validate resulting event
cy.dataCy('sp-connect-adapter-success-live-preview', {
timeout: 20000,
}).should('be.visible');

// validate that X event properties. The +1 is for the header row
cy.get('tr.mat-mdc-row', { timeout: 10000 }).should(
'have.length',
amountOfProperties + 1,
amountOfProperties,
);
}

Expand Down
2 changes: 1 addition & 1 deletion ui/cypress/tests/connect/editAdapter.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ describe('Test Edit Adapter', () => {
ConnectUtils.closeAdapterPreview();

ConnectUtils.startAndValidateAdapter(3);
ConnectUtils.goToConnect();

// Validate that name of adapter and data stream
cy.dataCy('adapter-name').contains(newAdapterName);
cy.get('.sp-dialog-content').contains(newAdapterName);
});

it('Successfully edit adapter with persistence pipeline', () => {
Expand Down
2 changes: 2 additions & 0 deletions ui/projects/streampipes/platform-services/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export * from './lib/model/user/user.model';
export * from './lib/model/assets/asset.model';
export * from './lib/model/labels/labels.model';

export * from './lib/model/assets/asset.constants';

export * from './lib/model/types/data-type';
export * from './lib/model/types/semantic-type';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<div fxLayout="column" *ngIf="selectedAsset">
<mat-tree
[dataSource]="dataSource"
[treeControl]="treeControl"
class="sp-tree"
#tree
>
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
<sp-asset-browser-node
class="w-100"
[node]="node"
[assetBrowserData]="assetBrowserData"
[assetSelectionMode]="assetSelectionMode"
[filteredAssetLinkType]="filteredAssetLinkType"
[resourceCount]="resourceCount"
[selectedAsset]="selectedAsset"
(selectedNodeEmitter)="selectNode($event)"
>
</sp-asset-browser-node>
</mat-tree-node>

<mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">
<div class="mat-tree-node">
<button
mat-icon-button
matTreeNodeToggle
[attr.data-cy]="'button-' + node.nodeName"
[attr.aria-label]="'Toggle ' + node.nodeName"
>
<mat-icon class="mat-icon-rtl-mirror">
{{
treeControl.isExpanded(node)
? 'expand_more'
: 'chevron_right'
}}
</mat-icon>
</button>
<sp-asset-browser-node
fxFlex="100"
[node]="node"
[assetBrowserData]="assetBrowserData"
[assetSelectionMode]="assetSelectionMode"
[filteredAssetLinkType]="filteredAssetLinkType"
[resourceCount]="resourceCount"
[selectedAsset]="selectedAsset"
(selectedNodeEmitter)="selectNode($event)"
>
</sp-asset-browser-node>
</div>
<div *ngIf="treeControl.isExpanded(node)" role="group">
<ng-container matTreeNodeOutlet></ng-container>
</div>
</mat-nested-tree-node>
</mat-tree>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*!
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

.sp-tree-invisible {
display: none;
}

.sp-tree ul,
.sp-tree li {
margin-top: 0;
margin-bottom: 0;
list-style-type: none;
}

.sp-tree .mat-nested-tree-node div[role='group'] {
padding-left: 20px;
}

.sp-tree div[role='group'] > .mat-tree-node {
padding-left: 20px;
}

.mat-tree-node {
min-height: 35px;
}

.mat-tree-node:hover {
background: var(--color-bg-1);
}
Loading

0 comments on commit 54b3f3a

Please sign in to comment.