Skip to content

Commit d91972c

Browse files
Manu ChaudharyManu Chaudhary
authored andcommitted
Added onChange event and updated test & readme
1 parent 66d10dc commit d91972c

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ The SDK supports automatic support for LQIP for your images, if you set lqip to
170170
##### How does the lqip work?
171171
The component tries to keep the it simple, it loads a lower quality image using the quality parameter to load a lower quality image, which is then replaced with the actual quality image later.
172172

173+
## File Upload
173174
#### ik-upload
174175
The SDK provides a simple Component to upload files to the ImageKit Media Library. It accepts `fileName` parameter as a prop. The file parameter is provided as an input from the user.
175176

@@ -184,4 +185,4 @@ Sample Usage
184185
<ik-upload fileName="my-upload" /></ik-upload>
185186
```
186187

187-
`ik-upload` component accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#request-structure-multipart-form-data) as props e.g. `tags`, `useUniqueFileName`, `folder` etc.
188+
`ik-upload` component accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#request-structure-multipart-form-data) as props e.g. `tags`, `useUniqueFileName`, `folder`, `isPrivateFile`, `customCoordinates` etc.

samples/imagekitio-angular4-sample/src/app/app.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div className="App">
22
<h1>Hi! This is an ImageKit Angular SDK Demo!</h1>
33
<p>Let's add an Image</p>
4-
<ik-image src="https://ik.imagekit.io/18ykd9wzp/default-image.jpg" alt="This is an alt">
4+
<ik-image src="https://ik.imagekit.io/demo/default-image.jpg" alt="This is an alt">
55
</ik-image>
66
<p>Let's transform this once</p>
7-
<ik-image src="https://ik.imagekit.io/18ykd9wzp/default-image.jpg" [transformation]="transformationOne"></ik-image>
7+
<ik-image src="https://ik.imagekit.io/demo/default-image.jpg" [transformation]="transformationOne"></ik-image>
88
<p>Let's transform this more than once</p>
99
<ik-image path="{{path}}" [transformation]="transformationTwo"></ik-image>
1010
<p>LQIP</p>

sdk/lib/src/imagekitio-angular/ik-image/ik-image.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Component, AfterViewInit, OnInit, ElementRef, Input } from '@angular/core';
1+
import { Component, AfterViewInit, OnInit, ElementRef, Input, OnChanges } from '@angular/core';
22
import { ImagekitService } from '../imagekit.service';
33

44
@Component({
55
selector: 'ik-image',
66
template: `<img src={{src}}>`,
77
})
8-
export class IkImageComponent implements AfterViewInit, OnInit {
8+
export class IkImageComponent implements AfterViewInit, OnInit, OnChanges {
99
@Input('src') src:string;
1010
@Input('path') path:string;
1111
@Input('urlEndpoint') urlEndpoint:string;
@@ -25,6 +25,10 @@ export class IkImageComponent implements AfterViewInit, OnInit {
2525
this.setUrl(this.src, this.path, this.transformation, this.lqip, this.urlEndpoint, this.transformationPosition, this.queryParameters);
2626
}
2727

28+
ngOnChanges(): void {
29+
this.ngOnInit();
30+
}
31+
2832
ngAfterViewInit() {
2933
const that = this;
3034
this.loadImage(this.lqip && this.lqip.active ? this.lqipUrl : this.url);

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imagekitio-angular",
3-
"version": "0.0.0",
3+
"version": "1.0.0",
44
"license": "MIT",
55
"scripts": {
66
"ng": "ng",

sdk/src/sdk-tests/ik-image.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("IkImageComponent", () => {
2323
expect(component.url).toBe(`https://example.com/def?ik-sdk-version=${version}`);
2424
});
2525

26-
it("Presence and absence of trailing slash in should not result in double slash (//) in the returned url", () => {
26+
it("Presence and absence of trailing slash in urlEndpoint should not result in double slash (//) in the returned url", () => {
2727
let comp: IkImageComponent;
2828
let iKService: ImagekitService;
2929
iKService = new ImagekitService({
@@ -49,7 +49,7 @@ describe("IkImageComponent", () => {
4949
);
5050
});
5151

52-
it("Presence and absence of leading slash in parameter should not result in double slash (//) in the returned url", () => {
52+
it("Presence and absence of leading slash in path parameter should not result in double slash (//) in the returned url", () => {
5353
let comp: IkImageComponent;
5454
let iKService: ImagekitService;
5555
iKService = new ImagekitService({
@@ -114,8 +114,8 @@ describe("IkImageComponent", () => {
114114
});
115115

116116
it("setUrl should create correct URL when src is provided", () => {
117-
component.setUrl("abc");
118-
expect(component.url).toContain(`/abc?ik-sdk-version=${version}`);
117+
component.setUrl("https://test-absolute-path.com/image.jpg");
118+
expect(component.url).toContain(`https://test-absolute-path.com/image.jpg?ik-sdk-version=${version}`);
119119
});
120120

121121
it("setUrl should create correct URL when path is provided", () => {

0 commit comments

Comments
 (0)