diff --git a/app/controllers/admin/app_catalog/web_apps_controller.rb b/app/controllers/admin/app_catalog/web_apps_controller.rb new file mode 100644 index 0000000..052d06a --- /dev/null +++ b/app/controllers/admin/app_catalog/web_apps_controller.rb @@ -0,0 +1,9 @@ +class Admin::AppCatalog::WebAppsController < Admin::AppCatalogController + def index + @pagy, @web_apps = pagy(AppCatalog::WebApp.order('created_at desc')) + + @stats = { + known_apps: AppCatalog::WebApp.count + } + end +end diff --git a/app/controllers/admin/app_catalog_controller.rb b/app/controllers/admin/app_catalog_controller.rb new file mode 100644 index 0000000..507ea04 --- /dev/null +++ b/app/controllers/admin/app_catalog_controller.rb @@ -0,0 +1,9 @@ +class Admin::AppCatalogController < Admin::BaseController + before_action :set_current_section + + private + + def set_current_section + @current_section = :app_catalog + end +end diff --git a/app/models/remote_storage_authorization.rb b/app/models/remote_storage_authorization.rb index ea6e2ac..b4fe715 100644 --- a/app/models/remote_storage_authorization.rb +++ b/app/models/remote_storage_authorization.rb @@ -23,6 +23,7 @@ class RemoteStorageAuthorization < ApplicationRecord after_destroy :remove_token_expiry_job def url + # TODO use web app scope in addition to host uri = URI.parse self.redirect_uri "#{uri.scheme}://#{client_id}" end diff --git a/app/views/admin/app_catalog/web_apps/index.html.erb b/app/views/admin/app_catalog/web_apps/index.html.erb new file mode 100644 index 0000000..aff8066 --- /dev/null +++ b/app/views/admin/app_catalog/web_apps/index.html.erb @@ -0,0 +1,52 @@ +<%= render HeaderComponent.new(title: "App Catalog") %> + +<%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_app_catalog') do %> +
+ <%= render QuickstatsContainerComponent.new do %> + <%= render QuickstatsItemComponent.new( + type: :number, + title: 'Known Web Apps', + value: @stats[:known_apps], + ) %> + <%# <%= render QuickstatsItemComponent.new( + <%# type: :number, + <%# title: 'Accepted', + <%# value: @stats[:accepted], + <%# ) %> + <%# <%= render QuickstatsItemComponent.new( + <%# type: :number, + <%# title: 'Users with referrals', + <%# value: @stats[:users_with_referrals], + <%# meta: "/ #{User.count}" + <%# ) %> + <% end %> +
+ <% if @web_apps.any? %> +
+

Web Apps

+ + + + + + + + + + + <% @web_apps.each do |web_app| %> + + + + + + + <% end %> + +
NameURL
<%= web_app.name %><%= link_to web_app.url, web_app.url, + target: "_blank", rel: "nofollow noopener", + class: "ks-text-link" %>
+ <%== pagy_nav @pagy %> +
+ <% end %> +<% end %> diff --git a/app/views/icons/_globe.html.erb b/app/views/icons/_globe.html.erb index 0a0586d..62237bf 100644 --- a/app/views/icons/_globe.html.erb +++ b/app/views/icons/_globe.html.erb @@ -1 +1 @@ - \ No newline at end of file + diff --git a/app/views/icons/_star.html.erb b/app/views/icons/_star.html.erb index bcdc31a..5734060 100644 --- a/app/views/icons/_star.html.erb +++ b/app/views/icons/_star.html.erb @@ -1 +1 @@ - \ No newline at end of file + diff --git a/app/views/shared/_admin_nav.html.erb b/app/views/shared/_admin_nav.html.erb index 7762431..1ba5eb3 100644 --- a/app/views/shared/_admin_nav.html.erb +++ b/app/views/shared/_admin_nav.html.erb @@ -10,5 +10,9 @@ <%= link_to "Lightning", admin_lightning_path, class: main_nav_class(@current_section, :lightning) %> <% end %> +<% if Setting.remotestorage_enabled? %> + <%= link_to "Apps", admin_app_catalog_web_apps_path, + class: main_nav_class(@current_section, :app_catalog) %> +<% end %> <%= link_to "Settings", admin_settings_registrations_path, class: main_nav_class(@current_section, :settings) %> diff --git a/app/views/shared/_admin_sidenav_app_catalog.html.erb b/app/views/shared/_admin_sidenav_app_catalog.html.erb new file mode 100644 index 0000000..6fa14bc --- /dev/null +++ b/app/views/shared/_admin_sidenav_app_catalog.html.erb @@ -0,0 +1,10 @@ +<%= render SidenavLinkComponent.new( + name: "Web Apps", path: admin_app_catalog_web_apps_path, icon: "globe", + active: current_page?(admin_app_catalog_web_apps_path) +) %> +<%= render SidenavLinkComponent.new( + name: "Recommended Apps", path: "#", icon: "star", disabled: true +) %> +<%= render SidenavLinkComponent.new( + name: "OAuth Apps", path: "#", icon: "key", disabled: true +) %> diff --git a/config/routes.rb b/config/routes.rb index e7fef10..ad11ec3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -60,11 +60,16 @@ Rails.application.routes.draw do namespace :admin do root to: 'dashboard#index' + resources 'users', param: 'address', only: ['index', 'show'], constraints: { address: /.*/ } get 'invitations', to: 'invitations#index' resources :donations get 'lightning', to: 'lightning#index' + namespace :app_catalog do + resources 'web_apps', only: ['index'] + end + namespace :settings do resources 'registrations', only: ['index', 'create'] resources 'services', only: ['index', 'create']