Use the admin_enqueue_scripts hook to load JS in the dashboard. The $hook parameter lets you limit the script to specific admin screens.

function lotgrafix_admin_scripts( $hook ) {
    if ( 'post.php' !== $hook && 'post-new.php' !== $hook ) {
        return;
    }

    wp_enqueue_script(
        'lotgrafix-admin',
        get_template_directory_uri() . '/js/admin.js',
        array(),
        '1.0.0',
        true
    );
}
add_action( 'admin_enqueue_scripts', 'lotgrafix_admin_scripts' );
«
»