forked from EVOgeek/Vmeda.Online
		
	
						commit
						b5867fd011
					
				| @ -52,19 +52,19 @@ | ||||
|             </ion-card-content> | ||||
|         </ion-card> | ||||
| 
 | ||||
|         <ion-card list *ngIf="notificationsEnabled"> | ||||
|         <ion-card list *ngIf="notificationsEnabled && event.timestart - 600 > currentTime"> | ||||
|             <ion-item> | ||||
|                 <ion-label>{{ 'addon.calendar.notifications' | translate }}</ion-label> | ||||
|                 <ion-select [(ngModel)]="notificationTime" (ionChange)="updateNotificationTime($event)" interface="action-sheet"> | ||||
|                     <ion-option value="-1">{{ 'core.defaultvalue' | translate :{$a: defaultTimeReadable} }}</ion-option> | ||||
|                     <ion-option value="-1" *ngIf="event.timestart - defaultTime > currentTime">{{ 'core.defaultvalue' | translate :{$a: defaultTimeReadable} }}</ion-option> | ||||
|                     <ion-option value="0">{{ 'core.settings.disabled' | translate }}</ion-option> | ||||
|                     <ion-option value="10">{{ 600 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="30">{{ 1800 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="60">{{ 3600 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="120">{{ 7200 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="360">{{ 21600 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="720">{{ 43200 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="1440">{{ 86400 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="30" *ngIf="event.timestart - 1800 > currentTime">{{ 1800 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="60" *ngIf="event.timestart - 3600 > currentTime">{{ 3600 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="120" *ngIf="event.timestart - 7200 > currentTime">{{ 7200 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="360" *ngIf="event.timestart - 21600 > currentTime">{{ 21600 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="720" *ngIf="event.timestart - 43200 > currentTime">{{ 43200 | coreDuration }}</ion-option> | ||||
|                     <ion-option value="1440" *ngIf="event.timestart - 86400 > currentTime">{{ 86400 | coreDuration }}</ion-option> | ||||
|                 </ion-select> | ||||
|             </ion-item> | ||||
|         </ion-card> | ||||
|  | ||||
| @ -48,12 +48,14 @@ export class AddonCalendarEventPage { | ||||
|     notificationsEnabled = false; | ||||
|     moduleUrl = ''; | ||||
|     categoryPath = ''; | ||||
|     currentTime: number; | ||||
|     defaultTime: number; | ||||
| 
 | ||||
|     constructor(private translate: TranslateService, private calendarProvider: AddonCalendarProvider, navParams: NavParams, | ||||
|             private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, timeUtils: CoreTimeUtilsProvider, | ||||
|             private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, | ||||
|             private calendarHelper: AddonCalendarHelperProvider, private sitesProvider: CoreSitesProvider, | ||||
|             localNotificationsProvider: CoreLocalNotificationsProvider, private courseProvider: CoreCourseProvider, | ||||
|             private textUtils: CoreTextUtilsProvider) { | ||||
|             private textUtils: CoreTextUtilsProvider, private timeUtils: CoreTimeUtilsProvider) { | ||||
| 
 | ||||
|         this.eventId = navParams.get('id'); | ||||
|         this.notificationsEnabled = localNotificationsProvider.isAvailable(); | ||||
| @ -61,9 +63,12 @@ export class AddonCalendarEventPage { | ||||
|         if (this.notificationsEnabled) { | ||||
|             this.calendarProvider.getEventNotificationTimeOption(this.eventId).then((notificationTime) => { | ||||
|                 this.notificationTime = notificationTime; | ||||
|                 this.loadNotificationTime(); | ||||
|             }); | ||||
| 
 | ||||
|             this.calendarProvider.getDefaultNotificationTime().then((defaultTime) => { | ||||
|                 this.defaultTime = defaultTime * 60; | ||||
|                 this.loadNotificationTime(); | ||||
|                 if (defaultTime === 0) { | ||||
|                     // Disabled by default.
 | ||||
|                     this.defaultTimeReadable = this.translate.instant('core.settings.disabled'); | ||||
| @ -111,6 +116,9 @@ export class AddonCalendarEventPage { | ||||
|             this.calendarHelper.formatEventData(event); | ||||
|             this.event = event; | ||||
| 
 | ||||
|             this.currentTime = this.timeUtils.timestamp(); | ||||
|             this.loadNotificationTime(); | ||||
| 
 | ||||
|             // Reset some of the calculated data.
 | ||||
|             this.categoryPath = ''; | ||||
|             this.courseName = ''; | ||||
| @ -178,6 +186,19 @@ export class AddonCalendarEventPage { | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Loads notification time by discarding options not in the list. | ||||
|      */ | ||||
|     loadNotificationTime(): void { | ||||
|         if (typeof this.notificationTime != 'undefined') { | ||||
|             if (this.notificationTime > 0 && this.event.timestart - this.notificationTime * 60 < this.currentTime) { | ||||
|                 this.notificationTime = 0; | ||||
|             } else if (this.notificationTime < 0 && this.event.timestart - this.defaultTime < this.currentTime) { | ||||
|                 this.notificationTime = 0; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Refresh the event. | ||||
|      * | ||||
|  | ||||
| @ -18,10 +18,14 @@ | ||||
|   tr { | ||||
|     @extend .row; | ||||
|     padding: 0; | ||||
|     @include media-breakpoint-down(sm) { | ||||
|       flex-direction: column; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   td, th { | ||||
|     @extend .col; | ||||
|     min-height: auto; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -10,8 +10,8 @@ | ||||
| </ion-header> | ||||
| <ion-content> | ||||
|     <div class="fixed-content core-tabs-bar"> | ||||
|         <a class="tab-slide" [attr.aria-selected]="!search.searchingAdvanced" (click)="toggleAdvanced()">{{ 'addon.mod_data.search' | translate}}</a> | ||||
|         <a class="tab-slide" [attr.aria-selected]="search.searchingAdvanced" (click)="toggleAdvanced()">{{ 'addon.mod_data.advancedsearch' | translate }}</a> | ||||
|         <a class="tab-slide" [attr.aria-selected]="!search.searchingAdvanced" (click)="changeAdvanced(false)">{{ 'addon.mod_data.search' | translate}}</a> | ||||
|         <a class="tab-slide" [attr.aria-selected]="search.searchingAdvanced" (click)="changeAdvanced(true)">{{ 'addon.mod_data.advancedsearch' | translate }}</a> | ||||
|     </div> | ||||
|     <form (ngSubmit)="searchEntries($event)" [formGroup]="searchForm"> | ||||
|         <ion-list no-margin> | ||||
|  | ||||
| @ -176,9 +176,11 @@ export class AddonModDataSearchPage { | ||||
| 
 | ||||
|     /** | ||||
|      * Toggles between advanced to normal search. | ||||
|      * | ||||
|      * @param {boolean} advanced True for advanced, false for basic. | ||||
|      */ | ||||
|     toggleAdvanced(): void { | ||||
|         this.search.searchingAdvanced = !this.search.searchingAdvanced; | ||||
|     changeAdvanced(advanced: boolean): void { | ||||
|         this.search.searchingAdvanced = advanced; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -57,7 +57,12 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | ||||
| 
 | ||||
|         this.canGetUrl = this.urlProvider.isGetUrlWSAvailable(); | ||||
| 
 | ||||
|         this.loadContent(); | ||||
|         this.loadContent().then(() => { | ||||
|             if ((this.shouldIframe || (this.shouldEmbed && this.isOther)) || | ||||
|                     (!this.shouldIframe && (!this.shouldEmbed || !this.isOther))) { | ||||
|                 this.logView(); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -168,14 +173,23 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Opens a file. | ||||
|      * Log view into the site and checks module completion. | ||||
|      * | ||||
|      * @return {Promise<void>} Promise resolved when done. | ||||
|      */ | ||||
|     go(): void { | ||||
|         this.urlProvider.logView(this.module.instance).then(() => { | ||||
|     protected logView(): Promise<void> { | ||||
|         return this.urlProvider.logView(this.module.instance).then(() => { | ||||
|             this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||
|         }).catch(() => { | ||||
|             // Ignore errors.
 | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Opens a file. | ||||
|      */ | ||||
|     go(): void { | ||||
|         this.logView(); | ||||
|         this.urlHelper.open(this.url); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -33,6 +33,9 @@ ion-app.app-root { | ||||
|   .img-responsive { | ||||
|     display: block; | ||||
|     max-width: 100%; | ||||
|     &[height] { | ||||
|       height: auto; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   .opacity-hide { opacity: 0; } | ||||
|  | ||||
| @ -297,6 +297,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { | ||||
|             setTimeout(() => { | ||||
|                 this.domUtils.scrollToElementBySelector(this.content, '#core-course-module-' + this.moduleId); | ||||
|             }, 200); | ||||
|         } else { | ||||
|             this.domUtils.scrollToTop(this.content, 0); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -80,6 +80,7 @@ export class CoreFormatTextDirective implements OnChanges { | ||||
|      */ | ||||
|     ngOnChanges(changes: { [name: string]: SimpleChange }): void { | ||||
|         if (changes.text) { | ||||
|             this.hideShowMore(); | ||||
|             this.formatAndRenderContents(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -298,7 +298,7 @@ export class CoreLocalNotificationsProvider { | ||||
|         return this.appDB.getRecord(this.TRIGGERED_TABLE, { id: notification.id }).then((stored) => { | ||||
|             return stored.at === notification.at.getTime() / 1000; | ||||
|         }).catch(() => { | ||||
|             return false; | ||||
|             return this.localNotifications.isTriggered(notification.id); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
| @ -478,22 +478,23 @@ export class CoreLocalNotificationsProvider { | ||||
|     protected scheduleNotification(notification: CoreILocalNotification): Promise<any> { | ||||
|         // Check if the notification has been triggered already.
 | ||||
|         return this.isTriggered(notification).then((triggered) => { | ||||
|             if (!triggered) { | ||||
|                 // Check if sound is enabled for notifications.
 | ||||
|                 return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { | ||||
|                     if (!soundEnabled) { | ||||
|                         notification.sound = null; | ||||
|                     } else { | ||||
|                         delete notification.sound; // Use default value.
 | ||||
|                     } | ||||
|             // Cancel the current notification in case it gets scheduled twice.
 | ||||
|             return this.localNotifications.cancel(notification.id).finally(() => { | ||||
|                 if (!triggered) { | ||||
|                     // Check if sound is enabled for notifications.
 | ||||
|                     return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { | ||||
|                         if (!soundEnabled) { | ||||
|                             notification.sound = null; | ||||
|                         } else { | ||||
|                             delete notification.sound; // Use default value.
 | ||||
|                         } | ||||
| 
 | ||||
|                     // Remove from triggered, since the notification could be in there with a different time.
 | ||||
|                     this.removeTriggered(notification.id); | ||||
|                     this.localNotifications.cancel(notification.id).finally(() => { | ||||
|                         // Remove from triggered, since the notification could be in there with a different time.
 | ||||
|                         this.removeTriggered(notification.id); | ||||
|                         this.localNotifications.schedule(notification); | ||||
|                     }); | ||||
|                 }); | ||||
|             } | ||||
|                 } | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user