// Copyright (c) 2023, JINGROW
// For license information, please see license.txt
/* eslint-disable */

jingrow.query_reports['Agent Versions'] = {
	onload: function (report) {
		report.page.add_button(__('Update Agent'), () => {
			let filters = {
				server_type: jingrow.query_report.get_filter_value('server_type'),
				exclude_self_hosted: jingrow.query_report.get_filter_value(
					'exclude_self_hosted',
				),
			};
			let team = jingrow.query_report.get_filter_value('team');
			if (team) {
				filters['team'] = team;
			}
			jingrow
				.call('jcloud.jcloud.report.agent_versions.agent_versions.update_agent', {
					filters: filters,
				})
				.then((r) => {
					jingrow.query_report.refresh();
				});
		});
	},
};
