Keelan Giles is the last-gasp hero as Ospreys edge out Dragons in a United Rugby Championship thriller in Bridgend.