- Notifications
You must be signed in to change notification settings - Fork254
Feature - iconscout intergration#1547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
19 commits Select commitHold shift + click to select a range
0639f1b
integrate iconscout in icon button and image comp
raheeliftikhar56879f3b
integrate iconscout with jsonLottie comp
raheeliftikhar565111f9
added dotlottie option in lottie comp
raheeliftikhar59dfe557
download asset from icon-scout and save as base64 string
raheeliftikhar57ee4135
updated naming for iconScoutAsset
raheeliftikhar5fdc8050
updated naming for iconScoutAsset
raheeliftikhar5b29b1dd
used dotLottie player for different modes
raheeliftikhar509d7e9d
added option in IconComp to select icons from IconScout
raheeliftikhar560e4561
fixed asset selection popup
raheeliftikhar55a73042
show free/premium assets + redirect to subscription page on clicking …
raheeliftikhar56dea7b9
show loading when user select's an icon to download
raheeliftikhar5aff1582
added autoHeight and aspectRatio options in json lottie
raheeliftikhar50dc69c6
fixed selected icon preview in controlButton
raheeliftikhar56886a0e
added fit/align controls in json lottie comp
raheeliftikhar5a29d735
Changing to Flow API
516d9d2
Search and AssetURL APis changed to Flow Endpoint
4b50843
added events + exposed play/pause/stop methods with json lottie comp
raheeliftikhar599f5725
allow media pack subscribers to use icon scout assets
raheeliftikhar59aaa4be
Merge branch 'dev' into feature-iconscout-intergration
FalkWolskyFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionsclient/packages/lowcoder/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletionsclient/packages/lowcoder/src/api/iconFlowApi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
import Api from "api/api"; | ||
import axios, { AxiosInstance, AxiosPromise, AxiosRequestConfig } from "axios"; | ||
import { calculateFlowCode } from "./apiUtils"; | ||
export interface SearchParams { | ||
query: string; | ||
asset: string; | ||
per_page: number; | ||
page: 1; | ||
sort: string; | ||
formats?: string; | ||
price?: string; | ||
} | ||
export type ResponseType = { | ||
response: any; | ||
}; | ||
const lcHeaders = { | ||
"Lowcoder-Token": calculateFlowCode(), | ||
"Content-Type": "application/json" | ||
}; | ||
let axiosIns: AxiosInstance | null = null; | ||
const getAxiosInstance = (clientSecret?: string) => { | ||
if (axiosIns && !clientSecret) { | ||
return axiosIns; | ||
} | ||
const headers: Record<string, string> = { | ||
"Content-Type": "application/json", | ||
}; | ||
const apiRequestConfig: AxiosRequestConfig = { | ||
baseURL: "https://api-service.lowcoder.cloud/api/flow", | ||
headers, | ||
}; | ||
axiosIns = axios.create(apiRequestConfig); | ||
return axiosIns; | ||
} | ||
class IconFlowApi extends Api { | ||
static async secureRequest(body: any, timeout: number = 6000): Promise<any> { | ||
let response; | ||
const axiosInstance = getAxiosInstance(); | ||
// Create a cancel token and set timeout for cancellation | ||
const source = axios.CancelToken.source(); | ||
const timeoutId = setTimeout(() => { | ||
source.cancel("Request timed out."); | ||
}, timeout); | ||
// Request configuration with cancel token | ||
const requestConfig: AxiosRequestConfig = { | ||
method: "POST", | ||
withCredentials: true, | ||
data: body, | ||
cancelToken: source.token, // Add cancel token | ||
}; | ||
try { | ||
response = await axiosInstance.request(requestConfig); | ||
} catch (error) { | ||
if (axios.isCancel(error)) { | ||
// Retry once after timeout cancellation | ||
try { | ||
// Reset the cancel token and retry | ||
const retrySource = axios.CancelToken.source(); | ||
const retryTimeoutId = setTimeout(() => { | ||
retrySource.cancel("Retry request timed out."); | ||
}, 20000); | ||
response = await axiosInstance.request({ | ||
...requestConfig, | ||
cancelToken: retrySource.token, | ||
}); | ||
clearTimeout(retryTimeoutId); | ||
} catch (retryError) { | ||
console.warn("Error at Secure Flow Request. Retry failed:", retryError); | ||
throw retryError; | ||
} | ||
} else { | ||
console.warn("Error at Secure Flow Request:", error); | ||
throw error; | ||
} | ||
} finally { | ||
clearTimeout(timeoutId); // Clear the initial timeout | ||
} | ||
return response; | ||
} | ||
} | ||
export const searchAssets = async (searchParameters : SearchParams) => { | ||
const apiBody = { | ||
path: "webhook/scout/search-asset", | ||
data: searchParameters, | ||
method: "post", | ||
headers: lcHeaders | ||
}; | ||
try { | ||
const result = await IconFlowApi.secureRequest(apiBody); | ||
return result?.data?.response?.items?.total > 0 ? result.data.response.items as any : null; | ||
} catch (error) { | ||
console.error("Error searching Design Assets:", error); | ||
throw error; | ||
} | ||
}; | ||
export const getAssetLinks = async (uuid: string, params: Record<string, string>) => { | ||
const apiBody = { | ||
path: "webhook/scout/get-asset-links", | ||
data: {"uuid" : uuid, "params" : params}, | ||
method: "post", | ||
headers: lcHeaders | ||
}; | ||
try { | ||
const result = await IconFlowApi.secureRequest(apiBody); | ||
return result?.data?.response?.download?.url.length > 0 ? result.data.response.download as any : null; | ||
} catch (error) { | ||
console.error("Error searching Design Assets:", error); | ||
throw error; | ||
} | ||
}; | ||
/* | ||
static async search(params: SearchParams): Promise<any> { | ||
let response; | ||
try { | ||
response = await getAxiosInstance().request({ | ||
url: '/v3/search', | ||
method: "GET", | ||
withCredentials: false, | ||
params: { | ||
...params, | ||
}, | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
return response?.data.response.items; | ||
} | ||
static async download(uuid: string, params: Record<string, string>): Promise<any> { | ||
const response = await getAxiosInstance(clientSecret).request({ | ||
url: `/v3/items/${uuid}/api-download?format=${params.format}`, | ||
method: "POST", | ||
withCredentials: false, | ||
}); | ||
return response?.data.response.download; | ||
} | ||
*/ | ||
export default IconFlowApi; |
15 changes: 15 additions & 0 deletionsclient/packages/lowcoder/src/api/iconscoutApi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Api from "api/api"; | ||
import axios from "axios"; | ||
export type ResponseType = { | ||
response: any; | ||
}; | ||
class IconScoutApi extends Api { | ||
static async downloadAsset(url: string): Promise<any> { | ||
const response = await axios.get(url, {responseType: 'blob'}) | ||
return response?.data; | ||
} | ||
} | ||
export default IconScoutApi; |
5 changes: 0 additions & 5 deletionsclient/packages/lowcoder/src/api/subscriptionApi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
57 changes: 30 additions & 27 deletionsclient/packages/lowcoder/src/app.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletionsclient/packages/lowcoder/src/comps/comps/iconComp.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
25 changes: 22 additions & 3 deletionsclient/packages/lowcoder/src/comps/comps/imageComp.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.