Files
projectmycelium/src/views/dashboard/index.html

305 lines
13 KiB
HTML

{% extends "dashboard/layout.html" %}
{% block title %}Mycelium Dashboard - Overview{% endblock %}
{% block dashboard_content %}
<div class="my-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="mb-1">Dashboard Overview</h1>
<p class="lead mb-0">Welcome, {% if user.name %}{{ user.name }}{% else %}{{ user.email }}{% endif %}</p>
</div>
<div class="d-flex">
<a href="/dashboard/wallet" class="btn btn-primary">
<i class="bi bi-currency-exchange me-1"></i> Get Credits
</a>
</div>
</div>
<!-- Status Summary -->
<div class="row mt-4">
<div class="col-md-3">
<div class="stats-card primary">
<h5 class="card-title">Active Deployments</h5>
<div class="d-flex justify-content-between align-items-end">
<h2 class="mb-0">{% if user_metrics is defined and user_metrics.active_deployments_count is defined %}{{ user_metrics.active_deployments_count }}{% else %}0{% endif %}</h2>
<small class="text-muted">Applications</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="stats-card success">
<h5 class="card-title">Resources</h5>
<div class="d-flex justify-content-between align-items-end">
<h2 class="mb-0">{{ active_compute_resources_count | default(value=0) }}</h2>
<small class="text-muted">Active Slices</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="stats-card warning">
<h5 class="card-title">Current Cost</h5>
<div class="d-flex justify-content-between align-items-end">
<h2 class="mb-0">{{ total_monthly_cost | default(value=0) | format_decimal(precision=2) }}</h2>
<small class="text-muted">{{ currency_symbol | default(value="$") }}/month</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="stats-card info">
<h5 class="card-title">Wallet Balance</h5>
<div class="d-flex justify-content-between align-items-end">
<h2 class="mb-0" id="dashboardWalletBalance">{{ currency_symbol | default(value="$") }}{% if user_metrics is defined and user_metrics.wallet_balance is defined %}{{ user_metrics.wallet_balance | format_decimal(precision=2) }}{% else %}0{% endif %}</h2>
<small class="text-muted">Credits (<span id="dashboardCurrencyCode">{{ display_currency | default(value="MC") }}</span>)</small>
</div>
</div>
</div>
</div>
<!-- Quick Actions -->
<div class="row mt-4">
<div class="col-12">
<div class="dashboard-section">
<h3>Quick Actions</h3>
<div class="row">
<div class="col-md-3">
<a href="/marketplace/applications" class="btn btn-outline-primary w-100 mb-2">
<i class="bi bi-box-seam me-2"></i> Deploy Applications
</a>
</div>
<div class="col-md-3">
<a href="/marketplace/compute" class="btn btn-outline-success w-100 mb-2">
<i class="bi bi-cpu me-2"></i> Reserve Resources
</a>
</div>
<div class="col-md-3">
<a href="/dashboard/wallet" class="btn btn-outline-info w-100 mb-2">
<i class="bi bi-wallet2 me-2"></i> Manage Wallet
</a>
</div>
<div class="col-md-3">
<a href="/dashboard/resource_provider" class="btn btn-outline-info w-100 mb-2">
<i class="bi bi-hdd-rack me-2"></i> Add a Mycelium Node
</a>
</div>
</div>
<div class="row">
<div class="col-md-3">
<a href="/dashboard/settings" class="btn btn-outline-secondary w-100 mb-2">
<i class="bi bi-gear me-2"></i> Account Settings
</a>
</div>
<div class="col-md-3">
<a href="/marketplace" class="btn btn-outline-dark w-100 mb-2">
<i class="bi bi-shop me-2"></i> Browse Marketplace
</a>
</div>
</div>
</div>
</div>
</div>
<!-- Roles Section -->
<div class="row mt-4">
<div class="col-12">
<h3>Your Roles</h3>
<p>Manage your Mycelium experience through different perspectives:</p>
</div>
<div class="col-md-6 col-lg-3 mb-4">
<div class="dashboard-card">
<span class="badge bg-primary badge-role">USER</span>
<h4>User Dashboard</h4>
<p>Deploy apps, manage resources, monitor costs, and track usage.</p>
<div class="d-grid">
<a href="/dashboard/user" class="btn btn-sm btn-outline-primary">Access User Dashboard</a>
</div>
</div>
</div>
<div class="col-md-6 col-lg-3 mb-4">
<div class="dashboard-card">
<span class="badge bg-success badge-role">RESOURCE PROVIDER</span>
<h4>Resource Provider Dashboard</h4>
<p>Manage your nodes, create slices, set pricing, and track earnings.</p>
<div class="d-grid">
<a href="/dashboard/resource_provider" class="btn btn-sm btn-outline-success">Access Resource Provider Dashboard</a>
</div>
</div>
</div>
<div class="col-md-6 col-lg-3 mb-4">
<div class="dashboard-card">
<span class="badge bg-info badge-role">APPLICATION PROVIDER</span>
<h4>Application Provider Dashboard</h4>
<p>Develop, deploy, and manage applications for the TF ecosystem.</p>
<div class="d-grid">
<a href="/dashboard/application-provider" class="btn btn-sm btn-outline-info">Access Application Provider Dashboard</a>
</div>
</div>
</div>
<div class="col-md-6 col-lg-3 mb-4">
<div class="dashboard-card">
<span class="badge bg-warning badge-role">SERVICE PROVIDER</span>
<h4>Service Provider Dashboard</h4>
<p>Offer professional services and manage maintenance requests.</p>
<div class="d-grid">
<a href="/dashboard/service-provider" class="btn btn-sm btn-outline-warning">Access Service Provider Dashboard</a>
</div>
</div>
</div>
</div>
<!-- Statistics Section -->
<div class="row mt-4">
<div class="col-12">
<div class="dashboard-section">
<h3>Statistics</h3>
<div class="row">
<div class="col-md-6">
<div class="card mb-4 h-100">
<div class="card-header">
<h5>Resource Utilization</h5>
</div>
<div class="card-body d-flex justify-content-center align-items-center">
<canvas id="resourceUtilizationOverviewChart" width="400" height="300"></canvas>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card mb-4 h-100">
<div class="card-header">
<h5>Credits Usage Trend</h5>
</div>
<div class="card-body d-flex justify-content-center align-items-center">
<canvas id="creditsUsageOverviewChart" width="400" height="300"></canvas>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="card mb-4 h-100">
<div class="card-header">
<h5>User Activity</h5>
</div>
<div class="card-body d-flex justify-content-center align-items-center">
<canvas id="userActivityChart" width="400" height="300"></canvas>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card mb-4 h-100">
<div class="card-header">
<h5>Deployment Distribution</h5>
</div>
<div class="card-body d-flex justify-content-center align-items-center">
<canvas id="deploymentDistributionChart" width="400" height="300"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Recent Activity -->
<div class="row mt-4">
<div class="col-12">
<div class="dashboard-section">
<h3>Recent Activity</h3>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Date</th>
<th>Action</th>
<th>Status</th>
<th>Details</th>
</tr>
</thead>
<tbody>
{% if recent_activities is defined and recent_activities and recent_activities | length > 0 %}
{% for activity in recent_activities %}
<tr>
<td>{{ activity.date }}</td>
<td>{{ activity.action }}</td>
<td>
{% if activity.status == "Completed" %}
<span class="badge bg-success">{{ activity.status }}</span>
{% elif activity.status == "Active" %}
<span class="badge bg-success">{{ activity.status }}</span>
{% elif activity.status == "Pending" %}
<span class="badge bg-info">{{ activity.status }}</span>
{% else %}
<span class="badge bg-secondary">{{ activity.status }}</span>
{% endif %}
</td>
<td>{{ activity.details }}</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="4" class="text-center text-muted">No recent activity</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.js"></script>
<style>
/* Ensure charts have consistent sizes */
.card.h-100 {
height: 400px !important;
}
.card-body {
height: 340px;
}
</style>
<!-- JSON hydration for dashboard charts -->
<script type="application/json" id="dashboard-chart-data">
{
"displayCurrency": "{% if display_currency is defined and display_currency %}{{ display_currency }}{% else %}MC{% endif %}",
"resourceUtilization": {
{% if user_metrics is defined and user_metrics.resource_utilization is defined %}
"cpu": {{ user_metrics.resource_utilization.cpu }},
"memory": {{ user_metrics.resource_utilization.memory }},
"storage": {{ user_metrics.resource_utilization.storage }},
"network": {{ user_metrics.resource_utilization.network }}
{% else %}
"cpu": 0, "memory": 0, "storage": 0, "network": 0
{% endif %}
},
"creditsUsageTrend": [
{% if user_metrics is defined and user_metrics.cost_trend is defined %}
{% for value in user_metrics.cost_trend %}{{ value }}{% if not loop.last %}, {% endif %}{% endfor %}
{% else %}0, 0, 0, 0, 0, 0{% endif %}
],
"userActivity": {
"deployments": [
0, 0, 0, 0, 0, 0
],
"resourceReservations": [
0, 0, 0, 0, 0, 0
]
},
"deploymentDistribution": {
"regions": [],
"nodes": [],
"slices": [],
"apps": [],
"gateways": []
}
}
</script>
<!-- Externalized dashboard logic (charts + wallet updater) -->
<script src="/static/js/dashboard.js"></script>
{% endblock %}