Added PowerGridService to make the logic reusable

This is just refactoring for the logic, I didn't add anything new.
I took the responsibility from the controller and split it on service and view to make it reusable and maintainable.