Skip to content

Commit c02115e

Browse files
feat(patch): Add new files from our changes
1 parent 10edd5b commit c02115e

File tree

7 files changed

+358
-0
lines changed

7 files changed

+358
-0
lines changed

.github/workflows/docker_build.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: docker
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
docker:
12+
name: Docker
13+
runs-on: 8CoreUbuntu
14+
environment:
15+
name: Docker Hub
16+
url: https://hub.docker.com/r/intergral/grafana
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Login to Docker Hub
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_TOKEN }}
28+
29+
# https://github.com/docker/setup-qemu-action
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
32+
with:
33+
platforms: linux/amd64,linux/arm64
34+
# https://github.com/docker/setup-buildx-action
35+
- name: Set up Docker Buildx
36+
id: buildx
37+
uses: docker/setup-buildx-action@v3
38+
with:
39+
platforms: linux/amd64,linux/arm64
40+
41+
- name: Build and push
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
platforms: linux/amd64,linux/arm64
46+
build-args: |
47+
BINGO=false
48+
COMMIT_SHA=${{ github.sha }}
49+
BUILD_BRANCH=main
50+
push: true
51+
tags: intergral/grafana:${{ github.ref_name }}

.github/workflows/on_push_go.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build & Test Go
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Set up Go 1.22
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: 1.22.x
22+
23+
- name: Check out code
24+
uses: actions/checkout@v4
25+
26+
- name: Setup go-junit-report
27+
run: go install github.com/jstemmer/go-junit-report/v2@latest
28+
29+
- name: Build
30+
run: make gen-go
31+
32+
- name: Test
33+
run: make test-go
34+
35+
build:
36+
name: Build
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Set up Go 1.22
40+
uses: actions/setup-go@v5
41+
with:
42+
go-version: 1.22.x
43+
44+
- name: Check out code
45+
uses: actions/checkout@v4
46+
47+
- name: Mod Download
48+
run: go mod download
49+
50+
- name: Build
51+
run: make build-go
52+
53+
lint:
54+
name: Lint & Format
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Set up Go 1.23
58+
uses: actions/setup-go@v5
59+
with:
60+
go-version: 1.23.x
61+
62+
- name: Check out code
63+
uses: actions/checkout@v4
64+
65+
- name: Build
66+
run: make gen-go
67+
68+
- run: make lint-go

.github/workflows/on_push_ui.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build & Test UI
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
19+
- name: Check out code
20+
uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 20.x
25+
cache: "yarn"
26+
27+
- name: Check dependencies
28+
run: |
29+
yarn install --immutable
30+
31+
- name: Test
32+
run: yarn test:coverage
33+
34+
build:
35+
name: Build
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Check out code
39+
uses: actions/checkout@v4
40+
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: 20.x
44+
cache: "yarn"
45+
46+
- name: Check dependencies
47+
run: |
48+
yarn install --immutable
49+
50+
- name: Build
51+
run: yarn build
52+
53+
lint:
54+
name: Lint & Format
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Check out code
58+
uses: actions/checkout@v4
59+
60+
- uses: actions/setup-node@v4
61+
with:
62+
node-version: 20.x
63+
cache: "yarn"
64+
65+
- name: Check dependencies
66+
run: |
67+
yarn install --immutable
68+
69+
- name: Lint
70+
run: yarn lint

