added proxy
This commit is contained in:
parent
49cca47038
commit
86b7c21ebb
|
@ -72,6 +72,10 @@
|
|||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "app:build",
|
||||
"proxyConfig": "src/proxy.conf.json"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "app:build:production"
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
import { AlertOptions } from "@ionic/angular";
|
||||
import { title } from "process";
|
||||
import { StoragehubService } from "../storagehub.service";
|
||||
import { Item } from "./item.model";
|
||||
import { WSItem } from "./ws-item";
|
||||
|
||||
export interface Action {
|
||||
|
||||
getAlertOptions(item: WSItem, storagehub: StoragehubService): AlertOptions;
|
||||
|
||||
actionHandler(data: any, storagehub: StoragehubService): any;
|
||||
|
||||
getName(): string;
|
||||
|
||||
getActionType(): string | undefined;
|
||||
|
||||
mustReload(): boolean;
|
||||
}
|
||||
|
||||
export class DeleteAction implements Action {
|
||||
|
||||
getAlertOptions(item: WSItem, storagehub: StoragehubService): AlertOptions {
|
||||
var title = item.getTitle();
|
||||
var options: AlertOptions = {
|
||||
header: `Are you sure to delete item ${title} ?`,
|
||||
buttons: [{
|
||||
text: 'No',
|
||||
role: 'cancel'
|
||||
},
|
||||
{
|
||||
text: 'Yes',
|
||||
handler: () => {
|
||||
this.actionHandler(item, storagehub);
|
||||
}
|
||||
}]
|
||||
};
|
||||
return options;
|
||||
|
||||
}
|
||||
actionHandler(data: WSItem, storagehub: StoragehubService) {
|
||||
storagehub.deleteItem(data.item.id).subscribe((res) =>console.log(`item ${data.getTitle()} deleted`) );
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
return "Delete";
|
||||
}
|
||||
getActionType(): string | undefined {
|
||||
return "destructive";
|
||||
}
|
||||
|
||||
mustReload(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class Actions {
|
||||
|
||||
private static actions: Action[] = [new DeleteAction()];
|
||||
public static getActionsPerType(type: string): Action[] {
|
||||
/*switch (type) {
|
||||
case 'SharedFolder':
|
||||
break;
|
||||
case 'FolderItem':
|
||||
break;
|
||||
case 'PDFFileItem':
|
||||
break;
|
||||
case 'ImageFile':
|
||||
break;
|
||||
case 'ExternalLink':
|
||||
break;
|
||||
default:
|
||||
}*/
|
||||
return Actions.actions;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
import { StoragehubService } from "../storagehub.service";
|
||||
import { Action, Actions } from "./actions";
|
||||
import { Item } from "./item.model";
|
||||
|
||||
export class WSItem {
|
||||
|
||||
item: Item;
|
||||
storagehubService: StoragehubService;
|
||||
type: string;
|
||||
|
||||
constructor(item: Item, storagehubService: StoragehubService) {
|
||||
constructor(item: Item) {
|
||||
this.item = item;
|
||||
this.storagehubService = storagehubService;
|
||||
const tempType$ = this.getType(item);
|
||||
this.type = tempType$ ? tempType$ :"";
|
||||
}
|
||||
|
@ -52,36 +51,6 @@ export class WSItem {
|
|||
return this.item.vreFolder? this.item.displayName: this.item.title;
|
||||
}
|
||||
|
||||
|
||||
getActions(): Action[] {
|
||||
return Actions.getActionsPerType(this.type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface Action {
|
||||
|
||||
execute(): void;
|
||||
getName(): string;
|
||||
}
|
||||
|
||||
class Actions{
|
||||
public static getActionsPerType(type:string): Action[] {
|
||||
let actions: Action[] = [];
|
||||
/*switch (type) {
|
||||
case 'SharedFolder':
|
||||
break;
|
||||
case 'FolderItem':
|
||||
break;
|
||||
case 'PDFFileItem':
|
||||
break;
|
||||
case 'ImageFile':
|
||||
break;
|
||||
case 'ExternalLink':
|
||||
break;
|
||||
default:
|
||||
}*/
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</ion-text>
|
||||
|
||||
<ion-list>
|
||||
<ion-item *ngFor="let i of wsItems">
|
||||
<ion-item *ngFor="let i of items">
|
||||
<mat-icon slot="start">{{ i.getIconInfo() }}</mat-icon>
|
||||
<ion-label text-wrap (click)="itemClicked(i)">
|
||||
{{ i.getTitle() }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, OnInit, Input, CUSTOM_ELEMENTS_SCHEMA, Output, EventEmitter, ElementRef, ViewChild } from '@angular/core';
|
||||
|
||||
import { Platform, AlertController, ToastController, IonicModule, ActionSheetController, ActionSheetButton } from '@ionic/angular';
|
||||
import { Platform, AlertController, ToastController, IonicModule, ActionSheetController, ActionSheetButton, AlertOptions } from '@ionic/angular';
|
||||
|
||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
@ -10,6 +10,7 @@ import { CommonModule } from '@angular/common';
|
|||
import { Item } from '../model/item.model';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { WSItem } from '../model/ws-item';
|
||||
import { Action, Actions } from '../model/actions';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
|
@ -24,11 +25,9 @@ import { WSItem } from '../model/ws-item';
|
|||
})
|
||||
export class ShowFolderComponent implements OnInit {
|
||||
|
||||
@Output() folderClickedEvent = new EventEmitter<Item>();
|
||||
@Output() folderClickedEvent = new EventEmitter<WSItem>();
|
||||
|
||||
@Input() items: Item[] = [];
|
||||
|
||||
wsItems: WSItem[] = [];
|
||||
@Input() items: WSItem[] = [];
|
||||
|
||||
@Input() parentItem: WSItem | undefined;
|
||||
|
||||
|
@ -45,23 +44,22 @@ export class ShowFolderComponent implements OnInit {
|
|||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.items.forEach(i => this.wsItems.push(new WSItem(i, this.storagehub)) );
|
||||
}
|
||||
|
||||
loadDocuments() {
|
||||
console.log("loadDoc called");
|
||||
if (this.parentItem)
|
||||
this.storagehub.getChildren(this.parentItem.item.id, false).subscribe(
|
||||
(res) => {
|
||||
this.items = res;
|
||||
this.items.forEach(i => this.wsItems.push(new WSItem(i, this.storagehub)) );
|
||||
const tmpItems$ : WSItem[] = []
|
||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||
this.items = tmpItems$;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
itemClicked(item: WSItem) {
|
||||
if (item.isFolder()) {
|
||||
this.folderClickedEvent.emit(item.item);
|
||||
this.folderClickedEvent.emit(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +81,7 @@ export class ShowFolderComponent implements OnInit {
|
|||
}
|
||||
|
||||
async createFolder() {
|
||||
let alert = await this.alertCtrl.create({
|
||||
this.presentAlertControl({
|
||||
header: 'Create folder',
|
||||
message: 'Please specify the name of the new folder',
|
||||
inputs: [
|
||||
|
@ -111,18 +109,17 @@ export class ShowFolderComponent implements OnInit {
|
|||
}
|
||||
]
|
||||
});
|
||||
await alert.present();
|
||||
}
|
||||
|
||||
async presentActionSheet(item: WSItem) {
|
||||
|
||||
var buttons :ActionSheetButton<any>[] = [];
|
||||
item.getActions().forEach( action => buttons.push({
|
||||
text: action.name,
|
||||
Actions.getActionsPerType(item.type).forEach( action => buttons.push({
|
||||
text: action.getName(),
|
||||
data: {
|
||||
action: action.name,
|
||||
action: action.getName(),
|
||||
},
|
||||
handler: () => action.execute()
|
||||
role: action.getActionType(),
|
||||
handler: () => this.actionHandler(action, item)
|
||||
}));
|
||||
|
||||
buttons.push({
|
||||
|
@ -143,8 +140,20 @@ export class ShowFolderComponent implements OnInit {
|
|||
});
|
||||
|
||||
await actionSheet.present();
|
||||
|
||||
const result = await actionSheet.onDidDismiss();
|
||||
}
|
||||
|
||||
async presentAlertControl(options: AlertOptions){
|
||||
let alert = await this.alertCtrl.create(options);
|
||||
await alert.present();
|
||||
}
|
||||
|
||||
async actionHandler(action: Action, item: WSItem){
|
||||
var options: AlertOptions = action.getAlertOptions(item, this.storagehub);
|
||||
if (options){
|
||||
await this.presentAlertControl(options);
|
||||
}else
|
||||
await action.actionHandler(item, this.storagehub);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ItemWrapper } from './model/item-wrapper.model';
|
|||
|
||||
|
||||
const token = "b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548";
|
||||
const shURL = "https://workspace-repository.dev.d4science.org/storagehub/workspace/";
|
||||
const shURL = "/shub/storagehub/workspace";
|
||||
|
||||
|
||||
@Injectable()
|
||||
|
@ -28,7 +28,7 @@ export class StoragehubService {
|
|||
}
|
||||
|
||||
getTrashRoot(): Observable<Item> {
|
||||
const getTrashURL = `${shURL}trash/?gcube-token=${token}&exclude=hl:accounting`;
|
||||
const getTrashURL = `${shURL}/trash/?gcube-token=${token}&exclude=hl:accounting`;
|
||||
return this.http.get<ItemWrapper>(getTrashURL, {observe: "body", responseType: "json"}).pipe(
|
||||
map(value => value.item),
|
||||
catchError(this.error)
|
||||
|
@ -36,7 +36,7 @@ export class StoragehubService {
|
|||
}
|
||||
|
||||
getVres(): Observable<Item[]> {
|
||||
const getVresURL = `${shURL}vrefolders/?gcube-token=${token}&exclude=hl:accounting`;
|
||||
const getVresURL = `${shURL}/vrefolders/?gcube-token=${token}&exclude=hl:accounting`;
|
||||
return this.http.get<ItemList>(getVresURL, {observe: 'body', responseType: 'json'}).pipe(
|
||||
map(value => value.itemlist),
|
||||
catchError(this.error)
|
||||
|
@ -44,7 +44,7 @@ export class StoragehubService {
|
|||
}
|
||||
|
||||
getItem(id: string): Observable<Item> {
|
||||
const getWsURL = `${shURL}items/${id}?gcube-token=${token}&exclude=hl:accounting`;
|
||||
const getWsURL = `${shURL}/items/${id}?gcube-token=${token}&exclude=hl:accounting`;
|
||||
return this.http.get<ItemWrapper>(getWsURL, {observe: 'body', responseType: 'json'}).pipe(
|
||||
map(value => value.item),
|
||||
catchError(this.error)
|
||||
|
@ -52,7 +52,7 @@ export class StoragehubService {
|
|||
}
|
||||
|
||||
getChildren(id:string, onlyFolder?:boolean): Observable<Item[]>{
|
||||
let getWsURL = `${shURL}items/${id}/children?gcube-token=${token}&exclude=hl:accounting`;
|
||||
let getWsURL = `${shURL}/items/${id}/children?gcube-token=${token}&exclude=hl:accounting`;
|
||||
if (onlyFolder)
|
||||
getWsURL += '&onlyType=nthl:workspaceItem';
|
||||
return this.http.get<ItemList>(getWsURL).pipe(
|
||||
|
@ -62,7 +62,7 @@ export class StoragehubService {
|
|||
}
|
||||
|
||||
getAnchestor(id:string): Observable<Item[]>{
|
||||
let getWsURL = `${shURL}items/${id}/ancherstors?gcube-token=${token}&exclude=hl:accounting`;
|
||||
let getWsURL = `${shURL}/items/${id}/ancherstors?gcube-token=${token}&exclude=hl:accounting`;
|
||||
console.log("ws children "+getWsURL);
|
||||
return this.http.get<ItemList>(getWsURL, {observe: 'body', responseType: 'json'}).pipe(
|
||||
map(value => value.itemlist),
|
||||
|
@ -71,7 +71,7 @@ export class StoragehubService {
|
|||
}
|
||||
|
||||
uploadFile(parentId: string, name: string, file: File){
|
||||
let uploadURL = `${shURL}items/${parentId}/create/FILE?gcube-token=${token}`;
|
||||
let uploadURL = `${shURL}/items/${parentId}/create/FILE?gcube-token=${token}`;
|
||||
const formData = new FormData();
|
||||
formData.append("name", name);
|
||||
formData.append("description", "");
|
||||
|
@ -82,7 +82,7 @@ export class StoragehubService {
|
|||
}
|
||||
|
||||
createFolder(parentId: string, name: string, description: string) : Observable<any> {
|
||||
let createFolderURL = `${shURL}items/${parentId}/create/FOLDER?gcube-token=${token}`;
|
||||
let createFolderURL = `${shURL}/items/${parentId}/create/FOLDER?gcube-token=${token}`;
|
||||
const formData = new FormData();
|
||||
let body = `name=${name}&description=${description}`;
|
||||
return this.http.post(createFolderURL, body, {observe: 'body', responseType: 'text' , headers: { 'Content-Type' : 'application/x-www-form-urlencoded' }}).pipe(
|
||||
|
@ -90,6 +90,14 @@ export class StoragehubService {
|
|||
);
|
||||
}
|
||||
|
||||
deleteItem(itemId: string) : Observable<any> {
|
||||
let deleteItemUrl = `${shURL}/items/${itemId}?gcube-token=${token}`;
|
||||
console.log("delete item done with url "+deleteItemUrl);
|
||||
return this.http.delete( deleteItemUrl).pipe(
|
||||
catchError(this.error)
|
||||
);
|
||||
}
|
||||
|
||||
error(error: HttpErrorResponse) {
|
||||
let errorMessage = '';
|
||||
if (error.error instanceof ErrorEvent) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { Item } from '../model/item.model';
|
||||
import { WSItem } from '../model/ws-item';
|
||||
import { StoragehubService } from '../storagehub.service';
|
||||
|
||||
@Component({
|
||||
|
@ -13,7 +14,7 @@ import { StoragehubService } from '../storagehub.service';
|
|||
|
||||
export class TrashPage implements OnInit {
|
||||
|
||||
values: Item[] = [];
|
||||
values: WSItem[] = [];
|
||||
|
||||
constructor(private storagehub: StoragehubService) { }
|
||||
|
||||
|
@ -26,11 +27,15 @@ export class TrashPage implements OnInit {
|
|||
|
||||
private onSuccess(res: Item) {
|
||||
this.storagehub.getChildren(res.id, false).subscribe(
|
||||
(res) => this.values = res
|
||||
(res) => {
|
||||
const tmpItems$ : WSItem[] = []
|
||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||
this.values = tmpItems$;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public getValues(): Item[] {
|
||||
public getValues(): WSItem[] {
|
||||
return this.values;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ import { StoragehubService } from '../storagehub.service';
|
|||
})
|
||||
export class VresPage implements OnInit {
|
||||
|
||||
values: Item[] = [];
|
||||
values: WSItem[] = [];
|
||||
|
||||
item: Item | undefined;
|
||||
item: WSItem | undefined;
|
||||
|
||||
folderid: string | undefined;
|
||||
|
||||
|
@ -27,12 +27,16 @@ export class VresPage implements OnInit {
|
|||
this.folderid = this.route.snapshot.paramMap.get('folderid') || undefined;
|
||||
if (!this.folderid)
|
||||
this.storagehub.getVres().subscribe(
|
||||
(res) => this.values = res
|
||||
(res) => {
|
||||
const tmpItems$ : WSItem[] = []
|
||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||
this.values = tmpItems$;
|
||||
}
|
||||
);
|
||||
else
|
||||
this.storagehub.getItem(this.folderid).subscribe(
|
||||
(res) => {
|
||||
this.item = res;
|
||||
this.item = new WSItem(res);
|
||||
this.onSuccess(res);
|
||||
}
|
||||
);
|
||||
|
@ -42,21 +46,23 @@ export class VresPage implements OnInit {
|
|||
private onSuccess(item: Item) {
|
||||
|
||||
this.storagehub.getChildren(item.id, false).subscribe(
|
||||
(res) => this.values = res
|
||||
(res) => {
|
||||
const tmpItems$ : WSItem[] = []
|
||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||
this.values = tmpItems$;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public getValues(): Item[] {
|
||||
public getValues(): WSItem[] {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
openFolder(item: Item) {
|
||||
this.router.navigateByUrl(`tabs/vres/${item.id}`);
|
||||
openFolder(item: WSItem) {
|
||||
this.router.navigateByUrl(`tabs/vres/${item.item.id}`);
|
||||
}
|
||||
|
||||
public getCurrentItem(): WSItem | undefined{
|
||||
if (this.item)
|
||||
return new WSItem(this.item, this.storagehub);
|
||||
return undefined;
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ import { Component, OnInit } from '@angular/core';
|
|||
import { Platform, AlertController, ToastController } from '@ionic/angular';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { Item } from '../model/item.model';
|
||||
import { StoragehubService } from '../storagehub.service';
|
||||
import { WSItem } from '../model/ws-item';
|
||||
import { Item } from '../model/item.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ws',
|
||||
|
@ -14,11 +14,11 @@ import { WSItem } from '../model/ws-item';
|
|||
})
|
||||
export class WsPage implements OnInit {
|
||||
|
||||
values: Item[] = [];
|
||||
values: WSItem[] = [];
|
||||
|
||||
folderid: string | undefined;
|
||||
|
||||
item : Item | undefined ;
|
||||
item : WSItem | undefined ;
|
||||
|
||||
constructor(private storagehub: StoragehubService,
|
||||
private router: Router,
|
||||
|
@ -33,7 +33,7 @@ export class WsPage implements OnInit {
|
|||
else
|
||||
this.storagehub.getItem(this.folderid).subscribe(
|
||||
(res) => {
|
||||
this.item = res;
|
||||
this.item = new WSItem(res);
|
||||
this.onSuccess(res);
|
||||
}
|
||||
);
|
||||
|
@ -42,21 +42,23 @@ export class WsPage implements OnInit {
|
|||
private onSuccess(item: Item) {
|
||||
|
||||
this.storagehub.getChildren(item.id, false).subscribe(
|
||||
(res) => this.values = res
|
||||
(res) => {
|
||||
const tmpItems$ : WSItem[] = []
|
||||
res.forEach(i => tmpItems$.push(new WSItem(i)));
|
||||
this.values = tmpItems$;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public getValues(): Item[] {
|
||||
return this.values;
|
||||
public getValues(): WSItem[] {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
openFolder(item: Item) {
|
||||
this.router.navigateByUrl(`tabs/ws/${item.id}`);
|
||||
openFolder(item: WSItem) {
|
||||
this.router.navigateByUrl(`tabs/ws/${item.item.id}`);
|
||||
}
|
||||
|
||||
public getCurrentItem() : WSItem | undefined{
|
||||
if (this.item)
|
||||
return new WSItem(this.item, this.storagehub);
|
||||
return undefined;
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"/shub": {
|
||||
"target": "https://workspace-repository.dev.d4science.org",
|
||||
"secure": "true",
|
||||
"changeOrigin": "true",
|
||||
"logLevel": "debug",
|
||||
"pathRewrite": {"^/shub" : ""}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue