diff --git a/wg_dashboard_backend/routers/v1/peer.py b/wg_dashboard_backend/routers/v1/peer.py
index 1bfb02e..e845b66 100644
--- a/wg_dashboard_backend/routers/v1/peer.py
+++ b/wg_dashboard_backend/routers/v1/peer.py
@@ -99,6 +99,10 @@ def edit_peer(
peer=peer,
server=server
))
- peer.sync(sess)
+ sess.query(models.WGPeer)\
+ .filter_by(id=peer.id)\
+ .update(peer.dict(exclude={"id"}))
+
+ sess.commit()
return peer
diff --git a/wg_dashboard_frontend/src/app/page/components/modal-confirm/modal-confirm.component.ts b/wg_dashboard_frontend/src/app/page/components/modal-confirm/modal-confirm.component.ts
index b6fa531..767be8b 100644
--- a/wg_dashboard_frontend/src/app/page/components/modal-confirm/modal-confirm.component.ts
+++ b/wg_dashboard_frontend/src/app/page/components/modal-confirm/modal-confirm.component.ts
@@ -38,7 +38,7 @@ export class ModalConfirmComponent implements OnInit {
open($event){
if (this.noConfirm) {
- this.onConfirm.emit();
+ this.onConfirm.emit($event);
return true;
}
@@ -48,13 +48,13 @@ export class ModalConfirmComponent implements OnInit {
}
confirm($event){
$event.stopPropagation();
- this.onConfirm.emit();
+ this.onConfirm.emit($event);
this.shown= false;
}
cancel($event){
- this.onCancel.emit();
+ this.onCancel.emit($event);
this.shown = false
}
diff --git a/wg_dashboard_frontend/src/app/page/dashboard/peer/peer.component.ts b/wg_dashboard_frontend/src/app/page/dashboard/peer/peer.component.ts
index 81229d6..7d8d3d4 100644
--- a/wg_dashboard_frontend/src/app/page/dashboard/peer/peer.component.ts
+++ b/wg_dashboard_frontend/src/app/page/dashboard/peer/peer.component.ts
@@ -38,6 +38,7 @@ export class PeerComponent implements OnInit {
edit() {
if (this.peer._edit) {
+
// Submit the edit (True -> False)
const idx = this.server.peers.indexOf(this.peer);
this.serverAPI.editPeer(this.peer).subscribe((newPeer) => {
diff --git a/wg_dashboard_frontend/src/app/page/dashboard/server/server.component.html b/wg_dashboard_frontend/src/app/page/dashboard/server/server.component.html
index 223c4f1..dbf8b2d 100644
--- a/wg_dashboard_frontend/src/app/page/dashboard/server/server.component.html
+++ b/wg_dashboard_frontend/src/app/page/dashboard/server/server.component.html
@@ -110,7 +110,7 @@
@@ -127,6 +127,7 @@
+ LOL {{peer !== selectedPeer}}
diff --git a/wg_dashboard_frontend/src/app/pages/components/components.component.html b/wg_dashboard_frontend/src/app/pages/components/components.component.html
deleted file mode 100644
index e69de29..0000000
diff --git a/wg_dashboard_frontend/src/app/pages/components/components.component.scss b/wg_dashboard_frontend/src/app/pages/components/components.component.scss
deleted file mode 100644
index e69de29..0000000
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/accordion.scss b/wg_dashboard_frontend/src/app/pages/dashboard/accordion.scss
deleted file mode 100644
index aa56ba7..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/accordion.scss
+++ /dev/null
@@ -1,34 +0,0 @@
-.mdl-accordion.mdl-accordion--opened {
- border-top: 1px solid #e0e0e0;
- border-bottom: 1px solid #e0e0e0;
- margin-top: -1px;
-}
-.mdl-accordion.mdl-accordion--opened + .mdl-accordion.mdl-accordion--opened {
- border-top: none;
- margin-top: 0
-}
-.mdl-accordion .mdl-accordion__content-wrapper {
- overflow: hidden;
-}
-.mdl-accordion .mdl-accordion__content {
- transition-property: margin-top;
- transition-duration: 0.2s;
-}
-.mdl-accordion .mdl-accordion__icon {
- transition-property: transform;
- transition-duration: 0.2s;
- color: rgba(0,0,0,0.3);
-
- position: absolute;
- right: 6px;
- margin-top: -3px;
-}
-.mdl-accordion.mdl-accordion--opened .mdl-accordion__icon {
- transform: rotate(-180deg);
-}
-.mdl-accordion.mdl-accordion--opened .mdl-accordion__button {
- color: teal;
-}
-.mdl-accordion.mdl-accordion--opened .mdl-accordion__content {
- margin-top: 0 !important;
-}
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/add-server/add-server.component.html b/wg_dashboard_frontend/src/app/pages/dashboard/add-server/add-server.component.html
deleted file mode 100644
index 40d3b02..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/add-server/add-server.component.html
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
- Add Server
-
-
-
-
-
-
-
-
-
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/add-server/add-server.component.ts b/wg_dashboard_frontend/src/app/pages/dashboard/add-server/add-server.component.ts
deleted file mode 100644
index 0078156..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/add-server/add-server.component.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import {Component, Input, OnInit} from '@angular/core';
-import {FormControl, FormGroup, Validators} from "@angular/forms";
-import {IPValidator} from "../../../validators/ip-address.validator";
-import {NumberValidator} from "../../../validators/number.validator";
-import {Server} from "../../../interfaces/server";
-import {ServerService} from "../../../services/server.service";
-import {DataService} from "../../../services/data.service";
-
-@Component({
- selector: 'app-add-server',
- templateUrl: './add-server.component.html',
- styleUrls: ['./add-server.component.scss']
-})
-export class AddServerComponent implements OnInit {
-
- @Input() servers: Array;
-
- serverForm = new FormGroup({
- address: new FormControl('', [IPValidator.isIPAddress]),
- interface: new FormControl('', [Validators.required, Validators.minLength(3)]),
- listen_port: new FormControl('', [Validators.required, NumberValidator.stringIsNumber]),
- endpoint: new FormControl('', Validators.required),
- private_key: new FormControl('', [Validators.minLength(44), Validators.maxLength(44)]),
- public_key: new FormControl('', [Validators.minLength(44), Validators.maxLength(44)]),
- shared_key: new FormControl('', [Validators.minLength(44), Validators.maxLength(44)]),
- post_up: new FormControl(''),
- post_down: new FormControl(''),
-
- // Unused on backend
- is_running: new FormControl(false),
- peers: new FormControl([]),
- });
- isEdit: boolean = false;
- editServer: Server = null;
-
- constructor(private serverAPI: ServerService, private comm: DataService) { }
-
- ngOnInit(): void {
-
- this.comm.on("server-edit").subscribe( (data: Server) => {
- this.isEdit = true;
- this.serverForm.setValue(data);
- this.editServer = data;
- })
-
- }
-
- add(form: Server) {
-
- if(this.isEdit){
- const idx = this.servers.indexOf(this.editServer);
- this.serverAPI.editServer(this.editServer, form).subscribe((server: Server) => {
- this.servers[idx] = server;
- });
-
- } else {
-
- this.serverAPI.addServer(form).subscribe((server: Server) => {
- this.servers.push(server);
- });
- }
-
- this.isEdit = false;
- this.serverForm.reset();
- this.editServer = null;
- }
-
- getKeyPair() {
- this.serverAPI.getKeyPair().subscribe((kp: any) => {
- this.serverForm.patchValue({
- private_key: kp.private_key,
- public_key: kp.public_key
- })
- });
- }
-
- getPSK() {
- this.serverAPI.getPSK().subscribe((psk: any) => {
- this.serverForm.patchValue({
- shared_key: psk.psk
- })
- });
- }
-}
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.component.html b/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.component.html
deleted file mode 100644
index 349ee80..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.component.html
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
- Servers
-
-
- No Servers
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.component.ts b/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.component.ts
deleted file mode 100644
index b69c352..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.component.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import {Component, HostBinding, OnInit} from '@angular/core';
-
-import { UpgradableComponent } from 'theme/components/upgradable';
-import {AbstractControl, FormControl, FormGroup, NgForm, Validators} from "@angular/forms";
-// goog-webfont-dl -o src/theme/fonts/font-roboto.css -p assets/fonts/Roboto -d src/assets/fonts/Roboto -a Roboto
-
-import * as IPCIDR from "ip-cidr";
-import {Server} from "../../interfaces/server";
-import {ServerService} from "../../services/server.service";
-
-import {Peer} from "../../interfaces/peer";
-import {IPValidator} from "../../validators/ip-address.validator";
-
-
-
-
-@Component({
- selector: 'app-dashboard',
- styleUrls: ['./dashboard.component.scss', './accordion.scss'],
- templateUrl: './dashboard.component.html',
-})
-export class DashboardComponent extends UpgradableComponent implements OnInit
-{
- @HostBinding('class.mdl-grid') private readonly mdlGrid = true;
- @HostBinding('class.mdl-grid--no-spacing') private readonly mdlGridNoSpacing = true;
-
- servers: Array = [];
-
- constructor(private serverAPI: ServerService) {
- super();
- }
-
- ngOnInit(): void {
- this.serverAPI.getServers()
- .subscribe( (servers: Array) => {
- this.servers.push(...servers)
- servers.forEach((server) => {
-
- this.serverAPI.serverStats(server).subscribe((stats: Peer[]) => {
- stats.forEach( item => {
- const peer = server.peers.find(x => x.public_key == item.public_key);
- peer._stats = item
- });
-
-
- });
-
-
- });
-
-
- })
- }
-
-}
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.module.ts b/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.module.ts
deleted file mode 100644
index e493d32..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/dashboard.module.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { CommonModule } from '@angular/common';
-import { NgModule } from '@angular/core';
-import {FormsModule, ReactiveFormsModule} from '@angular/forms';
-
-import { ThemeModule } from 'theme';
-
-import { DashboardComponent } from './dashboard.component';
-import { PeerComponent } from './peer/peer.component';
-import { ComponentsModule } from "../components";
-import { AddServerComponent } from './add-server/add-server.component';
-import { ServerComponent } from './server/server.component';
-import {AppModule} from "../../app.module";
-import {QRCodeModule} from "angularx-qrcode";
-
-@NgModule({
- imports: [
- CommonModule,
- ThemeModule,
- FormsModule,
- ReactiveFormsModule,
- ComponentsModule,
- QRCodeModule
- ],
- declarations: [
- DashboardComponent,
- PeerComponent,
- AddServerComponent,
- ServerComponent,
- ],
- exports: [
- ],
-})
-export class DashboardModule { }
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/index.ts b/wg_dashboard_frontend/src/app/pages/dashboard/index.ts
deleted file mode 100644
index 99a7347..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { DashboardComponent } from './dashboard.component';
-export { DashboardModule } from './dashboard.module';
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.html b/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.html
deleted file mode 100644
index 4f3738f..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.html
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.scss b/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.scss
deleted file mode 100644
index 76ff171..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.scss
+++ /dev/null
@@ -1,16 +0,0 @@
-.peer-item > div{
- padding-top: 15px;
- padding-bottom: 15px;
- border-top: 1px solid black;
-
-}
-
-.peer-item-header > div{
- font-weight: bold;
- padding-top: 15px;
- padding-bottom: 15px;
-}
-
-.no-padding{
- padding: 0 !important;
-}
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.ts b/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.ts
deleted file mode 100644
index e59955c..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/peer/peer.component.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import {Component, Input, OnInit} from '@angular/core';
-import {ServerService} from "../../../services/server.service";
-import {Peer} from "../../../interfaces/peer";
-import {Server} from "../../../interfaces/server";
-
-@Component({
- selector: 'app-peer',
- templateUrl: './peer.component.html',
- styleUrls: ['./peer.component.scss']
-})
-export class PeerComponent implements OnInit {
-
- @Input("peer") peer: Peer;
- @Input("server") server: Server;
-
- config: string = "Loading...";
-
-
- constructor(public serverAPI: ServerService) { }
-
- ngOnInit(): void {
- }
-
- edit(){
- if(this.peer._edit) {
-
- // Submit the edit (True -> False)
- const idx = this.server.peers.indexOf(this.peer);
- this.serverAPI.editPeer(this.peer).subscribe((newPeer) => {
- this.server.peers[idx] = newPeer;
- });
-
- } else if(!this.peer._edit) {
- this.peer._expand = true;
-
- // Open for edit. aka do nothing (False -> True
-
- }
-
- this.peer._edit = !this.peer._edit;
-
-
- }
-
- delete(){
- const idx = this.server.peers.indexOf(this.peer);
- this.serverAPI.deletePeer(this.peer).subscribe((apiServer) => {
- this.server.peers.splice(idx, 1);
- })
- }
-
- fetchConfig() {
- this.serverAPI.peerConfig(this.peer).subscribe((config: any) => {
- this.config = config.config
- })
- }
-
- pInt(string: string) {
- return parseInt(string)
- }
-}
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/server/server.component.html b/wg_dashboard_frontend/src/app/pages/dashboard/server/server.component.html
deleted file mode 100644
index 6162892..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/server/server.component.html
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
- {{server.interface}}
-
- check_circle
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/wg_dashboard_frontend/src/app/pages/dashboard/server/server.component.ts b/wg_dashboard_frontend/src/app/pages/dashboard/server/server.component.ts
deleted file mode 100644
index 349a373..0000000
--- a/wg_dashboard_frontend/src/app/pages/dashboard/server/server.component.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import {Component, Input, OnInit, Output} from '@angular/core';
-import {Server} from "../../../interfaces/server";
-import {ServerService} from "../../../services/server.service";
-import {DataService} from "../../../services/data.service";
-
-@Component({
- selector: 'app-server',
- templateUrl: './server.component.html',
- styleUrls: ['./server.component.scss']
-})
-export class ServerComponent implements OnInit {
- @Input() server: Server;
- @Input() servers: Array;
- serverConfig: string;
-
- constructor(private serverAPI: ServerService, private comm: DataService) { }
-
- ngOnInit(): void {
-
- this.serverAPI.serverConfig(this.server).subscribe((x: any) => this.serverConfig = x.config)
-
- }
-
- edit(){
-
- this.comm.emit('server-edit', this.server);
- }
-
- stop() {
- this.serverAPI.stopServer(this.server).subscribe((apiServer) => {
- this.server.is_running = apiServer.is_running
- })
- }
-
- start() {
- this.serverAPI.startServer(this.server).subscribe((apiServer) => {
- this.server.is_running = apiServer.is_running
- })
- }
-
- addPeer() {
- this.serverAPI.addPeer(this.server).subscribe((peer) => {
- this.server.peers.push(peer)
- })
- }
-
- restart() {
- this.serverAPI.restartServer(this.server).subscribe((apiServer) => {
- this.server.is_running = apiServer.is_running
- })
- }
-
-
- delete() {
- const index = this.servers.indexOf(this.server);
- this.serverAPI.deleteServer(this.server).subscribe((apiServer) => {
- this.servers.splice(index, 1);
- })
- }
-}
diff --git a/wg_dashboard_frontend/src/app/pages/user/edit/edit.component.html b/wg_dashboard_frontend/src/app/pages/user/edit/edit.component.html
deleted file mode 100644
index 6e2720c..0000000
--- a/wg_dashboard_frontend/src/app/pages/user/edit/edit.component.html
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
- Edit User
-
-
-
-
-
-
-
-
-
-
diff --git a/wg_dashboard_frontend/src/app/pages/user/edit/edit.component.ts b/wg_dashboard_frontend/src/app/pages/user/edit/edit.component.ts
deleted file mode 100644
index 5cd430a..0000000
--- a/wg_dashboard_frontend/src/app/pages/user/edit/edit.component.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-import {FormControl, FormGroup, Validators} from "@angular/forms";
-import {AuthService} from "@services/*";
-import {Router} from "@angular/router";
-
-@Component({
- selector: 'app-edit',
- templateUrl: './edit.component.html',
- styleUrls: ['./edit.component.scss']
-})
-export class EditComponent implements OnInit {
-
- public editForm: FormGroup = new FormGroup({
- full_name: new FormControl(''),
- password: new FormControl('', Validators.required),
- email: new FormControl('', [
- Validators.required,
- Validators.pattern('^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$'),
- Validators.maxLength(20),
- ]),
- username: new FormControl('', [Validators.required, Validators.maxLength(20)]),
- });
- public user: any;
- public error: string;
-
- constructor(private authService: AuthService,
- private router: Router) {
-
- }
-
- public ngOnInit() {
- this.user = this.authService.user;
-
-
- this.editForm.setValue({
- full_name: this.user.full_name,
- password: "",
- email: this.user.email,
- username: this.user.username
- })
- }
-
- public edit() {
- if (this.editForm.valid) {
- this.authService.edit(this.editForm.getRawValue())
- .subscribe(res => this.router.navigate(['/app/dashboard']),
- error => this.error = error.message);
- }
- }
-
-}
diff --git a/wg_dashboard_frontend/src/app/pages/user/login/login.component.html b/wg_dashboard_frontend/src/app/pages/user/login/login.component.html
deleted file mode 100644
index ea2cfce..0000000
--- a/wg_dashboard_frontend/src/app/pages/user/login/login.component.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
- Edit User
-
-
-
-
-
-
-
-
-
-
diff --git a/wg_dashboard_frontend/src/app/pages/user/login/login.component.spec.ts b/wg_dashboard_frontend/src/app/pages/user/login/login.component.spec.ts
deleted file mode 100644
index d6d85a8..0000000
--- a/wg_dashboard_frontend/src/app/pages/user/login/login.component.spec.ts
+++ /dev/null
@@ -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;
-
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [ LoginComponent ]
- })
- .compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(LoginComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/wg_dashboard_frontend/src/app/pages/user/login/login.component.ts b/wg_dashboard_frontend/src/app/pages/user/login/login.component.ts
deleted file mode 100644
index 0cfee7b..0000000
--- a/wg_dashboard_frontend/src/app/pages/user/login/login.component.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
-import {AuthService} from "@services/*";
-import {Router} from "@angular/router";
-
-@Component({
- selector: 'app-login',
- templateUrl: './login.component.html',
- styleUrls: ['./login.component.scss']
-})
-export class LoginComponent implements OnInit {
-
- public loginForm: FormGroup;
- public username;
- public password;
- public error: string;
-
- constructor(private authService: AuthService,
- private fb: FormBuilder,
- private router: Router) {
-
-
- this.loginForm = this.fb.group({
- password: new FormControl('', Validators.required),
- username: new FormControl('', [
- Validators.required,
- ]),
- });
- this.username = this.loginForm.get('username');
- this.password = this.loginForm.get('password');
- }
-
- public ngOnInit() {
- this.authService.logout();
- this.loginForm.valueChanges.subscribe(() => {
- this.error = null;
- });
- }
-
- public login() {
- this.error = null;
- if (this.loginForm.valid) {
- this.authService.login(this.loginForm.getRawValue())
- .subscribe(res => this.router.navigate(['/app/dashboard']),
- error => this.error = error.message);
- }
- }
-
- public onInputChange(event) {
- event.target.required = true;
- }
-
-}
diff --git a/wg_dashboard_frontend/src/app/pages/user/user.module.ts b/wg_dashboard_frontend/src/app/pages/user/user.module.ts
deleted file mode 100644
index cd2cf77..0000000
--- a/wg_dashboard_frontend/src/app/pages/user/user.module.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { NgModule } from '@angular/core';
-import { CommonModule } from '@angular/common';
-import { EditComponent } from './edit/edit.component';
-import {ReactiveFormsModule} from "@angular/forms";
-import {CardModule} from "../../../theme/components/card";
-import { LoginComponent } from './login/login.component';
-
-
-
-@NgModule({
- declarations: [
- EditComponent,
- LoginComponent
- ],
- imports: [
- CommonModule,
- ReactiveFormsModule,
- CardModule
- ]
-})
-export class UserModule {
-
-}
|