diff --git a/app/controllers/api/v1/accounts/dashboard_apps_controller.rb b/app/controllers/api/v1/accounts/dashboard_apps_controller.rb new file mode 100644 index 000000000..a8d7ebcb9 --- /dev/null +++ b/app/controllers/api/v1/accounts/dashboard_apps_controller.rb @@ -0,0 +1,44 @@ +class Api::V1::Accounts::DashboardAppsController < Api::V1::Accounts::BaseController + before_action :fetch_dashboard_apps, except: [:create] + before_action :fetch_dashboard_app, only: [:show, :update, :destroy] + + def index; end + + def show; end + + def create + @dashboard_app = Current.account.dashboard_apps.create!( + permitted_payload.merge(user_id: Current.user.id) + ) + end + + def update + @dashboard_app.update!(permitted_payload) + end + + def destroy + @dashboard_app.destroy! + head :no_content + end + + private + + def fetch_dashboard_apps + @dashboard_apps = Current.account.dashboard_apps + end + + def fetch_dashboard_app + @dashboard_app = @dashboard_apps.find(permitted_params[:id]) + end + + def permitted_payload + params.require(:dashboard_app).permit( + :title, + content: [:url, :type] + ) + end + + def permitted_params + params.permit(:id) + end +end diff --git a/app/javascript/dashboard/api/dashboardApps.js b/app/javascript/dashboard/api/dashboardApps.js new file mode 100644 index 000000000..b22ab698e --- /dev/null +++ b/app/javascript/dashboard/api/dashboardApps.js @@ -0,0 +1,9 @@ +import ApiClient from './ApiClient'; + +class DashboardAppsAPI extends ApiClient { + constructor() { + super('dashboard_apps', { accountScoped: true }); + } +} + +export default new DashboardAppsAPI(); diff --git a/app/javascript/dashboard/api/specs/dashboardApps.spec.js b/app/javascript/dashboard/api/specs/dashboardApps.spec.js new file mode 100644 index 000000000..f3196ae2a --- /dev/null +++ b/app/javascript/dashboard/api/specs/dashboardApps.spec.js @@ -0,0 +1,13 @@ +import dashboardAppsAPI from '../dashboardApps'; +import ApiClient from '../ApiClient'; + +describe('#dashboardAppsAPI', () => { + it('creates correct instance', () => { + expect(dashboardAppsAPI).toBeInstanceOf(ApiClient); + expect(dashboardAppsAPI).toHaveProperty('get'); + expect(dashboardAppsAPI).toHaveProperty('show'); + expect(dashboardAppsAPI).toHaveProperty('create'); + expect(dashboardAppsAPI).toHaveProperty('update'); + expect(dashboardAppsAPI).toHaveProperty('delete'); + }); +}); diff --git a/app/javascript/dashboard/components/widgets/DashboardApp/Frame.vue b/app/javascript/dashboard/components/widgets/DashboardApp/Frame.vue new file mode 100644 index 000000000..0c2c0e8ed --- /dev/null +++ b/app/javascript/dashboard/components/widgets/DashboardApp/Frame.vue @@ -0,0 +1,64 @@ +