Removed obsolte frontend parts
This commit is contained in:
parent
2f19aafa80
commit
983ee5171a
|
@ -1,57 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
||||||
"project": {
|
|
||||||
"name": "pdnsmanager"
|
|
||||||
},
|
|
||||||
"apps": [
|
|
||||||
{
|
|
||||||
"root": "src",
|
|
||||||
"outDir": "dist",
|
|
||||||
"assets": [
|
|
||||||
"assets",
|
|
||||||
"favicon.ico"
|
|
||||||
],
|
|
||||||
"index": "index.html",
|
|
||||||
"main": "main.ts",
|
|
||||||
"polyfills": "polyfills.ts",
|
|
||||||
"test": "test.ts",
|
|
||||||
"tsconfig": "tsconfig.app.json",
|
|
||||||
"testTsconfig": "tsconfig.spec.json",
|
|
||||||
"prefix": "app",
|
|
||||||
"styles": [
|
|
||||||
"styles.scss"
|
|
||||||
],
|
|
||||||
"scripts": [],
|
|
||||||
"environmentSource": "environments/environment.ts",
|
|
||||||
"environments": {
|
|
||||||
"dev": "environments/environment.ts",
|
|
||||||
"prod": "environments/environment.prod.ts"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"e2e": {
|
|
||||||
"protractor": {
|
|
||||||
"config": "./protractor.conf.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lint": [
|
|
||||||
{
|
|
||||||
"project": "src/tsconfig.app.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "src/tsconfig.spec.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"project": "e2e/tsconfig.e2e.json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"test": {
|
|
||||||
"karma": {
|
|
||||||
"config": "./karma.conf.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaults": {
|
|
||||||
"styleExt": "scss",
|
|
||||||
"component": {}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
# Editor configuration, see http://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
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { PdnsmanagerPage } from './app.po';
|
|
||||||
|
|
||||||
describe('pdnsmanager App', () => {
|
|
||||||
let page: PdnsmanagerPage;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
page = new PdnsmanagerPage();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display welcome message', () => {
|
|
||||||
page.navigateTo();
|
|
||||||
expect(page.getParagraphText()).toEqual('Welcome to app!!');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { browser, by, element } from 'protractor';
|
|
||||||
|
|
||||||
export class PdnsmanagerPage {
|
|
||||||
navigateTo() {
|
|
||||||
return browser.get('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
getParagraphText() {
|
|
||||||
return element(by.css('app-root h1')).getText();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "../out-tsc/e2e",
|
|
||||||
"module": "commonjs",
|
|
||||||
"target": "es5",
|
|
||||||
"types": [
|
|
||||||
"jasmine",
|
|
||||||
"jasminewd2",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
// Karma configuration file, see link for more information
|
|
||||||
// https://karma-runner.github.io/0.13/config/configuration-file.html
|
|
||||||
|
|
||||||
module.exports = function (config) {
|
|
||||||
config.set({
|
|
||||||
basePath: '',
|
|
||||||
frameworks: ['jasmine', '@angular/cli'],
|
|
||||||
plugins: [
|
|
||||||
require('karma-jasmine'),
|
|
||||||
require('karma-chrome-launcher'),
|
|
||||||
require('karma-jasmine-html-reporter'),
|
|
||||||
require('karma-coverage-istanbul-reporter'),
|
|
||||||
require('@angular/cli/plugins/karma')
|
|
||||||
],
|
|
||||||
client:{
|
|
||||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
||||||
},
|
|
||||||
coverageIstanbulReporter: {
|
|
||||||
reports: [ 'html', 'lcovonly' ],
|
|
||||||
fixWebpackSourcePaths: true
|
|
||||||
},
|
|
||||||
angularCli: {
|
|
||||||
environment: 'dev'
|
|
||||||
},
|
|
||||||
reporters: ['progress', 'kjhtml'],
|
|
||||||
port: 9876,
|
|
||||||
colors: true,
|
|
||||||
logLevel: config.LOG_INFO,
|
|
||||||
autoWatch: true,
|
|
||||||
browsers: ['Chrome'],
|
|
||||||
singleRun: false
|
|
||||||
});
|
|
||||||
};
|
|
8367
frontend/package-lock.json
generated
8367
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,51 +0,0 @@
|
||||||
{
|
|
||||||
"name": "pdnsmanager",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
|
||||||
"ng": "ng",
|
|
||||||
"start": "ng serve --proxy-config proxy.conf.json",
|
|
||||||
"build": "ng build",
|
|
||||||
"test": "ng test",
|
|
||||||
"lint": "ng lint",
|
|
||||||
"e2e": "ng e2e"
|
|
||||||
},
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@angular/animations": "^4.3.1",
|
|
||||||
"@angular/common": "^4.3.1",
|
|
||||||
"@angular/compiler": "^4.3.1",
|
|
||||||
"@angular/core": "^4.3.1",
|
|
||||||
"@angular/forms": "^4.3.1",
|
|
||||||
"@angular/http": "^4.3.1",
|
|
||||||
"@angular/platform-browser": "^4.3.1",
|
|
||||||
"@angular/platform-browser-dynamic": "^4.3.1",
|
|
||||||
"@angular/router": "^4.3.1",
|
|
||||||
"bootstrap": "^4.0.0-alpha.6",
|
|
||||||
"core-js": "^2.4.1",
|
|
||||||
"font-awesome": "^4.7.0",
|
|
||||||
"rxjs": "^5.1.0",
|
|
||||||
"zone.js": "^0.8.4"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@angular/cli": "^1.2.3",
|
|
||||||
"@angular/compiler-cli": "^4.3.1",
|
|
||||||
"@angular/language-service": "^4.3.1",
|
|
||||||
"@types/jasmine": "~2.5.53",
|
|
||||||
"@types/jasminewd2": "~2.0.2",
|
|
||||||
"@types/node": "~6.0.60",
|
|
||||||
"codelyzer": "~3.0.1",
|
|
||||||
"jasmine-core": "~2.6.2",
|
|
||||||
"jasmine-spec-reporter": "~4.1.0",
|
|
||||||
"karma": "~1.7.0",
|
|
||||||
"karma-chrome-launcher": "~2.1.1",
|
|
||||||
"karma-cli": "~1.0.1",
|
|
||||||
"karma-coverage-istanbul-reporter": "^1.2.1",
|
|
||||||
"karma-jasmine": "~1.1.0",
|
|
||||||
"karma-jasmine-html-reporter": "^0.2.2",
|
|
||||||
"protractor": "~5.1.2",
|
|
||||||
"ts-node": "~3.0.4",
|
|
||||||
"tslint": "~5.3.2",
|
|
||||||
"typescript": "~2.3.3"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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: [
|
|
||||||
'./e2e/**/*.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: 'e2e/tsconfig.e2e.json'
|
|
||||||
});
|
|
||||||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"/api": {
|
|
||||||
"target": "http://localhost:8000",
|
|
||||||
"secure": false
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
import {NgModule} from '@angular/core';
|
|
||||||
import {Routes, RouterModule} from '@angular/router';
|
|
||||||
|
|
||||||
import {DomainsComponent} from './pages/domains/domains.component';
|
|
||||||
import {UsersComponent} from './pages/users/users.component';
|
|
||||||
import {LoginComponent} from './pages/login/login.component';
|
|
||||||
import {RecordEditComponent} from './pages/record-edit/record-edit.component';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
|
||||||
{
|
|
||||||
path: 'domains/edit/:id',
|
|
||||||
component: RecordEditComponent
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'domains',
|
|
||||||
component: DomainsComponent
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'users',
|
|
||||||
component: UsersComponent
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
component: LoginComponent,
|
|
||||||
pathMatch: 'full'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
redirectTo: '/',
|
|
||||||
pathMatch: 'prefix'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
imports: [RouterModule.forRoot(routes)],
|
|
||||||
exports: [RouterModule]
|
|
||||||
})
|
|
||||||
export class AppRoutingModule {}
|
|
|
@ -1,12 +0,0 @@
|
||||||
<app-navbar *ngIf="sessionService.getIsLoggedIn()" brand="PDNS Manager">
|
|
||||||
<app-navbar-entry icon="navicon" target="/domains">Domains</app-navbar-entry>
|
|
||||||
<app-navbar-entry icon="users" target="/users">Users</app-navbar-entry>
|
|
||||||
<app-navbar-entry icon="sign-out" right (click)="logout()" neverActive>Logout</app-navbar-entry>
|
|
||||||
</app-navbar>
|
|
||||||
<app-navbar *ngIf="!sessionService.getIsLoggedIn()" brand="PDNS Manager"></app-navbar>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<router-outlet></router-outlet>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<app-modal-container></app-modal-container>
|
|
|
@ -1,3 +0,0 @@
|
||||||
div.container {
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
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', async(() => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
const app = fixture.debugElement.componentInstance;
|
|
||||||
expect(app).toBeTruthy();
|
|
||||||
}));
|
|
||||||
});
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { Component } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
|
|
||||||
import { SessionService } from './services/session/session.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-root',
|
|
||||||
templateUrl: './app.component.html',
|
|
||||||
styleUrls: ['./app.component.scss']
|
|
||||||
})
|
|
||||||
export class AppComponent {
|
|
||||||
title = 'app';
|
|
||||||
|
|
||||||
constructor(private sessionService: SessionService,
|
|
||||||
private router: Router) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the logout procedure using the SessionService.
|
|
||||||
*/
|
|
||||||
logout() {
|
|
||||||
this.sessionService.logOut()
|
|
||||||
.then(() => {
|
|
||||||
this.router.navigate(['/']);
|
|
||||||
}, () => {
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
|
||||||
import {NgModule} from '@angular/core';
|
|
||||||
import {HttpModule} from '@angular/http';
|
|
||||||
|
|
||||||
import {AppRoutingModule} from './app-routing.module';
|
|
||||||
import {AppComponent} from './app.component';
|
|
||||||
|
|
||||||
import {NavbarComponent} from './partials/navbar/navbar.component';
|
|
||||||
import {NavbarEntryComponent} from './partials/navbar-entry/navbar-entry.component';
|
|
||||||
import {FaIconComponent} from './partials/fa-icon/fa-icon.component';
|
|
||||||
import {AlertComponent} from './partials/alert/alert.component';
|
|
||||||
import {AlertMessageComponent} from './partials/alert-message/alert-message.component';
|
|
||||||
import {ModalContainerComponent} from './partials/modal-container/modal-container.component';
|
|
||||||
import {SortComponent} from './partials/sort/sort.component';
|
|
||||||
|
|
||||||
import {DomainsComponent} from './pages/domains/domains.component';
|
|
||||||
import {UsersComponent} from './pages/users/users.component';
|
|
||||||
import {LoginComponent} from './pages/login/login.component';
|
|
||||||
import {RecordEditComponent} from './pages/record-edit/record-edit.component';
|
|
||||||
|
|
||||||
import {HttpService} from './services/http/http.service';
|
|
||||||
import {ModalService} from './services/modal/modal.service';
|
|
||||||
import {SessionService} from './services/session/session.service';
|
|
||||||
import {DomainsService} from './services/domains/domains.service';
|
|
||||||
import {RecordEditService} from './services/record-edit/record-edit.service';
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [
|
|
||||||
AppComponent,
|
|
||||||
NavbarComponent,
|
|
||||||
NavbarEntryComponent,
|
|
||||||
FaIconComponent,
|
|
||||||
DomainsComponent,
|
|
||||||
UsersComponent,
|
|
||||||
LoginComponent,
|
|
||||||
AlertComponent,
|
|
||||||
AlertMessageComponent,
|
|
||||||
ModalContainerComponent,
|
|
||||||
SortComponent,
|
|
||||||
RecordEditComponent
|
|
||||||
],
|
|
||||||
imports: [
|
|
||||||
BrowserModule,
|
|
||||||
AppRoutingModule,
|
|
||||||
FormsModule,
|
|
||||||
HttpModule
|
|
||||||
],
|
|
||||||
providers: [SessionService,
|
|
||||||
HttpService,
|
|
||||||
DomainsService,
|
|
||||||
ModalService,
|
|
||||||
RecordEditService],
|
|
||||||
bootstrap: [AppComponent]
|
|
||||||
})
|
|
||||||
export class AppModule {}
|
|
|
@ -1,3 +0,0 @@
|
||||||
export interface DomainNameAnswer {
|
|
||||||
name: string
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
export interface DomainsAnswer {
|
|
||||||
pages: {
|
|
||||||
current: number,
|
|
||||||
total: number
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
id: number,
|
|
||||||
name: string,
|
|
||||||
type: string,
|
|
||||||
records: number
|
|
||||||
}[]
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
export interface ModalOptions {
|
|
||||||
heading: string,
|
|
||||||
body: string,
|
|
||||||
acceptText: string,
|
|
||||||
dismisText: string,
|
|
||||||
acceptClass: string
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
export interface SessionAnswer {
|
|
||||||
status: string
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
export interface SortEvent {
|
|
||||||
field: string,
|
|
||||||
order: number
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td class="cell-vertical-middle">
|
|
||||||
<div>
|
|
||||||
<strong>ID</strong>
|
|
||||||
<app-sort #sortId field="id" (sort)="sort($event)"></app-sort>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="cell-vertical-middle">
|
|
||||||
<div class="form-inline">
|
|
||||||
<strong>Name</strong>
|
|
||||||
<app-sort #sortName field="name" (sort)="sort($event)"></app-sort>
|
|
||||||
<input class="form-control no-shadow" placeholder="Search" autocomplete="off"
|
|
||||||
type="text" [(ngModel)]="searchName" (ngModelChange)="loadDomains()">
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="cell-vertical-middle">
|
|
||||||
<div class="form-inline">
|
|
||||||
<strong>Type</strong>
|
|
||||||
<app-sort #sortType field="type" (sort)="sort($event)"></app-sort>
|
|
||||||
<select class="form-control no-shadow" [(ngModel)]="searchType" (ngModelChange)="loadDomains()">
|
|
||||||
<option value="none">No filter...</option>
|
|
||||||
<option value="MASTER">Master</option>
|
|
||||||
<option value="NATIVE">Native</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="cell-vertical-middle">
|
|
||||||
<div>
|
|
||||||
<strong>Records</strong>
|
|
||||||
<app-sort #sortRecords field="records" (sort)="sort($event)"></app-sort>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="cell-vertical-middle"></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let domain of data.data" (click)="onClickDomain(domain.id)">
|
|
||||||
<td>{{domain.id}}</td>
|
|
||||||
<td>{{domain.name}}</td>
|
|
||||||
<td>{{domain.type}}</td>
|
|
||||||
<td>{{domain.records}}</td>
|
|
||||||
<td>
|
|
||||||
<div>
|
|
||||||
<app-fa-icon icon="trash" (click)="deleteDomain(domain.id, domain.name)"></app-fa-icon>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
tbody {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cell-vertical-middle {
|
|
||||||
vertical-align: middle !important;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { DomainsComponent } from './domains.component';
|
|
||||||
|
|
||||||
describe('DomainsComponent', () => {
|
|
||||||
let component: DomainsComponent;
|
|
||||||
let fixture: ComponentFixture<DomainsComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ DomainsComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(DomainsComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,106 +0,0 @@
|
||||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
|
||||||
import {Router, ActivatedRoute} from '@angular/router';
|
|
||||||
|
|
||||||
import {DomainsService} from 'app/services/domains/domains.service';
|
|
||||||
import {DomainsAnswer} from 'app/interfaces/domains-answer';
|
|
||||||
import {ModalService} from 'app/services/modal/modal.service';
|
|
||||||
import {SortComponent} from 'app/partials/sort/sort.component';
|
|
||||||
import {SortEvent} from 'app/interfaces/sort-event';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-domains',
|
|
||||||
templateUrl: './domains.component.html',
|
|
||||||
styleUrls: ['./domains.component.scss']
|
|
||||||
})
|
|
||||||
export class DomainsComponent implements OnInit {
|
|
||||||
|
|
||||||
data: DomainsAnswer = {pages: {current: 1, total: 1}, data: []};
|
|
||||||
|
|
||||||
@ViewChild('sortId') sortId: SortComponent;
|
|
||||||
@ViewChild('sortName') sortName: SortComponent;
|
|
||||||
@ViewChild('sortType') sortType: SortComponent;
|
|
||||||
@ViewChild('sortRecords') sortRecords: SortComponent;
|
|
||||||
|
|
||||||
private sortField: string = null;
|
|
||||||
private sortOrder = 0;
|
|
||||||
|
|
||||||
private searchName: string;
|
|
||||||
private searchType = 'none';
|
|
||||||
|
|
||||||
constructor(private domainsService: DomainsService,
|
|
||||||
private modalService: ModalService,
|
|
||||||
private router: Router,
|
|
||||||
private route: ActivatedRoute) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.loadDomains();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the domains from the server using the parameters specified in
|
|
||||||
* the properties of the components.
|
|
||||||
*/
|
|
||||||
loadDomains() {
|
|
||||||
const field = this.sortField ? this.sortField : '';
|
|
||||||
const searchType = this.searchType === 'none' ? '' : this.searchType;
|
|
||||||
|
|
||||||
this.domainsService.getDomains(1, field, this.sortOrder, this.searchName, searchType)
|
|
||||||
.then((data: DomainsAnswer) => {
|
|
||||||
this.data = data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a domain.
|
|
||||||
*
|
|
||||||
* @param id Id of domain to delete
|
|
||||||
* @param name Name of domain to delete (only used for modal dialog)
|
|
||||||
*/
|
|
||||||
deleteDomain(id: number, name: string) {
|
|
||||||
this.modalService.showMessage({
|
|
||||||
heading: 'Delete Domain?',
|
|
||||||
body: `Are you shure you want to delete the zone ${name}?`,
|
|
||||||
acceptText: 'Delete',
|
|
||||||
dismisText: 'Cancel',
|
|
||||||
acceptClass: 'danger'
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.domainsService.deleteDomain(id);
|
|
||||||
this.loadDomains();
|
|
||||||
}, () => {
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes a sort event and applies the data to the current component state.
|
|
||||||
*
|
|
||||||
* @param event The SortEvent to process
|
|
||||||
*/
|
|
||||||
sort(event: SortEvent) {
|
|
||||||
this.sortId.resetIfNotField(event.field);
|
|
||||||
this.sortName.resetIfNotField(event.field);
|
|
||||||
this.sortType.resetIfNotField(event.field);
|
|
||||||
this.sortRecords.resetIfNotField(event.field);
|
|
||||||
|
|
||||||
if (event.order === 0) {
|
|
||||||
this.sortField = null;
|
|
||||||
} else {
|
|
||||||
this.sortField = event.field;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sortOrder = event.order;
|
|
||||||
|
|
||||||
this.loadDomains();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Navigates to the domain edit page
|
|
||||||
*
|
|
||||||
* @param id Id of the domain to edit
|
|
||||||
*/
|
|
||||||
onClickDomain(id: Number) {
|
|
||||||
this.router.navigate(['edit', id], {relativeTo: this.route});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-6 col-lg-3 offset-md-6">
|
|
||||||
|
|
||||||
<app-alert *ngIf="loginError">
|
|
||||||
<app-alert-message strong>Username or password wrong!</app-alert-message>
|
|
||||||
</app-alert>
|
|
||||||
|
|
||||||
<form #loginForm="ngForm" (ngSubmit)="tryLogin()">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label">Username</label>
|
|
||||||
<input type="text" class="form-control" placeholder="Username"
|
|
||||||
autocapitalize="none" autocomplete="off" name="username"
|
|
||||||
ngModel #name="ngModel" required>
|
|
||||||
</div>
|
|
||||||
<app-alert *ngIf="name.errors && (name.dirty || name.touched || submited)">
|
|
||||||
<app-alert-message *ngIf="name.errors.required">Name is required!</app-alert-message>
|
|
||||||
</app-alert>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label" >Password</label>
|
|
||||||
<input type="password" class="form-control" placeholder="Password"
|
|
||||||
name="password" #password="ngModel" required ngModel>
|
|
||||||
</div>
|
|
||||||
<app-alert *ngIf="password.errors && (password.dirty || password.touched || submited)">
|
|
||||||
<app-alert-message *ngIf="password.errors.required">Password is required!</app-alert-message>
|
|
||||||
</app-alert>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary" >Login</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { LoginComponent } from './login.component';
|
|
||||||
|
|
||||||
describe('LoginComponent', () => {
|
|
||||||
let component: LoginComponent;
|
|
||||||
let fixture: ComponentFixture<LoginComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ LoginComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(LoginComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Component, ViewChild } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { NgForm } from '@angular/forms';
|
|
||||||
|
|
||||||
import { SessionService } from 'app/services/session/session.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-login',
|
|
||||||
templateUrl: './login.component.html',
|
|
||||||
styleUrls: ['./login.component.scss']
|
|
||||||
})
|
|
||||||
export class LoginComponent {
|
|
||||||
@ViewChild('loginForm') loginForm: NgForm;
|
|
||||||
|
|
||||||
private submited = false;
|
|
||||||
private loginError = false;
|
|
||||||
|
|
||||||
constructor(private sessionService: SessionService,
|
|
||||||
private router: Router) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries a login atempt to the server using the data from the login form.
|
|
||||||
* If this is successfull the login in performed, if not an error will be
|
|
||||||
* shown.
|
|
||||||
*/
|
|
||||||
tryLogin() {
|
|
||||||
this.submited = true;
|
|
||||||
if (!this.loginForm.valid) { return; }
|
|
||||||
const value = this.loginForm.value;
|
|
||||||
this.sessionService.tryLogin(value.username, value.password).then(() => {
|
|
||||||
this.loginForm.reset();
|
|
||||||
this.submited = false;
|
|
||||||
this.loginError = false;
|
|
||||||
this.router.navigate(['/domains']);
|
|
||||||
}, () => {
|
|
||||||
this.loginError = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h2>{{domainName}}</h2>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h3>SOA</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<form>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-sm-6 col-md-4 col-lg-3">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="soa-primary" class="control-label">Primary</label>
|
|
||||||
<input type="text" class="form-control" id="soa-primary" placeholder="Primary" autocomplete="off" data-regex="^([^.]+\.)*[^.]+$" tabindex="1">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="soa-mail" class="control-label">Email</label>
|
|
||||||
<input type="text" class="form-control" id="soa-mail" placeholder="Email" autocomplete="off" data-regex="^.+@[^.]+(\.[^.]+)*$" tabindex="2">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-sm-6 col-md-3 col-lg-2 offset-lg-1">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="soa-refresh" class="control-label">Refresh</label>
|
|
||||||
<input type="text" class="form-control" id="soa-refresh" placeholder="Refresh" autocomplete="off" data-regex="^[0-9]+$" tabindex="3">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="soa-retry" class="control-label">Retry</label>
|
|
||||||
<input type="text" class="form-control" id="soa-retry" placeholder="Retry" autocomplete="off" data-regex="^[0-9]+$" tabindex="4">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-sm-6 col-md-3 col-lg-2 offset-lg-1">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="soa-expire" class="control-label">Expire</label>
|
|
||||||
<input type="text" class="form-control" id="soa-expire" placeholder="Expire" autocomplete="off" data-regex="^[0-9]+$" tabindex="5">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="soa-ttl" class="control-label">TTL</label>
|
|
||||||
<input type="text" class="form-control" id="soa-ttl" placeholder="TTL" autocomplete="off" data-regex="^[0-9]+$" tabindex="6">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-sm-6 col-md-2 col-lg-2 offset-lg-1">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="soa-serial" class="control-label">Serial</label>
|
|
||||||
<input type="text" class="form-control" id="soa-serial" placeholder="Serial" disabled data-regex=".*">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<button disabled type="submit" class="btn btn-primary" tabindex="7">Save</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { RecordEditComponent } from './record-edit.component';
|
|
||||||
|
|
||||||
describe('RecordEditComponent', () => {
|
|
||||||
let component: RecordEditComponent;
|
|
||||||
let fixture: ComponentFixture<RecordEditComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ RecordEditComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(RecordEditComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,29 +0,0 @@
|
||||||
import {Component, OnInit} from '@angular/core';
|
|
||||||
import {ActivatedRoute, ParamMap} from '@angular/router';
|
|
||||||
|
|
||||||
import {RecordEditService} from 'app/services/record-edit/record-edit.service';
|
|
||||||
import {DomainNameAnswer} from 'app/interfaces/domain-name-answer';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-record-edit',
|
|
||||||
templateUrl: './record-edit.component.html',
|
|
||||||
styleUrls: ['./record-edit.component.scss']
|
|
||||||
})
|
|
||||||
export class RecordEditComponent implements OnInit {
|
|
||||||
|
|
||||||
private domainName = '';
|
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
|
||||||
private recordEditService: RecordEditService) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.route.paramMap.subscribe((params: ParamMap) => {
|
|
||||||
this.initDomain(parseInt(params.get('id'), 10));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async initDomain(id: number) {
|
|
||||||
this.domainName = (await this.recordEditService.getDomainName(id)).name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
<p>
|
|
||||||
users works!
|
|
||||||
</p>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { UsersComponent } from './users.component';
|
|
||||||
|
|
||||||
describe('UsersComponent', () => {
|
|
||||||
let component: UsersComponent;
|
|
||||||
let fixture: ComponentFixture<UsersComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ UsersComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(UsersComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-users',
|
|
||||||
templateUrl: './users.component.html',
|
|
||||||
styleUrls: ['./users.component.scss']
|
|
||||||
})
|
|
||||||
export class UsersComponent implements OnInit {
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
<p><ng-content></ng-content></p>
|
|
|
@ -1,3 +0,0 @@
|
||||||
p {
|
|
||||||
margin: 0px !important;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AlertMessageComponent } from './alert-message.component';
|
|
||||||
|
|
||||||
describe('AlertMessageComponent', () => {
|
|
||||||
let component: AlertMessageComponent;
|
|
||||||
let fixture: ComponentFixture<AlertMessageComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ AlertMessageComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AlertMessageComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,12 +0,0 @@
|
||||||
import {Component} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-alert-message',
|
|
||||||
templateUrl: './alert-message.component.html',
|
|
||||||
styleUrls: ['./alert-message.component.scss']
|
|
||||||
})
|
|
||||||
export class AlertMessageComponent {
|
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
<div class="alert" [ngClass]="'alert-' + type" role="alert">
|
|
||||||
<ng-content></ng-content>
|
|
||||||
</div>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AlertComponent } from './alert.component';
|
|
||||||
|
|
||||||
describe('AlertComponent', () => {
|
|
||||||
let component: AlertComponent;
|
|
||||||
let fixture: ComponentFixture<AlertComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ AlertComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AlertComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,13 +0,0 @@
|
||||||
import {Component, Input} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-alert',
|
|
||||||
templateUrl: './alert.component.html',
|
|
||||||
styleUrls: ['./alert.component.scss']
|
|
||||||
})
|
|
||||||
export class AlertComponent {
|
|
||||||
|
|
||||||
@Input() type = 'danger';
|
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
<span class="fa"
|
|
||||||
[class.fa-lg]="size == 1"
|
|
||||||
[class.fa-2x]="size == 2"
|
|
||||||
[class.fa-3x]="size == 3"
|
|
||||||
[class.fa-4x]="size == 4"
|
|
||||||
[class.fa-5x]="size == 5"
|
|
||||||
[class.fa-fw]="fixedWidth !== false"
|
|
||||||
[class.fa-spin]="animate == 'spin'"
|
|
||||||
[class.fa-pulse]="animate == 'pulse'"
|
|
||||||
[ngClass]="'fa-' + icon"
|
|
||||||
></span>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { FaIconComponent } from './fa-icon.component';
|
|
||||||
|
|
||||||
describe('FaIconComponent', () => {
|
|
||||||
let component: FaIconComponent;
|
|
||||||
let fixture: ComponentFixture<FaIconComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ FaIconComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(FaIconComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,16 +0,0 @@
|
||||||
import {Component, Input} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-fa-icon',
|
|
||||||
templateUrl: './fa-icon.component.html',
|
|
||||||
styleUrls: ['./fa-icon.component.scss']
|
|
||||||
})
|
|
||||||
export class FaIconComponent {
|
|
||||||
|
|
||||||
@Input() icon: string;
|
|
||||||
@Input() size = 0;
|
|
||||||
@Input() fixedWidth = false;
|
|
||||||
@Input() animate = '';
|
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
<div class="modal fade" [class.show]="animate" [class.in]="animate" [hidden]="!show" (click)="onDismis()">
|
|
||||||
<div class="modal-dialog" role="document">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title">{{options.heading}}</h5>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>{{options.body}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-default" (click)="onDismis()">{{options.dismisText}}</button>
|
|
||||||
<button type="button" class="btn" [ngClass]="'btn-' + options.acceptClass" (click)="onAccept()">{{options.acceptText}}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="modal-backdrop fade" [hidden]="!show" [class.show]="animate" [class.in]="animate"></div>
|
|
|
@ -1,3 +0,0 @@
|
||||||
div.modal {
|
|
||||||
display: block;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { ModalContainerComponent } from './modal-container.component';
|
|
||||||
|
|
||||||
describe('ModalContainerComponent', () => {
|
|
||||||
let component: ModalContainerComponent;
|
|
||||||
let fixture: ComponentFixture<ModalContainerComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ ModalContainerComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(ModalContainerComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,83 +0,0 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
|
||||||
import { ModalService } from 'app/services/modal/modal.service';
|
|
||||||
import { ModalOptions } from 'app/interfaces/modal-options';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-modal-container',
|
|
||||||
templateUrl: './modal-container.component.html',
|
|
||||||
styleUrls: ['./modal-container.component.scss']
|
|
||||||
})
|
|
||||||
export class ModalContainerComponent implements OnInit {
|
|
||||||
|
|
||||||
private options: ModalOptions = {
|
|
||||||
heading: '',
|
|
||||||
body: '',
|
|
||||||
acceptText: '',
|
|
||||||
dismisText: '',
|
|
||||||
acceptClass: 'primary'
|
|
||||||
};
|
|
||||||
|
|
||||||
private show = false;
|
|
||||||
private animate = false;
|
|
||||||
|
|
||||||
private currentResolve: Function;
|
|
||||||
private currentReject: Function;
|
|
||||||
|
|
||||||
constructor(private modalService: ModalService) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers this ModalContainerComponent to the ModalService.
|
|
||||||
*/
|
|
||||||
ngOnInit() {
|
|
||||||
this.modalService.registerModalContainer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receives a modal options component and sets the internal config
|
|
||||||
* accordingly. Also the modal dialog is shown with correct animation.
|
|
||||||
*/
|
|
||||||
showMessage(options: ModalOptions): Promise<void> {
|
|
||||||
this.options = options;
|
|
||||||
|
|
||||||
this.show = true;
|
|
||||||
window.setTimeout(() => this.animate = true, 50);
|
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
|
||||||
this.currentResolve = resolve;
|
|
||||||
this.currentReject = reject;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hides the modal dialog with correct animation.
|
|
||||||
*/
|
|
||||||
hideModal() {
|
|
||||||
this.animate = false;
|
|
||||||
window.setTimeout(() => this.show = false, 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler if the user triggers a dismis action.
|
|
||||||
*/
|
|
||||||
onDismis() {
|
|
||||||
this.hideModal();
|
|
||||||
if (this.currentReject) {
|
|
||||||
this.currentReject();
|
|
||||||
this.currentResolve = null;
|
|
||||||
this.currentReject = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler if the user triggers a accept action.
|
|
||||||
*/
|
|
||||||
onAccept() {
|
|
||||||
this.hideModal();
|
|
||||||
if (this.currentResolve) {
|
|
||||||
this.currentResolve();
|
|
||||||
this.currentResolve = null;
|
|
||||||
this.currentReject = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
<li class="nav-item" [routerLinkActive]="neverActive === false ? 'active' : ''">
|
|
||||||
<a [routerLink]="target" class="nav-link">
|
|
||||||
<app-fa-icon *ngIf="icon" [icon]="icon"></app-fa-icon>
|
|
||||||
<span *ngIf="icon"> </span>
|
|
||||||
<ng-content></ng-content>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { NavbarEntryComponent } from './navbar-entry.component';
|
|
||||||
|
|
||||||
describe('NavbarEntryComponent', () => {
|
|
||||||
let component: NavbarEntryComponent;
|
|
||||||
let fixture: ComponentFixture<NavbarEntryComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ NavbarEntryComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(NavbarEntryComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { Component, Input } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-navbar-entry',
|
|
||||||
templateUrl: './navbar-entry.component.html',
|
|
||||||
styleUrls: ['./navbar-entry.component.scss']
|
|
||||||
})
|
|
||||||
export class NavbarEntryComponent {
|
|
||||||
|
|
||||||
@Input() icon: string;
|
|
||||||
@Input() target: string;
|
|
||||||
@Input() neverActive = false;
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
<nav class="navbar navbar-toggleable-sm navbar-inverse bg-inverse">
|
|
||||||
<div class="container">
|
|
||||||
<button *ngIf="!isEmpty()" class="navbar-toggler navbar-toggler-right" (click)="toggleMenu()">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<a class="navbar-brand" href="#">{{ brand }}</a>
|
|
||||||
|
|
||||||
<div class="navbar-collapse" [class.collapse]="!open">
|
|
||||||
<ul #navbarEntries class="navbar-nav mr-auto">
|
|
||||||
<ng-content select="app-navbar-entry:not([right])"></ng-content>
|
|
||||||
</ul>
|
|
||||||
<ul #navbarEntriesRight class="navbar-nav">
|
|
||||||
<ng-content select="app-navbar-entry[right]"></ng-content>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
|
@ -1,6 +0,0 @@
|
||||||
/* Workaround for bootstrap 4 alpha 6*/
|
|
||||||
@media(max-width:768px){
|
|
||||||
.navbar .container {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { NavbarComponent } from './navbar.component';
|
|
||||||
|
|
||||||
describe('NavbarComponent', () => {
|
|
||||||
let component: NavbarComponent;
|
|
||||||
let fixture: ComponentFixture<NavbarComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ NavbarComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(NavbarComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,46 +0,0 @@
|
||||||
import { Component, ViewChild, ElementRef, Input } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-navbar',
|
|
||||||
templateUrl: './navbar.component.html',
|
|
||||||
styleUrls: ['./navbar.component.scss']
|
|
||||||
})
|
|
||||||
export class NavbarComponent {
|
|
||||||
@Input() brand: string;
|
|
||||||
|
|
||||||
private open: Boolean = false;
|
|
||||||
|
|
||||||
@ViewChild('navbarEntries') navbarEntries: any;
|
|
||||||
@ViewChild('navbarEntriesRight') navbarEntriesRight: any;
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggles if the menu is open.
|
|
||||||
*/
|
|
||||||
toggleMenu() {
|
|
||||||
this.open = !this.open;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if both ng-content slots are empty.
|
|
||||||
*
|
|
||||||
* @returns true if the slots are empty, false otherwise
|
|
||||||
*/
|
|
||||||
isEmpty() {
|
|
||||||
let isEmpty = true;
|
|
||||||
|
|
||||||
if (this.navbarEntries && this.navbarEntries.nativeElement.children) {
|
|
||||||
if (this.navbarEntries.nativeElement.children.length > 0) {
|
|
||||||
isEmpty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.navbarEntriesRight && this.navbarEntriesRight.nativeElement.children) {
|
|
||||||
if (this.navbarEntriesRight.nativeElement.children.length > 0) {
|
|
||||||
isEmpty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isEmpty;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
<app-fa-icon *ngIf="order === 0" icon="sort" fixedWidth (click)="toggle()"></app-fa-icon>
|
|
||||||
<app-fa-icon *ngIf="order === 1" icon="sort-amount-asc" fixedWidth (click)="toggle()"></app-fa-icon>
|
|
||||||
<app-fa-icon *ngIf="order === -1" icon="sort-amount-desc" fixedWidth (click)="toggle()"></app-fa-icon>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { SortComponent } from './sort.component';
|
|
||||||
|
|
||||||
describe('SortComponent', () => {
|
|
||||||
let component: SortComponent;
|
|
||||||
let fixture: ComponentFixture<SortComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ SortComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(SortComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,56 +0,0 @@
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
||||||
|
|
||||||
import { SortEvent } from 'app/interfaces/sort-event';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-sort',
|
|
||||||
templateUrl: './sort.component.html',
|
|
||||||
styleUrls: ['./sort.component.scss']
|
|
||||||
})
|
|
||||||
export class SortComponent {
|
|
||||||
|
|
||||||
@Output() sort = new EventEmitter<SortEvent>();
|
|
||||||
|
|
||||||
@Input() field: string;
|
|
||||||
private order = 0;
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the sort order for this field. No SortEvent is emitted.
|
|
||||||
*/
|
|
||||||
public reset() {
|
|
||||||
this.order = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the sort order for this field, except if this field is the one
|
|
||||||
* provided as parameter.
|
|
||||||
*
|
|
||||||
* @param field The fieldname not to reset
|
|
||||||
*/
|
|
||||||
public resetIfNotField(field: string) {
|
|
||||||
if (this.field !== field) {
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cycles between the three sort states possible. Emits a SortEvent.
|
|
||||||
*/
|
|
||||||
toggle() {
|
|
||||||
if (this.order === 0) {
|
|
||||||
this.order = 1;
|
|
||||||
} else if (this.order === 1) {
|
|
||||||
this.order = -1;
|
|
||||||
} else if (this.order === -1) {
|
|
||||||
this.order = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sort.emit({
|
|
||||||
field: this.field,
|
|
||||||
order: this.order
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { TestBed, inject } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { DomainsService } from './domains.service';
|
|
||||||
|
|
||||||
describe('DomainsService', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [DomainsService]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', inject([DomainsService], (service: DomainsService) => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
}));
|
|
||||||
});
|
|
|
@ -1,74 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
import { HttpService } from 'app/services/http/http.service';
|
|
||||||
import { DomainsAnswer } from 'app/interfaces/domains-answer';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DomainsService {
|
|
||||||
|
|
||||||
constructor(private httpService: HttpService) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a domain list from the API
|
|
||||||
*
|
|
||||||
* @param page The page which should be loaded from the API
|
|
||||||
* @param field The field to order the results by
|
|
||||||
* @param order If the results should be ordered asc or desc
|
|
||||||
* @param searchName A string which is used as searchstring on the name
|
|
||||||
* @param searchType The type of domains which should be retrieved
|
|
||||||
*
|
|
||||||
* @returns A Promise for a DomainsAnswer object
|
|
||||||
*/
|
|
||||||
getDomains(page: number, field: string, order: number, searchName: string, searchType: string) {
|
|
||||||
const _order = order === 1 ? 1 : 0;
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const body: any = {
|
|
||||||
sort: {
|
|
||||||
field: field,
|
|
||||||
order: _order
|
|
||||||
},
|
|
||||||
action: 'getDomains',
|
|
||||||
page: page
|
|
||||||
};
|
|
||||||
|
|
||||||
if (searchName) {
|
|
||||||
body.name = searchName;
|
|
||||||
}
|
|
||||||
if (searchType) {
|
|
||||||
body.type = searchType;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.httpService.post<DomainsAnswer>('api/domains.php', body)
|
|
||||||
.then((data: DomainsAnswer) => {
|
|
||||||
resolve(data);
|
|
||||||
}, (err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes one domain.
|
|
||||||
*
|
|
||||||
* @param id Id of the domain to delete
|
|
||||||
*
|
|
||||||
* @returns A Promise for an empty content
|
|
||||||
*/
|
|
||||||
deleteDomain(id: number) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const body = {
|
|
||||||
action: 'deleteDomain',
|
|
||||||
id: id
|
|
||||||
};
|
|
||||||
|
|
||||||
this.httpService.post<{}>('api/domains.php', body)
|
|
||||||
.then(() => {
|
|
||||||
resolve();
|
|
||||||
}, (err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { TestBed, inject } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { HttpService } from './http.service';
|
|
||||||
|
|
||||||
describe('HttpService', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [HttpService]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', inject([HttpService], (service: HttpService) => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
}));
|
|
||||||
});
|
|
|
@ -1,65 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class HttpService {
|
|
||||||
|
|
||||||
constructor(private http: Http) { }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Makes a GET request
|
|
||||||
*
|
|
||||||
* @param url URL which should be used
|
|
||||||
* @param params A URLSearchParams object for the request params
|
|
||||||
*
|
|
||||||
* @returns A Promise for a object of type T
|
|
||||||
*/
|
|
||||||
get<T>(url: string, params?: URLSearchParams) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const headers = new Headers();
|
|
||||||
headers.set('Content-Type', 'application/json')
|
|
||||||
|
|
||||||
this.http.get(url, {
|
|
||||||
headers: headers,
|
|
||||||
params: params
|
|
||||||
}).subscribe((res) => {
|
|
||||||
resolve(<T> res.json() || {});
|
|
||||||
}, (err: HttpErrorResponse) => {
|
|
||||||
if (err.error instanceof Error) {
|
|
||||||
reject(err.error);
|
|
||||||
} else {
|
|
||||||
reject(Error(`Backend returned code ${ err.status }`));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Makes a POST request
|
|
||||||
*
|
|
||||||
* @param url URL which should be used
|
|
||||||
* @param data Data to use as body
|
|
||||||
*
|
|
||||||
* @returns A Promise for a object of type T
|
|
||||||
*/
|
|
||||||
post<T>(url: string, data: any) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const headers = new Headers();
|
|
||||||
headers.set('Content-Type', 'application/json')
|
|
||||||
|
|
||||||
this.http.post(url, data, {
|
|
||||||
headers: headers
|
|
||||||
}).subscribe((res) => {
|
|
||||||
resolve(<T> res.json() || {});
|
|
||||||
}, (err: HttpErrorResponse) => {
|
|
||||||
if (err.error instanceof Error) {
|
|
||||||
reject(err.error);
|
|
||||||
} else {
|
|
||||||
reject(Error(`Backend returned code ${ err.status }`));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { TestBed, inject } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { ModalService } from './modal.service';
|
|
||||||
|
|
||||||
describe('ModalService', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [ModalService]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', inject([ModalService], (service: ModalService) => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
}));
|
|
||||||
});
|
|
|
@ -1,32 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
import { ModalContainerComponent } from 'app/partials/modal-container/modal-container.component';
|
|
||||||
import { ModalOptions } from 'app/interfaces/modal-options';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ModalService {
|
|
||||||
|
|
||||||
container: ModalContainerComponent;
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a ModalContainerComponent as output for the service
|
|
||||||
*
|
|
||||||
* @param container ModalContainerComponent to use
|
|
||||||
*/
|
|
||||||
registerModalContainer(container: ModalContainerComponent) {
|
|
||||||
this.container = container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Forwards modal options to a ModalContainerComponent to show them there.
|
|
||||||
*
|
|
||||||
* @param options ModalOptions to use
|
|
||||||
*/
|
|
||||||
showMessage(options: ModalOptions) {
|
|
||||||
if (this.container) {
|
|
||||||
return this.container.showMessage(options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { TestBed, inject } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { RecordEditService } from './record-edit.service';
|
|
||||||
|
|
||||||
describe('RecordEditService', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [RecordEditService]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', inject([RecordEditService], (service: RecordEditService) => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
}));
|
|
||||||
});
|
|
|
@ -1,34 +0,0 @@
|
||||||
import {Injectable} from '@angular/core';
|
|
||||||
|
|
||||||
import {HttpService} from 'app/services/http/http.service';
|
|
||||||
import {DomainNameAnswer} from 'app/interfaces/domain-name-answer';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class RecordEditService {
|
|
||||||
|
|
||||||
constructor(private httpService: HttpService) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the name of the domain
|
|
||||||
*
|
|
||||||
* @param id Id of the domain for which the name should be retrieved
|
|
||||||
*
|
|
||||||
* @returns A Promise for a DomainNameAnswer
|
|
||||||
*/
|
|
||||||
getDomainName(id: number): Promise<DomainNameAnswer> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const body = {
|
|
||||||
action: 'getDomainName',
|
|
||||||
domain: id
|
|
||||||
};
|
|
||||||
|
|
||||||
this.httpService.post<DomainNameAnswer>('api/edit-master.php', body)
|
|
||||||
.then((answer: DomainNameAnswer) => {
|
|
||||||
resolve(answer);
|
|
||||||
}, (err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { TestBed, inject } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { SessionService } from './session.service';
|
|
||||||
|
|
||||||
describe('SessionService', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [SessionService]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', inject([SessionService], (service: SessionService) => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
}));
|
|
||||||
});
|
|
|
@ -1,102 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { HttpService } from 'app/services/http/http.service';
|
|
||||||
|
|
||||||
import { SessionAnswer } from 'app/interfaces/session-answer';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class SessionService {
|
|
||||||
|
|
||||||
private isLoggedIn = false;
|
|
||||||
private userType: string;
|
|
||||||
|
|
||||||
constructor(private httpService: HttpService) {
|
|
||||||
this.loadState();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the user is logged in
|
|
||||||
*
|
|
||||||
* @returns true if the user is logged in, false otherwise
|
|
||||||
*/
|
|
||||||
getIsLoggedIn() {
|
|
||||||
return this.isLoggedIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the user type
|
|
||||||
*
|
|
||||||
* @returns User type of the current session
|
|
||||||
*/
|
|
||||||
getUserType() {
|
|
||||||
return this.userType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries a login to the server.
|
|
||||||
*
|
|
||||||
* @param username Username to use
|
|
||||||
* @param password Password to use
|
|
||||||
*
|
|
||||||
* @returns A Promise
|
|
||||||
*/
|
|
||||||
tryLogin(username: string, password: string) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const body = { user: username, password: password };
|
|
||||||
|
|
||||||
this.httpService.post<SessionAnswer>('api/index.php', body)
|
|
||||||
.then((data: SessionAnswer) => {
|
|
||||||
if (data.status === 'success') {
|
|
||||||
this.isLoggedIn = true;
|
|
||||||
this.userType = 'admin';
|
|
||||||
this.saveState();
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject(Error('Username or Password wrong'));
|
|
||||||
}
|
|
||||||
}, (err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a log out request to the server.
|
|
||||||
*
|
|
||||||
* @returns A Promise
|
|
||||||
*/
|
|
||||||
logOut() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.httpService.get<any>('api/logout.php')
|
|
||||||
.then(() => {
|
|
||||||
this.isLoggedIn = false;
|
|
||||||
this.userType = '';
|
|
||||||
this.saveState();
|
|
||||||
resolve();
|
|
||||||
}, (err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the state to the sessionStorage.
|
|
||||||
*/
|
|
||||||
saveState() {
|
|
||||||
sessionStorage.setItem('state', JSON.stringify({
|
|
||||||
isLoggedIn: this.isLoggedIn,
|
|
||||||
userType: this.userType
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the state from the sessionStorage.
|
|
||||||
*/
|
|
||||||
loadState() {
|
|
||||||
const state = JSON.parse(sessionStorage.getItem('state'));
|
|
||||||
if (state) {
|
|
||||||
this.isLoggedIn = state.isLoggedIn;
|
|
||||||
this.userType = state.userType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
export const environment = {
|
|
||||||
production: true
|
|
||||||
};
|
|
|
@ -1,8 +0,0 @@
|
||||||
// The file contents for the current environment will overwrite these during build.
|
|
||||||
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
|
|
||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
|
||||||
|
|
||||||
export const environment = {
|
|
||||||
production: false
|
|
||||||
};
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB |
|
@ -1,14 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>PDNS Manager</title>
|
|
||||||
<base href="/">
|
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<app-root>Loading...</app-root>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { enableProdMode } from '@angular/core';
|
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
||||||
|
|
||||||
import { AppModule } from './app/app.module';
|
|
||||||
import { environment } from './environments/environment';
|
|
||||||
|
|
||||||
if (environment.production) {
|
|
||||||
enableProdMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
|
|
@ -1,72 +0,0 @@
|
||||||
/**
|
|
||||||
* This file includes polyfills needed by Angular and is loaded before the app.
|
|
||||||
* You can add your own extra polyfills to this file.
|
|
||||||
*
|
|
||||||
* This file is divided into 2 sections:
|
|
||||||
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
|
||||||
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
|
||||||
* file.
|
|
||||||
*
|
|
||||||
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
|
||||||
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
|
||||||
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
|
||||||
*
|
|
||||||
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************************************************************************************
|
|
||||||
* BROWSER POLYFILLS
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
|
|
||||||
// import 'core-js/es6/symbol';
|
|
||||||
// import 'core-js/es6/object';
|
|
||||||
// import 'core-js/es6/function';
|
|
||||||
// import 'core-js/es6/parse-int';
|
|
||||||
// import 'core-js/es6/parse-float';
|
|
||||||
// import 'core-js/es6/number';
|
|
||||||
// import 'core-js/es6/math';
|
|
||||||
// import 'core-js/es6/string';
|
|
||||||
// import 'core-js/es6/date';
|
|
||||||
// import 'core-js/es6/array';
|
|
||||||
// import 'core-js/es6/regexp';
|
|
||||||
// import 'core-js/es6/map';
|
|
||||||
// import 'core-js/es6/weak-map';
|
|
||||||
// import 'core-js/es6/set';
|
|
||||||
|
|
||||||
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
|
|
||||||
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
|
||||||
|
|
||||||
/** Evergreen browsers require these. **/
|
|
||||||
import 'core-js/es6/reflect';
|
|
||||||
import 'core-js/es7/reflect';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required to support Web Animations `@angular/animation`.
|
|
||||||
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
|
|
||||||
**/
|
|
||||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************************
|
|
||||||
* Zone JS is required by Angular itself.
|
|
||||||
*/
|
|
||||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************************
|
|
||||||
* APPLICATION IMPORTS
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Date, currency, decimal and percent pipes.
|
|
||||||
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
|
|
||||||
*/
|
|
||||||
// import 'intl'; // Run `npm install --save intl`.
|
|
||||||
/**
|
|
||||||
* Need to import at least one locale-data with intl.
|
|
||||||
*/
|
|
||||||
// import 'intl/locale-data/jsonp/en';
|
|
|
@ -1,14 +0,0 @@
|
||||||
/* You can add global styles to this file, and also import other style files */
|
|
||||||
|
|
||||||
/* Bootstrap and customizations */
|
|
||||||
@import '~bootstrap/scss/bootstrap.scss';
|
|
||||||
|
|
||||||
/* Add font awesome */
|
|
||||||
$fa-font-path: "~font-awesome/fonts";
|
|
||||||
@import '~font-awesome/scss/font-awesome';
|
|
||||||
|
|
||||||
/* Custom global rules */
|
|
||||||
.no-shadow {
|
|
||||||
box-shadow: none !important;
|
|
||||||
border-color: #CCC !important;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
||||||
|
|
||||||
import 'zone.js/dist/long-stack-trace-zone';
|
|
||||||
import 'zone.js/dist/proxy.js';
|
|
||||||
import 'zone.js/dist/sync-test';
|
|
||||||
import 'zone.js/dist/jasmine-patch';
|
|
||||||
import 'zone.js/dist/async-test';
|
|
||||||
import 'zone.js/dist/fake-async-test';
|
|
||||||
import { getTestBed } from '@angular/core/testing';
|
|
||||||
import {
|
|
||||||
BrowserDynamicTestingModule,
|
|
||||||
platformBrowserDynamicTesting
|
|
||||||
} from '@angular/platform-browser-dynamic/testing';
|
|
||||||
|
|
||||||
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
|
||||||
declare const __karma__: any;
|
|
||||||
declare const require: any;
|
|
||||||
|
|
||||||
// Prevent Karma from running prematurely.
|
|
||||||
__karma__.loaded = function () {};
|
|
||||||
|
|
||||||
// First, initialize the Angular testing environment.
|
|
||||||
getTestBed().initTestEnvironment(
|
|
||||||
BrowserDynamicTestingModule,
|
|
||||||
platformBrowserDynamicTesting()
|
|
||||||
);
|
|
||||||
// Then we find all the tests.
|
|
||||||
const context = require.context('./', true, /\.spec\.ts$/);
|
|
||||||
// And load the modules.
|
|
||||||
context.keys().map(context);
|
|
||||||
// Finally, start Karma to run the tests.
|
|
||||||
__karma__.start();
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "../out-tsc/app",
|
|
||||||
"module": "es2015",
|
|
||||||
"baseUrl": "",
|
|
||||||
"types": []
|
|
||||||
},
|
|
||||||
"exclude": [
|
|
||||||
"test.ts",
|
|
||||||
"**/*.spec.ts"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "../out-tsc/spec",
|
|
||||||
"module": "commonjs",
|
|
||||||
"target": "es5",
|
|
||||||
"baseUrl": "",
|
|
||||||
"types": [
|
|
||||||
"jasmine",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"test.ts"
|
|
||||||
],
|
|
||||||
"include": [
|
|
||||||
"**/*.spec.ts",
|
|
||||||
"**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
|
5
frontend/src/typings.d.ts
vendored
5
frontend/src/typings.d.ts
vendored
|
@ -1,5 +0,0 @@
|
||||||
/* SystemJS module definition */
|
|
||||||
declare var module: NodeModule;
|
|
||||||
interface NodeModule {
|
|
||||||
id: string;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"compileOnSave": false,
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "./dist/out-tsc",
|
|
||||||
"baseUrl": "src",
|
|
||||||
"sourceMap": true,
|
|
||||||
"declaration": false,
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"target": "es5",
|
|
||||||
"typeRoots": [
|
|
||||||
"node_modules/@types"
|
|
||||||
],
|
|
||||||
"lib": [
|
|
||||||
"es2016",
|
|
||||||
"dom"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,135 +0,0 @@
|
||||||
{
|
|
||||||
"rulesDirectory": [
|
|
||||||
"node_modules/codelyzer"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"arrow-return-shorthand": true,
|
|
||||||
"callable-types": true,
|
|
||||||
"class-name": true,
|
|
||||||
"comment-format": [
|
|
||||||
true,
|
|
||||||
"check-space"
|
|
||||||
],
|
|
||||||
"curly": true,
|
|
||||||
"eofline": true,
|
|
||||||
"forin": true,
|
|
||||||
"import-blacklist": [
|
|
||||||
true,
|
|
||||||
"rxjs"
|
|
||||||
],
|
|
||||||
"import-spacing": true,
|
|
||||||
"indent": [
|
|
||||||
true,
|
|
||||||
"spaces"
|
|
||||||
],
|
|
||||||
"interface-over-type-literal": true,
|
|
||||||
"label-position": true,
|
|
||||||
"max-line-length": [
|
|
||||||
true,
|
|
||||||
140
|
|
||||||
],
|
|
||||||
"member-access": false,
|
|
||||||
"member-ordering": [
|
|
||||||
true,
|
|
||||||
"static-before-instance",
|
|
||||||
"variables-before-functions"
|
|
||||||
],
|
|
||||||
"no-arg": true,
|
|
||||||
"no-bitwise": true,
|
|
||||||
"no-console": [
|
|
||||||
true,
|
|
||||||
"debug",
|
|
||||||
"info",
|
|
||||||
"time",
|
|
||||||
"timeEnd",
|
|
||||||
"trace"
|
|
||||||
],
|
|
||||||
"no-construct": true,
|
|
||||||
"no-debugger": true,
|
|
||||||
"no-duplicate-super": true,
|
|
||||||
"no-empty": false,
|
|
||||||
"no-empty-interface": true,
|
|
||||||
"no-eval": true,
|
|
||||||
"no-inferrable-types": [
|
|
||||||
true,
|
|
||||||
"ignore-params"
|
|
||||||
],
|
|
||||||
"no-misused-new": true,
|
|
||||||
"no-non-null-assertion": true,
|
|
||||||
"no-shadowed-variable": true,
|
|
||||||
"no-string-literal": false,
|
|
||||||
"no-string-throw": true,
|
|
||||||
"no-switch-case-fall-through": true,
|
|
||||||
"no-trailing-whitespace": true,
|
|
||||||
"no-unnecessary-initializer": true,
|
|
||||||
"no-unused-expression": true,
|
|
||||||
"no-use-before-declare": true,
|
|
||||||
"no-var-keyword": true,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"one-line": [
|
|
||||||
true,
|
|
||||||
"check-open-brace",
|
|
||||||
"check-catch",
|
|
||||||
"check-else",
|
|
||||||
"check-whitespace"
|
|
||||||
],
|
|
||||||
"prefer-const": true,
|
|
||||||
"quotemark": [
|
|
||||||
true,
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"radix": true,
|
|
||||||
"semicolon": [
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"triple-equals": [
|
|
||||||
true,
|
|
||||||
"allow-null-check"
|
|
||||||
],
|
|
||||||
"typedef-whitespace": [
|
|
||||||
true,
|
|
||||||
{
|
|
||||||
"call-signature": "nospace",
|
|
||||||
"index-signature": "nospace",
|
|
||||||
"parameter": "nospace",
|
|
||||||
"property-declaration": "nospace",
|
|
||||||
"variable-declaration": "nospace"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"typeof-compare": true,
|
|
||||||
"unified-signatures": true,
|
|
||||||
"variable-name": false,
|
|
||||||
"whitespace": [
|
|
||||||
true,
|
|
||||||
"check-branch",
|
|
||||||
"check-decl",
|
|
||||||
"check-operator",
|
|
||||||
"check-separator",
|
|
||||||
"check-type"
|
|
||||||
],
|
|
||||||
"directive-selector": [
|
|
||||||
true,
|
|
||||||
"attribute",
|
|
||||||
"app",
|
|
||||||
"camelCase"
|
|
||||||
],
|
|
||||||
"component-selector": [
|
|
||||||
true,
|
|
||||||
"element",
|
|
||||||
"app",
|
|
||||||
"kebab-case"
|
|
||||||
],
|
|
||||||
"use-input-property-decorator": true,
|
|
||||||
"use-output-property-decorator": true,
|
|
||||||
"use-host-property-decorator": true,
|
|
||||||
"no-input-rename": true,
|
|
||||||
"no-output-rename": true,
|
|
||||||
"use-life-cycle-interface": true,
|
|
||||||
"use-pipe-transform-interface": true,
|
|
||||||
"component-class-suffix": true,
|
|
||||||
"directive-class-suffix": true,
|
|
||||||
"no-access-missing-member": true,
|
|
||||||
"templates-use-public": true,
|
|
||||||
"invoke-injectable": true
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue