diff --git a/gravitee-apim-console-webui/src/shared/components/file-preview/file-preview.component.html b/gravitee-apim-console-webui/src/shared/components/file-preview/file-preview.component.html new file mode 100644 index 00000000000..ef1e2f7a3a7 --- /dev/null +++ b/gravitee-apim-console-webui/src/shared/components/file-preview/file-preview.component.html @@ -0,0 +1,31 @@ + + + +
+
+
+ @for (line of payload.split('\n'); track line + i; let i = $index) { +
+ {{ i + 1 }} + {{ line | replaceSpaces }} +
+ } +
+
+
diff --git a/gravitee-apim-console-webui/src/shared/pipes/replace-spaces.pipe.spec.ts b/gravitee-apim-console-webui/src/shared/pipes/replace-spaces.pipe.spec.ts new file mode 100644 index 00000000000..abddb696f3c --- /dev/null +++ b/gravitee-apim-console-webui/src/shared/pipes/replace-spaces.pipe.spec.ts @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2015 The Gravitee team (http://gravitee.io) + * + * Licensed 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. + */ +import { ReplaceSpacesPipe } from './replace-spaces.pipe'; + +describe('ReplaceSpacesPipe', () => { + it('create an instance', () => { + const pipe = new ReplaceSpacesPipe(); + expect(pipe).toBeTruthy(); + }); + + it('should return modified spaces if there are more than one next to each other', () => { + const pipe = new ReplaceSpacesPipe(); + expect(pipe.transform(' ')).toEqual('\xa0\xa0'); + }); + + it('should return the same spaces if only one next to each other exists', () => { + const pipe = new ReplaceSpacesPipe(); + expect(pipe.transform(' ')).toEqual(' '); + }); + + it('should not modify spaces if they are not next to each other', () => { + const pipe = new ReplaceSpacesPipe(); + expect(pipe.transform(' A ')).toEqual(' A '); + }); +}); diff --git a/gravitee-apim-console-webui/src/shared/pipes/replace-spaces.pipe.ts b/gravitee-apim-console-webui/src/shared/pipes/replace-spaces.pipe.ts new file mode 100644 index 00000000000..271064b04f2 --- /dev/null +++ b/gravitee-apim-console-webui/src/shared/pipes/replace-spaces.pipe.ts @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2015 The Gravitee team (http://gravitee.io) + * + * Licensed 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. + */ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'replaceSpaces', + standalone: true, +}) +export class ReplaceSpacesPipe implements PipeTransform { + transform(line: string): string { + // Transform spaces if there are more than occurrence next to each other. + return line.replace(/\s{2,}/g, (match) => '\xa0'.repeat(match.length)); + } +} diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/analytics/model/EnvironmentAnalyticsQueryParameters.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/analytics/model/EnvironmentAnalyticsQueryParameters.java index 75c1bee7716..b25b3ccf20d 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/analytics/model/EnvironmentAnalyticsQueryParameters.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/analytics/model/EnvironmentAnalyticsQueryParameters.java @@ -20,6 +20,7 @@ import lombok.Data; import lombok.With; +<<<<<<< HEAD:gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/analytics/model/EnvironmentAnalyticsQueryParameters.java @Data @Builder public class EnvironmentAnalyticsQueryParameters { @@ -29,4 +30,17 @@ public class EnvironmentAnalyticsQueryParameters { long from; long to; +======= +import { ReplaceSpacesPipe } from '../../pipes/replace-spaces.pipe'; + +@Component({ + selector: 'file-preview', + standalone: true, + imports: [GioClipboardModule, ReplaceSpacesPipe], + templateUrl: './file-preview.component.html', + styleUrl: './file-preview.component.scss', +}) +export class FilePreviewComponent { + @Input() payload: string; +>>>>>>> c7cb597a7c (fix: code preview component fix):gravitee-apim-console-webui/src/shared/components/file-preview/file-preview.component.ts }