// Copyright (c) 2019, InfluxFramework LLC
// For license information, please see license.txt

influxframework.ui.form.on("Event Sync Log", {
	refresh: function (frm) {
		if (frm.doc.status == "Failed") {
			frm.add_custom_button(__("Resync"), function () {
				influxframework.call({
					method: "influxframework.event_streaming.doctype.event_producer.event_producer.resync",
					args: {
						update: frm.doc,
					},
					callback: function (r) {
						if (r.message) {
							influxframework.msgprint(r.message);
							frm.set_value("status", r.message);
							frm.save();
						}
					},
				});
			});
		}
	},
});
