diff --git a/cypress/integration/app.spec.ts b/cypress/integration/app.spec.ts index 3ece7ff..64608ef 100644 --- a/cypress/integration/app.spec.ts +++ b/cypress/integration/app.spec.ts @@ -1,9 +1,12 @@ describe('My First Test', () => { before(() => { - cy.visit('/login'); - cy.THUMDER_SignOut(); - cy.THUMDER_login(); + cy.visit('/'); + }); + + beforeEach(() => { + cy.setCookie('user', JSON.stringify(Cypress.env('USER_COOKIES'))); + cy.visit('/'); // Reload page }); it('Visits the initial project page', () => { diff --git a/cypress/integration/auth.spect.ts b/cypress/integration/auth.spec.ts similarity index 71% rename from cypress/integration/auth.spect.ts rename to cypress/integration/auth.spec.ts index f68a6f5..dba52dc 100644 --- a/cypress/integration/auth.spect.ts +++ b/cypress/integration/auth.spec.ts @@ -1,7 +1,13 @@ describe('Auth access', () => { + before(() => { + cy.visit('/'); + }); + beforeEach(() => { - cy.visit('/login'); + cy.setCookie('user', JSON.stringify(null)); + cy.visit('/'); // Reload page + cy.THUMDER_SignOut(); cy.THUMDER_login(); }); diff --git a/cypress/integration/calculator.spec.ts b/cypress/integration/calculator.spec.ts new file mode 100644 index 0000000..e7837cd --- /dev/null +++ b/cypress/integration/calculator.spec.ts @@ -0,0 +1,112 @@ +describe('Tests calculator', () => { + + before(() => { + cy.visit('/'); + cy.setCookie('user', JSON.stringify(Cypress.env('USER_COOKIES'))); + cy.visit('/'); // Reload page + cy.THUMDER_goCalculator(); + }); + + beforeEach(() => { + }); + + it('Check byte', () => { + cy.get("#byte_value").clear().type('123'); + cy.get("#byte_binary").should('have.value', '01111011'); + cy.get("#byte_hex").should('have.value', '7B'); + + cy.get("#byte_hex").clear().type('FF'); + cy.get("#byte_binary").should('have.value', '11111111'); + cy.get("#byte_value").should('have.value', '255'); + + cy.get("#byte_binary").clear().type('00001111'); + cy.get("#byte_value").should('have.value', '15'); + cy.get("#byte_hex").should('have.value', '0F'); + }); + + it('Check HalfWord', () => { + cy.get("#halfword_value").clear().type('123'); + cy.get("#halfword_binary").should('have.value', '0000000001111011'); + cy.get("#halfword_hex").should('have.value', '007B'); + + cy.get("#halfword_hex").clear().type('00FF'); + cy.get("#halfword_binary").should('have.value', '0000000011111111'); + cy.get("#halfword_value").should('have.value', '255'); + + cy.get("#halfword_binary").clear().type('1111111111111111'); + cy.get("#halfword_value").should('have.value', '65535'); + cy.get("#halfword_hex").should('have.value', 'FFFF'); + }); + + it('Check Word', () => { + cy.get("#word_value").clear().type('255'); + cy.get("#word_binary").should('have.value', '00000000000000000000000011111111'); + cy.get("#word_hex").should('have.value', '000000FF'); + + cy.get("#word_hex").clear().type('00001000'); + cy.get("#word_binary").should('have.value', '00000000000000000001000000000000'); + cy.get("#word_value").should('have.value', '4096'); + + cy.get("#word_binary").clear().type('11111111111111111111111111111111'); + cy.get("#word_value").should('have.value', '4294967295'); + cy.get("#word_hex").should('have.value', 'FFFFFFFF'); + }); + + it('Check Float SubNormal', () => { + // 1 + cy.get("#ieee754_number").clear().type('1'); + cy.get("#ieee754_binary").should('have.value', '00111111100000000000000000000000'); + cy.get("#ieee754_hex").should('have.value', '3F800000'); + + // 2 + cy.get("#ieee754_number").clear().type('{rightarrow}2'); + cy.get("#ieee754_binary").should('have.value', '01000000000000000000000000000000'); + cy.get("#ieee754_hex").should('have.value', '40000000'); + + // -1 + cy.get("#ieee754_number").clear().type('{rightarrow}1{leftarrow}{backspace}-'); + cy.get("#ieee754_binary").should('have.value', '10111111100000000000000000000000'); + cy.get("#ieee754_hex").should('have.value', 'BF800000'); + + // -2 + cy.get("#ieee754_number").clear().type('{rightarrow}2{leftarrow}{backspace}-'); + cy.get("#ieee754_binary").should('have.value', '11000000000000000000000000000000'); + cy.get("#ieee754_hex").should('have.value', 'C0000000'); + + // PI + cy.get("#ieee754_number").clear().type('{rightarrow}31415{movetostart}{rightarrow}{backspace}'); + cy.get("#ieee754_number").type('{movetostart}{rightarrow}.'); + cy.get("#ieee754_binary").should('have.value', '01000000010010010000111001010110'); + cy.get("#ieee754_hex").should('have.value', '40490E56'); + }); + + it('Check Double SubNormal', () => { + // 1 + cy.get("#ieee754_number_64").clear().type('1'); + cy.get("#ieee754_binary_64").should('have.value', '0011111111110000000000000000000000000000000000000000000000000000'); + cy.get("#ieee754_hex_64").should('have.value', '3FF0000000000000'); + + // 2 + cy.get("#ieee754_number_64").clear().type('{rightarrow}2'); + cy.get("#ieee754_binary_64").should('have.value', '0100000000000000000000000000000000000000000000000000000000000000'); + cy.get("#ieee754_hex_64").should('have.value', '4000000000000000'); + + // -1 + cy.get("#ieee754_number_64").clear().type('{rightarrow}1{leftarrow}{backspace}-'); + cy.get("#ieee754_binary_64").should('have.value', '1011111111110000000000000000000000000000000000000000000000000000'); + cy.get("#ieee754_hex_64").should('have.value', 'BFF0000000000000'); + + // -2 + cy.get("#ieee754_number_64").clear().type('{rightarrow}2{leftarrow}{backspace}-'); + cy.get("#ieee754_binary_64").should('have.value', '1100000000000000000000000000000000000000000000000000000000000000'); + cy.get("#ieee754_hex_64").should('have.value', 'C000000000000000'); + + // PI + cy.get("#ieee754_number_64").clear().type('{rightarrow}31415{movetostart}{rightarrow}{backspace}'); + cy.get("#ieee754_number_64").type('{movetostart}{rightarrow}.'); + cy.get("#ieee754_binary_64").should('have.value', '0100000000001001001000011100101011000000100000110001001001101111'); + cy.get("#ieee754_hex_64").should('have.value', '400921CAC0831400'); + + }); + +}); diff --git a/cypress/integration/cookies.spec.ts b/cypress/integration/cookies.spec.ts new file mode 100644 index 0000000..71841b0 --- /dev/null +++ b/cypress/integration/cookies.spec.ts @@ -0,0 +1,31 @@ +describe('Cookies', () => { + + before(() => { + cy.visit('/'); + // scy.setCookie('user', JSON.stringify(Cypress.env('USER_COOKIES'))); + cy.visit('/'); // Reload page + }); + + beforeEach(() => { + cy.clearCookie('cookieconsent_status'); + cy.visit('/'); // Reload page + cy.wait(1000); + }); + + it('Allow cookies', () => { + cy.get('.cc-window').then($element => { + if ($element.is(':visible')) { + cy.get('.cc-allow').click(); + } + }); + }); + + it('Decline cookies', () => { + cy.get('.cc-window').then($element => { + if ($element.is(':visible')) { + cy.get('.cc-deny').click(); + } + }); + }); + +}); diff --git a/cypress/integration/cycle-clock.spect.ts b/cypress/integration/cycle-clock.spec.ts similarity index 90% rename from cypress/integration/cycle-clock.spect.ts rename to cypress/integration/cycle-clock.spec.ts index 443cc39..4ac963d 100644 --- a/cypress/integration/cycle-clock.spect.ts +++ b/cypress/integration/cycle-clock.spec.ts @@ -1,10 +1,13 @@ describe('Cycle Clock Diagram', () => { before(() => { + cy.visit('/'); }); beforeEach(() => { - cy.visit('/login'); + cy.setCookie('user', JSON.stringify(Cypress.env('USER_COOKIES'))); + cy.visit('/'); // Reload page + cy.THUMDER_SignOut(); cy.THUMDER_login(); cy.THUMDER_goCycleClockDiagram(); diff --git a/cypress/integration/lang.spec.ts b/cypress/integration/lang.spec.ts index bbe7b54..2b52654 100644 --- a/cypress/integration/lang.spec.ts +++ b/cypress/integration/lang.spec.ts @@ -2,6 +2,12 @@ describe('Tests lang', () => { beforeEach(() => { cy.visit('/'); + }); + + beforeEach(() => { + cy.setCookie('user', JSON.stringify(Cypress.env('USER_COOKIES'))); + cy.visit('/'); // Reload page + cy.THUMDER_SignOut(); cy.THUMDER_login(); }); diff --git a/cypress/integration/memory.spect.ts b/cypress/integration/memory.spec.ts similarity index 97% rename from cypress/integration/memory.spect.ts rename to cypress/integration/memory.spec.ts index b56d796..83606a4 100644 --- a/cypress/integration/memory.spect.ts +++ b/cypress/integration/memory.spec.ts @@ -1,12 +1,13 @@ describe('Memory page', () => { before(() => { + cy.visit('/'); }); beforeEach(() => { - cy.visit('/'); - cy.THUMDER_SignOut(); - cy.THUMDER_login(); + cy.setCookie('user', JSON.stringify(Cypress.env('USER_COOKIES'))); + cy.visit('/'); // Reload page + cy.wait(1000); cy.THUMDER_goMemory(); cy.get('#editMemoryModalButton').click(); diff --git a/cypress/integration/navigate.spect.ts b/cypress/integration/navigate.spec.ts similarity index 82% rename from cypress/integration/navigate.spect.ts rename to cypress/integration/navigate.spec.ts index 07b1e18..2d563f6 100644 --- a/cypress/integration/navigate.spect.ts +++ b/cypress/integration/navigate.spec.ts @@ -1,43 +1,35 @@ -describe('Visit pages no auth', () => { +describe('Visit pages auth', () => { - beforeEach(() => { + before(() => { + cy.visit('/'); }); - it('go to login', () => { - cy.visit('/login'); - cy.url().should('contain', '/login'); + beforeEach(() => { + cy.setCookie('user', JSON.stringify(Cypress.env('USER_COOKIES'))); + cy.visit('/'); // Reload page }); - it('go to forgot my password', () => { - cy.visit('/forgot-password'); - cy.url().should('contain', '/forgot-password'); + it('can visit Multiview', () => { + cy.THUMDER_goMultiview(); }); - it('go to register a new membership', () => { - cy.visit('/register'); - cy.url().should('contain', '/register'); - cy.contains('Register a new membership'); + it('can visit calculator', () => { + cy.THUMDER_goCalculator(); }); -}); - -describe('Visit pages auth', () => { - - before(() => { - cy.visit('/login'); + it('can visit Code', () => { + cy.THUMDER_goCode(); }); - beforeEach(() => { - cy.THUMDER_SignOut(); - cy.THUMDER_login(); - // cy.THUMDER_login() + it('can visit Config', () => { + cy.THUMDER_goConfig(); }); - it('can visit calculator', () => { - cy.THUMDER_goCalculator(); + it('can visit Documentation', () => { + cy.THUMDER_goDocumentation(); }); - it('can visit file-manager', () => { + it('can visit File manager', () => { cy.THUMDER_goFileManager(); }); @@ -45,40 +37,54 @@ describe('Visit pages auth', () => { cy.THUMDER_goIDE(); }); - it('can visit Pipeline', () => { - cy.THUMDER_goPipeline(); + it('can visit Logger', () => { + cy.THUMDER_goLogger(); + }); + + it('can visit Memory', () => { + cy.THUMDER_goMemory(); }); it('can visit Cycle clock diagram', () => { cy.THUMDER_goCycleClockDiagram(); }); - it('can visit Memory', () => { - cy.THUMDER_goMemory(); + it('can visit Pipeline', () => { + cy.THUMDER_goPipeline(); }); - it('can visit Code', () => { - cy.THUMDER_goCode(); + it('can visit Profile', () => { + cy.THUMDER_goProfile(); }); it('can visit Registers', () => { cy.THUMDER_goRegisters(); }); - it('can visit Profile', () => { - cy.THUMDER_goProfile(); + it('can visit Statistics', () => { + cy.THUMDER_goStatistics(); }); - it('can visit Documentation', () => { - cy.THUMDER_goDocumentation(); +}); +describe('Visit pages no auth', () => { + + beforeEach(() => { }); - it('can visit Config', () => { - cy.THUMDER_goConfig(); + it('go to login', () => { + cy.visit('/login'); + cy.url().should('contain', '/login'); }); - it('can visit Multiview', () => { - cy.THUMDER_goMultiview(); + it('go to forgot my password', () => { + cy.visit('/forgot-password'); + cy.url().should('contain', '/forgot-password'); + }); + + it('go to register a new membership', () => { + cy.visit('/register'); + cy.url().should('contain', '/register'); + cy.contains('Register a new membership'); }); }); diff --git a/cypress/support/commands/goToPage.ts b/cypress/support/commands/goToPage.ts index 8612e94..76ba868 100644 --- a/cypress/support/commands/goToPage.ts +++ b/cypress/support/commands/goToPage.ts @@ -31,6 +31,12 @@ export function THUMDER_goPipeline() { cy.location('pathname').should('eq', '/auth/pipeline'); } +export function THUMDER_goLogger() { + THUMDER_openNavigation(); + cy.get('a[title="logger"]').click(); + cy.location('pathname').should('eq', '/auth/logger'); +} + export function THUMDER_goCycleClockDiagram() { THUMDER_openNavigation(); cy.get('a[title="cycle-clock-diagram"]').click(); @@ -55,6 +61,13 @@ export function THUMDER_goRegisters() { cy.location('pathname').should('eq', '/auth/registers'); } + +export function THUMDER_goStatistics() { + THUMDER_openNavigation(); + cy.get('a[title="statistics"]').click(); + cy.location('pathname').should('eq', '/auth/statistics'); +} + export function THUMDER_goProfile() { THUMDER_openNavigation(); cy.get('a[title="profile"]').click(); diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 22f8c4b..e1faa10 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -16,7 +16,7 @@ // When a command from ./commands is ready to use, import with `import './commands'` syntax import * as f_goToPage from './commands/goToPage'; import * as f_setLang from './commands/setLang'; -import { THUMDER_goMultiview, THUMDER_openNavigation } from "./commands/goToPage"; +import { THUMDER_goMultiview, THUMDER_goStatistics, THUMDER_openNavigation } from "./commands/goToPage"; function THUMDER_SignOut(): void { cy.wait(2000); @@ -41,18 +41,20 @@ Cypress.Commands.add('THUMDER_login', THUMDER_login); Cypress.Commands.add('THUMDER_SignOut', THUMDER_SignOut); Cypress.Commands.add('THUMDER_goHome', f_goToPage.THUMDER_goHome); -Cypress.Commands.add('THUMDER_goFileManager', f_goToPage.THUMDER_goFileManager); +Cypress.Commands.add('THUMDER_goMultiview', f_goToPage.THUMDER_goMultiview); Cypress.Commands.add('THUMDER_goCalculator', f_goToPage.THUMDER_goCalculator); +Cypress.Commands.add('THUMDER_goCode', f_goToPage.THUMDER_goCode); +Cypress.Commands.add('THUMDER_goConfig', f_goToPage.THUMDER_goConfig); +Cypress.Commands.add('THUMDER_goDocumentation', f_goToPage.THUMDER_goDocumentation); +Cypress.Commands.add('THUMDER_goFileManager', f_goToPage.THUMDER_goFileManager); Cypress.Commands.add('THUMDER_goIDE', f_goToPage.THUMDER_goIDE); Cypress.Commands.add('THUMDER_goPipeline', f_goToPage.THUMDER_goPipeline); -Cypress.Commands.add('THUMDER_goCycleClockDiagram', f_goToPage.THUMDER_goCycleClockDiagram); +Cypress.Commands.add('THUMDER_goLogger', f_goToPage.THUMDER_goLogger); Cypress.Commands.add('THUMDER_goMemory', f_goToPage.THUMDER_goMemory); -Cypress.Commands.add('THUMDER_goCode', f_goToPage.THUMDER_goCode); -Cypress.Commands.add('THUMDER_goRegisters', f_goToPage.THUMDER_goRegisters); +Cypress.Commands.add('THUMDER_goCycleClockDiagram', f_goToPage.THUMDER_goCycleClockDiagram); Cypress.Commands.add('THUMDER_goProfile', f_goToPage.THUMDER_goProfile); -Cypress.Commands.add('THUMDER_goDocumentation', f_goToPage.THUMDER_goDocumentation); -Cypress.Commands.add('THUMDER_goConfig', f_goToPage.THUMDER_goConfig); -Cypress.Commands.add('THUMDER_goMultiview', f_goToPage.THUMDER_goMultiview); +Cypress.Commands.add('THUMDER_goRegisters', f_goToPage.THUMDER_goRegisters); +Cypress.Commands.add('THUMDER_goStatistics', f_goToPage.THUMDER_goStatistics); Cypress.Commands.add('THUMDER_setLangSpanish', f_setLang.THUMDER_setLangSpanish); Cypress.Commands.add('THUMDER_setLangEnglish', f_setLang.THUMDER_setLangEnglish); @@ -79,37 +81,41 @@ declare global { THUMDER_SignOut(): void; + THUMDER_openNavigation(): void; + THUMDER_setLangSpanish(): void; THUMDER_setLangEnglish(): void; - THUMDER_openNavigation(): void; - THUMDER_goHome(): void; + THUMDER_goMultiview(): void; + THUMDER_goCalculator(): void; + THUMDER_goCode(): void; + + THUMDER_goConfig(): void; + + THUMDER_goDocumentation(): void; + THUMDER_goFileManager(): void; THUMDER_goIDE(): void; - THUMDER_goPipeline(): void; - - THUMDER_goCycleClockDiagram(): void; + THUMDER_goLogger(): void; THUMDER_goMemory(): void; - THUMDER_goCode(): void; + THUMDER_goCycleClockDiagram(): void; - THUMDER_goRegisters(): void; + THUMDER_goPipeline(): void; THUMDER_goProfile(): void; - THUMDER_goDocumentation(): void; - - THUMDER_goConfig(): void; + THUMDER_goRegisters(): void; - THUMDER_goMultiview(): void; + THUMDER_goStatistics(): void; } } } diff --git a/src/app/CONSTAST.ts b/src/app/CONSTAST.ts index 1fd2cbb..da41adc 100644 --- a/src/app/CONSTAST.ts +++ b/src/app/CONSTAST.ts @@ -1,4 +1,5 @@ import { IndividualConfig } from "ngx-toastr/toastr/toastr-config"; +import npm from '../../package.json'; import { PublicRoutes, PublicRoutesList, @@ -8,11 +9,29 @@ import { TypeFloatingPointStageConfiguration, TypeRegister, TypeRegisterToEdit, - TypeTableCode, TypeDataStatistics, TypePipeline, TypeStepSimulation + TypeTableCode, TypeDataStatistics, TypePipeline, TypeStepSimulation, InterfaceFileItem, TypeMultiviewConfiguration } from "./types"; import { SocketIoConfig } from "ngx-socket-io"; -export const NPM_VERSION = '1.2.7'; +export const NPM_VERSION = npm.version.toString(); +export const DEFAULT_INTERFACE_FILE_ITEM: InterfaceFileItem = { + $key: "", + content: "", + dataItem: undefined, + dateModified: undefined, + description: "", + e1_uid: "", + f_id: "", + hasSubDirectories: false, + isDirectory: false, + key: "", + name: "", + path: "", + pathKeys: [], + size: 0, + thumbnail: "" + +}; export const REGEX_IS_ABSOLUTE_HREF = new RegExp('(?:^[a-z][a-z0-9+.-]*:|\/\/)', 'i'); export const REGEX_HEXADECIMAL_08 = new RegExp('^(0x|0X|)?([a-fA-F0-9]{08})$', 'i'); @@ -23,6 +42,16 @@ export const DEFAULT_AUTO_SAVE: boolean = true; export const DEFAULT_LANG: TypeLang = 'en'; // 0x8000 --> 32768 export const DEFAULT_MEMORY_SIZE: number = 32768; +export const DEFAULT_MULTIVIEW_CONFIGURATION: TypeMultiviewConfiguration = { + calculator: false, + code: true, + cycle_clock: true, + memory: true, + pipeline: true, + registers: true, + statistics: false + +}; export const DEFAULT_FLOATING_POINT_STAGE_CONFIGURATION: TypeFloatingPointStageConfiguration = { addition: { count: 1, @@ -350,7 +379,10 @@ export const CONFIG_WEBSOCKET: SocketIoConfig = { url: 'http://localhost:3000', options: { transports: ['websocket'], - reconnection: false + reconnection: true, + reconnectionDelay: 20000, + reconnectionDelayMax: 25000, + reconnectionAttempts: 5 } }; @@ -384,7 +416,7 @@ export const AUTH_ROUTES: PublicRoutesList = [ data: {breadcrumb: 'Documentation'} }, { - lang: 'FILE-MANAGER', + lang: 'FILE_MANAGER', path: 'file-manager', routerLink: '/auth/file-manager', displayName: 'file-manager', @@ -412,7 +444,7 @@ export const AUTH_ROUTES: PublicRoutesList = [ data: {breadcrumb: 'Memory'} }, { - lang: "CYCLE-CLOCK-DIAGRAM", + lang: "CYCLE_CLOCK_DIAGRAM", path: "cycle-clock-diagram", routerLink: '/auth/cycle-clock-diagram', displayName: 'Cycle clock diagram', @@ -453,6 +485,13 @@ export const AUTH_ROUTES: PublicRoutesList = [ displayName: 'Multiview', data: {breadcrumb: 'Multiview'} }, + { + lang: "DEBUG", + path: "debug", + routerLink: '/auth/debug', + displayName: 'Debug', + data: {breadcrumb: 'Debug'} + }, ]; export const PUBLIC_ROUTES: PublicRoutes = { diff --git a/src/app/__core/auth/auth.service.ts b/src/app/__core/auth/auth.service.ts index 03dfa30..7dad907 100644 --- a/src/app/__core/auth/auth.service.ts +++ b/src/app/__core/auth/auth.service.ts @@ -4,7 +4,7 @@ import { AngularFireAuth } from "@angular/fire/auth"; import { AngularFirestore, AngularFirestoreDocument } from '@angular/fire/firestore'; import { ElectronService } from "../services"; import { Router } from "@angular/router"; -import { Subscription } from "rxjs"; +import { Observable, Subject, Subscription } from "rxjs"; import firebase from 'firebase/app'; import UserCredential = firebase.auth.UserCredential; @@ -13,6 +13,8 @@ import UserCredential = firebase.auth.UserCredential; }) export class AuthService implements OnInit, OnDestroy { + public isLogging$: Subject = new Subject(); + public userData: InterfaceUser; // Save logged in user data private subscriptions$ = new Subscription(); @@ -28,9 +30,11 @@ export class AuthService implements OnInit, OnDestroy { this.userData = user; localStorage.setItem('user', JSON.stringify(this.userData)); JSON.parse(localStorage.getItem('user')); + this.isLogging$.next(true); } else { localStorage.setItem('user', null); JSON.parse(localStorage.getItem('user')); + this.isLogging$.next(false); } }) ); @@ -44,6 +48,10 @@ export class AuthService implements OnInit, OnDestroy { this.subscriptions$.unsubscribe(); } + public getIsLoggingObservable(): Observable { + return this.isLogging$.asObservable(); + } + // Sign in with email/password async SignIn(email, password): Promise { try { diff --git a/src/app/__core/machine/debugger/BreakpointManager.ts b/src/app/__core/machine/debugger/BreakpointManager.ts index 60ef3db..55db94f 100644 --- a/src/app/__core/machine/debugger/BreakpointManager.ts +++ b/src/app/__core/machine/debugger/BreakpointManager.ts @@ -22,6 +22,10 @@ export class BreakpointManager { } public updateManager(breakpoints: TypeBreakpoints): void { + if (breakpoints === null || breakpoints === undefined) { + console.warn('Error, breakpoints null'); + return; + } this.breakpoints = {}; for (const [line, enabled] of Object.entries(breakpoints)) { this.breakpoints[line] = enabled; diff --git a/src/app/__core/machine/machine.service.ts b/src/app/__core/machine/machine.service.ts index 2384c0f..fc1420b 100644 --- a/src/app/__core/machine/machine.service.ts +++ b/src/app/__core/machine/machine.service.ts @@ -380,33 +380,37 @@ export class MachineService { if (this.statusMachineInStep.memory !== []) { for (const memory_value of this.statusMachineInStep.memory) { const address = memory_value.address; - const typeData = memory_value.typeData ?? "word"; + const typeData = memory_value.typeData ?? "Word"; switch (typeData) { - case "byte": { + case "Byte": { const binary08 = Utils.hexadecimalToBinary(memory_value.value); this.memory.setMemoryByteBinaryByAddress(address, binary08); break; } - case "halfword": { + case "HalfWord": { const binary16 = Utils.hexadecimalToBinary(memory_value.value); this.memory.setMemoryHalfWordBinaryByAddress(address, binary16); break; } - case "word": { + case "Word": { const binary32 = Utils.hexadecimalToBinary(memory_value.value); this.memory.setMemoryWordBinaryByAddress(address, binary32); break; } - case "float": { + case "Float": { const binary08 = Utils.hexadecimalToBinary(memory_value.value); this.memory.setMemoryFloatBinaryByAddress(address, binary08); break; } - case "double": { + case "Double": { const binary64 = Utils.hexadecimalToBinary(memory_value.value); this.memory.setMemoryDoubleBinaryByAddress(address, binary64); break; } + case "ASCII": { + + break; + } } // this.log('Dirección: ', address, 'con valor', value, 'de la instrucción', instructionText); } diff --git a/src/app/__core/services/file-system-nonodev96/file-system-storage.service.ts b/src/app/__core/services/file-system-nonodev96/file-system-storage.service.ts index 813b073..9b3464f 100644 --- a/src/app/__core/services/file-system-nonodev96/file-system-storage.service.ts +++ b/src/app/__core/services/file-system-nonodev96/file-system-storage.service.ts @@ -7,7 +7,7 @@ import { AngularFireDatabase, AngularFireList } from "@angular/fire/database"; import { AngularFirestore, AngularFirestoreCollection } from "@angular/fire/firestore"; import { Utils } from "../../../Utils"; import { FileItem } from "./file-system.service"; -import { InterfaceFileItem } from "../../../types"; +import { InterfaceFileItem, InterfaceUser } from "../../../types"; import firebase from "firebase/app"; import "firebase/firestore"; import Timestamp = firebase.firestore.Timestamp; @@ -23,7 +23,7 @@ export class FileSystemStorageService { constructor(private httpClient: HttpClient, private afs: AngularFirestore, private db: AngularFireDatabase) { - const userData = JSON.parse(localStorage.getItem('user')); + const userData = JSON.parse(localStorage.getItem('user')) as InterfaceUser; this.UID = userData.uid; this.fileItems_Collections = this.afs.collection('/fileitems', (ref) => { return ref.where("e1_uid", "==", this.UID); @@ -36,26 +36,31 @@ export class FileSystemStorageService { return Promise.resolve(1); } console.log('FileSystem isInitialize'); + return Promise.resolve(0); + } - const listNameExamples = ['prim.s', 'base.s', 'fact.s', 'gcm.s', 'input.s']; - for (const filename of listNameExamples) { - const defaultFile = new FileItem('', false, []); - defaultFile.name = filename; - defaultFile.key = Utils.uuidv4(); - - const content = await this.httpClient.get('assets/examples-dlx/' + filename, {responseType: 'text'}).toPromise(); - const fileItem: InterfaceFileItem = { - ...defaultFile, - dateModified: Timestamp.fromDate(new Date()), - f_id: '', - path: '', - pathKeys: [], - e1_uid: this.UID, - content: content, - description: '' - }; - await this.addFileItem(fileItem); + public async generateDefaultFiles(): Promise { + if (await this.isInitialize()) { + return Promise.resolve(1); } + const filename = 'prim.s'; + const defaultFileItem = new FileItem('', false, []); + defaultFileItem.name = filename; + defaultFileItem.key = Utils.uuidv4(); + + const content = await this.httpClient.get('assets/examples-dlx/' + filename, {responseType: 'text'}).toPromise(); + const defaultInterfaceFileItem: InterfaceFileItem = { + ...defaultFileItem, + dateModified: Timestamp.fromDate(new Date()), + e1_uid: this.UID, + content: content, + f_id: '', + path: '', + pathKeys: [], + description: '' + }; + console.debug("Se quiere crear un fichero con los siguientes datos %o", defaultInterfaceFileItem); + await this.addFileItem(defaultInterfaceFileItem); return Promise.resolve(0); } @@ -71,33 +76,41 @@ export class FileSystemStorageService { }); }) ); + // return this.fileItems_Collections.valueChanges(); } - public async addFileItem(interfaceFileItem: InterfaceFileItem) { - const clearItem: InterfaceFileItem = { - key: interfaceFileItem.key ?? '', - pathKeys: interfaceFileItem.pathKeys ?? [], - path: interfaceFileItem.path ?? '', - name: interfaceFileItem.name ?? '', - isDirectory: interfaceFileItem.isDirectory ?? false, - hasSubDirectories: interfaceFileItem.hasSubDirectories ?? false, - dateModified: interfaceFileItem.dateModified ?? Timestamp.fromDate(new Date()), - thumbnail: interfaceFileItem.thumbnail ?? '', - size: interfaceFileItem.size ?? 0, - dataItem: interfaceFileItem.dataItem ?? {}, + public async addFileItem(interfaceFileItem: InterfaceFileItem): Promise { + try { + const clearItem: InterfaceFileItem = { + key: interfaceFileItem.key ?? '', + pathKeys: interfaceFileItem.pathKeys ?? [], + path: interfaceFileItem.path ?? '', + name: interfaceFileItem.name ?? '', + isDirectory: interfaceFileItem.isDirectory ?? false, + hasSubDirectories: interfaceFileItem.hasSubDirectories ?? false, + dateModified: interfaceFileItem.dateModified ?? Timestamp.fromDate(new Date()), + thumbnail: interfaceFileItem.thumbnail ?? '', + size: interfaceFileItem.size ?? 0, + dataItem: interfaceFileItem.dataItem ?? {}, - e1_uid: this.UID, - f_id: interfaceFileItem.f_id ?? '', - description: interfaceFileItem.description ?? '', - content: interfaceFileItem.content ?? '' - }; - const id = this.afs.createId(); - await this.fileItems_Collections.doc(id).set(clearItem); + e1_uid: this.UID, + f_id: interfaceFileItem.f_id ?? '', + description: interfaceFileItem.description ?? '', + content: interfaceFileItem.content ?? '' + }; + const id = this.afs.createId(); + console.log("El nuevo fichero con ID", id, clearItem); + await this.fileItems_Collections.doc(id).set(clearItem, {merge: true}); + } catch (error) { + console.error(error); + } + return Promise.resolve(); } public async deleteFileItem(id: string): Promise { try { + console.debug("Se va a borrar en el servidor el documento con ID %s", id); const result = await this.fileItems_Collections.doc(id).delete(); return Promise.resolve(result); } catch (error) { diff --git a/src/app/__core/services/file-system-nonodev96/file-system.service.ts b/src/app/__core/services/file-system-nonodev96/file-system.service.ts index 5f7a0dd..712ee87 100644 --- a/src/app/__core/services/file-system-nonodev96/file-system.service.ts +++ b/src/app/__core/services/file-system-nonodev96/file-system.service.ts @@ -46,7 +46,7 @@ export class FileSystemService { } public async getItems(path: FileSystemItem): Promise> { - const results = this.ITEMS.filter(value => Utils.arrayIsEqual(value.pathKeys, path.pathKeys)); + const results = this.ITEMS; const fileItems = results.map((value) => { const item: FileItem = new FileItem('', false, []); item.key = value.key; @@ -164,28 +164,15 @@ export class FileSystemService { } public async deleteItem(item: FileSystemItem): Promise { - const index1 = this.items.findIndex(value => value.key === item.key); - if (index1 > -1) { - if (item.isDirectory) { - const listElementsToDelete = this.items.filter(value => Utils.isSubset(value.pathKeys, item.pathKeys)); - for (const fileItemToDelete of listElementsToDelete) { - const indexToDelete = this.items.findIndex(value => value.key === fileItemToDelete.key); - this.items.splice(indexToDelete, 1); - } - } - this.items.splice(index1, 1); - - const index2 = this.ITEMS.findIndex(value => value.key === item.key); - if (item.isDirectory) { - const listElementsToDelete = this.ITEMS.filter(value => Utils.isSubset(value.pathKeys, item.pathKeys)); - for (const fileItemToDelete of listElementsToDelete) { - const indexToDelete2 = this.ITEMS.findIndex(value => value.key === fileItemToDelete.key); - const {$key} = this.ITEMS[indexToDelete2]; - await this.fileSystemStorageService.deleteFileItem($key); - this.ITEMS.splice(indexToDelete2, 1); - } - } - this.ITEMS.splice(index2, 1); + const indexToDelete1 = this.items.findIndex(value => value.key === item.key); + if (indexToDelete1 > -1) { + this.items.splice(indexToDelete1, 1); + } + const indexToDelete2 = this.ITEMS.findIndex(value => value.key === item.key); + if (indexToDelete2 > -1) { + const {$key} = this.ITEMS[indexToDelete2]; + await this.fileSystemStorageService.deleteFileItem($key); + this.ITEMS.splice(indexToDelete2, 1); } return Promise.resolve(item); } @@ -202,4 +189,9 @@ export class FileSystemService { console.log('TODO', items); } + public async generateDefaultFiles(): Promise { + const code = await this.fileSystemStorageService.generateDefaultFiles(); + return Promise.resolve(code); + } + } diff --git a/src/app/__core/services/socket-provider-connect.service.ts b/src/app/__core/services/socket-provider-connect.service.ts index 6150a25..2fbe8d3 100644 --- a/src/app/__core/services/socket-provider-connect.service.ts +++ b/src/app/__core/services/socket-provider-connect.service.ts @@ -4,46 +4,90 @@ import { Socket } from 'ngx-socket-io'; import { ToastrService } from "ngx-toastr"; import { DEFAULT_CONFIG_TOAST } from "../../CONSTAST"; -import { BehaviorSubject, Subject } from "rxjs"; +import { Subject } from "rxjs"; @Injectable({ providedIn: 'root' }) export class SocketProviderConnectService { - private connectSubject = new Subject(); - private publicMessageSubject = new Subject(); - private privateMessageSubject = new Subject(); + private connect$ = new Subject(); + private publicMessage$ = new Subject(); + private privateMessage$ = new Subject(); - public connectObservable = this.connectSubject.asObservable(); - public publicMessageObservable = this.publicMessageSubject.asObservable(); - public privateMessageObservable = this.privateMessageSubject.asObservable(); + public connectObservable = this.connect$.asObservable(); + public publicMessageObservable = this.publicMessage$.asObservable(); + public privateMessageObservable = this.privateMessage$.asObservable(); + + /** + * TODO + * https://www.tutorialspoint.com/socket.io/socket.io_error_handling.htm + */ constructor(public socket: Socket, private translate: TranslateService, private toast: ToastrService) { + // When the client successfully connects. this.socket.ioSocket.on('connect', () => { const connect = this.socket.connect(); - this.connectSubject.next(connect); + this.connect$.next(connect); if (connect.connected) { - this.socket.ioSocket.on('message', (res) => { - this.publicMessageSubject.next(res); - }); this.socket.ioSocket.on(this.socket.ioSocket.id, (res) => { - this.privateMessageSubject.next(res); + this.privateMessage$.next(res); }); } }); + // When the client is in the process of connecting. + this.socket.ioSocket.on('connecting', () => { + console.debug('WebSocket-connecting'); + + }); + // When the client is disconnected. + this.socket.ioSocket.on('disconnect', () => { + console.debug('WebSocket-disconnect'); + }); + // When the connection to the server fails. + this.socket.ioSocket.on('connect_failed', (err) => { + console.debug('WebSocket-connect_failed'); + SocketProviderConnectService.handleErrors(err); + }); + // An error event is sent from the server. + this.socket.ioSocket.on('error', (err) => { + console.debug('WebSocket-error'); + SocketProviderConnectService.handleErrors(err); + }); + // When the server sends a message using the send function. + this.socket.ioSocket.on('message', (data) => { + console.debug('WebSocket-message'); + const title = this.translate.instant('WEBSOCKET.TITLE_NEW_MESSAGE'); + const message = this.translate.instant('WEBSOCKET.MESSAGE_NEW_MESSAGE', {type: 'message'}); + this.toast.info(title, message); + this.publicMessage$.next(data); + }); + // When reconnection to the server is successful. + this.socket.ioSocket.on('reconnect', () => { + console.debug('WebSocket-reconnect'); + + }); + // When the client is in the process of connecting. + this.socket.ioSocket.on('reconnecting', () => { + console.debug('WebSocket-reconnecting'); + + }); + // When the reconnection attempt fails. + this.socket.ioSocket.on('reconnect_failed', (err) => { + console.debug('WebSocket-reconnect_failed'); + SocketProviderConnectService.handleErrors(err); + }); - this.socket.ioSocket.on('connect_error', async () => { - const title_server_down_lang = await this.translate.get('TOAST.TITLE_SERVER_DOWN').toPromise(); - const message_server_down_lang = await this.translate.get('TOAST.MESSAGE_SERVER_DOWN').toPromise(); - this.toast.warning(message_server_down_lang, title_server_down_lang, DEFAULT_CONFIG_TOAST); + this.socket.ioSocket.on('connect_error', (err) => { + console.debug('WebSocket-connect_error'); + SocketProviderConnectService.handleErrors(err); + const title = this.translate.instant('TOAST.TITLE_SERVER_DOWN'); + const message = this.translate.instant('TOAST.MESSAGE_SERVER_DOWN'); + this.toast.warning(message, title, DEFAULT_CONFIG_TOAST); }); - this.socket.ioSocket.on('connect_failed', err => SocketProviderConnectService.handleErrors(err)); - this.socket.ioSocket.on('disconnect', err => SocketProviderConnectService.handleErrors(err)); - this.socket.ioSocket.on('error', err => SocketProviderConnectService.handleErrors(err)); } emitMessage(event = 'default', payload = {}) { diff --git a/src/app/__core/storage/storage.service.ts b/src/app/__core/storage/storage.service.ts index e562ed7..2f0f9ed 100644 --- a/src/app/__core/storage/storage.service.ts +++ b/src/app/__core/storage/storage.service.ts @@ -2,9 +2,9 @@ import { Injectable } from '@angular/core'; import { Observable, Subject } from "rxjs"; import { DEFAULT_AUTO_SAVE, - DEFAULT_FLOATING_POINT_STAGE_CONFIGURATION, + DEFAULT_FLOATING_POINT_STAGE_CONFIGURATION, DEFAULT_INTERFACE_FILE_ITEM, DEFAULT_LANG, - DEFAULT_MEMORY_SIZE, DEFAULT_TIME_SIMULATION + DEFAULT_MEMORY_SIZE, DEFAULT_MULTIVIEW_CONFIGURATION, DEFAULT_TIME_SIMULATION } from "../../CONSTAST"; @Injectable({ @@ -39,6 +39,9 @@ export class StorageService { if (!this.hasItem('floating_point_stage_configuration')) { this.setItem('floating_point_stage_configuration', DEFAULT_FLOATING_POINT_STAGE_CONFIGURATION); } + if (!this.hasItem('multiview_configuration')) { + this.setItem('multiview_configuration', DEFAULT_MULTIVIEW_CONFIGURATION); + } if (!this.hasItem('memory_size')) { this.setItem('memory_size', DEFAULT_MEMORY_SIZE); } @@ -51,5 +54,8 @@ export class StorageService { if (!this.hasItem('auto_save')) { this.setItem('auto_save', DEFAULT_AUTO_SAVE); } + if (!this.hasItem('interfaceFileItem')) { + this.setItem('interfaceFileItem', DEFAULT_INTERFACE_FILE_ITEM); + } } } diff --git a/src/app/__shared/guard/auth.guard.ts b/src/app/__shared/guard/auth.guard.ts index 0d35573..ff4734d 100644 --- a/src/app/__shared/guard/auth.guard.ts +++ b/src/app/__shared/guard/auth.guard.ts @@ -27,7 +27,7 @@ export class AuthGuard implements CanActivate { const lang_access_denied = await this.translate.get('TOAST.ACCESS_DENIED').toPromise(); const lang_login_false = await this.translate.get('TOAST.LOGIN_FALSE').toPromise(); this.toast.warning(lang_login_false, lang_access_denied, config); - await this.router.navigate(['/login']); + await this.router.navigateByUrl('/login'); } return Promise.resolve(this.authService.isLoggedIn); } diff --git a/src/app/__shared/guard/no-auth.guard.ts b/src/app/__shared/guard/no-auth.guard.ts index a1bb924..14e035d 100644 --- a/src/app/__shared/guard/no-auth.guard.ts +++ b/src/app/__shared/guard/no-auth.guard.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router'; import { Observable } from 'rxjs'; import { AuthService } from "../../__core/auth/auth.service"; +import { IndividualConfig } from "ngx-toastr/toastr/toastr-config"; @Injectable({ providedIn: 'root' @@ -11,8 +12,11 @@ export class NoAuthGuard implements CanActivate { constructor(public authService: AuthService, public router: Router) { } - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { - return !this.authService.isLoggedIn; + async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { + if (this.authService.isLoggedIn) { + await this.router.navigateByUrl('/'); + } + return Promise.resolve(!this.authService.isLoggedIn); } } diff --git a/src/app/_layouts/auth/layout-auth.component.html b/src/app/_layouts/auth/layout-auth.component.html index 0680b43..6382340 100644 --- a/src/app/_layouts/auth/layout-auth.component.html +++ b/src/app/_layouts/auth/layout-auth.component.html @@ -1 +1,46 @@ - +
+ + + + + + + + + +
+ +
+
+
+
+

{{ 'PAGES.HOME.TITLE' | translate }}

+
+
+ + + +
+
+
+
+ + + +
+ + + + +
+ +
+ + + + + + + + +
diff --git a/src/app/_layouts/auth/layout-auth.component.ts b/src/app/_layouts/auth/layout-auth.component.ts index 29ef597..e347fee 100644 --- a/src/app/_layouts/auth/layout-auth.component.ts +++ b/src/app/_layouts/auth/layout-auth.component.ts @@ -2,7 +2,7 @@ import { AfterViewInit, Component, Inject, OnInit } from "@angular/core"; import { DOCUMENT } from "@angular/common"; @Component({ - selector: "app-auth", + selector: "THUMDER-auth", templateUrl: "./layout-auth.component.html", }) export class LayoutAuthComponent implements OnInit, AfterViewInit { diff --git a/src/app/_layouts/landing/layout-landing.component.html b/src/app/_layouts/landing/layout-landing.component.html index 0680b43..6382340 100644 --- a/src/app/_layouts/landing/layout-landing.component.html +++ b/src/app/_layouts/landing/layout-landing.component.html @@ -1 +1,46 @@ - +
+ + + + + + + + + +
+ +
+
+
+
+

{{ 'PAGES.HOME.TITLE' | translate }}

+
+
+ + + +
+
+
+
+ + + +
+ + + + +
+ +
+ + + + + + + + +
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 84ba25a..94b76ca 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -48,9 +48,12 @@ import { LoggerView } from "./views/_auth/logger/logger.view"; const routes: Routes = [ { - path: '', - component: IndexView, - canActivate: [AuthGuard] + path: "", + component: LayoutAuthComponent, + canActivate: [AuthGuard], + children: [ + {path: "", component: IndexView, pathMatch: "full"}, + ] }, // _admin views { @@ -82,6 +85,8 @@ const routes: Routes = [ {path: "registers", component: RegistersView, data: {breadcrumb: 'Registers'}}, {path: "statistics", component: StatisticsView, data: {breadcrumb: 'Statistics'}}, {path: "multiview", component: MultiplesViewsComponent, data: {breadcrumb: 'Multiview'}}, + + {path: "debug", component: DebugView, data: {breadcrumb: 'Debug'}}, ], }, // _landing views @@ -109,26 +114,21 @@ const routes: Routes = [ component: ForgotPasswordView, canActivate: [NoAuthGuard] }, - { - path: "debug", - component: DebugView, - canActivate: [] - }, { path: 'monaco', component: MonacoEditorComponent }, - { - path: '**', - component: PageNotFoundComponent - }, + // { + // path: '**', + // component: PageNotFoundComponent + // }, ]; @NgModule({ imports: [ - RouterModule.forRoot(routes, {relativeLinkResolution: 'legacy'}), + RouterModule.forRoot(routes), ], exports: [RouterModule] }) diff --git a/src/app/app.component.html b/src/app/app.component.html index a7f87f2..6a164d6 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,53 +1,2 @@ - - - - - -
- - - - - - - - - -
- -
-
-
-
-

{{ 'PAGES.HOME.TITLE' | translate }}

-
-
- - - -
-
-
-
- - - -
- - - - -
- -
- - - - - - - - -
-
+ diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7c7bef6..26ae520 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -67,6 +67,7 @@ export class AppComponent implements OnInit, OnDestroy { this.translate.addLangs(['en', 'sp']); this.translate.setDefaultLang(this.lang); + // ngx-cookieconsent this.popupOpenSubscription = this.ccService.popupOpen$.subscribe( () => { // you can use this.ccService.getConfig() to do stuff... @@ -76,7 +77,7 @@ export class AppComponent implements OnInit, OnDestroy { this.popupCloseSubscription = this.ccService.popupClose$.subscribe( () => { // you can use this.ccService.getConfig() to do stuff... - console.log('popuClose'); + console.log('popupClose'); }); this.initializeSubscription = this.ccService.initialize$.subscribe( @@ -102,6 +103,11 @@ export class AppComponent implements OnInit, OnDestroy { // you can use this.ccService.getConfig() to do stuff... console.log(`noCookieLaw: ${JSON.stringify(event)}`); }); + this.updateCookiesConsentLang(); + + document.getElementById('cookieconsent:link').addEventListener('click', async (e) => { + await this.router.navigateByUrl('/cookies'); + }); } ngOnDestroy(): void { @@ -122,5 +128,25 @@ export class AppComponent implements OnInit, OnDestroy { this.storageService.setItem('lang', lang); this.lang = lang; this.translate.setDefaultLang(lang); + this.updateCookiesConsentLang(); + } + + private updateCookiesConsentLang() { + this.translate + .get(['cookie.header', 'cookie.message', 'cookie.dismiss', 'cookie.allow', 'cookie.deny', 'cookie.link', 'cookie.policy']) + .subscribe((data) => { + this.ccService.getConfig().content = this.ccService.getConfig().content || {}; + // Override default messages with the translated ones + this.ccService.getConfig().content.header = data['cookie.header']; + this.ccService.getConfig().content.message = data['cookie.message']; + this.ccService.getConfig().content.dismiss = data['cookie.dismiss']; + this.ccService.getConfig().content.allow = data['cookie.allow']; + this.ccService.getConfig().content.deny = data['cookie.deny']; + this.ccService.getConfig().content.link = data['cookie.link']; + this.ccService.getConfig().content.policy = data['cookie.policy']; + + this.ccService.destroy(); // remove previous cookie bar (with default messages) + this.ccService.init(this.ccService.getConfig()); // update config with translated messages + }); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2d914f3..6e0f4bd 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -110,7 +110,17 @@ const cookieConfig: NgcCookieConsentConfig = { } }, theme: 'edgeless', - type: 'opt-out' + type: 'opt-out', + content: { + href: "#", + }, + elements: { + messagelink: ` + {{message}}  + {{link}} + + ` + } }; diff --git a/src/app/components/navbars/auth-navbar/auth-navbar.component.html b/src/app/components/navbars/auth-navbar/auth-navbar.component.html index 538e352..ee7d8ea 100644 --- a/src/app/components/navbars/auth-navbar/auth-navbar.component.html +++ b/src/app/components/navbars/auth-navbar/auth-navbar.component.html @@ -29,13 +29,19 @@ + + diff --git a/src/app/types.ts b/src/app/types.ts index 1a57585..2eca32b 100644 --- a/src/app/types.ts +++ b/src/app/types.ts @@ -193,6 +193,15 @@ export type TypeCode = { code: string; // 0x00000000 }; +export type TypeMultiviewConfiguration = { + calculator: boolean; + pipeline: boolean; + cycle_clock: boolean; + memory: boolean; + registers: boolean; + code: boolean; + statistics: boolean; +}; export type TypeFloatingPointStageConfiguration = { addition: { count: number; @@ -243,6 +252,18 @@ export type TypePipeline = { WB: string; }; +export type TypeRegisterToUpdate = { + typeRegister: TypeRegister; + register: string; + value: string; +}; + +export type TypeMemoryToUpdate = { + typeData: TypeData; + address: string; + value: string; +}; + export type TypeStepSimulation = { step: number; instruction: string; @@ -263,15 +284,8 @@ export type TypeStepSimulation = { WB_stall: number; pipeline: TypePipeline; - registers: { - register: string; - value: string; - }[]; - memory: { - typeData: "byte" | "halfword" | "word" | "float" | "double"; - address: string; - value: string; - }[]; + registers: TypeRegisterToUpdate[]; + memory: TypeMemoryToUpdate[]; }; export type SimulationResponse = { diff --git a/src/app/views/_auth/_views/multiples-views.component.html b/src/app/views/_auth/_views/multiples-views.component.html index 1bef005..120a8b2 100644 --- a/src/app/views/_auth/_views/multiples-views.component.html +++ b/src/app/views/_auth/_views/multiples-views.component.html @@ -1,6 +1,28 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/views/_auth/_views/multiples-views.component.ts b/src/app/views/_auth/_views/multiples-views.component.ts index e62a89e..90de1a0 100644 --- a/src/app/views/_auth/_views/multiples-views.component.ts +++ b/src/app/views/_auth/_views/multiples-views.component.ts @@ -1,4 +1,5 @@ import { AfterViewInit, Component, OnInit } from '@angular/core'; +import { TypeMultiviewConfiguration } from "../../../types"; @Component({ selector: 'view-multiples-views', @@ -6,8 +7,10 @@ import { AfterViewInit, Component, OnInit } from '@angular/core'; styleUrls: [] }) export class MultiplesViewsComponent implements OnInit, AfterViewInit { + multiviewConfiguration: TypeMultiviewConfiguration; constructor() { + this.multiviewConfiguration = JSON.parse(localStorage.getItem('multiview_configuration')) as TypeMultiviewConfiguration; } ngOnInit(): void { diff --git a/src/app/views/_auth/config/config.view.html b/src/app/views/_auth/config/config.view.html index e6d6256..6e0ddc8 100644 --- a/src/app/views/_auth/config/config.view.html +++ b/src/app/views/_auth/config/config.view.html @@ -1,6 +1,6 @@
-

{{ 'CONFIG.FLOATING_POINT_STAGE_CONFIGURATION' | translate }}

+

{{ 'NAVIGATION.CONFIG' | translate }}

- +
+--> diff --git a/src/app/views/_auth/config/config.view.ts b/src/app/views/_auth/config/config.view.ts index 2215f3b..8458bdf 100644 --- a/src/app/views/_auth/config/config.view.ts +++ b/src/app/views/_auth/config/config.view.ts @@ -1,10 +1,10 @@ import { Component, OnInit } from '@angular/core'; -import { TypeFloatingPointStageConfiguration } from "../../../types"; +import { TypeFloatingPointStageConfiguration, TypeMultiviewConfiguration } from "../../../types"; import { StorageService } from "../../../__core/storage/storage.service"; import { DEFAULT_AUTO_SAVE, DEFAULT_FLOATING_POINT_STAGE_CONFIGURATION, - DEFAULT_MEMORY_SIZE, + DEFAULT_MEMORY_SIZE, DEFAULT_MULTIVIEW_CONFIGURATION, DEFAULT_TIME_SIMULATION } from "../../../CONSTAST"; import { MachineService } from "../../../__core/machine/machine.service"; @@ -20,6 +20,7 @@ interface EventTargetInput extends EventTarget { }) export class ConfigView implements OnInit { + multiviewConfiguration: TypeMultiviewConfiguration = DEFAULT_MULTIVIEW_CONFIGURATION; floatingPointStageConfiguration: TypeFloatingPointStageConfiguration; memorySize: number; timeSimulation: number; @@ -27,6 +28,7 @@ export class ConfigView implements OnInit { constructor(private storage: StorageService, private machine: MachineService) { + this.multiviewConfiguration = this.storage.getItem('multiview_configuration'); this.floatingPointStageConfiguration = this.storage.getItem('floating_point_stage_configuration'); this.memorySize = this.storage.getItem('memory_size'); this.timeSimulation = this.storage.getItem('time_simulation'); @@ -48,11 +50,15 @@ export class ConfigView implements OnInit { case 'auto_save': this.autoSave = this.storage.getItem('auto_save'); break; + case 'multiview_configuration': + this.multiviewConfiguration = this.storage.getItem('multiview_configuration'); + break; } }); } async updateConfiguration(): Promise { + this.storage.setItem('multiview_configuration', this.multiviewConfiguration); this.storage.setItem('floating_point_stage_configuration', this.floatingPointStageConfiguration); this.storage.setItem('memory_size', this.memorySize); this.storage.setItem('time_simulation', this.timeSimulation); @@ -62,6 +68,7 @@ export class ConfigView implements OnInit { } async resetConfiguration(): Promise { + this.storage.setItem('multiview_configuration', DEFAULT_MULTIVIEW_CONFIGURATION); this.storage.setItem('floating_point_stage_configuration', DEFAULT_FLOATING_POINT_STAGE_CONFIGURATION); this.storage.setItem('memory_size', DEFAULT_MEMORY_SIZE); this.storage.setItem('time_simulation', DEFAULT_TIME_SIMULATION); @@ -102,6 +109,10 @@ export class ConfigView implements OnInit { } updateTimeSimulation(target: EventTargetInput | any) { - this.timeSimulation = parseInt(target.value.toString()) + this.timeSimulation = parseInt(target.value.toString()); + } + + updateMultiviewConfig(target: EventTarget | any) { + } } diff --git a/src/app/views/_auth/file-manager/file-manager.view.html b/src/app/views/_auth/file-manager/file-manager.view.html index d24b54d..e73a5d4 100644 --- a/src/app/views/_auth/file-manager/file-manager.view.html +++ b/src/app/views/_auth/file-manager/file-manager.view.html @@ -1,14 +1,18 @@ + + +
- - - - + + + + - + @@ -52,7 +56,7 @@ - + @@ -64,7 +68,27 @@ - +
+ +
+
+

{{'DEBUG' | translate}}

+
+ + +
+
+
+

Files selected: {{filesSelected}}

+
+ +
- - - - - - - - - - - - - - -
{{ 'ADDRESS' | translate }}{{ 'TEXT' | translate }}{{ 'INSTRUCTION' | translate }}{{ 'CODE' | translate }}
{{item.address}}{{item.text}}{{item.instruction}}{{item.code}}
- -
- - - + [(ngModel)]="testCodeRequest"> + + + + + + + + + + + + + + +
{{ 'ADDRESS' | translate }}{{ 'TEXT' | translate }}{{ 'INSTRUCTION' | translate }}{{ 'CODE' | translate }}
{{item.address}}{{item.text}}{{item.instruction}}{{item.code}}
+ diff --git a/src/app/views/debug/debug-view.ts b/src/app/views/debug/debug-view.ts index ce235c6..4af76a5 100644 --- a/src/app/views/debug/debug-view.ts +++ b/src/app/views/debug/debug-view.ts @@ -2,10 +2,10 @@ import { Component, OnInit } from '@angular/core'; import { ToastrService } from "ngx-toastr"; import { Utils } from "../../Utils"; import { FileItem } from "../../__core/services/file-system-nonodev96/file-system.service"; -import { SocketProviderConnectService } from "../../__core/services/socket-provider-connect.service"; +import { SocketProviderConnectService } from "../../__core/services/socket-provider-connect.service"; import { DEFAULT_CONFIG_TOAST } from "../../CONSTAST"; -import { TypeCode } from "../../types"; +import { TypeCode, TypeData, TypeMemoryToUpdate, TypeRegister } from "../../types"; @Component({ selector: 'app-debug', @@ -15,7 +15,7 @@ import { TypeCode } from "../../types"; export class DebugView implements OnInit { public socketID: string = ""; - public testRequest: string = [ + public testCodeRequest: string = [ "main:", "ADDI R1, R0, #0", "ADDI R2, R0, #2", @@ -49,17 +49,17 @@ export class DebugView implements OnInit { "TRAP #0" ].join("\n"); - public testResponse: TypeCode[] = []; + public testCodeResponse: TypeCode[] = []; constructor(private toast: ToastrService, - private socketProviderConnect: SocketProviderConnectService) { + public socketProviderConnect: SocketProviderConnectService) { console.log("ioSocket: ", this.socketProviderConnect.socket.ioSocket); } ngOnInit(): void { - this.socketProviderConnect.socket.ioSocket.on("CodeResponse", (response) => { + this.socketProviderConnect.socket.on("CodeResponse", (response) => { const code = JSON.parse(response) as TypeCode[]; - this.testResponse = code.map((v) => { + this.testCodeResponse = code.map((v) => { return { address: v.address, code: v.code, @@ -68,8 +68,17 @@ export class DebugView implements OnInit { }; }); }); - } + this.socketProviderConnect.socket.on("UpdateRegisterResponse", (response) => { + const registers = JSON.parse(response) as TypeMemoryToUpdate[]; + console.log("Registers", registers); + }); + + this.socketProviderConnect.socket.on("UpdateMemoryResponse", (response) => { + const memory = JSON.parse(response) as TypeMemoryToUpdate[]; + console.log("Memory", memory); + }); + } showToast() { this.toast.success('Hello world!', 'Toast fun!', DEFAULT_CONFIG_TOAST); @@ -91,19 +100,63 @@ export class DebugView implements OnInit { localStorage.setItem('FileSystem', value); } - debugSocket() { - console.log(this.socketProviderConnect.socket.ioSocket); - this.socketID = this.socketProviderConnect.socket.ioSocket.id; - const file = { - content: this.testRequest - }; - this.socketProviderConnect.socket.emit("CodeRequest", JSON.stringify(file)); + debugCodeRequestSocket() { + try { + const file = { + content: this.testCodeRequest + }; + this.socketProviderConnect.emitMessage("CodeRequest", JSON.stringify(file)); + } catch (error) { + console.error(error); + } } - debugLanguage() { + async updateRegisterServer(typeRegister: TypeRegister, register: string, value: string): Promise { + try { + const payload = JSON.stringify({ + typeRegister: typeRegister, + register: register, + value: value + }); + this.socketProviderConnect.emitMessage('UpdateRegisterRequest', payload); + } catch (error) { + console.error(error); + return Promise.reject(error.message); + } + return Promise.resolve(true); + } + + async updateMemoryServer(typeData: TypeData, address: string, value: string): Promise { + try { + const payload = JSON.stringify({ + typeData: typeData, + address: address, + value: value + }); + this.socketProviderConnect.emitMessage('UpdateMemoryRequest', payload); + } catch (error) { + console.error(error); + return Promise.reject(error.message); + } + return Promise.resolve(true); + } + + async nextStep(): Promise { + try { + const payload = JSON.stringify({}); + this.socketProviderConnect.emitMessage('UpdateMemoryRequest', payload); + } catch (error) { + console.error(error); + return Promise.reject(error.message); + } + return Promise.resolve(true); } async getSomethingFromRemoteP(): Promise { return Promise.resolve(); } + + tr(value: string): TypeRegister { + return value as TypeRegister; + } } diff --git a/src/app/views/forgot-password/forgot-password.view.html b/src/app/views/forgot-password/forgot-password.view.html index a911b64..9b500f6 100644 --- a/src/app/views/forgot-password/forgot-password.view.html +++ b/src/app/views/forgot-password/forgot-password.view.html @@ -1,37 +1,39 @@ - - -
-