diff --git a/angular.json b/angular.json index 1d65967b..8b9949a6 100644 --- a/angular.json +++ b/angular.json @@ -23,7 +23,8 @@ "projects/sonar/src/assets" ], "styles": [ - "projects/sonar/src/styles.scss" + "projects/sonar/src/styles.scss", + "node_modules/ngx-spinner/animations/ball-zig-zag.css" ], "scripts": [], "preserveSymlinks": true, diff --git a/projects/sonar/.browserslistrc b/projects/sonar/.browserslistrc index 6b4a4542..3179d0bc 100644 --- a/projects/sonar/.browserslistrc +++ b/projects/sonar/.browserslistrc @@ -6,12 +6,11 @@ # npx browserslist last 2 Chrome versions -last 2 ChromeAndroid versions - -last 2 Safari versions -last 2 iOS versions - -last 2 Firefox versions -last 2 FirefoxAndroid versions - -# last 2 Edge versions \ No newline at end of file +last 1 Firefox version +last 2 Edge major versions +last 2 Safari major versions +last 2 iOS major versions +Firefox ESR +not dead +> 0.2% +not IE 9-11 diff --git a/projects/sonar/e2e/tsconfig.json b/projects/sonar/e2e/tsconfig.json index ca694f54..81b88910 100644 --- a/projects/sonar/e2e/tsconfig.json +++ b/projects/sonar/e2e/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../../../out-tsc/e2e", "module": "commonjs", - "target": "es2018", + "target": "es2022", "types": [ "jasmine", "node" diff --git a/projects/sonar/src/app/_layout/admin/admin.component.html b/projects/sonar/src/app/_layout/admin/admin.component.html index 2f110248..25724bfa 100644 --- a/projects/sonar/src/app/_layout/admin/admin.component.html +++ b/projects/sonar/src/app/_layout/admin/admin.component.html @@ -48,7 +48,7 @@ Deposits diff --git a/projects/sonar/src/app/app-routing.module.ts b/projects/sonar/src/app/app-routing.module.ts index b21bf9aa..cc730e7d 100644 --- a/projects/sonar/src/app/app-routing.module.ts +++ b/projects/sonar/src/app/app-routing.module.ts @@ -43,6 +43,7 @@ import { DetailComponent as ProjectDetailComponent } from './record/project/deta import { BriefViewComponent as SubdivisionBriefViewComponent } from './record/subdivision/brief-view/brief-view.component'; import { UserComponent } from './record/user/user.component'; import { UserService } from './user.service'; +import { MetadataComponent } from './deposit/metadata/metadata.component'; const adminModeDisabled = (): Observable => { return of({ @@ -57,6 +58,11 @@ const routes: Routes = [ component: AdminComponent, children: [ { path: '', component: DashboardComponent }, + { + path: 'deposit/create', + canActivate: mapToCanActivate([RoleGuard]), + component: UploadComponent, + }, { path: 'deposit/:id', canActivate: mapToCanActivate([RoleGuard]), @@ -65,7 +71,7 @@ const routes: Routes = [ }, children: [ { - path: 'create', + path: 'files', component: UploadComponent }, { @@ -74,7 +80,7 @@ const routes: Routes = [ }, { path: ':step', - component: DepositEditorComponent + component: MetadataComponent } ] } diff --git a/projects/sonar/src/app/app.component.html b/projects/sonar/src/app/app.component.html index 199f50d1..a57ab7b4 100644 --- a/projects/sonar/src/app/app.component.html +++ b/projects/sonar/src/app/app.component.html @@ -14,5 +14,7 @@  You should have received a copy of the GNU Affero General Public License  along with this program. If not, see . --> - + +

Loading…

