Class: Jpi::V1::Admin::ThemeController

Inherits:
BaseResourceController
  • Object
show all
Defined in:
app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb

Instance Method Summary collapse

Instance Method Details

#logoObject

POST /mnoe/jpi/v1/admin/theme/logo



35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb', line 35

def 
  logo_content = params[:logo].read
  [
    'frontend/src/images/main-logo.png',
    'public/dashboard/images/main-logo.png',
    'app/assets/images/mno_enterprise/main-logo.png'
  ].each do |filepath|
    FileUtils.mkdir_p(File.dirname(Rails.root.join(filepath)))
    File.open(Rails.root.join(filepath),'wb') { |f| f.write(logo_content) }
  end
  render json: {status:  'Ok'},  status: :created
end

#resetObject

POST /mnoe/jpi/v1/admin/theme/reset



28
29
30
31
32
# File 'app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb', line 28

def reset
  reset_previewer_style
  rebuild_previewer_style
  render json: {status:  'Ok'}
end

#saveObject

POST /mnoe/jpi/v1/admin/theme/save



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/mno_enterprise/jpi/v1/admin/theme_controller.rb', line 12

def save
  if params[:publish]
    # Recompile style for production use
    apply_previewer_style(params[:theme])
    publish_style
  else
    # Save and rebuild previewer style only
    # (so it is kept across page reloads)
    save_previewer_style(params[:theme])
    rebuild_previewer_style
  end

  render json: {status:  'Ok'},  status: :created
end