Skip to content

Commit

Permalink
migrations: create migration module
Browse files Browse the repository at this point in the history
* Adds check format support.

Signed-off-by: Johnny Mariéthoz <[email protected]>
  • Loading branch information
jma committed Sep 19, 2024
1 parent 5b9fc2e commit 7c53cf7
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/admin/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import { PERMISSIONS } from '@rero/shared';
import { PermissionGuard } from './guard/permission.guard';

const routes: Routes = [
{
path: 'migrations',
loadChildren: () => import('./migration/migration.module').then(m => m.MigrationModule)
},
{
path: '',
component: FrontpageComponent
Expand Down
9 changes: 9 additions & 0 deletions projects/admin/src/app/menu/menu-definition/menu-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,15 @@ export const MENU_APP: IMenuParent[] = [
permissions: [PERMISSIONS.PERM_MANAGEMENT]
}
},
{
name: 'Migrations',
router_link: ['/', 'migrations', 'records', 'migrations'],
attributes: { id: 'permissions-menu' },
extras: { iconClass: 'fa fa-cloud-upload' },
access: {
permissions: [PERMISSIONS.MIG_ACCESS]
}
},
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
RERO ILS UI
Copyright (C) 2024 RERO
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

@if (record) {
<h5>
<a
[routerLink]="[detailUrl.link]"
[queryParams]="{ migration: record.metadata.migration_id }"
>{{ record.id }} <p-badge [value]="record.metadata.conversion_status"
/></a>
</h5>
@if (record?.metadata?.json?.title[0].mainTitle[0].value) {
{{ record?.metadata?.json?.title[0].mainTitle[0].value }}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* RERO ILS UI
* Copyright (C) 2024 RERO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { Component, Input } from '@angular/core';
import { ResultItem } from '@rero/ng-core';

@Component({
selector: 'admin-migration-data',
templateUrl: './migration-data.component.html'
})
export class MigrationDataComponent implements ResultItem {

@Input() record: any;

/** Type of record */
@Input() type: string;

/** Detail Url */
@Input() detailUrl: { link: string, external: boolean };

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
RERO ILS UI
Copyright (C) 2024 RERO
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

@if (record) {
<a
[routerLink]="['..', 'migration_data']"
[queryParams]="{ migration: record.id }"
class="p-button float-right"
translate
>Check Conversion</a
>
<h5>
{{ record.metadata.name }} <p-badge [value]="record.metadata.status" />
</h5>
@if(record.metadata?.description) {
<p>
{{ record.metadata.description }}
</p>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* RERO ILS UI
* Copyright (C) 2024 RERO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { Component, Input } from '@angular/core';
import { ResultItem } from '@rero/ng-core';

@Component({
selector: 'admin-migration',
templateUrl: './migration.component.html'
})
export class MigrationComponent implements ResultItem {

@Input() record: any;

/** Type of record */
@Input() type: string;

/** Detail Url */
@Input() detailUrl: { link: string, external: boolean };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
RERO ILS UI
Copyright (C) 2020-2024 RERO
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
@if (record) {
<h5 class="mb-5">
{{record.id}} <p-badge [value]="record.conversion_status" />
</h5>
@if (messages) {
<p-messages
[(value)]="messages"
[enableService]="false"
[closable]="false" />
}
<div class="text-sm grid data">
<div class="markdown col" [innerHTML]="record.raw | markdown"></div>
<div class="json col" [innerHTML]="record.json| json | highlightJson"></div>
</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* RERO ILS UI
* Copyright (C) 2024 RERO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

::ng-deep {
.markdown td,
.markdown th {
padding: 0 10px;
}
}
.data {
.col {
max-height: 600px;
overflow: auto;
}
.json {
border-left: 1px solid gray;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* RERO ILS UI
* Copyright (C) 2024 RERO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { HttpClient } from '@angular/common/http';
import { Component, inject, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { of, Subscription, switchMap, tap } from 'rxjs';

@Component({
selector: 'admin-migration-data',
templateUrl: './migration-data.component.html',
styleUrl: './migration-data.component.scss',
})
export class MigrationDataComponent implements OnInit, OnDestroy {
/** Observable resolving record data */
record: any;
protected route = inject(ActivatedRoute);
protected http = inject(HttpClient);
private subscriptions = new Subscription();
messages = [];
ngOnInit(): void {
this.subscriptions.add(
this.route.paramMap
.pipe(
switchMap(() => {
const docType = this.route.snapshot.params.type;
const id = this.route.snapshot.params.pid;
const migrationId = this.route.snapshot.queryParams.migration;
if (docType == null || id == null || migrationId == null) {
return of(null);
}
return this.http.get(`/api/${docType}/${id}?migration=${migrationId}`);
}),
tap((record: any) => {
if (record?.conversion_logs) {
['info', 'warning', 'error'].map((field) => {
const log = record.conversion_logs[field];
if (log) {
this.messages.push({
severity: field == 'warning' ? 'warn' : field,
detail: log,
});
}
});
}
})
)
.subscribe((res) => (this.record = res))
);
}
/** OnDestroy hook */
ngOnDestroy(): void {
this.subscriptions.unsubscribe();
}
}
Loading

0 comments on commit 7c53cf7

Please sign in to comment.