import 'dart:html' as html;
import 'package:manager_api_new/api.dart';
import 'resource_formatting.dart';
/// Téléchargement d'une ressource sous son vrai nom.
///
/// L'ancienne modale forçait `'${label}.json'` quel que soit le type : un PNG
/// arrivait en `mon-image.json` et ne s'ouvrait nulle part sans renommage.
void downloadResource(ResourceDTO resource) {
final url = resource.url;
if (url == null) return;
final anchor = html.AnchorElement(href: url)
..download = downloadFileNameFor(resource)
..target = '_blank';
anchor.click();
}