eror handling on connection added

This commit is contained in:
Lucio Lelii 2023-03-14 15:56:50 +01:00
parent 2dbe90945c
commit f1713b05a8
73 changed files with 105 additions and 68 deletions

View File

@ -1,38 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gcube.workspace.starter">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="gcube.workspace.starter">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:name="io.ionic.starter.MainActivity" android:label="@string/title_activity_main" android:theme="@style/AppTheme.NoActionBarLaunch" android:launchMode="singleTask" android:exported="true">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="io.ionic.starter.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
<data android:mimeType="image/*" />
<data android:mimeType="application/pdf" />
<data android:mimeType="application/msword" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.presentation" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
</provider>
</application>

View File

@ -1,5 +1,23 @@
package io.ionic.starter;
import com.getcapacitor.BridgeActivity;
import android.content.Intent;
import android.webkit.ValueCallback;
public class MainActivity extends BridgeActivity {}
public class MainActivity extends BridgeActivity {
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) /*|| Intent.ACTION_SEND_MULTIPLE.equals(action))*/ && type != null) {
bridge.getActivity().setIntent(intent);
bridge.eval("window.dispatchEvent(new Event('sendIntentReceived'))", new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
}
});
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 988 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -1,6 +1,6 @@
import { Component, OnInit, Input, CUSTOM_ELEMENTS_SCHEMA, Output, EventEmitter, ElementRef, ViewChild } from '@angular/core';
import { AlertController, ToastController, IonicModule, ActionSheetController, ActionSheetButton, AlertOptions, ModalController, ModalOptions } from '@ionic/angular';
import { AlertController, ToastController, IonicModule, ActionSheetController, ActionSheetButton, AlertOptions, ModalController, ModalOptions, LoadingController } from '@ionic/angular';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { StoragehubService } from '../storagehub.service';
@ -15,6 +15,7 @@ import { Sorting, SortName, SortType } from '../model/sorting';
import { UploaderInfoService } from '../uploader-info.service';
import { EventService } from '../event.service';
import { OpenFile } from '../model/actions/open-file';
import { presentConnectionAlert } from '../_helper/utils';
@Component({
standalone: true,
@ -30,7 +31,7 @@ import { OpenFile } from '../model/actions/open-file';
export class ShowFolderComponent implements OnInit {
@Output() folderClickedEvent = new EventEmitter<WSItem>();
filteredItems: WSItem[] | undefined;
_items: WSItem[] | undefined;
@ -71,7 +72,8 @@ export class ShowFolderComponent implements OnInit {
private toastController: ToastController,
private uploaderInfo: UploaderInfoService,
private event: EventService,
private fileOpener: FileOpener
private fileOpener: FileOpener,
private loadingCtrl: LoadingController
) {
this.underUpload = this.getUnderUploadItems();
}
@ -92,8 +94,8 @@ export class ShowFolderComponent implements OnInit {
loadDocuments() {
this.filteredItems = undefined;
if (this.parentItem) {
this.storagehub.getChildren(this.parentItem.item.id).then((obs) => obs.subscribe(
(res) => {
this.storagehub.getChildren(this.parentItem.item.id).then((obs) => obs.subscribe({
next: (res) => {
const tmpItems$: WSItem[] = []
const tmpFiltered$: WSItem[] = []
var segmentFilterFunction = this.getSegmentFilterFunction();
@ -106,7 +108,9 @@ export class ShowFolderComponent implements OnInit {
this._items = tmpItems$.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
this.filteredItems = tmpFiltered$.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
this.underUpload = this.getUnderUploadItems();
})
},
error: err => presentConnectionAlert(err, this.alertCtrl)
})
)
}
}
@ -165,10 +169,10 @@ export class ShowFolderComponent implements OnInit {
itemClicked(item: WSItem) {
if (item.isFolder())
this.folderClickedEvent.emit(item);
else if (item.isFile()){
new OpenFile().open(this.storagehub, this.fileOpener, item);
else if (item.isFile()) {
new OpenFile(item).open(this.storagehub, this.fileOpener, this.loadingCtrl, this.alertCtrl);
}
}

View File

@ -1,8 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { AlertController } from '@ionic/angular';
import { lastValueFrom } from 'rxjs';
import { Item } from '../model/item.model';
import { WSItem } from '../model/ws-item';
import { StoragehubService } from '../storagehub.service';
import { presentConnectionAlert } from '../_helper/utils';
@Component({
selector: 'app-trash',
@ -16,22 +18,26 @@ export class TrashPage implements OnInit {
values: WSItem[] = [];
constructor(private storagehub: StoragehubService) { }
constructor(private storagehub: StoragehubService, private alertCtrl: AlertController) { }
ngOnInit() {
this.storagehub.getTrashRoot().then((obs) => obs.subscribe(
(res) => this.onSuccess(res)
this.storagehub.getTrashRoot().then((obs) => obs.subscribe({
next: (res) => this.onSuccess(res),
error: err => presentConnectionAlert(err, this.alertCtrl)
}
));
}
private onSuccess(res: Item) {
this.storagehub.getChildren(res.id, false).then((obs) => obs.subscribe(
(res) => {
this.storagehub.getChildren(res.id, false).then((obs) => obs.subscribe({
next: (res) => {
const tmpItems$: WSItem[] = []
res.forEach(i => tmpItems$.push(new WSItem(i)));
this.values = tmpItems$;
}
},
error: err => presentConnectionAlert(err, this.alertCtrl)
}
))
}

View File

@ -1,8 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AlertController } from '@ionic/angular';
import { Item } from '../model/item.model';
import { WSItem } from '../model/ws-item';
import { StoragehubService } from '../storagehub.service';
import { presentConnectionAlert } from '../_helper/utils';
@Component({
selector: 'app-vres',
@ -22,7 +24,8 @@ export class VresPage implements OnInit {
constructor(private storagehub: StoragehubService,
private router: Router,
private route: ActivatedRoute) { }
private route: ActivatedRoute,
private alertCtrl: AlertController) { }
ngOnInit() {
@ -34,20 +37,24 @@ export class VresPage implements OnInit {
this.root = !folderId;
if (!tmpItem) {
if (!folderId)
this.storagehub.getVres().then( (obs) => obs.subscribe(
(res) => {
this.storagehub.getVres().then((obs) => obs.subscribe({
next: (res) => {
const tmpItems$: WSItem[] = []
res.forEach(i => tmpItems$.push(new WSItem(i)));
this.values = tmpItems$;
}
));
},
error: err => presentConnectionAlert(err, this.alertCtrl)
}
))
else //folder is not cached
this.storagehub.getItem(folderId).then( (obs) => obs.subscribe(
(res) => {
this.storagehub.getItem(folderId).then((obs) => obs.subscribe({
next: (res) => {
this.item = new WSItem(res);
this.onSuccess(res)
}
));
},
error: err => presentConnectionAlert(err, this.alertCtrl)
}
))
} else {
this.item = tmpItem;
@ -58,12 +65,14 @@ export class VresPage implements OnInit {
private onSuccess(item: Item) {
this.storagehub.getChildren(item.id, false).then( (obs) => obs.subscribe(
(res) => {
this.storagehub.getChildren(item.id, false).then((obs) => obs.subscribe({
next: (res) => {
const tmpItems$: WSItem[] = []
res.forEach(i => tmpItems$.push(new WSItem(i)));
this.values = tmpItems$;
}
},
error: err => presentConnectionAlert(err, this.alertCtrl)
}
))
}

View File

@ -1,11 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { Platform, AlertController, ToastController } from '@ionic/angular';
import { AlertController} from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { StoragehubService } from '../storagehub.service';
import { WSItem } from '../model/ws-item';
import { Item } from '../model/item.model';
import { concatMap, from } from 'rxjs';
import { presentConnectionAlert } from '../_helper/utils';
@Component({
selector: 'app-ws',
@ -25,7 +24,8 @@ export class WsPage implements OnInit {
constructor(private storagehub: StoragehubService,
private router: Router,
private route: ActivatedRoute) { }
private route: ActivatedRoute,
private alertCtrl: AlertController) { }
ngOnInit() {
var folderId: string | undefined = this.route.snapshot.paramMap.get('folderId') || undefined;
@ -36,19 +36,23 @@ export class WsPage implements OnInit {
this.root = !folderId;
if (!tmpItem) {
if (!folderId)
this.storagehub.getWsRoot().then( (obs) => obs.subscribe(
(res) => {
this.storagehub.getWsRoot().then( (obs) => obs.subscribe({
next: (res) => {
this.item = new WSItem(res);
this.onSuccess(res)
}
));
},
error: (err) => presentConnectionAlert(err, this.alertCtrl)
}
))
else //folder is not cached
this.storagehub.getItem(folderId).then( (obs) => obs.subscribe(
(res) => {
this.storagehub.getItem(folderId).then( (obs) => obs.subscribe({
next: (res) => {
this.item = new WSItem(res);
this.onSuccess(res)
}
));
},
error: err => presentConnectionAlert(err, this.alertCtrl)
}
))
} else {
this.item = tmpItem;
this.onSuccess(tmpItem.item);
@ -58,13 +62,15 @@ export class WsPage implements OnInit {
private onSuccess(item: Item) {
this.storagehub.getChildren(item.id, false).then( (obs) => obs.subscribe(
(res) => {
this.storagehub.getChildren(item.id, false).then( (obs) => obs.subscribe({
next: (res) => {
const tmpItems$: WSItem[] = []
res.forEach(i => tmpItems$.push(new WSItem(i)));
this.values = tmpItems$;
}
))
},
error: (err) => presentConnectionAlert(err, this.alertCtrl),
})
)
}
public getValues(): WSItem[] | undefined {
@ -85,4 +91,5 @@ export class WsPage implements OnInit {
getTitle() {
return this.root ? "My Workspace" : this.item?.getTitle()
}
}