Commit 9cfe12e3 authored by Romain DELEAU's avatar Romain DELEAU

success/fail load save file

parent acef9781
......@@ -28,6 +28,9 @@ import { ZoomService } from './services/zoom/zoom.service';
import { MatDialog } from '@angular/material/dialog';
import { SaveDialogComponent } from './components/dialogs/save-dialog/save-dialog.component';
import { Title } from '@angular/platform-browser';
import { MatSnackBar } from '@angular/material/snack-bar';
import { LoadingsucessSnackbarComponent } from './components/snackbars/loadingsucess-snackbar/loadingsucess-snackbar.component';
import { LoadingfailSnackbarComponent } from './components/snackbars/loadingfail-snackbar/loadingfail-snackbar.component';
@Component({
selector: 'app-root',
......@@ -41,7 +44,8 @@ export class AppComponent {
@ViewChild('fileInput') fileInput: any;
constructor(private cdr: ChangeDetectorRef, protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService,
private elementRef: ElementRef, private zoomService: ZoomService, private dialog: MatDialog, private titleService: Title) {
private elementRef: ElementRef, private zoomService: ZoomService, private dialog: MatDialog, private titleService: Title,
private _snackBar: MatSnackBar) {
pieceDetailsService.piece = this.scenario;
this.scenario.missions.forEach(mission => {
......@@ -97,6 +101,7 @@ export class AppComponent {
const reader: FileReader = new FileReader();
reader.readAsText(file);
reader.onload = (e) => {
try {
const fileContent: string = reader.result as string;
const jsonData: any = JSON.parse(fileContent);
const scenario: Scenario = Object.assign(new Scenario(), jsonData);
......@@ -110,7 +115,7 @@ export class AppComponent {
scenario.ressources = jsonData.ressources.map((ressourceData: any) => Object.assign(new Ressource(), ressourceData));
scenario.comments = jsonData.comments.map((commentData: any) => Object.assign(new Comment(), commentData));
scenario.missions = jsonData.missions.map((missionData: any) => Object.assign(new Mission(), missionData));
scenario.missions.forEach((mission, index)=> {
scenario.missions.forEach((mission, index) => {
mission.chronologie = jsonData.missions[index].chronologie.map((chronologieData: any) => {
if (chronologieData !== null) {
return Object.assign(new Step(), chronologieData);
......@@ -223,12 +228,15 @@ export class AppComponent {
this.scenario = scenario;
this.pieceDetailsService.piece = this.scenario;
if (scenario.projectName) {
this.titleService.setTitle('RLG Maker - '+this.scenario.projectName);
this.titleService.setTitle('RLG Maker - ' + this.scenario.projectName);
} else {
this.titleService.setTitle('RLG Maker');
}
this.cdr.detectChanges();
this._snackBar.openFromComponent(LoadingsucessSnackbarComponent, { duration: 5000 });
} catch {
this._snackBar.openFromComponent(LoadingfailSnackbarComponent, { duration: 5000 });
}
};
}
}
......
......@@ -40,6 +40,8 @@ import { CreateDialogComponent } from './components/dialogs/create-dialog/create
import { GameCharactersComponent } from './pieces/game-characters/game-characters.component';
import { SaveDialogComponent } from './components/dialogs/save-dialog/save-dialog.component';
import { IdentifierSnackbarComponent } from './components/snackbars/identifier-snackbar/identifier-snackbar.component';
import { LoadingsucessSnackbarComponent } from './components/snackbars/loadingsucess-snackbar/loadingsucess-snackbar.component';
import { LoadingfailSnackbarComponent } from './components/snackbars/loadingfail-snackbar/loadingfail-snackbar.component';
@NgModule({
declarations: [
......@@ -71,7 +73,9 @@ import { IdentifierSnackbarComponent } from './components/snackbars/identifier-s
CreateDialogComponent,
GameCharactersComponent,
SaveDialogComponent,
IdentifierSnackbarComponent
IdentifierSnackbarComponent,
LoadingsucessSnackbarComponent,
LoadingfailSnackbarComponent
],
imports: [
BrowserModule,
......
::ng-deep .mat-snack-bar-container {
background-color: #f8aa14;
background-color: #fec001;
color: black;
box-shadow: 0px 0px 15px 5px #f8aa14;
//font-family: 'Glacial Indifference Bold';
justify-content: space-between;
box-shadow: 0px 0px 15px 5px #fec001;
text-align: center;
}
\ No newline at end of file
......@@ -8,8 +8,6 @@ import { MatSnackBarRef } from '@angular/material/snack-bar';
})
export class IdentifierSnackbarComponent implements OnInit {
snackBarRef = inject(MatSnackBarRef);
constructor() { }
ngOnInit(): void {
......
<span matSnackBarLabel>Chargement du fichier échoué</span>
\ No newline at end of file
::ng-deep .mat-snack-bar-container {
background-color: #de3e44;
color: white;
box-shadow: 0px 0px 15px 5px #de3e44;
text-align: center;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoadingfailSnackbarComponent } from './loadingfail-snackbar.component';
describe('LoadingfailSnackbarComponent', () => {
let component: LoadingfailSnackbarComponent;
let fixture: ComponentFixture<LoadingfailSnackbarComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoadingfailSnackbarComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(LoadingfailSnackbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-loadingfail-snackbar',
templateUrl: './loadingfail-snackbar.component.html',
styleUrls: ['./loadingfail-snackbar.component.scss']
})
export class LoadingfailSnackbarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
<span matSnackBarLabel>Chargement du fichier réussi</span>
\ No newline at end of file
::ng-deep .mat-snack-bar-container {
background-color: #1ba345;
color: white;
box-shadow: 0px 0px 15px 5px #1ba345;
text-align: center;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoadingsucessSnackbarComponent } from './loadingsucess-snackbar.component';
describe('LoadingsucessSnackbarComponent', () => {
let component: LoadingsucessSnackbarComponent;
let fixture: ComponentFixture<LoadingsucessSnackbarComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoadingsucessSnackbarComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(LoadingsucessSnackbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-loadingsucess-snackbar',
templateUrl: './loadingsucess-snackbar.component.html',
styleUrls: ['./loadingsucess-snackbar.component.scss']
})
export class LoadingsucessSnackbarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment