mno-enterprise-api 3.3.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mno_enterprise/config.js.coffee.erb +1 -0
  3. data/app/controllers/mno_enterprise/impersonate_controller.rb +5 -1
  4. data/app/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller.rb +93 -0
  5. data/app/controllers/mno_enterprise/jpi/v1/admin/impac/kpis_controller.rb +71 -0
  6. data/app/controllers/mno_enterprise/jpi/v1/admin/impac/widgets_controller.rb +70 -0
  7. data/app/controllers/mno_enterprise/jpi/v1/impac/dashboard_templates_controller.rb +5 -0
  8. data/app/views/mno_enterprise/auth/confirmations/_form.html.haml +10 -1
  9. data/app/views/mno_enterprise/jpi/v1/admin/base_resource/_member.json.jbuilder +1 -0
  10. data/app/views/mno_enterprise/jpi/v1/admin/impac/dashboard_templates/_template.json.jbuilder +16 -0
  11. data/app/views/mno_enterprise/jpi/v1/admin/impac/dashboard_templates/index.json.jbuilder +1 -0
  12. data/app/views/mno_enterprise/jpi/v1/admin/impac/dashboard_templates/show.json.jbuilder +1 -0
  13. data/app/views/mno_enterprise/jpi/v1/admin/impac/kpis/_kpi.json.jbuilder +2 -0
  14. data/app/views/mno_enterprise/jpi/v1/admin/impac/kpis/show.json.jbuilder +1 -0
  15. data/app/views/mno_enterprise/jpi/v1/admin/impac/widgets/_widget.json.jbuilder +7 -0
  16. data/app/views/mno_enterprise/jpi/v1/admin/impac/widgets/show.json.jbuilder +1 -0
  17. data/app/views/mno_enterprise/jpi/v1/app_feedbacks/_resource.json.jbuilder +1 -0
  18. data/app/views/mno_enterprise/jpi/v1/app_questions/_resource.json.jbuilder +1 -0
  19. data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +1 -0
  20. data/app/views/mno_enterprise/jpi/v1/impac/dashboard_templates/index.json.jbuilder +1 -0
  21. data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -1
  22. data/app/views/mno_enterprise/pages/loading.html.erb +1 -1
  23. data/config/routes.rb +12 -0
  24. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboard_templates_controller.rb +20 -0
  25. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +25 -2
  26. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/kpis_controller.rb +13 -11
  27. data/lib/mno_enterprise/concerns/controllers/jpi/v1/marketplace_controller.rb +1 -1
  28. data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +3 -1
  29. data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +11 -2
  30. data/spec/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller_spec.rb +225 -0
  31. data/spec/controllers/mno_enterprise/jpi/v1/admin/impac/kpis_controller_spec.rb +134 -0
  32. data/spec/controllers/mno_enterprise/jpi/v1/admin/impac/widgets_controller_spec.rb +150 -0
  33. data/spec/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller_spec.rb +2 -1
  34. data/spec/controllers/mno_enterprise/jpi/v1/app_questions_controller_spec.rb +2 -1
  35. data/spec/controllers/mno_enterprise/jpi/v1/impac/dashboard_templates_controller_spec.rb +97 -0
  36. data/spec/controllers/mno_enterprise/jpi/v1/impac/dashboards_controller_spec.rb +223 -0
  37. data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +31 -1
  38. data/spec/controllers/mno_enterprise/pages_controller_spec.rb +13 -2
  39. data/spec/routing/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller_routing_spec.rb +28 -0
  40. data/spec/routing/mno_enterprise/jpi/v1/admin/impac/kpis_controller_routing_spec.rb +20 -0
  41. data/spec/routing/mno_enterprise/jpi/v1/admin/impac/widgets_controller_routing_spec.rb +20 -0
  42. data/spec/routing/mno_enterprise/jpi/v1/impac/dashboard_templates_controller_routing_spec.rb +11 -0
  43. metadata +35 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59481a633a5a28ae2dd38005cdb551b228c5b5bf
4
- data.tar.gz: 76d54cd45bca2dffce920a50202d31688509389e
3
+ metadata.gz: 846a1b37e09b4377d95942c2a767e6940b6accf9
4
+ data.tar.gz: 523280be7a240646691ccacb1b9da059154ac75c
5
5
  SHA512:
