From 776a75c7837f95e4cf280d19e418f5e9d9f9348d Mon Sep 17 00:00:00 2001 From: "marcusferl@weifer.de" Date: Tue, 30 Aug 2022 14:34:47 +0200 Subject: [PATCH] nun --- src/app/backend/berechnung.ts | 44 +++++++++++++ src/app/header/header.component.ts | 6 +- src/app/input/input.component.ts | 6 +- src/app/myservice.service.spec.ts | 16 +++++ src/app/myservice.service.ts | 9 +++ src/app/output/output.component.html | 8 ++- src/app/output/output.component.scss | 4 +- src/app/output/output.component.ts | 98 ++++++++++------------------ 8 files changed, 119 insertions(+), 72 deletions(-) create mode 100644 src/app/backend/berechnung.ts create mode 100644 src/app/myservice.service.spec.ts create mode 100644 src/app/myservice.service.ts diff --git a/src/app/backend/berechnung.ts b/src/app/backend/berechnung.ts new file mode 100644 index 0000000..c09bd88 --- /dev/null +++ b/src/app/backend/berechnung.ts @@ -0,0 +1,44 @@ +export class Berechnung { + + binArr = new Array; + decArr = new Array; + + // Convert dec Numbers to Binary + decToBin(number: string) { + this.decArr = number.split(".") + this.decArr.forEach(element => { + let tmp = (Number(element)).toString(2) + if (tmp.length < 8) { + let slicer = (8 - tmp.length); + tmp = "0".repeat(slicer) + tmp + console.log(element) + } + this.binArr.push(tmp); + }); + return this.binArr.join(".") + } + + subNetMask(prefix: number) { + let mask = "" + return mask; + } + + broadCast(arr: any[]) { + + } + + netId(mask: string) { + let netId; + return netId; + } + + minIp() { + return null; + } + + max() { + return null; + } + +} + diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 7ab4cf7..f13222c 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -7,7 +7,11 @@ import { Component, OnInit } from '@angular/core'; }) export class HeaderComponent implements OnInit { - constructor() { } + constructor() { + + + + } ngOnInit(): void { } diff --git a/src/app/input/input.component.ts b/src/app/input/input.component.ts index 4725fdf..1d2fc4d 100644 --- a/src/app/input/input.component.ts +++ b/src/app/input/input.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { Berechnung } from '../backend/berechnung'; @Component({ selector: 'app-input', @@ -18,7 +19,10 @@ export class InputComponent implements OnInit { } onClick() { - alert(this.prefix_selection + " " + this.ipv4_eingabe) + var berechnung = new Berechnung; + let number = berechnung.decToBin(this.ipv4_eingabe) + alert(number) + } ngOnInit(): void { diff --git a/src/app/myservice.service.spec.ts b/src/app/myservice.service.spec.ts new file mode 100644 index 0000000..85c6cd1 --- /dev/null +++ b/src/app/myservice.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { MyserviceService } from './myservice.service'; + +describe('MyserviceService', () => { + let service: MyserviceService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(MyserviceService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/myservice.service.ts b/src/app/myservice.service.ts new file mode 100644 index 0000000..3376bf4 --- /dev/null +++ b/src/app/myservice.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class MyserviceService { + + constructor() { } +} diff --git a/src/app/output/output.component.html b/src/app/output/output.component.html index 5d1a20f..6aa43a3 100644 --- a/src/app/output/output.component.html +++ b/src/app/output/output.component.html @@ -1,5 +1,7 @@ -
+
-

-

+
+

+

+
\ No newline at end of file diff --git a/src/app/output/output.component.scss b/src/app/output/output.component.scss index c9ecf42..43450e6 100644 --- a/src/app/output/output.component.scss +++ b/src/app/output/output.component.scss @@ -1,8 +1,8 @@ .card { min-height: 40px; background-color: white; - width: 700px; - border: 1px solid rgba(0, 0, 0, 0.30); + width: 680px; + border: 3px solid rgba(0, 0, 0, 0.30); border-radius: 10px; overflow: hidden; position: relative; diff --git a/src/app/output/output.component.ts b/src/app/output/output.component.ts index 78f98e7..f5a01d1 100644 --- a/src/app/output/output.component.ts +++ b/src/app/output/output.component.ts @@ -1,4 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import { Berechnung } from '../backend/berechnung'; +import { InputComponent } from '../input/input.component'; + @Component({ selector: 'app-output', @@ -6,32 +9,40 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./output.component.scss'] }) export class OutputComponent implements OnInit { - ipv4_dec = "192.168.0.1"; - ipv4_bin = "11000000.10101000.00000000.00000001"; - subnet_dec = ""; - subnet_bin = ""; - broadcast_dec = ""; - broadcast_bin = ""; - netID_de = ""; - netID_bin = ""; - firstIP_dec = ""; - firstIP_bin = ""; - lastIP_dec = ""; - lastIP_bin = ""; - out = ["IPv4", "Subnetmask:", "Broadcast:", "Net-ID:", "First Ip:", "Last Ip:"] + + // Dictionary + bin_dec_dict = { + ipv4_dec: "", + ipv4_bin: "", + subnet_dec: "", + subnet_bin: "", + broadcast_dec: "", + broadcast_bin: "", + netID_de: "", + netID_bin: "", + firstIP_dec: "", + firstIP_bin: "", + lastIP_dec: "", + lastIP_bin: "" + } + + + + bin = ""; + dec = ""; + prefix = 0; + + outArr = ["IPv4", "Subnetmask:", "Broadcast:", "Net-ID:", "First Ip:", "Last Ip:"] constructor() { + } + onClick() { + var br = new Berechnung; - var arr = this.ipv4_dec.split("."); - - arr.forEach(element => { - console.log(element) - }); - var bb = new Berechnung(); - bb.decToBin("192.168.0.1") - - + // Dict Zugriff + this.bin_dec_dict.ipv4_bin = br.decToBin(this.dec) + this.bin_dec_dict.subnet_bin = br.subNetMask(this.prefix) } ngOnInit(): void { @@ -39,47 +50,4 @@ export class OutputComponent implements OnInit { } } -class Berechnung { - - binArr = new Array; - decArr = new Array; - - // Convert dec Numbers to Binary - decToBin(number: string) { - this.decArr = number.split(".") - this.decArr.forEach(element => { - let tmp = (Number(element)).toString(2) - if (tmp.length < 8) { - let slicer = (8 - tmp.length); - tmp = "0".repeat(slicer) + tmp - console.log(element) - } - this.binArr.push(tmp); - }); - return this.binArr.join(".") - } - - subNetMask(prefix: number) { - let mask = "" - return mask; - } - - broadCast(arr: any[]) { - - } - - netId(mask: string) { - let netId; - return netId; - } - - minIp() { - return null; - } - - max() { - return null; - } - -}