+
diff --git a/projects/sonar/src/app/app.module.ts b/projects/sonar/src/app/app.module.ts index a3f7f1df..c65bf5da 100644 --- a/projects/sonar/src/app/app.module.ts +++ b/projects/sonar/src/app/app.module.ts @@ -36,8 +36,12 @@ import { DropdownModule } from 'primeng/dropdown'; import { FileUploadModule } from 'primeng/fileupload'; import { InputTextModule } from 'primeng/inputtext'; import { OrderListModule } from 'primeng/orderlist'; -import { PanelModule } from 'primeng/panel'; import { PaginatorModule } from 'primeng/paginator'; +import { PanelModule } from 'primeng/panel'; +import { SplitButtonModule } from 'primeng/splitbutton'; +import { StepsModule } from 'primeng/steps'; +import { TabViewModule } from 'primeng/tabview'; +import { ToolbarModule } from 'primeng/toolbar'; import { AdminComponent } from './_layout/admin/admin.component'; import { AppConfigService } from './app-config.service'; import { AppInitializerService } from './app-initializer.service'; @@ -73,6 +77,11 @@ import { OtherFilesComponent } from './record/files/other-files/other-files.comp import { StatsFilesComponent } from './record/files/stats-files/stats-files.component'; import { UploadFilesComponent } from './record/files/upload-files/upload-files.component'; import { DetailComponent as HepvsProjectDetailComponent } from './record/hepvs/project/detail/detail.component'; + +import { ConfirmDialogModule } from 'primeng/confirmdialog'; +import { DialogModule } from 'primeng/dialog'; +import { FilesComponent } from './deposit/files/files.component'; +import { MetadataComponent } from './deposit/metadata/metadata.component'; import { IdentifierComponent } from './record/identifier/identifier.component'; import { DetailComponent as OrganisationDetailComponent } from './record/organisation/detail/detail.component'; import { OrganisationComponent } from './record/organisation/organisation.component'; @@ -82,6 +91,9 @@ import { BriefViewComponent as SubdivisionBriefViewComponent } from './record/su import { UserComponent } from './record/user/user.component'; import { ValidationComponent } from './record/validation/validation.component'; import { UserService } from './user.service'; +import { SwisscoveryComponent } from './deposit/editor/swisscovery/swisscovery.component'; +import { MessagesModule } from 'primeng/messages'; + export function appInitializerFactory(appInitializerService: AppInitializerService): () => Promise { return () => appInitializerService.initialize().toPromise(); @@ -130,7 +142,10 @@ export function minElementError(err: any, field: FormlyFieldConfig) { OtherFilesComponent, FaIconClassPipe, StatsFilesComponent, - FieldDescriptionComponent + FieldDescriptionComponent, + MetadataComponent, + FilesComponent, + SwisscoveryComponent ], imports: [ BrowserModule, @@ -138,6 +153,9 @@ export function minElementError(err: any, field: FormlyFieldConfig) { AppRoutingModule, HttpClientModule, CollapseModule.forRoot(), + StepsModule, + ToolbarModule, + TabViewModule , TabsModule.forRoot(), TooltipModule.forRoot(), ModalModule.forRoot(), @@ -162,7 +180,11 @@ export function minElementError(err: any, field: FormlyFieldConfig) { PanelModule, DividerModule, CarouselModule, - PaginatorModule + PaginatorModule, + SplitButtonModule, + DialogModule, + ConfirmDialogModule, + MessagesModule ], providers: [ { diff --git a/projects/sonar/src/app/core/step/step.component.html b/projects/sonar/src/app/core/step/step.component.html index 089daabb..a863e515 100644 --- a/projects/sonar/src/app/core/step/step.component.html +++ b/projects/sonar/src/app/core/step/step.component.html @@ -14,62 +14,9 @@  You should have received a copy of the GNU Affero General Public License  along with this program. If not, see . --> - - - - - - - {{ i + 1 }} - - - {{ ('step_' + step) | translate }} - + + diff --git a/projects/sonar/src/app/core/step/step.component.ts b/projects/sonar/src/app/core/step/step.component.ts index f2a459d5..48939a6b 100644 --- a/projects/sonar/src/app/core/step/step.component.ts +++ b/projects/sonar/src/app/core/step/step.component.ts @@ -15,6 +15,7 @@ * along with this program. If not, see . */ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { MenuItem } from 'primeng/api'; @Component({ selector: 'sonar-deposit-step', @@ -23,9 +24,6 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; }) export class StepComponent implements OnInit { /** Current step of the process */ - @Input() - currentStep: string = null; - /** Current max step, no link available for next steps. */ @Input() maxStep: string = null; @@ -34,66 +32,20 @@ export class StepComponent implements OnInit { @Input() steps: string[] = []; - /** Link prefix for building routes */ - @Input() - linkPrefix = ''; - - /** Event emitted when a deposit is deleted. */ - @Output() - cancel: EventEmitter = new EventEmitter(); - - /** Event emitted when a step is clicked. */ - @Output() - clicked: EventEmitter = new EventEmitter(); + items: MenuItem[] = []; ngOnInit() { - if (this.steps.length === 0) { - throw new Error('No steps defined'); - } - - if (!this.currentStep) { - this.currentStep = this.steps[0]; - } - if (!this.maxStep) { this.maxStep = this.steps[0]; } + let disabled = false; + this.items = this.steps.map((item: string): MenuItem => { + const data = {label: `step_${item}`, routerLink: ['..', item], disabled}; + if (this.maxStep === item) { + disabled = true; + } + return data; + }) } - /** - * Return index corresponding to the step parameter. - * - * @return Max step index - */ - get maxStepIndex(): number { - return this.steps.findIndex(element => element === this.maxStep); - } - - /** - * Return index corresponding to the step parameter. - * - * @return Current step index - */ - get currentStepIndex(): number { - return this.steps.findIndex(element => element === this.currentStep); - } - - /** - * Trigger a cancel on parent. - * - * @param event DOM event click - */ - doCancel(event: Event) { - event.preventDefault(); - this.cancel.emit(); - } - - /** - * Method triggered when a step is clicked. - * - * @param step Step clicked. - */ - click(step: string) { - this.clicked.emit(step); - } } diff --git a/projects/sonar/src/app/deposit/brief-view/brief-view.component.html b/projects/sonar/src/app/deposit/brief-view/brief-view.component.html index 258c7c41..16329180 100644 --- a/projects/sonar/src/app/deposit/brief-view/brief-view.component.html +++ b/projects/sonar/src/app/deposit/brief-view/brief-view.component.html @@ -85,13 +85,13 @@

diff --git a/projects/sonar/src/app/deposit/confirmation/confirmation.component.html b/projects/sonar/src/app/deposit/confirmation/confirmation.component.html index 25adaa25..2275c26f 100644 --- a/projects/sonar/src/app/deposit/confirmation/confirmation.component.html +++ b/projects/sonar/src/app/deposit/confirmation/confirmation.component.html @@ -28,7 +28,7 @@

{{ 'Confirmation' | translate }}

Back to public interface
  • - Deposit another publication + Deposit another publication
  • diff --git a/projects/sonar/src/app/deposit/confirmation/confirmation.component.ts b/projects/sonar/src/app/deposit/confirmation/confirmation.component.ts index edd6bc85..57d1e4c7 100644 --- a/projects/sonar/src/app/deposit/confirmation/confirmation.component.ts +++ b/projects/sonar/src/app/deposit/confirmation/confirmation.component.ts @@ -62,7 +62,7 @@ export class ConfirmationComponent implements OnInit { map((result) => result.metadata), catchError(() => { this._toastr.error(this._translateService.instant('Deposit not found')); - this._router.navigate(['deposit', '0', 'create']); + this._router.navigate(['records', 'deposits']); return of(null); }) ); diff --git a/projects/sonar/src/app/deposit/deposit.service.ts b/projects/sonar/src/app/deposit/deposit.service.ts index c37bc40a..f517e6f8 100644 --- a/projects/sonar/src/app/deposit/deposit.service.ts +++ b/projects/sonar/src/app/deposit/deposit.service.ts @@ -328,7 +328,9 @@ export class DepositService implements OnDestroy { extractPDFMetadata(deposit: any): Observable { return this._httpClient .get(`${this.depositEndPoint}/${deposit.pid}/extract-pdf-metadata`) - .pipe(catchError(err => this._handleError(err))); + .pipe( + catchError(err => this._handleError(err)) + ); } /** @@ -336,7 +338,7 @@ export class DepositService implements OnDestroy { * @param error - HttpErrorResponse */ private _handleError(error: HttpErrorResponse) { - this._toastrService.error(error.error.message); - return throwError('Something bad happened; please try again later.'); + this._toastrService.error(error.statusText); + return throwError(() => new Error('Something bad happened; please try again later.')); } } diff --git a/projects/sonar/src/app/deposit/editor/editor.component.html b/projects/sonar/src/app/deposit/editor/editor.component.html index a3ef7c78..e7289c08 100644 --- a/projects/sonar/src/app/deposit/editor/editor.component.html +++ b/projects/sonar/src/app/deposit/editor/editor.component.html @@ -14,182 +14,57 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> - - - - - - - -
    -
    -
    - -
    -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    - - -
    
    -        
    -
    -
    -
    - -
    - - -

    {{ 'Main file' | translate }}

    - {{ mainFile.key }} ({{ mainFile.size | filesize }}) - - - - - - - -
    -

    {{ 'Additional files' | translate }}

    -

    - {{ file.key }} ({{ file.size | filesize }}) - - - - - - -

    -
    -
    -
    -
    -
    -
    - - -