Compartir y URLs
Generar URLs compartibles para el dashboard
Genera enlaces compartibles y URLs para incrustar que permitan el acceso al dashboard. Comparte dashboards con interesados o incrústalos en aplicaciones externas.
Obtener URLs del Dashboard
GET /api/{tenantId}/{projectId}/dashboard/{dashboardId}/url
Genera URLs compartibles para un dashboard, incluyendo URLs estándar de visualización y URLs para incrustar con integración iframe.
Parámetros de ruta
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
tenantId |
GUID | Sí | El identificador del tenant |
projectId |
GUID | Sí | El identificador del proyecto |
dashboardId |
GUID | Sí | El identificador del dashboard |
Respuesta (200 OK)
{
"dashboardId": "880e8400-e29b-41d4-a716-446655440000",
"url": "https://your-instance.com/dashboard/880e8400-e29b-41d4-a716-446655440000",
"embedUrl": "https://your-instance.com/embed/dashboard/880e8400-e29b-41d4-a716-446655440000"
}
Campos de la respuesta
| Campo | Tipo | Descripción |
|---|---|---|
dashboardId |
GUID | El identificador del dashboard |
url |
string | URL estándar del dashboard (requiere autenticación) |
embedUrl |
string | URL para incrustar en iframe |
Respuestas de error
No encontrado (404):
{
"Error": "Dashboard not found",
"DashboardId": "880e8400-e29b-41d4-a716-446655440000"
}
Incrustación de Dashboard
Los dashboards de mindzieStudio pueden ser incrustados en aplicaciones externas utilizando tecnología iframe.
Incrustación básica
<iframe
src="https://your-instance.com/embed/dashboard/880e8400-e29b-41d4-a716-446655440000"
width="100%"
height="600"
frameborder="0"
allowfullscreen>
</iframe>
Incrustación responsiva
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
<iframe
src="https://your-instance.com/embed/dashboard/880e8400-e29b-41d4-a716-446655440000"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
frameborder="0"
allowfullscreen>
</iframe>
</div>
Tipos de URL
URL estándar
La URL estándar del dashboard requiere autenticación de usuario:
- Los usuarios deben iniciar sesión en mindzieStudio para ver el dashboard
- Proporciona interactividad completa del dashboard
- Adecuada para compartir dentro de equipos internos
URL para incrustar
La URL para incrustar está diseñada para integración en iframe:
- Interfaz simplificada optimizada para incrustación
- Puede requerir configuración adicional de autenticación
- Adecuada para portales y aplicaciones externas
Ejemplos de implementación
cURL
# Obtener URLs de dashboard
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/dashboard/880e8400-e29b-41d4-a716-446655440000/url" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
JavaScript/Node.js
const TENANT_ID = '12345678-1234-1234-1234-123456789012';
const PROJECT_ID = '87654321-4321-4321-4321-210987654321';
const BASE_URL = 'https://your-mindzie-instance.com';
async function getDashboardUrls(dashboardId, token) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/dashboard/${dashboardId}/url`;
const response = await fetch(url, {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (response.ok) {
return await response.json();
} else if (response.status === 404) {
throw new Error('Dashboard not found');
} else {
throw new Error(`Failed to get URLs: ${response.status}`);
}
}
// Generar código para incrustar
function generateEmbedCode(embedUrl, width = '100%', height = 600) {
return `<iframe
src="${embedUrl}"
width="${width}"
height="${height}"
frameborder="0"
allowfullscreen>
</iframe>`;
}
// Uso
const urls = await getDashboardUrls('dashboard-guid', 'your-auth-token');
console.log(`Dashboard URL: ${urls.url}`);
console.log(`Embed URL: ${urls.embedUrl}`);
console.log('\nEmbed code:');
console.log(generateEmbedCode(urls.embedUrl));
Python
import requests
TENANT_ID = '12345678-1234-1234-1234-123456789012'
PROJECT_ID = '87654321-4321-4321-4321-210987654321'
BASE_URL = 'https://your-mindzie-instance.com'
def get_dashboard_urls(dashboard_id, token):
"""Obtener URLs compartibles para un dashboard."""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/dashboard/{dashboard_id}/url'
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
if response.ok:
return response.json()
elif response.status_code == 404:
raise Exception('Dashboard not found')
else:
raise Exception(f'Failed to get URLs: {response.status_code}')
def generate_embed_code(embed_url, width='100%', height=600):
"""Generar código HTML para incrustar un dashboard."""
return f'''<iframe
src="{embed_url}"
width="{width}"
height="{height}"
frameborder="0"
allowfullscreen>
</iframe>'''
# Uso
urls = get_dashboard_urls('dashboard-guid', 'your-auth-token')
print(f"Dashboard URL: {urls['url']}")
print(f"Embed URL: {urls['embedUrl']}")
print('\nEmbed code:')
print(generate_embed_code(urls['embedUrl']))
C#
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
public class DashboardUrlResponse
{
public Guid DashboardId { get; set; }
public string Url { get; set; }
public string EmbedUrl { get; set; }
}
public class DashboardSharingClient
{
private readonly HttpClient _httpClient;
private readonly string _baseUrl;
private readonly Guid _tenantId;
private readonly Guid _projectId;
public DashboardSharingClient(string baseUrl, Guid tenantId, Guid projectId, string accessToken)
{
_baseUrl = baseUrl;
_tenantId = tenantId;
_projectId = projectId;
_httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
}
public async Task<DashboardUrlResponse> GetDashboardUrlsAsync(Guid dashboardId)
{
var url = $"{_baseUrl}/api/{_tenantId}/{_projectId}/dashboard/{dashboardId}/url";
var response = await _httpClient.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<DashboardUrlResponse>(json,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
}
else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
throw new Exception($"Dashboard {dashboardId} not found");
}
throw new Exception($"Failed to get URLs: {response.StatusCode}");
}
public string GenerateEmbedCode(string embedUrl, string width = "100%", int height = 600)
{
return $@"<iframe
src=""{embedUrl}""
width=""{width}""
height=""{height}""
frameborder=""0""
allowfullscreen>
</iframe>";
}
}
// Uso
var client = new DashboardSharingClient(
"https://your-mindzie-instance.com",
Guid.Parse("12345678-1234-1234-1234-123456789012"),
Guid.Parse("87654321-4321-4321-4321-210987654321"),
"your-access-token");
var urls = await client.GetDashboardUrlsAsync(Guid.Parse("dashboard-guid"));
Console.WriteLine($"Dashboard URL: {urls.Url}");
Console.WriteLine($"Embed URL: {urls.EmbedUrl}");
Console.WriteLine("\nEmbed code:");
Console.WriteLine(client.GenerateEmbedCode(urls.EmbedUrl));
Mejores prácticas
- Autenticación: Las URLs estándar requieren autenticación de usuario. Planifique su estrategia de compartición en consecuencia.
- Incrustación: Use URLs para incrustar cuando integre dashboards en aplicaciones o portales externos.
- Diseño responsivo: Use técnicas de iframe responsivas para incrustación compatible con dispositivos móviles.
- Seguridad: Considere las políticas de seguridad de su organización al compartir URLs de dashboards externamente.
Notas importantes
- Autenticación requerida: Ambos tipos de URL pueden requerir autenticación según la configuración de seguridad.
- Control de acceso: Los usuarios que accedan a URLs compartidas deben tener permisos apropiados para el tenant y proyecto.
- Compartición pública: Las funciones extendidas de compartición pública (protección con contraseña, expiración, etc.) se gestionan a través de la interfaz de mindzieStudio.