diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts deleted file mode 100644 index 5425ef7fb02a8d37f149954b0190b86ffe761b7e..0000000000000000000000000000000000000000 --- a/src/app/core/core.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; - -@NgModule({ - declarations: [], - imports: [ - CommonModule - ] -}) -export class CoreModule { } diff --git a/src/app/core/services/electron/electron.service.spec.ts b/src/app/core/services/electron/electron.service.spec.ts deleted file mode 100644 index 38fe2f0eefa66a3d9b9124995967b807bf3b8cdb..0000000000000000000000000000000000000000 --- a/src/app/core/services/electron/electron.service.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { ElectronService } from './electron.service'; - -describe('ElectronService', () => { - beforeEach(() => TestBed.configureTestingModule({})); - - it('should be created', () => { - const service: ElectronService = TestBed.get(ElectronService); - expect(service).toBeTruthy(); - }); -}); diff --git a/src/app/core/services/electron/electron.service.ts b/src/app/core/services/electron/electron.service.ts deleted file mode 100644 index 7dc81e8001d9bf27f4dddca2aa902dac9ef72882..0000000000000000000000000000000000000000 --- a/src/app/core/services/electron/electron.service.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Injectable } from '@angular/core'; - -// If you import a module but never use any of the imported values other than as TypeScript types, -// the resulting javascript file will look as if you never imported the module at all. -import { ipcRenderer, webFrame, remote } from 'electron'; -import * as childProcess from 'child_process'; -import * as fs from 'fs'; - -@Injectable({ - providedIn: 'root' -}) -export class ElectronService { - ipcRenderer: typeof ipcRenderer; - webFrame: typeof webFrame; - remote: typeof remote; - childProcess: typeof childProcess; - fs: typeof fs; - - get isElectron(): boolean { - return !!(window && window.process && window.process.type); - } - - constructor() { - // Conditional imports - if (this.isElectron) { - this.ipcRenderer = window.require('electron').ipcRenderer; - this.webFrame = window.require('electron').webFrame; - - // If you wan to use remote object, pleanse set enableRemoteModule to true in main.ts - // this.remote = window.require('electron').remote; - - this.childProcess = window.require('child_process'); - this.fs = window.require('fs'); - } - } -} diff --git a/src/app/core/services/index.ts b/src/app/core/services/index.ts deleted file mode 100644 index 8102c5af9c4f9f44b1748659020538c8779bfc5d..0000000000000000000000000000000000000000 --- a/src/app/core/services/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './electron/electron.service'; diff --git a/src/app/file-explorer/CREDIT b/src/app/file-explorer/CREDIT deleted file mode 100644 index e6c57007844110150f52195c1307c563d6abbf38..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/CREDIT +++ /dev/null @@ -1 +0,0 @@ -With credit to https://github.com/LukasMarx/angular-file-manager diff --git a/src/app/file-explorer/file-explorer.component.css b/src/app/file-explorer/file-explorer.component.css deleted file mode 100644 index 0c8f53a653bac3f2e03276db15b3506e85151964..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/file-explorer.component.css +++ /dev/null @@ -1,37 +0,0 @@ -/*:host { - height: 100%; - display: flex; - flex-direction: column; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -}*/ - -/*.file-or-folder { - padding: 8px; - overflow: hidden; -} - -.file-or-folder-icon { - width: 50px; - height: 50px; - font-size: 50px; -} - -.pointer { - cursor: pointer; -} - -.spacer { - flex: 1 1 auto; -} -.file-table { - height: 400px; -} - -.basic-container { - height: 400px; -}*/ diff --git a/src/app/file-explorer/file-explorer.component.html b/src/app/file-explorer/file-explorer.component.html deleted file mode 100644 index 349d76a0272631c2b376725869658d06a79b8850..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/file-explorer.component.html +++ /dev/null @@ -1,139 +0,0 @@ -<!-- -<mat-toolbar> - <mat-icon *ngIf="canNavigateUp" class="pointer" (click)="navigateUp()">arrow_upwards</mat-icon> - <span style="margin-left: 8px">{{path || 'Files'}}</span> - <span class="spacer"></span> -</mat-toolbar> --> - - -<!-- <div class="container" fxFlex fxLayout="row" fxLayoutAlign="space-between stretch"> --> - <!-- <div class="content" fxFlex fxLayout="row"> --> - <!-- <mat-grid-list cols="4" rowHeight="100px" fxFlex> - <mat-grid-tile *ngFor="let element of fileElements" class=file-or-folder> - <span [matMenuTriggerFor]="rootMenu" [matMenuTriggerData]="{element: element}" #menuTrigger="matMenuTrigger"></span> - <div fxLayout="column" fxLayoutAlign="space-between center" (click)="navigate(element)" (contextmenu)="openMenu($event, menuTrigger)"> - <mat-icon color="primary" class="file-or-folder-icon pointer" *ngIf="element.isFolder">folder</mat-icon> - <mat-icon color="primary" class="file-or-folder-icon pointer" *ngIf="!element.isFolder">insert_drive_file</mat-icon> - <span>{{element.name}}</span> - </div> - </mat-grid-tile> - </mat-grid-list> --> - - - <!-- <cdk-virtual-scroll-viewport itemSize="50px" style="height: 400px"> --> - <!-- <cdk-virtual-scroll-viewport itemSize="50px"> - - <div *cdkVirtualFor="let element of fileElements"> - <div fxFlex="row"> - <div fxFlex="10%"> - <mat-icon *ngIf="element.isFolder">folder</mat-icon> - <mat-icon *ngIf="!element.isFolder">insert_drive_file</mat-icon> - </div> - <div fxFlex> - {{ element.name }} - </div> - <div fxFlex="10%"> - {{ element.size }} - </div> - </div> - </div> - </cdk-virtual-scroll-viewport> --> - - - <table mat-table [dataSource]="fileElements" style="width: 100%; height: 100%; overflow-y: scroll"> - <ng-container matColumnDef="icon"> - <th mat-header-cell *matHeaderCellDef></th> - <td mat-cell *matCellDef="let element" (contextmenu)="onContextMenu($event, element)"> - <mat-icon *ngIf="element.isFolder">folder</mat-icon> - <mat-icon *ngIf="!element.isFolder">insert_drive_file</mat-icon> - <div style="position: fixed" - [style.left]="contextMenuPosition.x" - [style.top]="contextMenuPosition.y" - [matMenuTriggerFor]="contextMenu" - [matMenuTriggerData]="{element: element}"> - </div> - </td> - </ng-container> - <ng-container matColumnDef="name"> - <th mat-header-cell *matHeaderCellDef>Name</th> - <td mat-cell *matCellDef="let element" (contextmenu)="onContextMenu($event, element)"> - {{ element.name }} - <div style="position: fixed" - [style.left]="contextMenuPosition.x" - [style.top]="contextMenuPosition.y" - [matMenuTriggerFor]="contextMenu" - [matMenuTriggerData]="{element: element}"> - </div> - </td> - </ng-container> - <ng-container matColumnDef="size"> - <th mat-header-cell *matHeaderCellDef>Size</th> - <td mat-cell *matCellDef="let element" (contextmenu)="onContextMenu($event, element)"> - {{ element.size }} - <div style="position: fixed" - [style.left]="contextMenuPosition.x" - [style.top]="contextMenuPosition.y" - [matMenuTriggerFor]="contextMenu" - [matMenuTriggerData]="{element: element}"> - </div> - </td> - </ng-container> - <ng-container matColumnDef="online"> - <th mat-header-cell *matHeaderCellDef>Online</th> - <td mat-cell *matCellDef="let element" (contextmenu)="onContextMenu($event, element)"> - <div *ngIf="element.online !== undefined"> - <mat-icon *ngIf="element.online">check</mat-icon> - <mat-icon *ngIf="!element.online">close</mat-icon> - </div> - <div style="position: fixed" - [style.left]="contextMenuPosition.x" - [style.top]="contextMenuPosition.y" - [matMenuTriggerFor]="contextMenu" - [matMenuTriggerData]="{element: element}"> - </div> - </td> - </ng-container> - <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr> - <tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="navigate(row)"></tr> -<mat-menu #contextMenu="matMenu" [overlapTrigger]="false"> - <ng-template matMenuContent let-element="element"> - <!-- <button mat-menu-item [matMenuTriggerFor]="moveToMenu" [matMenuTriggerData]="{self: element}"> - <mat-icon>open_with</mat-icon> - <span>Move To</span> - </button> --> - <button mat-menu-item (click)="emitSendFile(element)"> - <mat-icon>send</mat-icon> - <span>Send file</span> - </button> - <button mat-menu-item (click)="openNewFolderDialog()"> - <mat-icon>send</mat-icon> - <span>New directory</span> - </button> - </ng-template> -</mat-menu> - </table> - - - - - - <!-- <mat-list> - <mat-list-item *ngFor="let element of fileElements" class=file-or-folder> - <span [matMenuTriggerFor]="rootMenu" [matMenuTriggerData]="{element: element}" #menuTrigger="matMenuTrigger"></span> - <div fxFlex="100%"> - <div fxLayout="row" fxLayoutAlign="start none" (click)="navigate(element)" (contextmenu)="openMenu($event, menuTrigger)"> - <div> - <mat-icon color="primary" class="file-or-folder-icon pointer" *ngIf="element.isFolder">folder</mat-icon> - <mat-icon color="primary" class="file-or-folder-icon pointer" *ngIf="!element.isFolder">insert_drive_file</mat-icon> - </div> - <span fxFlex>{{element.name}}</span> - <span>{{element.size}}</span> - </div> - </div> - - </mat-list-item> - </mat-list> --> - - <!-- </div> --> -<!-- </div> --> - diff --git a/src/app/file-explorer/file-explorer.component.ts b/src/app/file-explorer/file-explorer.component.ts deleted file mode 100644 index 7696f84f8b87022290c953c1086d8ad6ebac3c1e..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/file-explorer.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core'; -import { FileElement } from './model/element'; -import { MatMenu, MatMenuTrigger } from '@angular/material/menu'; -import { Observable } from 'rxjs/Observable'; -import { MatDialog } from '@angular/material/dialog'; -import { NewFolderDialogComponent } from './modals/newFolderDialog/newFolderDialog.component'; -import { RenameDialogComponent } from './modals/renameDialog/renameDialog.component'; - -@Component({ - selector: 'file-explorer', - templateUrl: './file-explorer.component.html', - styleUrls: ['./file-explorer.component.css'] -}) -export class FileExplorerComponent { - constructor(public dialog: MatDialog) {} - - @ViewChild(MatMenuTrigger) contextMenu: MatMenuTrigger; - - contextMenuPosition = { x: '0px', y: '0px' }; - - @Input() fileElements: FileElement[]; - @Input() canNavigateUp: string; - @Input() path: string; - @Input() disableSend: Boolean; - @Input() identities: any; - - @Output() folderAdded = new EventEmitter<{ name: string }>(); - @Output() elementRemoved = new EventEmitter<FileElement>(); - @Output() elementRenamed = new EventEmitter<FileElement>(); - @Output() elementMoved = new EventEmitter<{ element: FileElement; moveTo: FileElement }>(); - @Output() navigatedDown = new EventEmitter<FileElement>(); - @Output() navigatedUp = new EventEmitter(); - @Output() sendFile = new EventEmitter<FileElement>(); - @Output() idSelected = new EventEmitter<any>(); - displayedColumns: string[] = ['icon','name','size','online']; - fixedSizeData = Array(10000).fill(30); - - onContextMenu(event: MouseEvent, element: any) { - event.preventDefault(); - console.log('called onContextMenu with element',element); - this.contextMenuPosition.x = event.clientX + 'px'; - this.contextMenuPosition.y = event.clientY + 'px'; - this.contextMenu.menuData = { 'element': element }; - this.contextMenu.openMenu(); - } - - deleteElement(element: FileElement) { - this.elementRemoved.emit(element); - } - - navigate(element: FileElement) { - console.log('attempting navigate down'); - - if (element.isFolder) { - console.log('attempting navigate down',element.name); - - this.navigatedDown.emit(element); - } - } - - navigateUp() { - console.log('attempting navigate up'); - this.navigatedUp.emit(); - console.log('emitted navigateUp'); - } - - moveElement(element: FileElement, moveTo: FileElement) { - this.elementMoved.emit({ element: element, moveTo: moveTo }); - } - - rowClicked(row) { - console.log('row clicked',row); - } - - openNewFolderDialog() { - let dialogRef = this.dialog.open(NewFolderDialogComponent); - dialogRef.afterClosed().subscribe(res => { - if (res) { - this.folderAdded.emit({ name: res }); - } - }); - } - - openRenameDialog(element: FileElement) { - let dialogRef = this.dialog.open(RenameDialogComponent); - dialogRef.afterClosed().subscribe(res => { - if (res) { - element.name = res; - this.elementRenamed.emit(element); - } - }); - } - - emitSendFile(element: FileElement) { - console.log('called emitSendFile with element',element); - this.sendFile.emit(element); - } - - emitIdSelected(id: any) { - console.log('Im going to emit',id); - this.idSelected.emit(id); - } - - openMenu(event: MouseEvent, viewChild: MatMenuTrigger) { - event.preventDefault(); - viewChild.openMenu(); - } -} diff --git a/src/app/file-explorer/file-explorer.module.ts b/src/app/file-explorer/file-explorer.module.ts deleted file mode 100644 index 581cd17eb9af250d0897ebd0314da84316bd4c5d..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/file-explorer.module.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { MatToolbarModule } from '@angular/material/toolbar'; -import { MatIconModule } from '@angular/material/icon'; -import { MatGridListModule } from '@angular/material/grid-list'; -import { MatListModule } from '@angular/material/list'; -import { MatMenuModule } from '@angular/material/menu'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { MatDialogModule } from '@angular/material/dialog'; -import { MatInputModule } from '@angular/material/input'; -import { NewFolderDialogComponent } from './modals/newFolderDialog/newFolderDialog.component'; -import { MatButtonModule } from '@angular/material/button'; -import { FormsModule } from '@angular/forms'; -import { RenameDialogComponent } from './modals/renameDialog/renameDialog.component'; -import { FileExplorerComponent } from './file-explorer.component'; -import {MatTableModule} from '@angular/material/table'; -import {ScrollingModule} from '@angular/cdk/scrolling'; -import {MatSidenavModule} from '@angular/material/sidenav' -import { MatSelectModule } from '@angular/material/select'; - - -// import {cdkScrollable} from '@angular/' - -@NgModule({ - imports: [ - CommonModule, - MatToolbarModule, - FlexLayoutModule, - MatIconModule, - MatGridListModule, - MatListModule, - MatMenuModule, - BrowserAnimationsModule, - MatDialogModule, - MatInputModule, - FormsModule, - MatButtonModule, - MatTableModule, - ScrollingModule, - MatSidenavModule, - MatSelectModule, - ], - declarations: [FileExplorerComponent, NewFolderDialogComponent, RenameDialogComponent], - exports: [FileExplorerComponent], - entryComponents: [NewFolderDialogComponent, RenameDialogComponent] -}) -export class FileExplorerModule {} diff --git a/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.css b/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.css deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.html b/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.html deleted file mode 100644 index 275a3a60634a9dd2f383604dc6ba0d821c76cf54..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.html +++ /dev/null @@ -1,12 +0,0 @@ -<h1 mat-dialog-title>Create a new folder</h1> - -<mat-dialog-content> - <mat-form-field class="example-full-width"> - <input matInput placeholder="Folder Name" [(ngModel)]="folderName"> - </mat-form-field> -</mat-dialog-content> - -<mat-dialog-actions> - <button mat-raised-button mat-dialog-close>Cancel</button> - <button mat-raised-button [mat-dialog-close]="folderName" color="primary">OK</button> -</mat-dialog-actions> \ No newline at end of file diff --git a/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.spec.ts b/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.spec.ts deleted file mode 100644 index 6346483cc9e3c7c114f78a717e9358f3ce481346..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* tslint:disable:no-unused-variable */ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { DebugElement } from '@angular/core'; - -import { NewFolderDialogComponent } from './newFolderDialog.component'; - -describe('NewFolderDialogComponent', () => { - let component: NewFolderDialogComponent; - let fixture: ComponentFixture<NewFolderDialogComponent>; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ NewFolderDialogComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(NewFolderDialogComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.ts b/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.ts deleted file mode 100644 index 5cb47eac18bf4ca08a3739a8f9a025fea00dd98e..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/modals/newFolderDialog/newFolderDialog.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { MatDialogRef } from '@angular/material/dialog'; - -@Component({ - selector: 'app-newFolderDialog', - templateUrl: './newFolderDialog.component.html', - styleUrls: ['./newFolderDialog.component.css'] -}) -export class NewFolderDialogComponent implements OnInit { - constructor(public dialogRef: MatDialogRef<NewFolderDialogComponent>) {} - - folderName: string; - - ngOnInit() {} -} diff --git a/src/app/file-explorer/modals/renameDialog/renameDialog.component.css b/src/app/file-explorer/modals/renameDialog/renameDialog.component.css deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/file-explorer/modals/renameDialog/renameDialog.component.html b/src/app/file-explorer/modals/renameDialog/renameDialog.component.html deleted file mode 100644 index dcc611c4820ac114fd4cf5b14c98c1b8164d90db..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/modals/renameDialog/renameDialog.component.html +++ /dev/null @@ -1,12 +0,0 @@ -<h1 mat-dialog-title>Rename Element</h1> - -<mat-dialog-content> - <mat-form-field class="example-full-width"> - <input matInput placeholder="Folder Name" [(ngModel)]="folderName"> - </mat-form-field> -</mat-dialog-content> - -<mat-dialog-actions> - <button mat-raised-button mat-dialog-close>Cancel</button> - <button mat-raised-button [mat-dialog-close]="folderName" color="primary">OK</button> -</mat-dialog-actions> \ No newline at end of file diff --git a/src/app/file-explorer/modals/renameDialog/renameDialog.component.ts b/src/app/file-explorer/modals/renameDialog/renameDialog.component.ts deleted file mode 100644 index ccac0c2d6a5d4216346a06b268c46d6ffe268f66..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/modals/renameDialog/renameDialog.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { MatDialogRef } from '@angular/material/dialog'; - -@Component({ - selector: 'app-renameDialog', - templateUrl: './renameDialog.component.html', - styleUrls: ['./renameDialog.component.css'] -}) -export class RenameDialogComponent implements OnInit { - constructor(public dialogRef: MatDialogRef<RenameDialogComponent>) {} - - folderName: string; - - ngOnInit() {} -} diff --git a/src/app/file-explorer/model/element.ts b/src/app/file-explorer/model/element.ts deleted file mode 100644 index 9b91920de6af2b6dc69640f776125c53b6b710eb..0000000000000000000000000000000000000000 --- a/src/app/file-explorer/model/element.ts +++ /dev/null @@ -1,6 +0,0 @@ -export class FileElement { - isFolder: boolean; - name: string; - size: number; - online: boolean; -} diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts deleted file mode 100644 index 88746a9f83b94ab1b1a7f8639e40c6e63eb8f3d6..0000000000000000000000000000000000000000 --- a/src/app/shared/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './page-not-found/page-not-found.component'; diff --git a/src/app/shared/components/page-not-found/page-not-found.component.html b/src/app/shared/components/page-not-found/page-not-found.component.html deleted file mode 100644 index 330fbc2d0c1dd26d489ad1c8b7d835eff39bca99..0000000000000000000000000000000000000000 --- a/src/app/shared/components/page-not-found/page-not-found.component.html +++ /dev/null @@ -1,3 +0,0 @@ -<p> - page-not-found works! -</p> diff --git a/src/app/shared/components/page-not-found/page-not-found.component.scss b/src/app/shared/components/page-not-found/page-not-found.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/shared/components/page-not-found/page-not-found.component.spec.ts b/src/app/shared/components/page-not-found/page-not-found.component.spec.ts deleted file mode 100644 index 89162fd3d943252f99eb7f646bb6a63475f80b37..0000000000000000000000000000000000000000 --- a/src/app/shared/components/page-not-found/page-not-found.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { PageNotFoundComponent } from './page-not-found.component'; - -describe('PageNotFoundComponent', () => { - let component: PageNotFoundComponent; - let fixture: ComponentFixture<PageNotFoundComponent>; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PageNotFoundComponent] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PageNotFoundComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/shared/components/page-not-found/page-not-found.component.ts b/src/app/shared/components/page-not-found/page-not-found.component.ts deleted file mode 100644 index ae41e0d80613c08a6f05a53b70fad9cc3f414f46..0000000000000000000000000000000000000000 --- a/src/app/shared/components/page-not-found/page-not-found.component.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-page-not-found', - templateUrl: './page-not-found.component.html', - styleUrls: ['./page-not-found.component.scss'] -}) -export class PageNotFoundComponent implements OnInit { - constructor() {} - - ngOnInit(): void {} -} diff --git a/src/app/shared/directives/index.ts b/src/app/shared/directives/index.ts deleted file mode 100644 index 84937176f730bc2acb6db476492333d787894af7..0000000000000000000000000000000000000000 --- a/src/app/shared/directives/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './webview/webview.directive'; diff --git a/src/app/shared/directives/webview/webview.directive.spec.ts b/src/app/shared/directives/webview/webview.directive.spec.ts deleted file mode 100644 index d157f015b614c78d38f57e08e5991b878bf70005..0000000000000000000000000000000000000000 --- a/src/app/shared/directives/webview/webview.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { WebviewDirective } from './webview.directive'; - -describe('WebviewDirective', () => { - it('should create an instance', () => { - const directive = new WebviewDirective(); - expect(directive).toBeTruthy(); - }); -}); diff --git a/src/app/shared/directives/webview/webview.directive.ts b/src/app/shared/directives/webview/webview.directive.ts deleted file mode 100644 index 239fed4a3afb3df99c01b015fde2802ab865f565..0000000000000000000000000000000000000000 --- a/src/app/shared/directives/webview/webview.directive.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Directive } from '@angular/core'; - -@Directive({ - selector: 'webview' -}) -export class WebviewDirective { - constructor() { } -} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts deleted file mode 100644 index 9a662838f319b3cdd478eeca8c62dd831a88b1a1..0000000000000000000000000000000000000000 --- a/src/app/shared/shared.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; - -import { TranslateModule } from '@ngx-translate/core'; - -import { PageNotFoundComponent } from './components/'; -import { WebviewDirective } from './directives/'; -import { FormsModule } from '@angular/forms'; - -@NgModule({ - declarations: [PageNotFoundComponent, WebviewDirective], - imports: [CommonModule, TranslateModule, FormsModule], - exports: [TranslateModule, WebviewDirective, FormsModule] -}) -export class SharedModule {} diff --git a/src/app/tes.service.ts b/src/app/tes.service.ts index 82b1dd505840ef0a744da4b07d5e04b8efaad6c3..ace88a2df319e1f065f4dd01d395415ba910bdf4 100644 --- a/src/app/tes.service.ts +++ b/src/app/tes.service.ts @@ -178,22 +178,25 @@ public addUserHealth(identity,resp) { submissionError(identity: Identity, error: any) { - if (identity.expiry < Date.now()) { - console.error('submissionError'); + console.error('submissionError',identity.expiry,Date.now()); + if (identity.expiry !== null && identity.expiry < Date.now()) { + console.error('submissionError',identity.expiry,Date.now()); console.log(error); //this.notifications.notify("Your login has expired. Please log in again", () => { this.authorisationService.updateAgentContents().subscribe( () => {return} ) } ); this.notifications.notify("Your login has expired. Please log in again", () => this.authorisationService.refresh()) return; } - if (error.status != 0) { - try { - this.notifications.notify(error); - console.error(error); - } catch { - this.notifications.notify('Job Submission failed'); - console.error(error); - } - } + + return this.handleGenericError(identity,error,null); + // if (error.status != 0) { + // try { + // this.notifications.notify(error); + // console.error(error); + // } catch { + // this.notifications.notify('Job Submission failed'); + // console.error(error); + // } + // } } cancelError(error: any) { @@ -438,38 +441,99 @@ private handleAppInstanceError(job: Job, action: AppAction, error: HttpErrorResp if (job.identity.expiry > Date.now() && (error.hasOwnProperty("status") && error.status == 401)) { this.notifications.notify("It looks like the application is running slow. Please try again in a few minutes."); return throwError("app instance error, possibly pam_slurm_adopt"); - } else { - console.log('else strategy',job.identity.expiry, Date.now(),error.status); - return this.handleGenericError(job,action,error,msg); - } + } + + + + console.log('else strategy',job.identity.expiry, Date.now(),error.status); + return this.handleGenericError(job.identity,error,msg); } private handleTunnelError(job: Job, action: AppAction, error: HttpErrorResponse): Observable<any> { console.error(error); console.log('in handle tunnel error'); - const msg: string = "Attempting to create an SSH tunnel to" + job.batch_host + " via " + job.identity.site.host; + const msg: string = "Attempting to create an SSH tunnel to " + job.batch_host + " via " + job.identity.site.host; if (job.identity.expiry > Date.now() && (error.hasOwnProperty("status") && error.status == 401)) { this.notifications.notify("It looks like the application is running slow. Please try again in a few minutes.") return throwError("tunnel error, possible pam_slurm_adopt"); } else { - return this.handleGenericError(job,action,error,msg); + return this.handleGenericError(job.identity,error,msg); } } -private handleGenericError(job: Job, action: AppAction, error: HttpErrorResponse, msg: string): Observable<any> { +private unraw(str: string): string { + return str.replace(/\\[0-9]|\\['"\bfnrtv]|\\x[0-9a-f]{2}|\\u[0-9a-f]{4}|\\u\{[0-9a-f]+\}|\\./ig, match => { + switch (match[1]) { + case "'": + case "\"": + case "\\": + return match[1]; + case "b": + return "\b"; + case "f": + return "\f"; + case "n": + return "\n"; + case "r": + return "\r"; + case "t": + return "\t"; + case "v": + return "\v"; + case "u": + if (match[2] === "{") { + return String.fromCodePoint(parseInt(match.substring(3), 16)); + } + return String.fromCharCode(parseInt(match.substring(2), 16)); + case "x": + return String.fromCharCode(parseInt(match.substring(2), 16)); + case "0": + return "\0"; + default: // E.g., "\q" === "q" + return match.substring(1); + } + }); +} + + +private handleGenericError(identity: Identity, error: HttpErrorResponse, msg: string): Observable<any> { + + console.error('handleGenericError'); + console.error(error); + // If the API returned a error code, and a json object with a message, display that message var emsg: string = ""; if (error.hasOwnProperty('error') && error.error.hasOwnProperty('message') ) { emsg = error.error.message; - } else { - emsg = error.message; + this.notifications.notify(emsg); + console.error('handleGenericError throwing the error again',emsg); + return throwError(error); + } + + // If the API returuned an error code, and a string with the substring "failed with error message b" display that. + var PATTERN: string ='failed with error message b' + + if (error.hasOwnProperty("error") && error.error.hasOwnProperty("detail")) { + console.error('handleGenericError, found error.error.detail'); + var startidx: number = error.error.detail.indexOf(PATTERN); + if (startidx !== -1) { + console.error(error.error.detail.slice(startidx+PATTERN.length+1,error.error.detail.length-1)); + let rawstr = error.error.detail.slice(startidx+PATTERN.length+1,error.error.detail.length-1); + let unrawstr = this.unraw(rawstr); + this.notifications.notify(unrawstr); + return throwError(error); + } } - if (job.identity.expiry < Date.now() && (error.hasOwnProperty("status") && error.status == 401)) { + console.error('handleGenericError, no error.error.detail'); + + // If the API returned status 401 (unauthorized) and the identity has expired, refresh the identity + if (identity.expiry !== null && identity.expiry < Date.now() && (error.hasOwnProperty("status") && error.status == 401)) { console.error('handleGenericError'); this.notifications.notify("Your login has expired. Please log in again", () => { this.authorisationService.refresh(); } ); return throwError(error); } + // If the API returned any of THESE status code, and didn't give either a json message of a string message, display a generic message if (error.hasOwnProperty("status") && error.status == 500) { this.notifications.notify("The Strudel2 API server had an error.\n Please report this via the contact us link.\nThe error message was"+emsg); return throwError(error); @@ -486,6 +550,14 @@ private handleGenericError(job: Job, action: AppAction, error: HttpErrorResponse this.notifications.notify("A networking error occured. Is your internet connection OK?") return throwError(error); } + + if (error.hasOwnProperty('message')) { + emsg = error.message; + this.notifications.notify(emsg); + console.error('handleGenericError throwing the error again',emsg); + return throwError(error); + } + this.notifications.notify(error); return throwError(error); } diff --git a/src/styles.scss b/src/styles.scss index 0c01f73925d7175a97b8b626f7b47cd27f205881..2e9c571201f3c6770b84d1101ac10b11ebb2572a 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -181,6 +181,10 @@ $custom-typography: mat.define-typography-config( background-color: transparent !important; } +.mat-mdc-snack-bar-label { + white-space: pre-wrap +} + .strudel-light-theme { $strudel-app-primary: mat.define-palette($md-monashpalette); $strudel-app-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);