2022-04-22 08:33:13 -05:00
|
|
|
import { css } from '@emotion/css';
|
2021-09-13 23:09:55 -05:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-09-13 23:09:55 -05:00
|
|
|
import { getBackendSrv } from '@grafana/runtime';
|
2022-07-06 10:00:56 -05:00
|
|
|
import { Page } from 'app/core/components/Page/Page';
|
2021-09-13 23:09:55 -05:00
|
|
|
import { useNavModel } from 'app/core/hooks/useNavModel';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-09-13 23:09:55 -05:00
|
|
|
import { GrafanaCloudBackend } from './types';
|
|
|
|
|
|
|
|
export default function CloudAdminPage() {
|
|
|
|
const navModel = useNavModel('live-cloud');
|
|
|
|
const [cloud, setCloud] = useState<GrafanaCloudBackend[]>([]);
|
2021-09-14 15:27:51 -05:00
|
|
|
const [error, setError] = useState<string>();
|
2021-09-13 23:09:55 -05:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
getBackendSrv()
|
2021-11-09 10:12:10 -06:00
|
|
|
.get(`api/live/write-configs`)
|
2021-09-13 23:09:55 -05:00
|
|
|
.then((data) => {
|
2021-11-09 10:12:10 -06:00
|
|
|
setCloud(data.writeConfigs);
|
2021-09-13 23:09:55 -05:00
|
|
|
})
|
2021-09-14 15:27:51 -05:00
|
|
|
.catch((e) => {
|
|
|
|
if (e.data) {
|
|
|
|
setError(JSON.stringify(e.data, null, 2));
|
|
|
|
}
|
|
|
|
});
|
2021-09-13 23:09:55 -05:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Page navModel={navModel}>
|
|
|
|
<Page.Contents>
|
2021-09-14 15:27:51 -05:00
|
|
|
{error && <pre>{error}</pre>}
|
2021-09-13 23:09:55 -05:00
|
|
|
{!cloud && <>Loading cloud definitions</>}
|
|
|
|
{cloud &&
|
|
|
|
cloud.map((v) => {
|
|
|
|
return (
|
|
|
|
<div key={v.uid}>
|
|
|
|
<h2>{v.uid}</h2>
|
|
|
|
<pre className={styles.row}>{JSON.stringify(v.settings, null, 2)}</pre>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</Page.Contents>
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-03 13:15:55 -05:00
|
|
|
const styles = {
|
|
|
|
row: css`
|
|
|
|
cursor: pointer;
|
|
|
|
`,
|
2021-09-13 23:09:55 -05:00
|
|
|
};
|