Commit d6f15aae authored by naji's avatar naji
Browse files

bugs

parent 5a776fce
......@@ -35,16 +35,16 @@
* knowledge of the CeCILL-C license and that you accept its terms.
*/
import { registerLocaleData } from '@angular/common';
import { HttpBackend, HttpClient } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { default as localeFr } from '@angular/common/locales/fr';
import { APP_INITIALIZER, LOCALE_ID, NgModule } from '@angular/core';
import { BrowserModule, Title } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ServiceWorkerModule } from '@angular/service-worker';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { MissingTranslationHandler, TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { QuicklinkModule } from 'ngx-quicklink';
// import { VitamUILibraryModule } from 'projects/vitamui-library/src/public-api';
import { VitamUICommonModule, WINDOW_LOCATION } from 'ui-frontend-common';
import { VitamUICommonModule, VitamuiMissingTranslationHandler, WINDOW_LOCATION } from 'ui-frontend-common';
import { environment } from '../environments/environment';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
......@@ -52,23 +52,19 @@ import { AppComponent } from './app.component';
import { MatToolbarModule } from '@angular/material/toolbar';
import { PastisConfiguration } from './core/classes/pastis-configuration';
import { RegisterIconsService } from './core/services/register-icons.service';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { ToastrModule } from 'ngx-toastr';
import { InjectorModule } from 'ui-frontend-common';
import { LoggerModule } from 'ui-frontend-common';
import { BASE_URL } from 'ui-frontend-common';
import { ENVIRONMENT } from 'ui-frontend-common';
import { SedaVisualizerService } from './seda-visualizer.service';
import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
/* export function httpLoaderFactory(httpClient: HttpClient): MultiTranslateHttpLoader {
export function httpLoaderFactory(httpClient: HttpClient): MultiTranslateHttpLoader {
return new MultiTranslateHttpLoader(httpClient, [
{ prefix: './assets/shared-i18n/', suffix: '.json' },
{ prefix: './assets/i18n/', suffix: '.json' },
]);
} */
export function translateHttpLoaderFactory(httpBackend: HttpBackend): TranslateHttpLoader {
return new TranslateHttpLoader(new HttpClient(httpBackend), '../assets/i18n/', '.json');
}
registerLocaleData(localeFr, 'fr');
......@@ -87,7 +83,7 @@ registerLocaleData(localeFr, 'fr');
MatToolbarModule,
// VitamUILibraryModule,
QuicklinkModule,
/* TranslateModule.forRoot({
TranslateModule.forRoot({
missingTranslationHandler: { provide: MissingTranslationHandler, useClass: VitamuiMissingTranslationHandler },
defaultLanguage: 'fr',
loader: {
......@@ -95,17 +91,6 @@ registerLocaleData(localeFr, 'fr');
useFactory: httpLoaderFactory,
deps: [HttpClient],
},
}), */
TranslateModule.forRoot({
defaultLanguage: 'fr',
loader: {
provide: TranslateLoader,
/* useFactory: httpLoaderFactory,
deps: [HttpClient]*/
deps: [HttpBackend],
useFactory: translateHttpLoaderFactory
}
}),
ToastrModule.forRoot({
positionClass: 'toast-bottom-full-width',
......
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
*/
import { TestBed } from '@angular/core/testing';
import { NoticeService } from './notice.service';
describe('PopupService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: NoticeService = TestBed.get(NoticeService);
expect(service).toBeTruthy();
});
});
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
*/
import { Injectable } from '@angular/core';
import { ArchivalProfileUnit } from '../../models/archival-profile-unit';
import { Notice } from '../../models/notice.model';
import { Profile } from '../../models/profile';
import { FileService } from './file.service';
@Injectable({
providedIn: 'root'
})
export class NoticeService {
constructor(private fileService: FileService) { }
notice: Notice;
getNotice(){
this.fileService.notice.subscribe(
(value: any) => {
this.notice = value;
return this.notice;
},
(error) => {
console.log(error)
}
)
}
createPuaNotice(retour: any): ArchivalProfileUnit{
class ArchivalProfileUnitModel implements ArchivalProfileUnit {
id: string;
tenant: number;
version: number;
identifier: string;
name: string;
description: string;
status: string;
creationDate: string;
lastUpdate: string;
activationDate: string;
deactivationDate: string;
controlSchema: string;
fields: string[];
}
let profileDescription = new ArchivalProfileUnitModel();
profileDescription.identifier = retour.identifier;
profileDescription.name = retour.intitule;
profileDescription.description = retour.description;
profileDescription.status = retour.selectedStatus;
profileDescription.controlSchema = "{}"
return profileDescription;
}
createPaNotice(retour: any): Profile{
class ProfileModel implements Profile {
id: string;
status: string;
tenant: number;
version: number;
identifier: string;
name: string;
description: string;
creationDate: string;
lastUpdate: string;
activationDate: string;
deactivationDate: string;
format: string;
path: string;
}
let profile = new ProfileModel();
profile.identifier = retour.identifier;
profile.name = retour.intitule;
profile.description = retour.description;
profile.status = retour.selectedStatus;
profile.format = 'RNG';
return profile
}
}
......@@ -88,18 +88,31 @@ export class ProfileService implements OnDestroy {
this.subscriptions.forEach((subscriptions) => subscriptions.unsubscribe())
}
getAllProfiles(): Observable<ProfileDescription[]>{
getAllProfiles(): void{
if(environment.standalone){
console.error("*******************************" + this.pastisConfig.getAllProfilesUrl)
return this.apiService.get(this.pastisConfig.getAllProfilesUrl);
this.getStandaloneProfiles().subscribe((profiles: ProfileDescription[]) => {
if (profiles) {
this.retrievedProfiles.next(profiles)
console.log("Profiles: ", this.retrievedProfiles);
}
});
}
else{
return this.getAllProfilesVitam();
this.getAllProfilesVitam();
//return this.getAllProfilesPaginated(pageRequest);
//return this.apiService.get(this.pastisConfig.getAllProfilesUrl);
}
}
refreshListProfiles(): void{
this.getAllProfiles();
}
getStandaloneProfiles(): Observable<ProfileDescription[]>{
return this.apiService.get(this.pastisConfig.getAllProfilesUrl);
}
getAllProfilesPA(): Observable<ProfileDescription[]> {
let allProfilesPA: any;
const params = new HttpParams().set('embedded', 'ALL');
......@@ -116,24 +129,27 @@ export class ProfileService implements OnDestroy {
return allProfilesPUA;
}
getAllProfilesVitam(): Observable<ProfileDescription[]> {
this.subscription3$=this.getAllProfilesPUA().subscribe((profileList:ProfileDescription[] ) => {
if (profileList) {
console.log(profileList.length + "profileListPUA");
this.retrievedProfiles.next(profileList);
}
})
this.subscription4$= this.getAllProfilesPA().subscribe((profileList:ProfileDescription[] ) => {
if (profileList) {
console.log(profileList.length + "profileListPA");
this.retrievedProfiles.next(profileList);
getAllProfilesVitam(): void{
let profiles: ProfileDescription[] = [];
this.subscription3$=this.getAllProfilesPUA().subscribe((profileListPUA:ProfileDescription[] ) => {
if (profileListPUA) {
console.log(profileListPUA.length + "profileListPUA");
profileListPUA.forEach((p) => {
p.type = "PUA"
profiles.push(p);
});
this.subscription4$= this.getAllProfilesPA().subscribe((profileListPA:ProfileDescription[] ) => {
if (profileListPA) {
console.log(profileListPA.length + "profileListPA");
profileListPA.forEach((p) => {
p.type = "PA"
profiles.push(p);
});
this.retrievedProfiles.next(profiles);
}
})
}
})
this.subscriptions.push(this.subscription3$)
this.subscriptions.push(this.subscription4$)
return this.retrievedProfiles;
}
getProfileOld(): Observable<FileNode[]> {
......
......@@ -7,10 +7,10 @@ export interface ArchivalProfileUnit extends Id {
name: string;
description: string;
status: string;
creationdate: string;
lastupdate: string;
activationdate: string;
deactivationdate: string;
creationDate: string;
lastUpdate: string;
activationDate: string;
deactivationDate: string;
controlSchema: string;
fields: string[];
}
import {Id} from "ui-frontend-common";
export interface Profile extends Id {
type: string;
fileName: string;
baseName: string;
status: string;
lastModified: string;
tenant: number;
version: number;
identifier: string;
name: string;
description: string;
creationdate: string;
lastupdate: string;
activationdate: string;
deactivationdate: string;
controlSchema: string;
fields: string[];
creationDate: string;
lastUpdate: string;
activationDate: string;
deactivationDate: string;
format: string;
path: string;
}
......@@ -159,16 +159,10 @@ export class ListProfileComponent extends SidenavPage<ProfileDescription> implem
}
private refreshListProfiles() {
return this.profileService.getAllProfiles().subscribe((profileList: ProfileDescription[]) => {
this.profileService.refreshListProfiles();
return this.profileService.retrievedProfiles.subscribe((profileList: ProfileDescription[]) => {
if (profileList) {
profileList.forEach((p) => {
if (p.controlSchema) {
p.type = "PUA"
} else {
p.type = "PA"
}
this.retrievedProfiles.push(p);
});
this.retrievedProfiles = profileList;
console.log("Profiles: ", this.retrievedProfiles);
}
this.matDataSource = new MatTableDataSource<ProfileDescription>(this.retrievedProfiles);
......
......@@ -17,6 +17,7 @@ import {NotificationService} from "../../../../core/services/notification.servic
export class ProfileInformationTabComponent implements OnInit {
@Output() updated: EventEmitter<boolean> = new EventEmitter<boolean>();
@Output() close: EventEmitter<boolean> = new EventEmitter<boolean>();
form: FormGroup;
statusProfile = new FormControl();
......@@ -41,6 +42,7 @@ export class ProfileInformationTabComponent implements OnInit {
@Input()
set inputProfile(profileDescription: ProfileDescription) {
console.error(JSON.stringify(profileDescription))
this._inputProfile = profileDescription;
this.resetForm(this.inputProfile);
......@@ -116,6 +118,8 @@ export class ProfileInformationTabComponent implements OnInit {
this.inputProfile = this._inputProfile;
console.log(JSON.stringify(result))
this.loggingService.showSuccess("La modification du profil a bien été effectué");
this.profileService.refreshListProfiles();
this.close.emit(true);
}, () => {
this.submited = false;
......
......@@ -33,7 +33,7 @@
<mat-tab-group #tabs class="preview-tab-group">
<mat-tab label="{{ 'PROFILE_PREVIEW.NOTICE' | translate }}">
<profile-information-tab #infoTab (updated)="updatedChange($event, 0)"
<profile-information-tab #infoTab (updated)="updatedChange($event, 0)" (close)="closeNotice($event)"
[inputProfile]="inputProfile" [readOnly]="isPopup"></profile-information-tab>
</mat-tab>
......
......@@ -59,6 +59,12 @@ export class ProfilePreviewComponent implements AfterViewInit {
this.tabUpdated[index] = updated;
}
closeNotice(updated: boolean) {
if(updated){
this.emitClose();
}
}
async checkBeforeExit() {
if (await this.confirmAction()) {
const submitProfileUpdate: Observable<ProfileDescription> = this.tabLinks[this.tabs.selectedIndex].prepareSubmit(this.inputProfile);
......
......@@ -6,6 +6,7 @@ import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
import { FileUploader } from 'ng2-file-upload';
import { environment } from 'projects/pastis/src/environments/environment';
import { Subscription } from 'rxjs';
import { NoticeService } from '../../core/services/notice.service';
import { ProfileService } from '../../core/services/profile.service';
import { ArchivalProfileUnit } from '../../models/archival-profile-unit';
import { FileNode } from '../../models/file-node';
......@@ -84,8 +85,8 @@ export class PastisPopupOptionComponent implements OnInit, OnDestroy {
constructor(private router:Router, private profileService: ProfileService,
public dialog: MatDialog,
private translateService: TranslateService) { }
public dialog: MatDialog, private noticeService: NoticeService,
private translateService: TranslateService) { }
ngOnInit(): void {
constantToTranslate.call(this, this.editProfile);
......@@ -166,30 +167,11 @@ export class PastisPopupOptionComponent implements OnInit, OnDestroy {
//TODO : Vérifier mode PA PUA : faire la pop up de sauvegarde qui envoie un pa ou un pua avec modele à completer par le retour
if (result.mode === "PUA") {
console.log("je suis sur un enregistrement d'un PUA")
class ProfileDescriptionModel implements ArchivalProfileUnit {
id: string;
tenant: number;
version: number;
identifier: string;
name: string;
description: string;
status: string;
creationdate: string;
lastupdate: string;
activationdate: string;
deactivationdate: string;
controlSchema: string;
fields: string[];
}
let profileDescription = new ProfileDescriptionModel();
profileDescription.identifier = retour.identifier;
profileDescription.name = retour.intitule;
profileDescription.description = retour.description;
profileDescription.status = retour.selectedStatus;
profileDescription.controlSchema = "{}"
let profileDescription = this.noticeService.createPuaNotice(retour);
this.profileService.createArchivalUnitProfile(profileDescription).subscribe(() => {
this.profileService.createArchivalUnitProfile(profileDescription).subscribe(() => {
this.profileService.refreshListProfiles();
console.log("ok create")
}, (error: any) => {
console.error(error);
......@@ -199,67 +181,13 @@ export class PastisPopupOptionComponent implements OnInit, OnDestroy {
console.log("Je suis sur un enregistrmeent d'un PA")
console.log(retour.identifier)
class ProfileModel implements Profile {
activationdate: string;
baseName: string;
controlSchema: string;
creationdate: string;
deactivationdate: string;
description: string;
fields: string[];
fileName: string;
format: string;
id: string;
identifier: string;
lastModified: string;
lastupdate: string;
name: string;
path: string;
status: string;
tenant: number;
type: string;
version: number;
}
let profile = new ProfileModel();
profile.identifier = retour.identifier;
profile.name = retour.intitule;
profile.description = retour.description;
profile.status = retour.selectedStatus;
profile.format = 'RNG';
class ProfileDescriptionModel implements ProfileDescription {
activationDate: string;
controlSchema: string;
creationDate: string;
deactivationDate: string;
description: string;
fields: string[];
format: string;
id: string;
identifier: string;
lastUpdate: string;
name: string;
path: string;
status: string;
tenant: number;
type: string;
version: number;
}
let profileDescription = new ProfileDescriptionModel();
profileDescription.identifier = retour.identifier;
profileDescription.name = retour.intitule;
profileDescription.description = retour.description;
profileDescription.status = retour.selectedStatus;
profileDescription.format = 'RNG';
//CREER NOTICE PUIS ASSIGNER LE PROFIL A LA NOTICE
console.error("Before " + JSON.stringify(this.profile))
this.profile = Object.assign(profile, this.profile)
console.error("After " + JSON.stringify(this.profile))
this.profileDescription = Object.assign(profileDescription, this.profileDescription)
console.log(JSON.stringify(this.profileDescription) + "profile object")
let profile: Profile = this.noticeService.createPaNotice(retour)
//STEP 1 : Create Notice
this.savePA();
this.profileService.createProfilePa(profile).subscribe((createdProfile) => {
console.log("ok create" + createdProfile)
}, (error: any) => {
console.error(error);
})
}
}
......@@ -270,15 +198,6 @@ export class PastisPopupOptionComponent implements OnInit, OnDestroy {
this.subscriptions.push(this.subscription2$);
}
savePA(){