eror handling on connection added
|
@ -1,38 +1,31 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="gcube.workspace.starter">
|
||||||
package="gcube.workspace.starter">
|
|
||||||
|
|
||||||
<application
|
<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">
|
||||||
android:allowBackup="true"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
<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">
|
||||||
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">
|
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<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>
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<provider
|
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
|
||||||
android:name="androidx.core.content.FileProvider"
|
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
|
||||||
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>
|
</provider>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,23 @@
|
||||||
package io.ionic.starter;
|
package io.ionic.starter;
|
||||||
|
|
||||||
import com.getcapacitor.BridgeActivity;
|
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) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 988 B After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 161 KiB After Width: | Height: | Size: 69 KiB |
|
@ -1,6 +1,6 @@
|
||||||
import { Component, OnInit, Input, CUSTOM_ELEMENTS_SCHEMA, Output, EventEmitter, ElementRef, ViewChild } from '@angular/core';
|
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 { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||||
import { StoragehubService } from '../storagehub.service';
|
import { StoragehubService } from '../storagehub.service';
|
||||||
|
@ -15,6 +15,7 @@ import { Sorting, SortName, SortType } from '../model/sorting';
|
||||||
import { UploaderInfoService } from '../uploader-info.service';
|
import { UploaderInfoService } from '../uploader-info.service';
|
||||||
import { EventService } from '../event.service';
|
import { EventService } from '../event.service';
|
||||||
import { OpenFile } from '../model/actions/open-file';
|
import { OpenFile } from '../model/actions/open-file';
|
||||||
|
import { presentConnectionAlert } from '../_helper/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
|
@ -30,7 +31,7 @@ import { OpenFile } from '../model/actions/open-file';
|
||||||
export class ShowFolderComponent implements OnInit {
|
export class ShowFolderComponent implements OnInit {
|
||||||
|
|
||||||
@Output() folderClickedEvent = new EventEmitter<WSItem>();
|
@Output() folderClickedEvent = new EventEmitter<WSItem>();
|
||||||
|
|
||||||
filteredItems: WSItem[] | undefined;
|
filteredItems: WSItem[] | undefined;
|
||||||
_items: WSItem[] | undefined;
|
_items: WSItem[] | undefined;
|
||||||
|
|
||||||
|
@ -71,7 +72,8 @@ export class ShowFolderComponent implements OnInit {
|
||||||
private toastController: ToastController,
|
private toastController: ToastController,
|
||||||
private uploaderInfo: UploaderInfoService,
|
private uploaderInfo: UploaderInfoService,
|
||||||
private event: EventService,
|
private event: EventService,
|
||||||
private fileOpener: FileOpener
|
private fileOpener: FileOpener,
|
||||||
|
private loadingCtrl: LoadingController
|
||||||
) {
|
) {
|
||||||
this.underUpload = this.getUnderUploadItems();
|
this.underUpload = this.getUnderUploadItems();
|
||||||
}
|
}
|
||||||
|
@ -92,8 +94,8 @@ export class ShowFolderComponent implements OnInit {
|
||||||
loadDocuments() {
|
loadDocuments() {
|
||||||
this.filteredItems = undefined;
|
this.filteredItems = undefined;
|
||||||
if (this.parentItem) {
|
if (this.parentItem) {
|
||||||
this.storagehub.getChildren(this.parentItem.item.id).then((obs) => obs.subscribe(
|
this.storagehub.getChildren(this.parentItem.item.id).then((obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
const tmpItems$: WSItem[] = []
|
const tmpItems$: WSItem[] = []
|
||||||
const tmpFiltered$: WSItem[] = []
|
const tmpFiltered$: WSItem[] = []
|
||||||
var segmentFilterFunction = this.getSegmentFilterFunction();
|
var segmentFilterFunction = this.getSegmentFilterFunction();
|
||||||
|
@ -106,7 +108,9 @@ export class ShowFolderComponent implements OnInit {
|
||||||
this._items = tmpItems$.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
|
this._items = tmpItems$.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
|
||||||
this.filteredItems = tmpFiltered$.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
|
this.filteredItems = tmpFiltered$.sort(Sorting.getSortFunction(this.currentSortName, this.currentSortType));
|
||||||
this.underUpload = this.getUnderUploadItems();
|
this.underUpload = this.getUnderUploadItems();
|
||||||
})
|
},
|
||||||
|
error: err => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,10 +169,10 @@ export class ShowFolderComponent implements OnInit {
|
||||||
itemClicked(item: WSItem) {
|
itemClicked(item: WSItem) {
|
||||||
if (item.isFolder())
|
if (item.isFolder())
|
||||||
this.folderClickedEvent.emit(item);
|
this.folderClickedEvent.emit(item);
|
||||||
else if (item.isFile()){
|
else if (item.isFile()) {
|
||||||
new OpenFile().open(this.storagehub, this.fileOpener, item);
|
new OpenFile(item).open(this.storagehub, this.fileOpener, this.loadingCtrl, this.alertCtrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { AlertController } from '@ionic/angular';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { Item } from '../model/item.model';
|
import { Item } from '../model/item.model';
|
||||||
import { WSItem } from '../model/ws-item';
|
import { WSItem } from '../model/ws-item';
|
||||||
import { StoragehubService } from '../storagehub.service';
|
import { StoragehubService } from '../storagehub.service';
|
||||||
|
import { presentConnectionAlert } from '../_helper/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-trash',
|
selector: 'app-trash',
|
||||||
|
@ -16,22 +18,26 @@ export class TrashPage implements OnInit {
|
||||||
|
|
||||||
values: WSItem[] = [];
|
values: WSItem[] = [];
|
||||||
|
|
||||||
constructor(private storagehub: StoragehubService) { }
|
constructor(private storagehub: StoragehubService, private alertCtrl: AlertController) { }
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.storagehub.getTrashRoot().then((obs) => obs.subscribe(
|
this.storagehub.getTrashRoot().then((obs) => obs.subscribe({
|
||||||
(res) => this.onSuccess(res)
|
next: (res) => this.onSuccess(res),
|
||||||
|
error: err => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private onSuccess(res: Item) {
|
private onSuccess(res: Item) {
|
||||||
this.storagehub.getChildren(res.id, false).then((obs) => obs.subscribe(
|
this.storagehub.getChildren(res.id, false).then((obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
const tmpItems$: WSItem[] = []
|
const tmpItems$: WSItem[] = []
|
||||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||||
this.values = tmpItems$;
|
this.values = tmpItems$;
|
||||||
}
|
},
|
||||||
|
error: err => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { AlertController } from '@ionic/angular';
|
||||||
import { Item } from '../model/item.model';
|
import { Item } from '../model/item.model';
|
||||||
import { WSItem } from '../model/ws-item';
|
import { WSItem } from '../model/ws-item';
|
||||||
import { StoragehubService } from '../storagehub.service';
|
import { StoragehubService } from '../storagehub.service';
|
||||||
|
import { presentConnectionAlert } from '../_helper/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-vres',
|
selector: 'app-vres',
|
||||||
|
@ -22,7 +24,8 @@ export class VresPage implements OnInit {
|
||||||
|
|
||||||
constructor(private storagehub: StoragehubService,
|
constructor(private storagehub: StoragehubService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute) { }
|
private route: ActivatedRoute,
|
||||||
|
private alertCtrl: AlertController) { }
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -34,20 +37,24 @@ export class VresPage implements OnInit {
|
||||||
this.root = !folderId;
|
this.root = !folderId;
|
||||||
if (!tmpItem) {
|
if (!tmpItem) {
|
||||||
if (!folderId)
|
if (!folderId)
|
||||||
this.storagehub.getVres().then( (obs) => obs.subscribe(
|
this.storagehub.getVres().then((obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
const tmpItems$: WSItem[] = []
|
const tmpItems$: WSItem[] = []
|
||||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||||
this.values = tmpItems$;
|
this.values = tmpItems$;
|
||||||
}
|
},
|
||||||
));
|
error: err => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
}
|
||||||
|
))
|
||||||
else //folder is not cached
|
else //folder is not cached
|
||||||
this.storagehub.getItem(folderId).then( (obs) => obs.subscribe(
|
this.storagehub.getItem(folderId).then((obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
this.item = new WSItem(res);
|
this.item = new WSItem(res);
|
||||||
this.onSuccess(res)
|
this.onSuccess(res)
|
||||||
}
|
},
|
||||||
));
|
error: err => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.item = tmpItem;
|
this.item = tmpItem;
|
||||||
|
@ -58,12 +65,14 @@ export class VresPage implements OnInit {
|
||||||
|
|
||||||
private onSuccess(item: Item) {
|
private onSuccess(item: Item) {
|
||||||
|
|
||||||
this.storagehub.getChildren(item.id, false).then( (obs) => obs.subscribe(
|
this.storagehub.getChildren(item.id, false).then((obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
const tmpItems$: WSItem[] = []
|
const tmpItems$: WSItem[] = []
|
||||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||||
this.values = tmpItems$;
|
this.values = tmpItems$;
|
||||||
}
|
},
|
||||||
|
error: err => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
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 { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
|
||||||
import { StoragehubService } from '../storagehub.service';
|
import { StoragehubService } from '../storagehub.service';
|
||||||
import { WSItem } from '../model/ws-item';
|
import { WSItem } from '../model/ws-item';
|
||||||
import { Item } from '../model/item.model';
|
import { Item } from '../model/item.model';
|
||||||
import { concatMap, from } from 'rxjs';
|
import { presentConnectionAlert } from '../_helper/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-ws',
|
selector: 'app-ws',
|
||||||
|
@ -25,7 +24,8 @@ export class WsPage implements OnInit {
|
||||||
|
|
||||||
constructor(private storagehub: StoragehubService,
|
constructor(private storagehub: StoragehubService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute) { }
|
private route: ActivatedRoute,
|
||||||
|
private alertCtrl: AlertController) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
var folderId: string | undefined = this.route.snapshot.paramMap.get('folderId') || undefined;
|
var folderId: string | undefined = this.route.snapshot.paramMap.get('folderId') || undefined;
|
||||||
|
@ -36,19 +36,23 @@ export class WsPage implements OnInit {
|
||||||
this.root = !folderId;
|
this.root = !folderId;
|
||||||
if (!tmpItem) {
|
if (!tmpItem) {
|
||||||
if (!folderId)
|
if (!folderId)
|
||||||
this.storagehub.getWsRoot().then( (obs) => obs.subscribe(
|
this.storagehub.getWsRoot().then( (obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
this.item = new WSItem(res);
|
this.item = new WSItem(res);
|
||||||
this.onSuccess(res)
|
this.onSuccess(res)
|
||||||
}
|
},
|
||||||
));
|
error: (err) => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
}
|
||||||
|
))
|
||||||
else //folder is not cached
|
else //folder is not cached
|
||||||
this.storagehub.getItem(folderId).then( (obs) => obs.subscribe(
|
this.storagehub.getItem(folderId).then( (obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
this.item = new WSItem(res);
|
this.item = new WSItem(res);
|
||||||
this.onSuccess(res)
|
this.onSuccess(res)
|
||||||
}
|
},
|
||||||
));
|
error: err => presentConnectionAlert(err, this.alertCtrl)
|
||||||
|
}
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
this.item = tmpItem;
|
this.item = tmpItem;
|
||||||
this.onSuccess(tmpItem.item);
|
this.onSuccess(tmpItem.item);
|
||||||
|
@ -58,13 +62,15 @@ export class WsPage implements OnInit {
|
||||||
|
|
||||||
private onSuccess(item: Item) {
|
private onSuccess(item: Item) {
|
||||||
|
|
||||||
this.storagehub.getChildren(item.id, false).then( (obs) => obs.subscribe(
|
this.storagehub.getChildren(item.id, false).then( (obs) => obs.subscribe({
|
||||||
(res) => {
|
next: (res) => {
|
||||||
const tmpItems$: WSItem[] = []
|
const tmpItems$: WSItem[] = []
|
||||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||||
this.values = tmpItems$;
|
this.values = tmpItems$;
|
||||||
}
|
},
|
||||||
))
|
error: (err) => presentConnectionAlert(err, this.alertCtrl),
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public getValues(): WSItem[] | undefined {
|
public getValues(): WSItem[] | undefined {
|
||||||
|
@ -85,4 +91,5 @@ export class WsPage implements OnInit {
|
||||||
getTitle() {
|
getTitle() {
|
||||||
return this.root ? "My Workspace" : this.item?.getTitle()
|
return this.root ? "My Workspace" : this.item?.getTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|