6
- metadata.gz: dc8fe919ad098561ade8eed41579e5395d89d88bc84187f5d1b582b333bd2142d8f8f1995032a356caa5017b0f63b2c652698a4d687ba2411961c212936a5461
7
- data.tar.gz: bf5fc80d57d306d94a89444444af57687f8e7ff870817c8a530e27fd3388032efc253be7c3a7c15f021ee9eb2e621b7f401d248ce730164c8dc14a97640da2c6
6
+ metadata.gz: 6f52fd948f00c51ea0d3b450864ee3ca443fc3f57f82c45b93994b5be7a1ee9e91fdfc0e91c93aa589225f156a26bb28b3037707f10a279a4a8db79b273cabd7
7
+ data.tar.gz: 57243387693928174a98c694054fbfdbd4e788101656800674a4297b4556c3a9cfd4ede660bd0d5323c65b0b0968cefb95d68f5ec338392dea89cde4b4f1c8e0
@@ -24,3 +24,4 @@ angular.module('mnoEnterprise.configuration', [])
24
24
  .constant('INTERCOM_ID', <%= MnoEnterprise.intercom_app_id.to_json %>)
25
25
  .constant('APP_NAME', <%= MnoEnterprise.app_name.to_json %>)
26
26
  .constant('URL_CONFIG', <%= Hash(Settings.url_config).to_json %>)
27
+ .constant('DEVISE_CONFIG', <%= Hash(Settings.devise).to_json %>)
@@ -11,7 +11,11 @@ module MnoEnterprise
11
11
  session[:impersonator_redirect_path] = params[:redirect_path].presence
12
12
  @user = MnoEnterprise::User.find(params[:user_id])
13
13
  if @user.present?
14
- impersonate(@user)
14
+ if @user.admin_role.present?
15
+ flash[:notice] = 'User is a staff member'
16
+ else
17
+ impersonate(@user)
18
+ end
15
19
  else
16
20
  flash[:notice] = "User doesn't exist"
17
21
  end
