forked from EVOgeek/Vmeda.Online
		
	MOBILE-3833 course: Move course downloads to course page
This commit is contained in:
		
							parent
							
								
									8fab7a9121
								
							
						
					
					
						commit
						6ecb08246b
					
				| @ -1,62 +0,0 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CoreCourseOptionsMenuHandler, CoreCourseOptionsMenuHandlerData } from '@features/course/services/course-options-delegate'; | ||||
| import { CoreCourseAnyCourseDataWithOptions } from '@features/courses/services/courses'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to inject an option into course menu so that user can get to the manage storage page. | ||||
|  */ | ||||
| @Injectable( { providedIn: 'root' }) | ||||
| export class AddonStorageManagerCourseMenuHandlerService implements CoreCourseOptionsMenuHandler { | ||||
| 
 | ||||
|     name = 'AddonStorageManager'; | ||||
|     priority = 500; | ||||
|     isMenuHandler = true; | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async isEnabledForCourse(): Promise<boolean> { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async isEnabled(): Promise<boolean> { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     getMenuDisplayData( | ||||
|         course: CoreCourseAnyCourseDataWithOptions, | ||||
|     ): CoreCourseOptionsMenuHandlerData { | ||||
|         return { | ||||
|             icon: 'fas-cloud-download-alt', | ||||
|             title: 'addon.storagemanager.coursedownloads', | ||||
|             page: 'storage/' + course.id, | ||||
|             pageParams: { | ||||
|                 title: course.displayname ?? course.fullname, | ||||
|             }, | ||||
|             class: 'addon-storagemanager-coursemenu-handler', | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonStorageManagerCourseMenuHandler = makeSingleton(AddonStorageManagerCourseMenuHandlerService); | ||||
| @ -14,12 +14,10 @@ | ||||
| 
 | ||||
| import { NgModule, APP_INITIALIZER } from '@angular/core'; | ||||
| import { Routes } from '@angular/router'; | ||||
| import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate'; | ||||
| import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module'; | ||||
| import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; | ||||
| import { CoreSitePreferencesRoutingModule } from '@features/settings/pages/site/site-routing'; | ||||
| import { CoreSettingsDelegate } from '@features/settings/services/settings-delegate'; | ||||
| import { AddonStorageManagerCourseMenuHandler } from './services/handlers/course-menu'; | ||||
| import { AddonStorageManagerSettingsHandler } from './services/handlers/settings'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
| @ -41,7 +39,6 @@ const routes: Routes = [ | ||||
|             provide: APP_INITIALIZER, | ||||
|             multi: true, | ||||
|             useValue: () => { | ||||
|                 CoreCourseOptionsDelegate.registerHandler(AddonStorageManagerCourseMenuHandler.instance); | ||||
|                 CoreSettingsDelegate.registerHandler(AddonStorageManagerSettingsHandler.instance); | ||||
|             }, | ||||
|         }, | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| <div [class.core-loading-container]="loading || !safeUrl" [ngStyle]="{'width': iframeWidth, 'height': iframeHeight}"> | ||||
| 
 | ||||
|     <core-navbar-buttons slot="end" append *ngIf="initialized && showFullscreenOnToolbar"> | ||||
|     <core-navbar-buttons slot="end" prepend *ngIf="initialized && showFullscreenOnToolbar"> | ||||
|         <ion-button fill="clear" (click)="toggleFullscreen()" | ||||
|             [attr.aria-label]="(fullscreen ? 'core.disablefullscreen' : 'core.fullscreen') | translate"> | ||||
|             <ion-icon *ngIf="!fullscreen" name="fas-expand" slot="icon-only" aria-hidden="true"></ion-icon> | ||||
|  | ||||
| @ -58,7 +58,7 @@ | ||||
|             <ion-item lines="full" class="ion-text-wrap"> | ||||
|                 <ion-label> | ||||
|                     <h2> | ||||
|                         <ion-icon name="fam-cloud-done" aria-hidden="true"></ion-icon> | ||||
|                         <ion-icon name="fas-cloud-download-alt" aria-hidden="true"></ion-icon> | ||||
|                         {{ 'addon.storagemanager.downloads' | translate }} | ||||
|                     </h2> | ||||
|                 </ion-label> | ||||
| @ -81,7 +81,7 @@ | ||||
|             </ion-item> | ||||
|             <ion-button fill="outline" expand="block" *ngIf="canPrefetch && displayOptions.displayPrefetch" class="ion-text-wrap" | ||||
|                 (click)="prefetch()" color="primary" [disabled]="prefetchDisabled"> | ||||
|                 <ion-icon *ngIf="!prefetchLoading" name="fam-cloud-done" slot="start" aria-hidden="true"></ion-icon> | ||||
|                 <ion-icon *ngIf="!prefetchLoading" name="fas-cloud-download-alt" slot="start" aria-hidden="true"></ion-icon> | ||||
|                 <ion-spinner *ngIf="prefetchLoading" slot="start" aria-hidden="true"></ion-spinner> | ||||
|                 <ion-label> | ||||
|                     {{ 'core.download' | translate }} | ||||
|  | ||||
| @ -1,4 +1,7 @@ | ||||
| <core-navbar-buttons slot="end"> | ||||
| <core-navbar-buttons slot="end" prepend> | ||||
|     <ion-button fill="clear" (click)="gotoCourseDownloads()" [attr.aria-label]="'addon.storagemanager.coursedownloads' | translate"> | ||||
|         <ion-icon name="fas-cloud-download-alt" slot="icon-only" aria-hidden="true"></ion-icon> | ||||
|     </ion-button> | ||||
| </core-navbar-buttons> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="!dataLoaded || !displayRefresher" (ionRefresh)="doRefresh($event.target)"> | ||||
|  | ||||
| @ -29,7 +29,6 @@ import { | ||||
| } from '@features/course/services/course-helper'; | ||||
| import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate'; | ||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||
| import { CoreCourseOptionsMenuHandlerToDisplay } from '@features/course/services/course-options-delegate'; | ||||
| import { CoreCourseSync, CoreCourseSyncProvider } from '@features/course/services/sync'; | ||||
| import { CoreCourseFormatComponent } from '../../components/course-format/course-format'; | ||||
| import { | ||||
| @ -54,7 +53,6 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy { | ||||
|     sections?: CoreCourseSection[]; | ||||
|     sectionId?: number; | ||||
|     sectionNumber?: number; | ||||
|     courseMenuHandlers: CoreCourseOptionsMenuHandlerToDisplay[] = []; | ||||
|     dataLoaded = false; | ||||
|     downloadCourseEnabled = false; | ||||
|     moduleId?: number; | ||||
| @ -368,8 +366,16 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     gotoCourseDownloads(): void { | ||||
|         CoreNavigator.navigateToSitePath( | ||||
|             `storage/${this.course.id}`, | ||||
|             { params: { title: this.course.fullname } }, | ||||
|         ); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Page destroyed. | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     ngOnDestroy(): void { | ||||
|         this.isDestroyed = true; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user