⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
app
/
core
/
utils
/
View File Name :
shortLinks.ts
import memoizeOne from 'memoize-one'; import { getBackendSrv, config } from '@grafana/runtime'; import { notifyApp } from 'app/core/actions'; import { createErrorNotification, createSuccessNotification } from 'app/core/copy/appNotification'; import { dispatch } from 'app/store/store'; import { copyStringToClipboard } from './explore'; function buildHostUrl() { return `${window.location.protocol}//${window.location.host}${config.appSubUrl}`; } function getRelativeURLPath(url: string) { let path = url.replace(buildHostUrl(), ''); return path.startsWith('/') ? path.substring(1, path.length) : path; } export const createShortLink = memoizeOne(async function (path: string) { try { const shortLink = await getBackendSrv().post(`/api/short-urls`, { path: getRelativeURLPath(path), }); return shortLink.url; } catch (err) { console.error('Error when creating shortened link: ', err); dispatch(notifyApp(createErrorNotification('Error generating shortened link'))); } }); export const createAndCopyShortLink = async (path: string) => { const shortLink = await createShortLink(path); if (shortLink) { copyStringToClipboard(shortLink); dispatch(notifyApp(createSuccessNotification('Shortened link copied to clipboard'))); } else { dispatch(notifyApp(createErrorNotification('Error generating shortened link'))); } };