Skip to content

Commit

Permalink
Merge pull request #100 from freifunk-berlin/vpn-config
Browse files Browse the repository at this point in the history
add vpn config to wizard
  • Loading branch information
andrenarchy authored Aug 27, 2017
2 parents be6fca0 + 349aa74 commit 4434aee
Show file tree
Hide file tree
Showing 20 changed files with 762 additions and 446 deletions.
237 changes: 237 additions & 0 deletions config-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
"id": "http://example.com/example.json",
"properties": {
"contact": {
"id": "/properties/contact",
"properties": {
"email": {
"id": "/properties/contact/properties/email",
"type": "string"
},
"name": {
"description": "Nodemaintainer ",
"id": "/properties/contact/properties/name",
"type": "string"
},
"sendToMap": {
"description": "Send entered email contact to Freifunkmap",
"id": "/properties/contact/properties/sendToMap",
"type": "boolean"
},
"showOnContactPage": {
"id": "/properties/contact/properties/showOnContactPage",
"type": "boolean"
}
},
"type": "object"
},
"internet": {
"properties": {
"internetTunnel": {
"properties": {
"files": {
"properties": {
"config": {
"description": "VPN configuration file",
"type": "string"
},
"cert": {
"description": "VPN certificate file",
"type": "string"
},
"cacert": {
"description": "VPN ca certificate file",
"type": "string"
},
"takey": {
"description": "TLS Auth key file",
"type": "string"
},
"key": {
"description": "VPN key file",
"type": "string"
}
},
"required": [
"config"
],
"type": "object"
},
"type": {
"description": "type of VPN tunnel",
"enum": [
null,
"openvpn"
],
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
"meshTunnel": {
"properties": {
"files": {
"properties": {
"config": {
"description": "VPN configuration file",
"type": "string"
},
"cert": {
"description": "VPN certificate file",
"type": "string"
},
"cacert": {
"description": "VPN ca certificate file",
"type": "string"
},
"takey": {
"description": "TLS Auth key file",
"type": "string"
},
"auth-user-pass": {
"description": "Auth User Pass file",
"type": "string"
},
"secret": {
"description": "secret file",
"type": "string"
},
"key": {
"description": "VPN key file",
"type": "string"
}
},
"required": [
"config"
],
"type": "object"
},
"type": {
"description": "type of VPN tunnel",
"enum": [
null,
"openvpn"
],
"type": "string"
}
},
"type": "object"
},
"share": {
"type": "boolean"
}
},
"type": "object"
},
"ip": {
"id": "/properties/ip",
"properties": {
"distribute": {
"description": "Distribute IP addresses to clients",
"id": "/properties/ip/properties/distribute",
"title": "",
"type": "boolean"
},
"meshLan": {
"id": "/properties/ip/properties/meshLan",
"type": "boolean"
},
"v4": {
"id": "/properties/ip/properties/v4",
"properties": {
"lan": {
"description": "mesh IP for LAN (Lanmesh)",
"id": "/properties/ip/properties/v4/properties/lan",
"type": "string"
},
"radio0": {
"id": "/properties/ip/properties/v4/properties/radio0",
"type": "string"
},
"radio1": {
"id": "/properties/ip/properties/v4/properties/radio1",
"type": "string"
}
},
"type": "object"
},
"v4ClientSubnet": {
"id": "/properties/ip/properties/v4ClientSubnet",
"type": "string"
},
"v6Prefix": {
"id": "/properties/ip/properties/v6Prefix",
"type": "string"
}
},
"type": "object"
},
"location": {
"id": "/properties/location",
"properties": {
"city": {
"id": "/properties/location/properties/city",
"type": "string"
},
"lat": {
"id": "/properties/location/properties/lat",
"type": "number"
},
"lng": {
"description": "alternative lon",
"id": "/properties/location/properties/lng",
"type": "number"
},
"postalCode": {
"id": "/properties/location/properties/postalCode",
"type": "string"
},
"street": {
"id": "/properties/location/properties/street",
"type": "string"
}
},
"type": "object"
},
"monitoring": {
"id": "/properties/monitoring",
"properties": {
"enabled": {
"description": "",
"id": "/properties/monitoring/properties/enabled",
"type": "boolean"
}
},
"type": "object"
},
"router": {
"id": "/properties/router",
"properties": {
"name": {
"id": "/properties/router/properties/name",
"type": "string"
},
"passwordHash": {
"id": "/properties/router/properties/passwordHash",
"type": "string"
},
"sshkeys": {
"id": "/properties/router/properties/sshkeys",
"items": {
"id": "/properties/router/properties/sshkeys/items",
"type": "string"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
}

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,21 @@
"webpack-dev-server": "^1.16.2"
},
"dependencies": {
"@uirouter/angularjs": "^1.0.6",
"angular": "^1.6.1",
"angular-animate": "^1.6.1",
"angular-bootstrap": "^0.12.2",
"angular-messages": "^1.6.1",
"angular-sanitize": "^1.6.1",
"angular-simple-logger": "^0.1.7",
"angular-translate": "^2.13.1",
"angular-translate-loader-static-files": "^2.13.1",
"angular-ui-bootstrap": "^2.4.0",
"angular-ui-router": "^1.0.0-beta.3",
"bootstrap": "^3.3.7",
"font-awesome": "^4.7.0",
"ip-address": "^5.0.2",
"leaflet": "^1.2.0",
"lodash": "^4.17.4",
"nano-md5": "^1.0.3",
"ssh-pub-key-validation": "^1.0.0",
"ui-leaflet": "^2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/home.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module } from 'angular';
import uiRouter from 'angular-ui-router';
import uiRouter from '@uirouter/angularjs';

export default module('app.components.home', [uiRouter])
.config(($stateProvider) => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import wizardIp from './wizard-ip/wizard-ip';
import wizardLocation from './wizard-location/wizard-location';
import wizardMonitoring from './wizard-monitoring/wizard-monitoring';
import wizardRouter from './wizard-router/wizard-router';
import wizardTunnel from './wizard-tunnel/wizard-tunnel';
import loadFileForm from './load-file-form/load-file-form';

export default module('app.components', [
authenticateModal.name,
Expand All @@ -34,4 +36,6 @@ export default module('app.components', [
wizardLocation.name,
wizardMonitoring.name,
wizardRouter.name,
wizardTunnel.name,
loadFileForm.name,
]);
2 changes: 1 addition & 1 deletion src/components/load-file-button/load-file-button.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<label class="btn btn-default btn-sm">
<div ng-transclude></div>
<input type="file" accept="{{$ctrl.accept}}">
<input type="file" accept="{{$ctrl.accept}}" data-ng-required="{{$ctrl.required}}">
</label>
23 changes: 20 additions & 3 deletions src/components/load-file-button/load-file-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,42 @@ export default module('app.components.load-file-button', [])
.component('loadFileButton', {
bindings: {
accept: '@',
base64: '@',
required: '@',
onDismiss: '&',
onLoaded: '&',
},
controller: class LoadFileButtonCtrl {
constructor($element, $scope, $window) {
'ngInject';

this.$element = $element;
this.$scope = $scope;
this.$window = $window;
$element.on('change', this.load.bind(this));
this.bindedLoad = this.load.bind(this);
$element.on('change', this.bindedLoad);
}

load(event) {
if (!event.target.files || event.target.files.length === 0) return;
const reader = new this.$window.FileReader();
reader.onload = frEvent => this.$scope.$apply(() => {
this.onLoaded({content: frEvent.target.result});
if (this.base64) {
this.onLoaded({content: frEvent.target.result.split(',')[1]});
} else {
this.onLoaded({content: frEvent.target.result});
}
});
reader.readAsText(event.target.files[0]);
if (this.base64) {
reader.readAsDataURL(event.target.files[0]);
} else {
reader.readAsText(event.target.files[0]);
}

// reset file
this.$element.off('change', this.bindedLoad);
event.target.value = '';
this.$element.on('change', this.bindedLoad);
}
},
template: require('./load-file-button.html'),
Expand Down
24 changes: 24 additions & 0 deletions src/components/load-file-form/load-file-form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="form-group has-feedback"
ng-class="formFeedback('{{$ctrl.idPrefix}}.{{$ctrl.details.property}}')">
<label for="{{$ctrl.idPrefix}}.{{$ctrl.details.property}}" class="col-xs-6 control-label">
{{'load-file-form.' + $ctrl.details.property + '.label' | translate}}
</label>
<div class="col-xs-6">
<load-file-button
ng-if="!$ctrl.fileContent"
id="{{$ctrl.idPrefix}}.{{$ctrl.details.property}}"
accept="{{$ctrl.details.fileExtensions}}"
base64="true"
on-loaded="$ctrl.fileContent = content"
required="$ctrl.details.required"
>
<span>{{'load-file-form.' + $ctrl.details.property + '.select' | translate}}</span>
</load-file-button>
<div ng-if="$ctrl.fileContent">
<i class="fa fa-fw fa-check text-success" aria-hidden="true"></i>
<button type="button" class="btn btn-sm btn-danger" ng-click="$ctrl.fileContent = undefined" title="Remove file">
<i class="fa fa-fw fa-trash-o" aria-hidden="true"></i>
</buton>
</div>
</div>
</div>
24 changes: 24 additions & 0 deletions src/components/load-file-form/load-file-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { module } from 'angular';

export default module('app.components.load-file-form', [])
.component('loadFileForm', {
bindings: {
details: '<',
onUpdate: '&',
fileContent: '<',
idPrefix: '@',
},
controller: class WizardTunnelCtrl {
constructor($scope) {
'ngInject';

$scope.$watch('$ctrl.fileContent', this.update.bind(this));
}

update() {
this.onUpdate({fileContent: this.fileContent});
}
},
template: require('./load-file-form.html'),
transclude: true,
});
2 changes: 1 addition & 1 deletion src/components/status-olsr/status-olsr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module } from 'angular';
import uiRouter from 'angular-ui-router';
import uiRouter from '@uirouter/angularjs';

export default module('app.components.status-olsr', [uiRouter])
.config(($stateProvider) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/status-system/status-system.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module } from 'angular';
import uiRouter from 'angular-ui-router';
import uiRouter from '@uirouter/angularjs';

require('./status-system.less');

Expand Down
Loading

0 comments on commit 4434aee

Please sign in to comment.