Skip to content

Commit

Permalink
remove message files
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Dec 4, 2023
1 parent 452cb67 commit 5ed4b22
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
12 changes: 6 additions & 6 deletions analytics-ui/src/sample/editor/repository.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
REPO_SAMPLES_CONTRIB_CUMULOCITY,
REPO_SAMPLES_CONTRIB_SIMULATION,
Repository,
getFileExtension,
removeFileExtension,
uuidCustom,
} from "../../shared/analytics.model";
import {
Expand Down Expand Up @@ -245,17 +247,17 @@ export class RepositoryService {
let dataArray = _.values(data);
const blocks = [];
for (let index = 0; index < dataArray.length; index++) {
if (dataArray[index].name.slice(-4) != ".json") {
if (getFileExtension(dataArray[index].name) != ".json") {
const tb: any = {
repositoryName: rep.name,
name: dataArray[index].name.slice(0, -4),
name: removeFileExtension(dataArray[index].name),
custom: true,
downloadUrl: dataArray[index].download_url,
url: dataArray[index].url,
};
tb.id = await this.resolveFullyQualified_CEP_Block_name(tb, rep);
blocks.push(tb);
console.log(`FQN:`,tb);
console.log(`FQN:`, tb);
}
}
return blocks;
Expand All @@ -281,9 +283,7 @@ export class RepositoryService {
return EMPTY;
}

async getAll_CEP_BlockSamples(
hideInstalled: boolean
): Promise<CEP_Block[]> {
async getAll_CEP_BlockSamples(hideInstalled: boolean): Promise<CEP_Block[]> {
const promises: Promise<CEP_Block[]>[] = [];
const reps: Repository[] = await this.loadRepositories();
const loadedBlocks = await this.analyticsService.getLoadedCEP_Blocks();
Expand Down
16 changes: 16 additions & 0 deletions analytics-ui/src/shared/analytics.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const PATH_CEP_STATUS = `${PATH_CEP_DIAGNOSTICS}/apamaCtrlStatus`;

export const STATUS_MESSAGE_01 = "Recording apama-ctrl safe mode state";

export const CEP_METADATA_FILE_EXTENSION = ".json";
export const GITHUB_BASE = "https://api.github.com";
export const REPO_SAMPLES_OWNER = "SoftwareAG";
export const REPO_SAMPLES_BLOCKSDK = `${GITHUB_BASE}/repos/${REPO_SAMPLES_OWNER}/apama-analytics-builder-block-sdk/contents/samples/blocks`;
Expand All @@ -107,11 +108,26 @@ export function uuidCustom(): string {
let id = Math.random().toString(36).slice(-6);
return id;
}

export function removeFileExtension(name: string): string {
let result = name.replace(/\.[^.]*$/, "");
return result;
}

export function getFileExtension(name: string): string {
const pattern = /\.([0-9a-z]+)(?:[\?#]|$)/i;
let result = name.match(pattern);
return result[0];
}

export function isCustomCEP_Block(block: CEP_Block): boolean {
return (
!block.id.startsWith("apama.analyticsbuilder.blocks") &&
!block.id.startsWith("apama.analyticskit.blocks.core") &&
!block.id.startsWith("apama.analyticskit.blocks.cumulocity")
);
}

// https://api.github.com/repos/SoftwareAG/apama-analytics-builder-block-sdk/contents/samples
// http://localhost:9000/cep/apamacorrelator/EN/block-metadata.json
// http://localhost:9000/service/cep/apamacorrelator/EN/core.json
9 changes: 4 additions & 5 deletions analytics-ui/src/shared/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import {
EXTENSION_ENDPOINT,
APPLICATION_ANALYTICS_BUILDER_SERVICE,
removeFileExtension,
CEP_METADATA_FILE_EXTENSION,
isCustomCEP_Block,
} from "./analytics.model";
import { filter, map, pairwise } from "rxjs/operators";

Expand Down Expand Up @@ -105,7 +107,7 @@ export class AnalyticsService {
const loadedExtensions: CEP_Metadata = await this.getCEP_Metadata();
extensions.forEach((ext) => {
ext.name = removeFileExtension(ext.name)
const key = ext.name + ".json";
const key = ext.name + CEP_METADATA_FILE_EXTENSION;
ext.loaded = loadedExtensions.metadatas.some((le) =>
key.includes(le)
);
Expand Down Expand Up @@ -153,10 +155,7 @@ export class AnalyticsService {
);
extension.analytics.forEach((block) => {
const cepBlock = block as CEP_Block;
cepBlock.custom =
!cepBlock.id.startsWith("apama.analyticsbuilder.blocks") &&
!cepBlock.id.startsWith("apama.analyticskit.blocks.core") &&
!cepBlock.id.startsWith("apama.analyticskit.blocks.cumulocity");
cepBlock.custom = isCustomCEP_Block(cepBlock);
cepBlock.extension = extensionNameAbbreviated;
//console.log("Inspect CEP_Block:", cepBlock.name, cepBlock.id, cepBlock.extension, cepBlock.custom)
result.push(cepBlock);
Expand Down

0 comments on commit 5ed4b22

Please sign in to comment.