diff --git a/docs/docs/gitsync.md b/docs/docs/gitsync.md index ef25dd3315..5a417ffb3e 100644 --- a/docs/docs/gitsync.md +++ b/docs/docs/gitsync.md @@ -11,563 +11,354 @@ import TabItem from '@theme/TabItem'; The GitSync feature enables synchronization of workspace applications with a git repository, streamlining application management and version control on ToolJet. -
-
-
-
-
-There are two types of generated SSH keys: **
-- **ED25519**: This is a secure and efficient algorithm that is used for generating SSH keys. It is recommended to use this key type. VCS providers like GitHub and GitLab recommend using this key type
-- **RSA**: This is an older algorithm that is used for generating SSH keys. It is not recommended to use this key type. Older VCS providers like Bitbucket recommend using this key type.
+
-
-
-
-### Step 5: Finish the GitSync configuration on ToolJet
+
+
+
+
+ 2. Enter the **SSH URL** of the repository (obtained in [Step 2](#2-obtain-the-repository-url)) in the **Git repo URL** field.
+ 3. Click on the **Generate SSH key** button, and copy the SSH key that is generated. The SSH key is used to authenticate ToolJet with the repository.
+
+
+
+ There are two types of generated SSH keys:
+ - **ED25519**: This is a secure and efficient algorithm that is used for generating SSH keys. It is recommended to use this key type. VCS providers like GitHub and GitLab recommend using this key type
+ - **RSA**: This is an older algorithm that is used for generating SSH keys. It is not recommended to use this key type. Older VCS providers like Bitbucket recommend using this key type.
+
+
+
+### 4. Deploy the SSH Key
+
+
+
+ 2. Enter a title for the SSH key in the **Title** field.
+ 3. Paste the SSH key that you copied in [Step 3](#3-configure-the-gitsync-feature-on-tooljet) in the **Key** field.
+ 4. Make sure that the **Allow write access** checkbox is checked, especially when configuring the GitSync feature to [push changes to Git](#pushing-changes-to-git-repo). However, it is not mandatory to check this option when setting up the GitSync feature for [pulling changes from Git](#pulling-changes-from-git-repo).
+ 5. Finally, click on the **Add key** button.
+
+
+
+
+
+ 3. In the **Key** field, paste the SSH key you generated in [Step 3](#3-configure-the-gitsync-feature-on-tooljet).
+ 4. Give your key a descriptive title.
+ 5. Set **Usage type** to **Authentication & signing**.
+ 6. Optionally, set an expiration date.
+ 7. Click **Add key** to save.
+
+
+
+ #### Option 2: Add as a Deploy Key
+
+ Use this option for access to a specific repository only.
+
+ 1. Navigate to the repository you want to add the key to.
+ 2. Click on the **Settings** tab and select **Repository**.
+ 3. Once you are in the **Repository Settings**, expand the **Deploy Keys** section.
+ 4. Click on the **Add new deploy key** button.
+ 5. Give your key a descriptive title.
+ 6. In the **Key** field, paste the SSH key you generated in ToolJet's Configure Git tab during the previous step.
+ 7. Enable the **Grant write permissions to this key** checkbox. We need this permission to push changes to the repository.
+ 8. Click **Add key** to save.
+
+
+
+
-
-
This option can be enabled or disabled from the **Configure git** tab on the **Workspace settings** page. By default, this option is disabled.
-
-
-
-
-
+
+
+
+
-
-Selecting the `Commit changes` option will create a new commit in the git repository. The commit message will be `App creation` and the author will be the user who created the app.
+Selecting the **Commit changes** option will create a new commit in the git repository. The commit message will be `App creation` and the author will be the user who created the app.
-
-
+
+
+
+
-
+
+
+
+
-
Once the changes are committed, the user can see the commit message, author, and date in the git repository.
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
The **JSON** file in the app folder will be replaced with the new version of the app, the **meta.json** file in the **.meta** folder gets updated with the new version id and version name. The commit message will be `Version creation` and the author will be the user who created the new version of the app.
-
-
+
+
+
+
-
On clicking the **Import from git repository** option, a modal will open with the dropdown to select the app to be imported from the git repository. Once the app is selected, the app name and the last commit will be displayed. Click on the **Import app** button to import the app from the git repository.
@@ -577,24 +368,12 @@ On clicking the **Import from git repository** option, a modal will open with th
- Workspace constants are not synced with the git repository. After pulling the app, if the app throws an error, the user will need to manually add the workspace constants.
:::
-
-
-
-
+
+This query will fetch the data from the ToolJet DB.
+
+### Transform the Data
+
+To restructure the data into a format compatible with the chart component, we will be using RunJS transformation.
+
+Create a new **RunJS** Query and add the following code:
+
+```js
+await queries.getRevenueDetails.run();
+
+let data = queries.getRevenueDetails.getData();
+
+const courseCounts = data.reduce((counts, obj) => {
+ if (obj.course) {
+ counts[obj.course] = (counts[obj.course] || 0) + 1;
+ }
+ return counts;
+}, {});
+
+const courseData = Object.keys(courseCounts).map(course => ({
+ x: course,
+ y: courseCounts[course]
+}));
+
+return {courseData};
+```
+
+
+
+This query will calculate the number of each course and return an array of objects that can be utilized to plot the pie chart.
+
+### Plotting Pie Chart
+
+1. Add a chart component from the component library available on right to the canvas.
+2. Under Properties section select **Pie** as the chart type from the dropdown.
+3. Under chart data section input `{{queries.
+
+
+
+This query will fetch the data from the ToolJet DB.
+
+### Transform the Data
+
+Create a new **RunJS** Query and add the following code:
+
+```js
+const data = queries.getLinechartData.data;
+
+const calculateAverage = (arr) => arr.reduce((sum, item) => sum + item.y, 0) / arr.length;
+
+const regionData = data.filter(item => item.region !== "Asia");
+
+const transformedData = regionData.map(item => {
+ if (item.rdate && typeof item.rdate === 'string') {
+ const dateParts = item.rdate.split('-');
+
+ if (dateParts.length === 3) {
+ const year = dateParts[2];
+ const month = dateParts[1];
+ return {
+ x: `${year}-${month}`,
+ y: item.y && !isNaN(item.y) ? item.y : 0
+ };
+ }
+ }
+
+ return { x: 'Invalid Date', y: 0 };
+});
+
+const validData = transformedData.filter(item => item.x !== 'Invalid Date');
+const averageY = calculateAverage(validData);
+
+const finalData = transformedData.map(item => ({
+ x: item.x,
+ y: item.y - averageY
+}));
+
+return finalData;
+```
+
+
+
+### Plotting Line Chart
+
+1. Add a chart component from the component library available on right to the canvas.
+2. Under Properties section select **Line** as the chart type from the dropdown.
+3. Under chart data section input `{{queries.
+
+
+
+This query will fetch the data from the ToolJet DB.
+
+### Transform the Data
+
+To restructure the data into a format compatible with the chart component, we will be using RunJS transformation.
+
+Create a new **RunJS** Query and add the following code:
+
+```js
+const dbData = queries.getCandlestickData.data;
+
+if (!Array.isArray(dbData) || dbData.length === 0) {
+ return { plotData: [] };
+}
+
+let dates = [];
+let openPrices = [];
+let highPrices = [];
+let lowPrices = [];
+let closePrices = [];
+
+dbData.forEach(row => {
+ dates.push(String(row.sdate));
+ openPrices.push(row.open);
+ highPrices.push(row.high);
+ lowPrices.push(row.low);
+ closePrices.push(row.sclose);
+});
+
+const transformedData = [
+ {
+ x: dates,
+ open: openPrices,
+ high: highPrices,
+ low: lowPrices,
+ close: closePrices,
+ type: 'candlestick'
+ }
+];
+
+let result = {
+ data: transformedData
+};
+
+return JSON.stringify(result)
+```
+
+
+
+### Plotting Candlestick Chart
+
+1. Add a chart component from the component library available on right to the canvas.
+2. Enable use plotly JSON schema under Plotly JSON Chart Schema section.
+3. Under JSON Description section input `{{queries.
+
+
+
+This query will fetch the data from the ToolJet DB.
+
+### Transform the Data
+
+To restructure the data into a format compatible with the chart component, we will be using RunPy transformation.
+
+Create a new **RunPy** Query and add the following code:
+
+```py
+import pandas as pd
+import json
+
+data_raw = queries.fetchHeatmapData.getData()
+
+data = data_raw.to_py() if hasattr(data_raw, 'to_py') else list(data_raw)
+
+df = pd.DataFrame(data)
+heatmap_data = df.pivot(index='y', columns='x', values='value')
+
+x_labels = [f"Column {i}" for i in heatmap_data.columns.tolist()]
+y_labels = [f"Row {i}" for i in heatmap_data.index.tolist()]
+
+output = {
+ "data": [
+ {
+ "z": heatmap_data.values.tolist(),
+ "x": x_labels,
+ "y": y_labels,
+ "type": "heatmap"
+ }
+ ]
+}
+
+output_str = json.dumps(output)
+
+output_str
+```
+
+
+
+### Plotting Heatmap Chart
+
+1. Add a chart component from the component library available on right to the canvas.
+2. Enable use plotly JSON schema under Plotly JSON Chart Schema section.
+3. Under JSON Description section input `{{queries.
+
+
+