.github/workflows/on_release.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Release
14+
runs-on: 8CoreUbuntu
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Login to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
username: ${{ secrets.DOCKERHUB_USERNAME }}
25+
password: ${{ secrets.DOCKERHUB_TOKEN }}
26+
27+
# https://github.com/docker/setup-qemu-action
28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v3
30+
# https://github.com/docker/setup-buildx-action
31+
- name: Set up Docker Buildx
32+
id: buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Build and push
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
platforms: linux/amd64,linux/arm64
40+
build-args: |
41+
BINGO=false
42+
COMMIT_SHA=${{ github.sha }}
43+
BUILD_BRANCH=main
44+
push: true
45+
tags: intergral/grafana:latest,intergral/grafana:${{ github.ref_name }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ButtonProps, Button } from '@grafana/ui';
2+
3+
type DataLinkButtonProps = {
4+
link: any;
5+
buttonProps?: ButtonProps;
6+
};
7+
8+
/**
9+
* @internal
10+
*/
11+
export function OpspilotDataLinkButton({ link, buttonProps }: DataLinkButtonProps) {
12+
return (
13+
<Button
14+
icon={link.target === '_blank' ? 'external-link-alt' : undefined}
15+
variant="primary"
16+
size="sm"
17+
onClick={() => {
18+
if (window.parent !== window) {
19+
const integration = {content: link.href, content_type: "log"}
20+
window.parent.postMessage({type: "opspilot-slave.sendIntegration", integration } , "*")
21+
}
22+
}}
23+
{...buttonProps}
24+
>
25+
{link.title}
26+
</Button>
27+
);
28+
}

public/app/intergral/intercom.ts

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { useEffect } from 'react';
2+
3+
// Declare Intercom as a global function
4+
declare global {
5+
interface Window {
6+
Intercom: any;
7+
}
8+
}
9+
10+
export function useIntercom(userName: string, userEmail: string) {
11+
useEffect(() => {
12+
// Check if we're in a browser environment
13+
if (typeof window === 'undefined' || typeof document === 'undefined') {
14+
console.warn('Intercom setup aborted: Not in a browser environment');
15+
return;
16+
}
17+
18+
// Intercom setup function
19+
const setupIntercom = () => {
20+
(function() {
21+
let w = window as any;
22+
let ic = w.Intercom;
23+
if (typeof ic === "function") {
24+
ic('reattach_activator');
25+
ic('update', w.intercomSettings);
26+
} else {
27+
let d = document;
28+
let i = function () {
29+
(i as any).c(arguments);
30+
};
31+
(i as any).q = [];
32+
(i as any).c = function(args: any) {
33+
(i as any).q.push(args);
34+
};
35+
w.Intercom = i;
36+
let l = function () {
37+
let s = d.createElement('script');
38+
s.type = 'text/javascript';
39+
s.async = true;
40+
s.src = 'https://widget.intercom.io/widget/ok1wowgi';
41+
let x = d.getElementsByTagName('script')[0];
42+
let parent = x?.parentNode || document.body
43+
parent.insertBefore(s, x || null);
44+
};
45+
if (document.readyState === 'complete') {
46+
l();
47+
} else if (w.attachEvent) {
48+
w.attachEvent('onload', l);
49+
} else {
50+
w.addEventListener('load', l, false);
51+
}
52+
}
53+
})();
54+
55+
window.Intercom("boot", {
56+
api_base: "https://api-iam.intercom.io",
57+
app_id: "ok1wowgi",
58+
name: userName,
59+
email: userEmail,
60+
});
61+
};
62+
63+
setupIntercom();
64+
65+
// Cleanup function
66+
return () => {
67+
if (window.Intercom) {
68+
window.Intercom('shutdown');
69+
}
70+
};
71+
}, [userName, userEmail]); // Re-run if userName or userEmail changes
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { useEffect } from 'react';
2+
3+
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
4+
5+
6+
export const useOpspilotMetadata = () => {
7+
useEffect(() => {
8+
const event = async (event: MessageEvent) => {
9+
if (event.data.type === 'opspilot-host.getMetadata') {
10+
window.parent.postMessage({type: "opspilot-slave.sendMetadata", metadata: {
11+
slaveUrl: window.location.pathname,
12+
timeStart: getTimeSrv().timeRange().from.valueOf(),
13+
timeEnd: getTimeSrv().timeRange().to.valueOf(),
14+
timezone: getTimeSrv().timeModel?.getTimezone() === 'browser' ? Intl.DateTimeFormat().resolvedOptions().timeZone : getTimeSrv().timeModel?.getTimezone(),
15+
} }, '*');
16+
}
17+
};
18+
window.addEventListener('message', event);
19+
return () => {
20+
window.removeEventListener('message', event);
21+
}
22+
}, []);
23+
24+
}

0 commit comments

Comments
 (0)