Add admin page for web apps
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							parent
							
								
									3e9a08a266
								
							
						
					
					
						commit
						2b8bfaaca8
					
				
							
								
								
									
										9
									
								
								app/controllers/admin/app_catalog/web_apps_controller.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								app/controllers/admin/app_catalog/web_apps_controller.rb
									
									
									
									
									
										Normal file
									
								
							| @ -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 | ||||
							
								
								
									
										9
									
								
								app/controllers/admin/app_catalog_controller.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								app/controllers/admin/app_catalog_controller.rb
									
									
									
									
									
										Normal file
									
								
							| @ -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 | ||||
| @ -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 | ||||
|  | ||||
							
								
								
									
										52
									
								
								app/views/admin/app_catalog/web_apps/index.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								app/views/admin/app_catalog/web_apps/index.html.erb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,52 @@ | ||||
| <%= render HeaderComponent.new(title: "App Catalog") %> | ||||
| 
 | ||||
| <%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_app_catalog') do %> | ||||
|   <section> | ||||
|     <%= 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 %> | ||||
|   </section> | ||||
|   <% if @web_apps.any? %> | ||||
|     <section> | ||||
|       <h3>Web Apps</h3> | ||||
|       <table class="divided mb-8"> | ||||
|         <thead> | ||||
|           <tr> | ||||
|             <th>Name</th> | ||||
|             <th>URL</th> | ||||
|             <th class="hidden md:table-cell">RS Auths</th> | ||||
|             <th class="hidden md:table-cell">Created at</th> | ||||
|           </tr> | ||||
|         </thead> | ||||
|         <tbody> | ||||
|           <% @web_apps.each do |web_app| %> | ||||
|             <tr> | ||||
|               <td><%= web_app.name %></td> | ||||
|               <td><%= link_to web_app.url, web_app.url, | ||||
|                               target: "_blank", rel: "nofollow noopener", | ||||
|                               class: "ks-text-link" %></td> | ||||
|               <td class="hidden md:table-cell"><%= web_app.remote_storage_authorizations.count %></td> | ||||
|               <td class="hidden md:table-cell"><%= web_app.created_at %></td> | ||||
|             </tr> | ||||
|           <% end %> | ||||
|         </tbody> | ||||
|       </table> | ||||
|       <%== pagy_nav @pagy %> | ||||
|     </section> | ||||
|   <% end %> | ||||
| <% end %> | ||||
| @ -1 +1 @@ | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-globe"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg> | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-globe <%= custom_class %>"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg> | ||||
|  | ||||
| Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 430 B | 
| @ -1 +1 @@ | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-star"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg> | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-star <%= custom_class %>"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg> | ||||
|  | ||||
| Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 360 B | 
| @ -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) %> | ||||
|  | ||||
							
								
								
									
										10
									
								
								app/views/shared/_admin_sidenav_app_catalog.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/views/shared/_admin_sidenav_app_catalog.html.erb
									
									
									
									
									
										Normal file
									
								
							| @ -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 | ||||
| ) %> | ||||
| @ -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'] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user