v0.1.0
This commit is contained in:
@@ -42,8 +42,9 @@ export class MailService {
|
||||
await firstValueFrom(this.client.post(this.iserv.backend + "/mail/send", data));
|
||||
}
|
||||
|
||||
public downloadAttachment(mailId: number, attachment: string): Observable<HttpEvent<Blob>> {
|
||||
return this.client.post(this.iserv.backend + `/mail/download/${mailId}/${attachment}`, this.iserv.userdata, {responseType: "blob", reportProgress: true, observe: "events"});
|
||||
public downloadAttachment(mailId: number, attachment: string): string {
|
||||
//return this.client.post(this.iserv.backend + `/mail/download/${mailId}/${attachment}`, this.iserv.userdata, {responseType: "blob", reportProgress: true, observe: "events"});
|
||||
return this.iserv.backend + `/mail/download/${mailId}/${attachment}?credentialString=${JSON.stringify(this.iserv.userdata)}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@ export class WebdavService {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public downloadFile(url: string): Observable<HttpEvent<Blob>> {
|
||||
return this.client.post(this.iserv.backend + "/webdav/download?url=" + url, this.iserv.userdata, {responseType: "blob", reportProgress: true, observe: "events"});
|
||||
public downloadFile(url: string): string {
|
||||
//return this.client.get(this.iserv.backend + `/webdav/download?url=${url}&credentialString=${JSON.stringify(this.iserv.userdata)}`, {responseType: "blob", reportProgress: true, observe: "events"});
|
||||
return this.iserv.backend + `/webdav/download?url=${url}&credentialString=${JSON.stringify(this.iserv.userdata)}`;
|
||||
}
|
||||
|
||||
public async delete(url: string) {
|
||||
|
||||
@@ -4,9 +4,7 @@ import {FormsModule} from '@angular/forms';
|
||||
import {ActionSheetController, AlertController, IonicModule, Platform, ToastController} from '@ionic/angular';
|
||||
import {WebdavService} from "../../api/webdav.service";
|
||||
import {DirectoryContent} from "../../entities/directoryContent";
|
||||
import {File} from "@awesome-cordova-plugins/file/ngx";
|
||||
import {saveAs} from "file-saver";
|
||||
import {HttpDownloadProgressEvent, HttpEventType} from "@angular/common/http";
|
||||
import {HttpEventType} from "@angular/common/http";
|
||||
|
||||
@Component({
|
||||
selector: 'app-files',
|
||||
@@ -47,29 +45,8 @@ export class FilesPage implements OnInit {
|
||||
if (item.type == "dir") {
|
||||
await this.switchDirectory(item.url);
|
||||
}else {
|
||||
this.webdav.downloadFile(item.url).subscribe(async event => {
|
||||
if (event.type == HttpEventType.DownloadProgress) {
|
||||
const e = event as HttpDownloadProgressEvent;
|
||||
this.progress = e.loaded / e.total * 100;
|
||||
}
|
||||
|
||||
if (event.type == HttpEventType.Response) {
|
||||
const blob = event.body;
|
||||
const file = new File();
|
||||
|
||||
if (this.platform.is('desktop')) {
|
||||
saveAs(blob, item.name);
|
||||
this.progress = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
const downloadPath = (
|
||||
this.platform.is('android')
|
||||
) ? file.externalDataDirectory : file.documentsDirectory;
|
||||
await file.writeFile(downloadPath, item.name, blob, {replace: true});
|
||||
this.progress = -1;
|
||||
}
|
||||
})
|
||||
const download = this.webdav.downloadFile(item.url);
|
||||
window.open(download, "_blank");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ import {IonicModule, IonModal, Platform, ToastController} from '@ionic/angular';
|
||||
import {MailService} from "../../api/mail.service";
|
||||
import {MailContent, MailFolder} from "../../entities/mail";
|
||||
import {marked} from "marked";
|
||||
import {HttpEventType} from "@angular/common/http";
|
||||
import {File} from "@awesome-cordova-plugins/file/ngx";
|
||||
import {saveAs} from "file-saver";
|
||||
import {MailComponent} from "../../components/mail/mail.component";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
|
||||
@@ -83,25 +80,8 @@ export class MailsPage implements OnInit {
|
||||
}
|
||||
|
||||
public async downloadAttachment(attachment: string, mailId: number) {
|
||||
this.showLoading = true;
|
||||
this.mail.downloadAttachment(mailId, attachment).subscribe(async event => {
|
||||
if (event.type == HttpEventType.Response) {
|
||||
const blob = event.body;
|
||||
const file = new File();
|
||||
|
||||
if (this.platform.is('desktop')) {
|
||||
saveAs(blob, attachment);
|
||||
this.showLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const downloadPath = (
|
||||
this.platform.is('android')
|
||||
) ? file.externalDataDirectory : file.documentsDirectory;
|
||||
await file.writeFile(downloadPath, attachment, blob, {replace: true});
|
||||
this.showLoading = false;
|
||||
}
|
||||
})
|
||||
const download = this.mail.downloadAttachment(mailId, attachment);
|
||||
window.open(download, "_blank");
|
||||
}
|
||||
|
||||
public async sendMail(receiver: string, subject: string, message: string, modal: IonModal) {
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<ion-buttons slot="start">
|
||||
<ion-button (click)="tableModal.dismiss(null, 'cancel')">Abbrechen</ion-button>
|
||||
</ion-buttons>
|
||||
<ion-title>{{currentLesson?.lesson.course || "Neue Stunde"}}</ion-title>
|
||||
<ion-title>{{currentLesson?.lesson?.course || "Neue Stunde"}}</ion-title>
|
||||
<ion-buttons slot="end">
|
||||
<ion-button (click)="tableModal.dismiss({lesson: {course: course.value, room: room.value, week: week.value}, day: day.value, time: lesson.value}, 'confirm')" [strong]="true">Fertig</ion-button>
|
||||
</ion-buttons>
|
||||
@@ -63,7 +63,7 @@
|
||||
<ion-content class="ion-padding course-content">
|
||||
<ion-item>
|
||||
<ion-label position="stacked">Kurs</ion-label>
|
||||
<ion-select aria-label="Kurs" interface="action-sheet" [value]="currentLesson?.lesson.course || courses[0].id" #course>
|
||||
<ion-select aria-label="Kurs" interface="action-sheet" [value]="currentLesson?.lesson?.course || courses[0].id" (ionChange)="room.value = getCommonCourseRoom(course.value)" #course>
|
||||
<ion-select-option *ngFor="let course of courses" [value]="course.id">
|
||||
{{course.name}}
|
||||
</ion-select-option>
|
||||
@@ -71,7 +71,7 @@
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label position="stacked">Wochentyp</ion-label>
|
||||
<ion-select aria-label="Wochentyp" interface="action-sheet" [value]="currentLesson?.lesson.week || 'all'" #week>
|
||||
<ion-select aria-label="Wochentyp" interface="action-sheet" [value]="currentLesson?.lesson?.week || 'all'" #week>
|
||||
<ion-select-option value="all">Immer</ion-select-option>
|
||||
<ion-select-option value="a">Woche A</ion-select-option>
|
||||
<ion-select-option value="b">Woche B</ion-select-option>
|
||||
@@ -79,7 +79,7 @@
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label position="stacked">Raum</ion-label>
|
||||
<ion-input aria-label="Raum" type="text" [value]="currentLesson?.lesson.room" #room/>
|
||||
<ion-input aria-label="Raum" type="text" [value]="currentLesson?.lesson?.room" #room/>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
|
||||
@@ -79,6 +79,10 @@ export class SchedulePage implements OnInit {
|
||||
}
|
||||
|
||||
if (event.detail.role == "confirm") {
|
||||
if (this.currentLesson != undefined) {
|
||||
delete this.timetable[this.currentLesson.day][this.currentLesson.time];
|
||||
}
|
||||
|
||||
const data = event.detail.data as {lesson: Lesson, day: string, time: number};
|
||||
this.timetable[data.day][data.time] = data.lesson;
|
||||
}
|
||||
@@ -87,4 +91,16 @@ export class SchedulePage implements OnInit {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
public getCommonCourseRoom(course: string): string {
|
||||
if (course == undefined) return "";
|
||||
|
||||
const rooms: string[] = [];
|
||||
for (let day of ['mon', 'tue', 'wed', 'thu', 'fri']) {
|
||||
const courseTime = this.timetable[day].filter(lesson => lesson != undefined && lesson.course == course) as Lesson[];
|
||||
rooms.push(...courseTime.map(time => time.room));
|
||||
}
|
||||
|
||||
return rooms[rooms.length - 1];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user