Total magnetic moment of atom
Firstly I recommend you to understand the concept of "Magnetic Susceptibility". My source for this is Miessler,Tarr Inorganic Chemistry Book 2nd edition.

Consider Ni2+, its electronic structure is 4s03d8. This is a d8 ion. Then it has 8 electrons in d orbitals. d orbitals have 5 degenerate level of orbitals. 

Also you should know gyromagnetic ratio which is the ratio of magnetic dipole moment to angular momentum of the system. (We got a system where quantum mechanics may be obeyed). 

So, considering orbitals and electrons that fill these orbitals we got two magnetic moment here. Spin magnetic moment(sum of it is S) and angular magnetic moment(sum of it is L).
I don't know properly write all calculations with codes. So I attached an image.