class AdminUpdate

Public Instance Methods

layout() click to toggle source
# File Views/Admin/Update.rb, line 2
def layout
  @order = 550
  @update = true

  gui_hbox do
    gui_vbox :nogroup do
      show_list_single :update_files, width: 300
      show_upload :upload_update, callback: true
      show_button :update, :delete
    end

    gui_window :confirm_win do
      show_html :confirm_html
      show_button :confirm_ok, :close
    end
  end
end
list_files() click to toggle source
# File Views/Admin/Update.rb, line 32
def list_files
  list_http + list_usb + list_tmp
end
list_http() click to toggle source
# File Views/Admin/Update.rb, line 20
def list_http
  []
end
list_tmp() click to toggle source
# File Views/Admin/Update.rb, line 28
def list_tmp
  Dir.glob('/tmp/*.pkg.tar.*z').collect { |f| "file://#{f}" }
end
list_usb() click to toggle source
# File Views/Admin/Update.rb, line 24
def list_usb
  []
end
rpc_button_confirm_ok(session, data) click to toggle source
# File Views/Admin/Update.rb, line 49
def rpc_button_confirm_ok(session, data)
  file = data._update_files.first
  log_msg :AdminUpdate, "Preparing update with #{file}"
  Entities.save_all
  log_msg :backup, 'Creating new backup'
  System.run_bool "#{GESTION_DIR}/Binaries/backup"
  System.run_bool "#{GESTION_DIR}/Binaries/gestion_update.rb #{file}"
  Platform.start 'gestion_update'
  reply(:eval, "document.location.href='http://local.profeda.org/update_progress.html'")
end
rpc_button_delete(session, data) click to toggle source
# File Views/Admin/Update.rb, line 60
def rpc_button_delete(session, data)
  return unless session.owner.permissions.index :admin
  case data._update_files
    when /^file:\/\/(.*)/
      File.exists? $1 and FileUtils.rm $1
  end
end
rpc_button_update(session, data) click to toggle source
# File Views/Admin/Update.rb, line 41
def rpc_button_update(session, data)
  reply(:window_show, :confirm_win) +
      reply(:update, confirm_html: '<h1>Updating - Danger!</h1>' +
                       'Are you sure you want to update with<br>' +
                       "<strong>#{data._update_files.first}</strong>?") +
      reply(:select, update_files: [data._update_files.first])
end
rpc_button_upload_update(session, data) click to toggle source
# File Views/Admin/Update.rb, line 68
def rpc_button_upload_update(session, data)
  file = ["file:///tmp/#{data._filename}"]
  rpc_update(session, file) +
      rpc_button_update(session, update_files: file)
end
rpc_update(_session, select = []) click to toggle source
# File Views/Admin/Update.rb, line 36
def rpc_update(_session, select = [])
  reply(:empty_update, update_files: (list_files + select)) +
      reply(:update, upload_update: 'Upload')
end