@@ -0,0 +1,93 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::Admin::Impac::DashboardTemplatesController < Jpi::V1::Admin::BaseResourceController
3
+
4
+ #==================================================================
5
+ # Instance methods
6
+ #==================================================================
7
+ # GET /mnoe/jpi/v1/admin/impac/dashboard_templates
8
+ def index
9
+ if params[:terms]
10
+ # For search mode
11
+ @dashboard_templates = []
12
+ JSON.parse(params[:terms]).map { |t| @dashboard_templates = @dashboard_templates | dashboard_templates.where(Hash[*t]) }
13
+ response.headers['X-Total-Count'] = @dashboards_templates.count
14
+ else
15
+ @dashboard_templates = dashboard_templates
16
+ @dashboard_templates = @dashboard_templates.limit(params[:limit]) if params[:limit]
17
+ @dashboard_templates = @dashboard_templates.skip(params[:offset]) if params[:offset]
18
+ @dashboard_templates = @dashboard_templates.order_by(params[:order_by]) if params[:order_by]
19
+ @dashboard_templates = @dashboard_templates.where(params[:where]) if params[:where]
20
+ @dashboard_templates = @dashboard_templates.all.fetch
21
+ response.headers['X-Total-Count'] = @dashboard_templates.metadata[:pagination][:count]
22
+ end
23
+ end
24
+
25
+ # GET /mnoe/jpi/v1/admin/impac/dashboard_templates/1
26
+ def show
27
+ render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless dashboard_template.present?
28
+ end
29
+
30
+ # POST /mnoe/jpi/v1/admin/impac/dashboard_templates
31
+ def create
32
+ @dashboard_template = MnoEnterprise::Impac::Dashboard.new(dashboard_template_params.merge(dashboard_type: 'template'))
33
+
34
+ # Abort on failure
35
+ unless @dashboard_template.save
36
+ return render json: { errors: dashboard_template.errors }, status: :bad_request
37
+ end
38
+
39
+ MnoEnterprise::EventLogger.info('dashboard_template_create', current_user.id, 'Dashboard Template Creation', dashboard_template)
40
+ render 'show'
41
+ end
42
+
43
+ # PATCH/PUT /mnoe/jpi/v1/admin/impac/dashboard_templates/1
44
+ def update
45
+ return render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless dashboard_template
46
+
47
+ # Abort on failure
48
+ unless dashboard_template.update(dashboard_template_params)
49
+ return render json: { errors: dashboard_template.errors }, status: :bad_request
50
+ end
51
+
52
+ MnoEnterprise::EventLogger.info('dashboard_template_update', current_user.id, 'Dashboard Template Update', dashboard_template)
53
+ render 'show'
54
+ end
55
+
56
+ # DELETE /mnoe/jpi/v1/admin/impac/dashboard_templates/1
57
+ def destroy
58
+ return render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless dashboard_template
59
+
60
+ # Abort on failure
61
+ unless dashboard_template.destroy
62
+ return render json: { errors: 'Cannot destroy dashboard template' }, status: :bad_request
63
+ end
64
+
65
+ MnoEnterprise::EventLogger.info('dashboard_template_delete', current_user.id, 'Dashboard Template Deletion', dashboard_template)
66
+ head status: :ok
67
+ end
68
+
69
+ private
70
+
71
+ def dashboard_templates
72
+ @dashboard_templates ||= MnoEnterprise::Impac::Dashboard.templates
73
+ end
74
+
75
+ def dashboard_template
76
+ @dashboard_template ||= dashboard_templates.find(params[:id].to_i)
77
+ end
78
+
79
+ def whitelisted_params
80
+ [:name, :currency, { widgets_order: [] }, { organization_ids: [] }, :published]
81
+ end
82
+
83
+ # Allows all metadata attrs to be permitted, and maps it to :settings
84
+ # for the Her "meta_data" issue.
85
+ def dashboard_template_params
86
+ params.require(:dashboard).permit(*whitelisted_params).tap do |whitelisted|
87
+ whitelisted[:settings] = params[:dashboard][:metadata] || {}
88
+ end
89
+ .except(:metadata)
90
+ end
91
+ end
92
+ end
93
+
@@ -0,0 +1,71 @@
1
+ module MnoEnterprise
2
+ # From the Admin panel, an admin can create/update/delete kpis to/from a dashboard template
3
+ class Jpi::V1::Admin::Impac::KpisController < Jpi::V1::Admin::BaseResourceController
4
+ before_filter :find_valid_kpi, only: [:update, :delete]
5
+
6
+ # POST /mnoe/jpi/v1/admin/impac/dashboard_templates/:id/kpis
7
+ def create
8
+ return render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless template.present?
9
+
10
+ @kpi = template.kpis.create(kpi_create_params)
11
+ return render json: { errors: (@kpi && @kpi.errors).to_a }, status: :bad_request unless @kpi.present? && @kpi.valid?
12
+
13
+ MnoEnterprise::EventLogger.info('kpi_create', current_user.id, 'Template KPI Creation', @kpi)
14
+ @no_content = true
15
+ render 'show'
16
+ end
17
+
18
+ # PUT /mnoe/jpi/v1/admin/impac/kpis/:id
19
+ def update
20
+ unless kpi.present? && kpi.update(kpi_update_params)
21
+ return render json: { errors: 'Cannot update kpi' }, status: :bad_request
22
+ end
23
+
24
+ MnoEnterprise::EventLogger.info('kpi_update', current_user.id, 'Template KPI Update', kpi)
25
+ @nocontent = !params['metadata']
26
+ render 'show'
27
+ end
28
+
29
+ # DELETE /mnoe/jpi/v1/admin/impac/kpis/:id
30
+ def destroy
31
+ unless kpi.present? && kpi.destroy
32
+ return render json: { errors: 'Cannot delete kpi' }, status: :bad_request
33
+ end
34
+
35
+ MnoEnterprise::EventLogger.info('kpi_delete', current_user.id, 'Template KPI Deletion', kpi)
36
+ head status: :ok
37
+ end
38
+
39
+ private
40
+
41
+ def template
42
+ MnoEnterprise::Impac::Dashboard.templates.find(params[:dashboard_template_id].to_i)
43
+ end
44
+
45
+ def kpi
46
+ @kpi ||= MnoEnterprise::Impac::Kpi.find(params[:id].to_i)
47
+ end
48
+
49
+ def kpi_create_params
50
+ whitelist = [:dashboard_id, :widget_id, :endpoint, :source, :element_watched, { extra_watchables: [] }]
51
+ extract_params(whitelist)
52
+ end
53
+
54
+ def kpi_update_params
55
+ whitelist = [:element_watched, {extra_watchables: []}]
56
+ extract_params(whitelist)
57
+ end
58
+
59
+ def extract_params(whitelist)
60
+ (p = params).require(:kpi).permit(*whitelist).tap do |whitelisted|
61
+ whitelisted[:settings] = p[:kpi][:metadata] || {}
62
+ # TODO: strong params for targets & extra_params attributes (keys will depend on the kpi).
63
+ whitelisted[:targets] = p[:kpi][:targets] if p[:kpi][:targets].present?
64
+ whitelisted[:extra_params] = p[:kpi][:extra_params] if p[:kpi][:extra_params].present?
65
+ end
66
+ .except(:metadata)
67
+ end
68
+
69
+ alias :find_valid_kpi :kpi
70
+ end
71
+ end
@@ -0,0 +1,70 @@
1
+ module MnoEnterprise
2
+ # From the Admin panel, an admin can:
3
+ # - add widgets to template dashboards (passing the dashboard template id)
4
+ # - update any widget (passing its id)
5
+ # - delete any widget (passing its id)
6
+ class Jpi::V1::Admin::Impac::WidgetsController < Jpi::V1::Admin::BaseResourceController
7
+
8
+ # POST /mnoe/jpi/v1/admin/impac/dashboard_templates/:id/widgets
9
+ def create
10
+ return render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless template.present?
11
+
12
+ @widget = template.widgets.create(widget_create_params)
13
+ return render json: { errors: (widget && widget.errors).to_a }, status: :bad_request unless widget.present? && widget.valid?
14
+
15
+ MnoEnterprise::EventLogger.info('widget_create', current_user.id, 'Template Widget Creation', widget)
16
+ @no_content = true
17
+ render 'show'
18
+ end
19
+
20
+ # PUT /mnoe/jpi/v1/admin/impac/widgets/:id
21
+ def update
22
+ unless widget.present? && widget.update(widget_update_params)
23
+ return render json: { errors: 'Cannot update widget' }, status: :bad_request
24
+ end
25
+
26
+ MnoEnterprise::EventLogger.info('widget_update', current_user.id, 'Template Widget Update', widget)
27
+ @nocontent = !params['metadata']
28
+ render 'show'
29
+ end
30
+
31
+ # DELETE /mnoe/jpi/v1/admin/impac/widgets/:id
32
+ def destroy
33
+ unless widget.present? && widget.destroy
34
+ return render json: { errors: 'Cannot delete widget' }, status: :bad_request
35
+ end
36
+
37
+ MnoEnterprise::EventLogger.info('widget_delete', current_user.id, 'Template Widget Deletion', widget)
38
+ head status: :ok
39
+ end
40
+
41
+ private
42
+
43
+ def template
44
+ MnoEnterprise::Impac::Dashboard.templates.find(params[:dashboard_template_id].to_i)
45
+ end
46
+
47
+ def widget
48
+ @widget ||= MnoEnterprise::Impac::Widget.find(params[:id].to_i)
49
+ end
50
+
51
+ def widget_create_params
52
+ params.require(:widget).permit(:endpoint, :name, :width).tap do |whitelisted|
53
+ whitelisted[:settings] = params[:widget][:metadata] || {}
54
+ # TODO: remove when all deployed versions of Impac! Angular will be above v1.5.0
55
+ # When this is done:
56
+ # - :widget_category can definitively be renamed to :endpoint in mnohub and mnoe
57
+ # - the widget templates can be completely removed from mnohub and mnoe
58
+ whitelisted[:widget_category] = params[:widget][:endpoint]
59
+ end
60
+ .except(:metadata)
61
+ end
62
+
63
+ def widget_update_params
64
+ params.require(:widget).permit(:name, :width).tap do |whitelisted|
65
+ whitelisted[:settings] = params[:widget][:metadata] || {}
66
+ end
67
+ .except(:metadata)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::Impac::DashboardTemplatesController < Jpi::V1::BaseResourceController
3
+ include MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::DashboardTemplatesController
4
+ end
5
+ end
@@ -1,4 +1,4 @@
1
- %div{ 'ng-init' => "user = { $pwdScore: {}, name: '#{resource.name}', surname: '#{resource.surname}', phone: '#{resource.phone}' }" }
1
+ %div{ 'ng-init' => "user = { $pwdScore: {}, name: '#{resource.name}', surname: '#{resource.surname}', phone: '#{resource.phone}'}" }
2
2
 
