First-principles study of charge and magnetic ordering in monolayer NbSe2