Weighted Energy-Dissipation principle for gradient flows in metric spaces