Skip to content

Commit e5bc27a

Browse files
committed
✨ replaced the custom Strapi chartbrew components with iframes instead
1 parent a27170b commit e5bc27a

15 files changed

Lines changed: 84 additions & 1394 deletions

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,29 @@ If you want to use the plugin with a managed service account at [chartbrew.com](
118118

119119
![](https://raw.githubusercontent.com/chartbrew/strapi-plugin-chartbrew/master/admin/src/assets/chartbrew-connection.jpg)
120120

121+
### Cannot load the dashboards
122+
123+
If you cannot load the dashboard, you may have to tweak the Strapi security settings. To do this, open the `config/middlewares.js` file and add the following attribute:
124+
125+
```
126+
{
127+
name: "strapi::security",
128+
config: {
129+
contentSecurityPolicy: {
130+
useDefaults: true,
131+
directives: {
132+
"default-src": ["'self'"],
133+
"frame-src": ["'self'", "https://app.chartbrew.com"], // allow Chartbrew iframe
134+
// If your Strapi admin runs on localhost and does websockets, keep these sane too:
135+
"connect-src": ["'self'", "ws://localhost:1337", "https://app.chartbrew.com"],
136+
},
137+
},
138+
},
139+
}
140+
```
141+
142+
If you are self-hosting Chartbrew, you will need to replace `https://app.chartbrew.com` with your own Chartbrew client URL.
143+
121144
### Cannot authenticate with Chartbrew
122145

123146
[**Read more here**](https://github.com/chartbrew/strapi-plugin-chartbrew/issues/13)

admin/src/actions/project.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,43 @@ import { getSettings } from './store';
22
import axiosInstance from '../utils/axiosInstance';
33
import { PLUGIN_ID } from '../pluginId';
44

5-
export async function getProjects() {
5+
export async function getProjectCharts(projectId) {
66
const { host, token } = await getSettings();
77

8-
return fetch(`${host}/project/user`, {
8+
return fetch(`${host}/project/${projectId}/chart`, {
99
method: 'GET',
1010
headers: new Headers({
1111
accept: 'application/json',
1212
authorization: `Bearer ${token}`,
1313
}),
1414
})
1515
.then((response) => {
16-
if (!response.ok) throw new Error('Cannot fetch user projects.');
16+
if (!response.ok) throw new Error('Cannot fetch project charts.');
1717

1818
return response.json();
1919
})
20-
.then((projects) => {
21-
return projects;
20+
.then((charts) => {
21+
return charts;
2222
})
2323
.catch((err) => {
2424
return Promise.reject(err);
2525
});
2626
}
2727

28-
export async function getProjectCharts(projectId) {
28+
export async function getProjectReport(brewName) {
2929
const { host, token } = await getSettings();
3030

31-
return fetch(`${host}/project/${projectId}/chart`, {
31+
const response = await fetch(`${host}/project/${brewName}/report`, {
3232
method: 'GET',
3333
headers: new Headers({
3434
accept: 'application/json',
3535
authorization: `Bearer ${token}`,
3636
}),
37-
})
38-
.then((response) => {
39-
if (!response.ok) throw new Error('Cannot fetch project charts.');
37+
});
4038

41-
return response.json();
42-
})
43-
.then((charts) => {
44-
return charts;
45-
})
46-
.catch((err) => {
47-
return Promise.reject(err);
48-
});
39+
if (!response.ok) throw new Error('Cannot fetch project report.');
40+
41+
return response.json();
4942
}
5043

5144
export async function createProject(projectId, data) {

admin/src/actions/team.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getSettings } from './store';
22

3-
export async function getUserTeam(userId) {
3+
export async function getUserTeam() {
44
const { host, token } = await getSettings();
55

66
return fetch(`${host}/team`, {

admin/src/components/ChartbrewCharts/BarChart.jsx

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)