Method: Orchestrator::Api::SystemsController#remove

Defined in:
app/controllers/orchestrator/api/systems_controller.rb

#removeObject

Removes the module from the system and deletes it if not used elsewhere



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/orchestrator/api/systems_controller.rb', line 55

def remove
    module_id = params.permit(:module_id)[:module_id]
    mod = ::Orchestrator::Module.find module_id

    if @cs.modules.include? module_id
        remove = true

        @cs.modules.delete(module_id)
        @cs.save!

        ControlSystem.using_module(module_id).each do |cs|
            if cs.id != @cs.id
                remove = false
                break
            end
        end

        mod.delete if remove
    end
    render :nothing => true
end