3
3
  = form_for(resource, as: resource_name, :url => mno_enterprise.user_confirmation_finalize_path, :html => { 'name' => 'loginForm', :class => 'autofill-detect text-center' }) do |f|
4
4
 
@@ -39,6 +39,15 @@
39
39
 
40
40
  = f.hidden_field :confirmation_token, value: @confirmation_token
41
41
 
42
+ - unless @user[:meta_data][:tos_accepted_at]
43
+ %br
44
+ .row
45
+ .col-sm-12
46
+ .checkbox-section.text-center
47
+ = check_box_tag 'tos', 'accept', false, required: true, style: "margin-top: -3px;", 'ng-model' => 'acceptTos'
48
+ %label{for: 'tos'}= t('mno_enterprise.auth.registrations.new.user_accept')
49
+ = link_to t('mno_enterprise.auth.registrations.new.tos'), MnoEnterprise.router.terms_url, target: '_blank'
50
+
42
51
  %br/
43
52
  %div
44
53
  %button{ :class => "btn btn-warning btn-login", :type => "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'loginForm.$invalid', 'ng-hide' => 'hasClicked' }= t('mno_enterprise.auth.confirmations.show.confirm')
@@ -2,6 +2,7 @@ if member.is_a?(MnoEnterprise::User)
2
2
  json.uid member.uid
3
3
  json.entity 'User'
4
4
  json.role member.role(organization) if organization
5
+ json.admin_role member.admin_role
5
6
 
6
7
  status = case
7
8
  when member.confirmed? then 'active'
@@ -0,0 +1,16 @@
1
+ json.extract! template, :id, :name, :full_name, :currency
2
+
3
+ json.metadata template.settings
4
+
5
+ json.data_sources template.organizations(current_user.organizations).compact.map do |org|
6
+ json.id org.id
7
+ json.uid org.uid
8
+ json.label org.name
9
+ end
10
+
11
+ json.kpis template.kpis, partial: 'mno_enterprise/jpi/v1/admin/impac/kpis/kpi', as: :kpi
12
+ json.widgets template.widgets, partial: 'mno_enterprise/jpi/v1/admin/impac/widgets/widget', as: :widget
13
+
14
+ json.created_at template.created_at
15
+ json.updated_at template.updated_at
16
+ json.published template.published
@@ -0,0 +1 @@
1
+ json.array! @dashboard_templates, partial: 'template', as: :template
@@ -0,0 +1 @@
1
+ json.partial! 'template', template: @dashboard_template
@@ -0,0 +1,2 @@
1
+ json.ignore_nil!
2
+ json.extract! kpi, :id, :element_watched, :endpoint, :source, :targets, :settings, :extra_watchables, :extra_params
@@ -0,0 +1 @@
1
+ json.partial! 'kpi', kpi: @kpi
@@ -0,0 +1,7 @@
1
+ json.id widget.id
2
+ json.name widget.name
3
+ json.endpoint (widget.endpoint || widget.widget_category)
4
+ json.width widget.width
5
+ json.metadata widget.settings
6
+
7
+ json.kpis widget.kpis, partial: 'mno_enterprise/jpi/v1/admin/impac/kpis/kpi', as: :kpi
@@ -0,0 +1 @@
1
+ json.partial! 'widget', widget: @widget
@@ -2,6 +2,7 @@ json.partial! 'app_review', app_review: app_feedback
2
2
 
3
3
  json.comments do
4
4
  json.array! app_feedback[:comments] do |app_comment|
5
+ next if app_comment['status'] == 'rejected'
5
6
  json.partial! 'comment', app_comment: app_comment
6
7
  end
7
8
  end
@@ -2,6 +2,7 @@ json.partial! 'app_review', app_review: app_question, show_rating: false
2
2
 
3
3
  json.answers do
4
4
  json.array! app_question[:answers] do |app_answer|
5
+ next if app_answer['status'] == 'rejected'
5
6
  json.partial! 'answer', app_answer: app_answer
6
7
  end
7
8
  end
@@ -18,6 +18,7 @@ json.cache! ['v1', @user.cache_key] do
18
18
  json.avatar_url avatar_url(@user)
19
19
  if current_impersonator
20
20
  json.current_impersonator true
21
+ json.current_impersonator_role current_impersonator.admin_role
21
22
  end
22
23
 
23
24
  if @user.respond_to?(:intercom_user_hash)
@@ -0,0 +1 @@
1
+ json.array! @templates, partial: 'mno_enterprise/jpi/v1/impac/dashboards/dashboard', as: :dashboard
@@ -1,4 +1,4 @@
1
1
  json.ignore_nil!
2
2
  json.extract! kpi, :id, :element_watched, :endpoint, :source, :targets, :settings, :extra_watchables, :extra_params
3
3
 
4
- json.alerts kpi.alerts, partial: 'mno_enterprise/jpi/v1/impac/alerts/alert', as: :alert if kpi.alerts.any?
4
+ json.alerts kpi.alerts, partial: 'mno_enterprise/jpi/v1/impac/alerts/alert', as: :alert if kpi.alerts.to_a.any?
@@ -4,7 +4,7 @@
4
4
  <div class="spacer3 hidden-xs hidden-sm"></div>
5
5
  <input type="hidden" ng-model="appInstance">
6
6
  <div class='align-center'>
7
- <%= image_tag 'mno_enterprise/main-logo.png' %>
7
+ <%= image_tag(main_logo_white_bg_path) %>
8
8
 
9
9
  <div class="spacer2"></div>
10
10
 
@@ -145,6 +145,8 @@ MnoEnterprise::Engine.routes.draw do
145
145
  end
146
146
 
147
147
  namespace :impac do
148
+ post 'dashboards/:id/copy', to: 'dashboards#copy'
149
+
148
150
  resources :dashboards, only: [:index, :show, :create, :update, :destroy] do
149
151
  resources :widgets, shallow: true, only: [:create, :update, :destroy]
150
152
  resources :kpis, shallow: true, only: [:show, :create, :update, :destroy] do
@@ -158,6 +160,8 @@ MnoEnterprise::Engine.routes.draw do
158
160
  resources :organizations, only: [] do
159
161
  resources :widgets, only: :index
160
162
  end
163
+
164
+ resources :dashboard_templates, only: :index
161
165
  end
162
166
 
163
167
 
@@ -211,6 +215,14 @@ MnoEnterprise::Engine.routes.draw do
211
215
  post 'theme/save'
212
216
  post 'theme/reset'
213
217
  put 'theme/logo'
218
+
219
+ # Dashboard templates designer
220
+ namespace :impac do
221
+ resources :dashboard_templates, only: [:index, :show, :destroy, :update, :create] do
222
+ resources :widgets, shallow: true, only: [:create, :update, :destroy]
223
+ resources :kpis, shallow: true, only: [:create, :update, :destroy]
224
+ end
225
+ end
214
226
  end
215
227
  end
216
228
  end
@@ -0,0 +1,20 @@
1
+ module MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::DashboardTemplatesController
2
+ extend ActiveSupport::Concern
3
+
4
+ #==================================================================
5
+ # Included methods
6
+ #==================================================================
7
+ # 'included do' causes the included code to be evaluated in the
8
+ # context where it is included rather than being executed in the module's context
9
+ included do
10
+ respond_to :json
11
+ end
12
+
13
+ #==================================================================
14
+ # Instance methods
15
+ #==================================================================
16
+ # GET /mnoe/jpi/v1/impac/dashboard_templates
17
+ def index
18
+ @templates = MnoEnterprise::Impac::Dashboard.published_templates
19
+ end
20
+ end