文件操作 - validation.ts
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/features/manage-dashboards/utils/validation.ts
编辑文件内容
import validationSrv from '../services/ValidationSrv'; import { getBackendSrv } from '@grafana/runtime'; export const validateDashboardJson = (json: string) => { try { JSON.parse(json); return true; } catch (error) { return 'Not valid JSON'; } }; export const validateGcomDashboard = (gcomDashboard: string) => { // From DashboardImportCtrl const match = /(^\d+$)|dashboards\/(\d+)/.exec(gcomDashboard); return match && (match[1] || match[2]) ? true : 'Could not find a valid Grafana.com id'; }; export const validateTitle = (newTitle: string, folderId: number) => { return validationSrv .validateNewDashboardName(folderId, newTitle) .then(() => { return true; }) .catch(error => { if (error.type === 'EXISTING') { return error.message; } }); }; export const validateUid = (value: string) => { return getBackendSrv() .get(`/api/dashboards/uid/${value}`) .then(existingDashboard => { return `Dashboard named '${existingDashboard?.dashboard.title}' in folder '${existingDashboard?.meta.folderTitle}' has the same uid`; }) .catch(error => { error.isHandled = true; return true; }); };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件