Commit c2b3d382 authored by brdunn's avatar brdunn
Browse files

Moved the webui to it's own git

parent 5abdef61
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events.json
speed-measure-plugin.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
# IPAM
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.8.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"IPAM": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/IPAM",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": [],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "IPAM:build"
},
"configurations": {
"production": {
"browserTarget": "IPAM:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "IPAM:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"IPAM-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "IPAM:serve"
},
"configurations": {
"production": {
"devServerTarget": "IPAM:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "IPAM"
}
\ No newline at end of file
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
\ No newline at end of file
import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to IPAM!');
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
});
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get(browser.baseUrl) as Promise<any>;
}
getTitleText() {
return element(by.css('app-root h1')).getText() as Promise<string>;
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
\ No newline at end of file
This diff is collapsed.
{
"name": "ipam",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.12",
"@angular/cdk": "^7.3.7",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"core-js": "^2.5.4",
"package.json": "^2.0.1",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.8",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
<mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="subnet_name">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Subnet </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element?.subnet_name}} </mat-cell>
</ng-container>
<ng-container matColumnDef="ipv4">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> IPV4 </mat-header-cell>
<mat-cell *matCellDef="let element" (click) = "getClick('ipv4')" > {{element?.ipv4}} </mat-cell>
</ng-container>
<ng-container matColumnDef="ipv6">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> IPV6 </mat-header-cell>
<mat-cell *matCellDef="let element" (click)="getClick('ipv6')"> {{element?.ipv6}} </mat-cell>
</ng-container>
<ng-container matColumnDef="host">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Host </mat-header-cell>
<mat-cell *matCellDef="let element" (click)="getClick('host')"> {{element?.host}} </mat-cell>
</ng-container>
<ng-container matColumnDef="mac_addr">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Mac Address </mat-header-cell>
<mat-cell *matCellDef="let element" (click)="getClick('mac_addr')"> {{element?.mac_addr}} </mat-cell>
</ng-container>
<ng-container matColumnDef="adapter">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Adapter </mat-header-cell>
<mat-cell *matCellDef="let element" (click)="getClick('adapter')"> {{element?.adapter}} </mat-cell>
</ng-container>
<mat-header-row style="font-weight: bold" *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selectRow(row)"></mat-row>
</mat-table>
import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'IPAM'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('IPAM');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to IPAM!');
});
});
import { Component } from '@angular/core';
import {MatTable} from '@angular/material/table';
import {MatToolbarModule} from '@angular/material/toolbar';
import { SampleService } from './sample.service';
import { Observable } from 'rxjs';
import { delay } from 'q';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
import { DialogOverviewComponent, Records } from './dialog-overview/dialog-overview.component';
//import { ConsoleReporter } from 'jasmine';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(private sampleService: SampleService, public dialog: MatDialog){
}
title = 'IPAM';
dataSource: any;
returned_record_id: any;
returned_host_id: any;
returned_mac_addr: any;
ipv4: any;
ipv6: any;
host: any;
adapter: any;
mac: any;
ipResultSet: IPResultSet[] = [];
currentRecordData: PostUIObject = {};
postUIObject: PostUIObject = {};
selectedRow: PostUIObject = {};
selectedCell: string = '';
AvailableRecordTypes: String[] = []
AvailabeRecords: Records[] = []
AllRecordList: Records[] =[]
hostRecords: Records[] = []
new_record: Records = {
id: 22,
Data: 'A',
record_type: 'A',
host: null,
dropDownRecordType: null
}
ngOnInit(){
// this.getUserInformation();
//this.getAvailableIPs();
//this.testRecords.push(this.new_record);
//this.UpdateIp();
this.getAllIps();
//this.getRecords(3);
//this.PutRecords();
//this.getIPsByRange()
//this.PostPreambles()
//this.PostRecords();
//this.DeleteHost(6);
// if(this.returned_record_id != null){
// this.PostHosts(this.returned_record_id);
// }else{
// console.log('No ID returned');
// }
}
ngOnDestroy(){
this.hostRecords = [];
}
displayedColumns: string[] = ['subnet_name', 'ipv4', 'ipv6', 'host', 'mac_addr', 'adapter'];
getClick(selectedValue): any{
this.selectedCell = selectedValue;
}
selectRow(row): any{
this.selectedRow = row;
if(this.selectedCell == 'ipv4' || this.selectedCell == 'ipv6'){
this.sampleService.GetRecords()
.toPromise()
.then((res) => {
res.forEach(element => {
if(this.AvailableRecordTypes.indexOf(element.record_type) < 0){
this.AvailableRecordTypes.push(element.record_type);
this.AvailabeRecords.push(element);
}
});
let records = res.find(x => x.host == row['host_id']);
if(records){
this.AllRecordList.push(records);
}
this.openDialog();
})
}
}
getAvailableIPs(): void{
this.sampleService.ListAvailableIPs()
.toPromise()
.then((res) => {
console.log("hi")
})
}
getAllIps(): void{
this.sampleService.ListAllIPs()
.toPromise()
.then((res) => {
res.forEach(x => {
let item = new IPResultSet(x.id != null ? x.id : null , x.ipv4, x.ipv6, x.mac_addr != null ? x.mac_addr.adapter.host.host_name: null, x.mac_addr != null ? x.mac_addr.id : null, x.mac_addr != null ? x.mac_addr.mac : null, x.mac_addr !== null ? x.mac_addr.adapter.id : null, x.mac_addr!== null ? x.mac_addr.adapter.adapter_name : null, x.subnet !== null ? x.subnet.id : null, x.subnet !== null ? x.subnet.subnet_name : null, null, x.mac_addr !== null ? x.mac_addr.adapter.host.id : null, null, this.AvailableRecords);
this.ipResultSet.push(item)
})
this.dataSource = this.ipResultSet;
})
}
getIPsByRange(): void{
this.sampleService.ListIPsByRange()
.toPromise()
.then((res) => {
console.log("hi")
})
}
PostAdapters(hostID, adapter_name): any {
this.sampleService.PostAdapters(hostID, adapter_name)
.toPromise()
.then((res) => {
console.log('Adapter inserted.')
})
}
DeleteHost(hostID): void{
this.sampleService.DeleteHost(hostID)
.toPromise()
.then((res) => {
console.log('host deleted')
})
}
PutInformation(host_name, ipv4?, ipv6?, mac_address?, adapter_name?, record_type?): void {
if(this.currentRecordData.host_name !== host_name){
let host_id = this.ipResultSet.find(x => x.host == this.currentRecordData.host_name).host_id
this.sampleService.UpdateHost(host_id, host_name)
.toPromise()
.then((res) => {
console.log('host name updated');
})
}
if(record_type !== null){