Moves common code in hardware types to directive for reuse

Pulls out the common part in hardware types CRUD pages to be a directive.