Partage & URLs

Générer des URLs de tableau de bord partageables

Générez des liens partageables et des URLs d’intégration pour accéder aux tableaux de bord. Partagez les tableaux de bord avec les parties prenantes ou intégrez-les dans des applications externes.

Obtenir les URLs du tableau de bord

GET /api/{tenantId}/{projectId}/dashboard/{dashboardId}/url

Génère des URLs partageables pour un tableau de bord, y compris les URLs de vue standard et les URLs d’intégration pour l’intégration iframe.

Paramètres de chemin

Paramètre Type Requis Description
tenantId GUID Oui L’identifiant du locataire
projectId GUID Oui L’identifiant du projet
dashboardId GUID Oui L’identifiant du tableau de bord

Réponse (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"
}

Champs de réponse

Champ Type Description
dashboardId GUID L’identifiant du tableau de bord
url chaîne de caractères URL standard du tableau de bord (requiert une authentification)
embedUrl chaîne de caractères URL d’intégration pour iframe

Réponses d’erreur

Non trouvé (404):

{
  "Error": "Dashboard not found",
  "DashboardId": "880e8400-e29b-41d4-a716-446655440000"
}

Intégration du tableau de bord

Les tableaux de bord mindzieStudio peuvent être intégrés dans des applications externes en utilisant la technologie iframe.

Intégration basique

<iframe
  src="https://your-instance.com/embed/dashboard/880e8400-e29b-41d4-a716-446655440000"
  width="100%"
  height="600"
  frameborder="0"
  allowfullscreen>
</iframe>

Intégration responsive

<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>

Types d’URLs

URL standard

L’URL standard du tableau de bord nécessite une authentification utilisateur :

  • Les utilisateurs doivent se connecter à mindzieStudio pour voir le tableau de bord
  • Offre une interactivité complète du tableau de bord
  • Convient pour le partage en équipe interne

URL d’intégration

L’URL d’intégration est conçue pour l’intégration iframe :

  • Interface simplifiée optimisée pour l’intégration
  • Peut nécessiter une configuration d’authentification supplémentaire
  • Convient pour les portails et les applications externes

Exemples d’implémentation

cURL

# Obtenir les URLs du tableau de bord
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}`);
  }
}

// Générer le code d’intégration
function generateEmbedCode(embedUrl, width = '100%', height = 600) {
  return `<iframe
  src="${embedUrl}"
  width="${width}"
  height="${height}"
  frameborder="0"
  allowfullscreen>
</iframe>`;
}

// Utilisation
const urls = await getDashboardUrls('dashboard-guid', 'your-auth-token');

console.log(`URL du tableau de bord : ${urls.url}`);
console.log(`URL d’intégration : ${urls.embedUrl}`);
console.log('\nCode d’intégration :');
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):
    """Obtenir les URLs partageables pour un tableau de bord."""
    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):
    """Générer le code HTML d’intégration pour un tableau de bord."""
    return f'''<iframe
  src="{embed_url}"
  width="{width}"
  height="{height}"
  frameborder="0"
  allowfullscreen>
</iframe>'''

# Utilisation
urls = get_dashboard_urls('dashboard-guid', 'your-auth-token')

print(f"URL du tableau de bord : {urls['url']}")
print(f"URL d’intégration : {urls['embedUrl']}")
print('\nCode d’intégration :')
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>";
    }
}

// Utilisation
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($"URL du tableau de bord : {urls.Url}");
Console.WriteLine($"URL d’intégration : {urls.EmbedUrl}");
Console.WriteLine("\nCode d’intégration :");
Console.WriteLine(client.GenerateEmbedCode(urls.EmbedUrl));

Bonnes pratiques

  • Authentification : Les URLs standard requièrent une authentification utilisateur. Planifiez votre stratégie de partage en conséquence.
  • Intégration : Utilisez les URLs d’intégration lors de l’intégration des tableaux de bord dans des applications ou portails externes.
  • Design responsive : Utilisez les techniques iframe responsive pour une intégration adaptée aux mobiles.
  • Sécurité : Prenez en compte les politiques de sécurité de votre organisation lors du partage des URLs de tableau de bord à l’extérieur.

Notes importantes

  • Authentification requise : Les deux types d’URL peuvent nécessiter une authentification selon votre configuration de sécurité.
  • Contrôle d’accès : Les utilisateurs accédant aux URLs partagées doivent avoir les permissions appropriées pour le locataire et le projet.
  • Partage public : Les fonctionnalités avancées de partage public (protection par mot de passe, expiration, etc.) sont gérées via l’interface mindzieStudio.