共有とURL
共有可能なダッシュボードURLの生成
ダッシュボードへのアクセス用の共有リンクおよび埋め込みURLを生成します。関係者とダッシュボードを共有したり、外部アプリケーションに埋め込んだりできます。
ダッシュボードURLの取得
GET /api/{tenantId}/{projectId}/dashboard/{dashboardId}/url
ダッシュボードの共有可能なURLを生成します。標準ビュー用URLとiframe統合用の埋め込みURLが含まれます。
パスパラメーター
| パラメーター | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | Yes | テナント識別子 |
projectId |
GUID | Yes | プロジェクト識別子 |
dashboardId |
GUID | Yes | ダッシュボード識別子 |
レスポンス (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"
}
レスポンスフィールド
| フィールド | 種類 | 説明 |
|---|---|---|
dashboardId |
GUID | ダッシュボード識別子 |
url |
string | 標準ダッシュボードURL(認証が必要) |
embedUrl |
string | iframe統合用埋め込みURL |
エラー応答
Not Found (404):
{
"Error": "Dashboard not found",
"DashboardId": "880e8400-e29b-41d4-a716-446655440000"
}
ダッシュボードの埋め込み
mindzieStudioのダッシュボードはiframe技術を使用して外部アプリケーションに埋め込むことができます。
基本的な埋め込み
<iframe
src="https://your-instance.com/embed/dashboard/880e8400-e29b-41d4-a716-446655440000"
width="100%"
height="600"
frameborder="0"
allowfullscreen>
</iframe>
レスポンシブ埋め込み
<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>
URLの種類
標準URL
標準のダッシュボードURLはユーザー認証が必要です:
- ユーザーはmindzieStudioにログインしてダッシュボードを表示
- ダッシュボードの完全なインタラクティビティを提供
- 内部チームでの共有に適している
埋め込みURL
埋め込みURLはiframe統合用に設計されています:
- 埋め込みに最適化されたシンプルなインターフェース
- 追加の認証設定が必要な場合がある
- ポータルや外部アプリケーションに適している
実装例
cURL
# ダッシュボードURLを取得
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}`);
}
}
// 埋め込みコードの生成
function generateEmbedCode(embedUrl, width = '100%', height = 600) {
return `<iframe
src="${embedUrl}"
width="${width}"
height="${height}"
frameborder="0"
allowfullscreen>
</iframe>`;
}
// 使用例
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):
"""ダッシュボードの共有可能なURLを取得します。"""
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):
"""ダッシュボードのHTML埋め込みコードを生成します。"""
return f'''<iframe
src="{embed_url}"
width="{width}"
height="{height}"
frameborder="0"
allowfullscreen>
</iframe>'''
# 使用例
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>";
}
}
// 使用例
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));
ベストプラクティス
- 認証: 標準URLはユーザー認証が必要です。共有戦略を適切に計画してください。
- 埋め込み: 外部アプリケーションやポータルにダッシュボードを統合する場合は埋め込みURLを使用してください。
- レスポンシブデザイン: モバイル対応の埋め込みにはレスポンシブiframe技術を活用してください。
- セキュリティ: ダッシュボードURLを外部共有する場合は、自組織のセキュリティポリシーを考慮してください。
重要な注意点
- 認証必須: URLの種類にかかわらず、セキュリティ設定により認証が必要となる場合があります。
- アクセス制御: 共有URLにアクセスするユーザーは、テナントおよびプロジェクトに対して適切な権限を持っている必要があります。
- 公開共有: パスワード保護や有効期限などの拡張された公開共有機能はmindzieStudioのUIから管理されます。