Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ console-app/node_modules
.dev.vars*
!.dev.vars.example
!.env.example


scripts/e2e/.known_hosts
scripts/e2e/.known_hosts.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class ServiceTemplatesCategoryArray1779720000000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP INDEX IF EXISTS "IDX_serviceTemplates_category"
`);

await queryRunner.query(`
ALTER TABLE "serviceTemplates"
ALTER COLUMN "category" TYPE text[]
USING (
CASE
WHEN "category" IS NULL THEN NULL
WHEN trim("category"::text) = '' THEN NULL
ELSE ARRAY[trim("category"::text)]
END
)
`);

await queryRunner.query(`
CREATE INDEX "IDX_serviceTemplates_category"
ON "serviceTemplates" USING GIN ("category")
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP INDEX IF EXISTS "IDX_serviceTemplates_category"
`);

await queryRunner.query(`
ALTER TABLE "serviceTemplates"
ALTER COLUMN "category" TYPE varchar(100)
USING (
CASE
WHEN "category" IS NULL THEN NULL
WHEN array_length("category", 1) IS NULL THEN NULL
ELSE left("category"[1], 100)
END
)
`);

await queryRunner.query(`
CREATE INDEX "IDX_serviceTemplates_category"
ON "serviceTemplates" ("category")
`);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class ServiceTemplatesDescriptions1779730000000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "serviceTemplates"
ADD COLUMN "shortDescription" text
`);

await queryRunner.query(`
ALTER TABLE "serviceTemplates"
ADD COLUMN "longDescription" text
`);

await queryRunner.query(`
UPDATE "serviceTemplates"
SET "shortDescription" = "description"
WHERE "description" IS NOT NULL
AND trim("description") <> ''
`);

await queryRunner.query(`
ALTER TABLE "serviceTemplates"
DROP COLUMN "description"
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "serviceTemplates"
ADD COLUMN "description" text
`);

await queryRunner.query(`
UPDATE "serviceTemplates"
SET "description" = "shortDescription"
WHERE "shortDescription" IS NOT NULL
AND trim("shortDescription") <> ''
`);

await queryRunner.query(`
ALTER TABLE "serviceTemplates"
DROP COLUMN "shortDescription"
`);

await queryRunner.query(`
ALTER TABLE "serviceTemplates"
DROP COLUMN "longDescription"
`);
}
}
6 changes: 4 additions & 2 deletions apps/control-panel-app/seeders/templates.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,10 @@ async function seedFromTemplates(configService: ConfigService): Promise<void> {
const payload = {
slug: templateRecord.slug,
name: templateRecord.name,
description: templateRecord.description || null,
category: templateRecord.category || null,
shortDescription: templateRecord.shortDescription || null,
longDescription: templateRecord.longDescription || null,
category:
templateRecord.category.length > 0 ? templateRecord.category : null,
tags: templateRecord.tags.length > 0 ? templateRecord.tags : null,
documentation: templateRecord.documentation || null,
logo: templateRecord.logo || null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export interface TemplateListItemDto {
slug: string;
name: string;
description: string;
category: string;
shortDescription: string;
longDescription: string | null;
category: string[];
tags: string[];
logo: string | null;
port: number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ export class ServiceTemplateEntity extends BaseEntity {
name!: string;

@Column({ type: "text", nullable: true })
description!: string | null;
shortDescription!: string | null;

@Column({ type: "varchar", length: 100, nullable: true })
category!: string | null;
@Column({ type: "text", nullable: true })
longDescription!: string | null;

@Column("text", { array: true, nullable: true })
category!: string[] | null;

@Column("text", { array: true, nullable: true })
tags!: string[] | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import {
getTemplateDescriptionFromComments,
getTemplateLongDescriptionFromComments,
parseTemplateCommentMetadata,
parseTemplateVariables,
TemplatePayloadService,
Expand Down Expand Up @@ -165,14 +167,25 @@ export class ServiceTemplateService {
return {
slug: template.slug,
name: template.name,
description:
template.description?.trim() || commentMetadata?.slogan?.trim() || "",
shortDescription:
template.shortDescription?.trim() ||
(commentMetadata
? getTemplateDescriptionFromComments(commentMetadata)
: ""),
longDescription:
template.longDescription?.trim() ||
(commentMetadata
? getTemplateLongDescriptionFromComments(commentMetadata) || null
: null),
category:
template.category?.trim() || commentMetadata?.category?.trim() || "",
template.category && template.category.length > 0
? template.category
: (commentMetadata?.category ?? []),
tags:
template.tags && template.tags.length > 0
? template.tags
: (commentMetadata?.tags ?? []),
logo: template.logo?.trim() || null,
port: template.port ?? commentMetadata?.port ?? 0,
};
}
Expand Down
Loading
Loading