Merge pull request #40 from GNS3/electronjs
Initial electronjs integration
@ -28,7 +28,9 @@
|
||||
"environmentSource": "environments/environment.ts",
|
||||
"environments": {
|
||||
"dev": "environments/environment.ts",
|
||||
"prod": "environments/environment.prod.ts"
|
||||
"prod": "environments/environment.prod.ts",
|
||||
"electronProd": "environments/environment.electron.prod.ts",
|
||||
"electronDev": "environments/environment.electron.ts"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
48
.appveyor.yml
Normal file
@ -0,0 +1,48 @@
|
||||
version: 1.0.{build}
|
||||
|
||||
# Do not build feature branch with open Pull Requests
|
||||
skip_branch_with_pr: true
|
||||
|
||||
platform:
|
||||
- x64
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
install:
|
||||
- ps: Install-Product node 8 x64
|
||||
- yarn
|
||||
|
||||
build_script:
|
||||
- yarn buildforelectron
|
||||
- "%PYTHON%\\python.exe -m pip install -r scripts\\requirements.txt"
|
||||
- "%PYTHON%\\python.exe scripts\\build.py download"
|
||||
- "%PYTHON%\\python.exe scripts\\build.py build -b dist"
|
||||
- "%PYTHON%\\python.exe scripts\\build.py validate -b dist"
|
||||
- yarn electron-builder --win --x64
|
||||
|
||||
- ps: $OutputDirectory = $((Get-Date).ToString('yyyy-MM-dd'))
|
||||
- ps: If ($env:APPVEYOR_REPO_TAG -eq $false) { New-Item -ItemType Directory -Path "$OutputDirectory" }
|
||||
- ps: If ($env:APPVEYOR_REPO_TAG -eq $false) { move build\*.exe "$OutputDirectory" }
|
||||
- ps: If ($env:APPVEYOR_REPO_TAG -eq $false) { cd $OutputDirectory; Get-ChildItem -Filter '*.exe' | Rename-Item -NewName {$_.Name -replace ".exe","-$env:APPVEYOR_REPO_BRANCH-$env:APPVEYOR_BUILD_NUMBER.exe"} }
|
||||
- ps: If ($env:APPVEYOR_REPO_TAG -eq $false) { $execs = Get-ChildItem -Filter '*.exe'; $artifact = $execs[0].basename; }
|
||||
- ps: If ($env:APPVEYOR_REPO_TAG -eq $false) { cd ..; Push-AppveyorArtifact "$((Get-Date).ToString('yyyy-MM-dd'))\*.exe" -FileName "$((Get-Date).ToString('yyyy-MM-dd'))\$artifact.exe" }
|
||||
|
||||
test: off
|
||||
|
||||
deploy:
|
||||
- provider: FTP
|
||||
protocol: sftp
|
||||
host: frs.sourceforge.net
|
||||
username: gns3build
|
||||
password:
|
||||
secure: YRiLLoY27UOZ8QJHqqdESBQFfPfENKV0cLI/QFSsbWc=
|
||||
folder: "../../../../frs/project/gns-3/Nightly Builds"
|
||||
artifact: /.*\.exe/
|
||||
on:
|
||||
appveyor_repo_tag: false # deploy on branch only
|
||||
|
||||
environment:
|
||||
GH_TOKEN:
|
||||
secure: Zb0F4wfA/3zXZBQiEmEGpKIP17hD9gb/CNwxQE2N3J4Eq3z58mp0K0ey5g8Dupsb
|
||||
PYTHON: "C:\\Python36-x64"
|
78
.circleci/config.yml
Normal file
@ -0,0 +1,78 @@
|
||||
# iOS CircleCI 2.0 configuration file
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
macos:
|
||||
xcode: "9.1.0"
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
- run:
|
||||
name: Set timezone and check current datetime
|
||||
command: |
|
||||
sudo systemsetup -settimezone Europe/Warsaw
|
||||
echo "Today is $(date +"%Y-%m-%d %T")"
|
||||
|
||||
- run:
|
||||
name: Install project
|
||||
# there is an issue with yarn and cache during executed on CI; for now we just run it twice, second should
|
||||
# be successful. Check it later if updates fixed the issue
|
||||
command: |
|
||||
yarn || true
|
||||
yarn || true
|
||||
|
||||
- run:
|
||||
name: Building WebUI for distribution
|
||||
command: |
|
||||
yarn buildforelectron
|
||||
|
||||
- run:
|
||||
name: Building gns3server
|
||||
command: |
|
||||
# brew update is required due to bug in CCI: https://discuss.circleci.com/t/homebrew-must-be-run-under-ruby-2-3-runtimeerror/17232/5
|
||||
brew update
|
||||
brew --env
|
||||
brew --config
|
||||
brew install python3
|
||||
pip3 install -r scripts/requirements.txt
|
||||
python3 scripts/build.py download
|
||||
python3 scripts/build.py build -b dist
|
||||
python3 scripts/build.py validate -b dist
|
||||
|
||||
- run:
|
||||
name: Dist project
|
||||
command: |
|
||||
yarn electron-builder --mac --x64
|
||||
|
||||
- run:
|
||||
name: Gather artifacts
|
||||
command: |
|
||||
mkdir artifacts
|
||||
cp build/*.dmg artifacts/
|
||||
|
||||
- store_artifacts:
|
||||
path: artifacts
|
||||
destination: artifacts
|
||||
|
||||
- deploy:
|
||||
name: Deploying on SourceForge
|
||||
command: |
|
||||
echo "Deploying on SourceForge"
|
||||
ssh-keyscan -H frs.sourceforge.net >> ~/.ssh/known_hosts
|
||||
mkdir -p artifacts/release
|
||||
cd artifacts; for file in *.dmg; do mv "$file" "release/${file%.dmg}-${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}.dmg"; done; cd ..
|
||||
echo "mkdir \"/home/frs/project/gns-3/Nightly Builds/$(date +"%Y-%m-%d")\"" | sftp gns3build@frs.sourceforge.net || true
|
||||
echo "Copying to SourceForge"
|
||||
scp artifacts/release/* gns3build@frs.sourceforge.net:"/home/frs/project/gns-3/Nightly\ Builds/$(date +"%Y-%m-%d")/"
|
||||
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build_and_deploy:
|
||||
jobs:
|
||||
- build:
|
||||
filters:
|
||||
tags:
|
||||
only: /v.*/
|
||||
|
8
.gitignore
vendored
@ -4,6 +4,13 @@
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
/ng-dist
|
||||
/build
|
||||
/scripts/tmp
|
||||
/scripts/env
|
||||
/scripts/build
|
||||
/scripts/dist
|
||||
/env
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
@ -32,6 +39,7 @@
|
||||
npm-debug.log
|
||||
testem.log
|
||||
/typings
|
||||
/yarn-error.log
|
||||
|
||||
# e2e
|
||||
/e2e/*.js
|
||||
|
34
.travis.yml
@ -7,22 +7,37 @@ addons:
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- google-chrome-stable
|
||||
- google-chrome-beta
|
||||
- g++-4.8
|
||||
|
||||
before_install:
|
||||
- export CHROME_BIN=chromium-browser
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
|
||||
before_script:
|
||||
- npm install -g karma
|
||||
# Ubuntu trusty supports max python3.4, cx_freeze-5.1.1 requires min 3.5
|
||||
- |
|
||||
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
|
||||
export PATH="~/.pyenv/bin:$PATH"
|
||||
eval "$(pyenv init -)"
|
||||
eval "$(pyenv virtualenv-init -)"
|
||||
pyenv virtualenv 3.6.3 general
|
||||
pyenv global general
|
||||
python3 -V
|
||||
pip3 -V
|
||||
|
||||
script: ng test --watch=false
|
||||
|
||||
before_script:
|
||||
- yarn
|
||||
|
||||
script: yarn ng test --watch=false
|
||||
|
||||
after_script:
|
||||
- ng build --base-href /${TRAVIS_BRANCH}/
|
||||
# publish on gns3.github.io
|
||||
- yarn ng build --base-href /${TRAVIS_BRANCH}/
|
||||
- export GIT_LAST_LOG="$(git log -1 --pretty=%B)"
|
||||
- git clone https://${GITHUB_CREDENTIALS}@github.com/GNS3/gns3.github.io.git github-pages
|
||||
- mkdir -p github-pages/${TRAVIS_BRANCH}
|
||||
@ -33,4 +48,15 @@ after_script:
|
||||
- git add -A
|
||||
- git commit -m "Deploy - $GIT_LAST_LOG"
|
||||
- git push origin master
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
|
||||
# publish
|
||||
- yarn buildforelectron
|
||||
- python3 -m venv env
|
||||
- |
|
||||
source env/bin/activate
|
||||
pip3 install -r scripts/requirements.txt
|
||||
python3 scripts/build.py download
|
||||
python3 scripts/build.py build -b dist
|
||||
# python3 scripts/build.py validate -b dist
|
||||
- yarn electron-builder --linux --x64
|
||||
|
40
.yarnclean
Normal file
@ -0,0 +1,40 @@
|
||||
# test directories
|
||||
__tests__
|
||||
node_modules/*/test
|
||||
node_modules/*/tests
|
||||
powered-test
|
||||
e2e
|
||||
|
||||
# asset directories
|
||||
docs
|
||||
doc
|
||||
website
|
||||
images
|
||||
|
||||
# examples
|
||||
example
|
||||
examples
|
||||
|
||||
# code coverage directories
|
||||
coverage
|
||||
.nyc_output
|
||||
|
||||
# build scripts
|
||||
Makefile
|
||||
Gulpfile.js
|
||||
Gruntfile.js
|
||||
|
||||
# configs
|
||||
.tern-project
|
||||
.gitattributes
|
||||
.editorconfig
|
||||
.*ignore
|
||||
.eslintrc
|
||||
.jshintrc
|
||||
.flowconfig
|
||||
.documentup.json
|
||||
.yarn-metadata.json
|
||||
|
||||
# misc
|
||||
*.gz
|
||||
*.md
|
45
README.md
@ -33,7 +33,6 @@ ng serve --port 8080
|
||||
Application is accessible on `http://localhost:8080/`. The app will automatically reload if you change any of the source files.
|
||||
|
||||
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.
|
||||
@ -51,6 +50,50 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.
|
||||
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
||||
Before running the tests make sure you are serving the app via `ng serve`.
|
||||
|
||||
# How to build gns3server for WebUI?
|
||||
|
||||
python3 scripts/build.py build -b dist
|
||||
|
||||
# Releasing
|
||||
|
||||
## Bumping releases
|
||||
|
||||
We're using [version-bump-prompt](https://www.npmjs.com/package/version-bump-prompt) for increasing version.
|
||||
|
||||
Intall `bump` via:
|
||||
|
||||
npm install -g version-bump-prompt
|
||||
|
||||
If you would like to bump prepatch just type:
|
||||
|
||||
bump --prepatch --tag --push
|
||||
|
||||
## Final release
|
||||
|
||||
We have got configured CircleCI, TravisCI and AppVeyor for distributing application for particular platform. In order to release you need to tag your code nad push it.
|
||||
|
||||
Using `bump`:
|
||||
|
||||
bump --patch --tag --push
|
||||
|
||||
Or manually:
|
||||
|
||||
git tag v0.0.1
|
||||
git push origin v0.0.1
|
||||
|
||||
|
||||
When artifacts are made you can see draft release here: [gns3-web-ui releases](https://github.com/GNS3/gns3-web-ui/releases) which is waiting to be published.
|
||||
After release please change current version in `package.json` to `X.X.X-beta.0`'. Otherwise artifacts will be overwritten during the next commit.
|
||||
|
||||
You may use `bump` to achieve that:
|
||||
|
||||
bump --prepatch
|
||||
|
||||
## Staging release
|
||||
|
||||
In case you would like to create a new staging release. Please create draft release on github, like `0.0.1-dev1`. After successful build you can find there artifacts.
|
||||
|
||||
|
||||
## Further help
|
||||
|
||||
If you want to contribute to GNS3 Web UI feel free to reach us at `developers@gns3.net`.
|
||||
|
52
electron-builder.yml
Normal file
@ -0,0 +1,52 @@
|
||||
appId: com.gns3.web-ui
|
||||
copyright: "Copyright © 2018 GNS3"
|
||||
productName: "GNS3 Web UI Prototype"
|
||||
#forceCodeSigning: true
|
||||
artifactName: "${productName}-${os}-${arch}-${version}.${ext}"
|
||||
asar: true
|
||||
compression: normal
|
||||
|
||||
directories:
|
||||
output: build
|
||||
|
||||
files:
|
||||
- dist
|
||||
- main.js
|
||||
- package.json
|
||||
|
||||
mac:
|
||||
category: public.app-category.developer-tools
|
||||
# publish: github
|
||||
target:
|
||||
- dmg
|
||||
dmg:
|
||||
# background: "build/appdmg.png"
|
||||
icon: "dist/assets/icons/mac/icon.icns"
|
||||
iconSize: 128
|
||||
contents:
|
||||
- x: 380
|
||||
y: 240
|
||||
type: link
|
||||
path: /Applications
|
||||
- x: 122
|
||||
y: 240
|
||||
type: file
|
||||
|
||||
linux:
|
||||
# publish: github
|
||||
icon: "dist/assets/icons/png"
|
||||
category: "Network"
|
||||
packageCategory: "Network"
|
||||
description: "GNS3 Web Ui Prototype application. Please don't use it as long as it's not officially announced."
|
||||
target:
|
||||
- deb
|
||||
- AppImage
|
||||
maintainer: "Dominik Ziajka <dominik@gns3.net>"
|
||||
win:
|
||||
publish:
|
||||
provider: "github"
|
||||
owner: "GNS3"
|
||||
icon: "dist/assets/icons/win/icon.ico"
|
||||
|
||||
nsis:
|
||||
perMachine: true
|
100
main.js
Normal file
@ -0,0 +1,100 @@
|
||||
const electron = require('electron');
|
||||
var fs = require('fs');
|
||||
// Module to control application life.
|
||||
const app = electron.app;
|
||||
// Module to create native browser window.
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow;
|
||||
|
||||
let serverProc = null;
|
||||
|
||||
let isWin = /^win/.test(process.platform);
|
||||
|
||||
const createServerProc = () => {
|
||||
fs.readdir(path.join(__dirname, 'dist'), (err, files) => {
|
||||
var serverPath = null;
|
||||
|
||||
files.forEach((filename) => {
|
||||
if(filename.startsWith('exe.')) {
|
||||
if (isWin) {
|
||||
serverPath = path.join(__dirname, 'dist', filename, 'gns3server.exe');
|
||||
}
|
||||
else {
|
||||
serverPath = path.join(__dirname, 'dist', filename, 'gns3server');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (serverPath != null) {
|
||||
serverProc = require('child_process').execFile(serverPath, []);
|
||||
|
||||
if (serverProc != null) {
|
||||
console.log('gns3server started from path: ' + serverPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const exitServerProc = () => {
|
||||
serverProc.kill();
|
||||
serverProc = null;
|
||||
}
|
||||
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({width: 800, height: 600});
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'dist/index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}));
|
||||
|
||||
// Open the DevTools.
|
||||
// mainWindow.webContents.openDevTools();
|
||||
|
||||
// Emitted when the window is closed.
|
||||
mainWindow.on('closed', function () {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
});
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow);
|
||||
|
||||
app.on('ready', createServerProc);
|
||||
app.on('will-quit', exitServerProc);
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function () {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', function () {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (mainWindow === null) {
|
||||
createWindow()
|
||||
}
|
||||
});
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
1141
package-lock.json
generated
68
package.json
@ -1,31 +1,43 @@
|
||||
{
|
||||
"name": "gns3-web-ui",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"version": "0.0.1-beta.0",
|
||||
"license": "GPLv3",
|
||||
"main": "main.js",
|
||||
"repository": {
|
||||
"type" : "git",
|
||||
"url": "https://github.com/GNS3/gns3-web-ui.git"
|
||||
},
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"startforelectron": "ng serve -e electronDev",
|
||||
"build": "ng build",
|
||||
"buildforelectron": "ng build -e electronProd",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e"
|
||||
"e2e": "ng e2e",
|
||||
"electrondev": "concurrently -k \"yarn startforelectron\" \"electron .\"",
|
||||
"distlinux": "yarn buildforelectron && electron-builder --linux --x64",
|
||||
"distwin": "yarn buildforelectron && electron-builder --win --x64",
|
||||
"distmac": "yarn buildforelectron && electron-builder --mac --x64",
|
||||
"release": "build"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^4.4.6",
|
||||
"@angular/cdk": "^2.0.0-beta.12",
|
||||
"@angular/common": "^4.0.0",
|
||||
"@angular/compiler": "^4.0.0",
|
||||
"@angular/core": "^4.0.0",
|
||||
"@angular/forms": "^4.0.0",
|
||||
"@angular/http": "^4.0.0",
|
||||
"@angular/material": "^2.0.0-beta.12",
|
||||
"@angular/platform-browser": "^4.0.0",
|
||||
"@angular/platform-browser-dynamic": "^4.0.0",
|
||||
"@angular/router": "^4.0.0",
|
||||
"@angular/animations": "^5.1.2",
|
||||
"@angular/cdk": "^5.0.3",
|
||||
"@angular/common": "^5.1.2",
|
||||
"@angular/compiler": "^5.1.2",
|
||||
"@angular/core": "^5.1.2",
|
||||
"@angular/forms": "^5.1.2",
|
||||
"@angular/http": "^5.1.2",
|
||||
"@angular/material": "^5.0.3",
|
||||
"@angular/platform-browser": "^5.1.2",
|
||||
"@angular/platform-browser-dynamic": "^5.1.2",
|
||||
"@angular/router": "^5.1.2",
|
||||
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.4",
|
||||
"angular2-indexeddb": "^1.0.11",
|
||||
"bootstrap": "^4.0.0-beta",
|
||||
"angular2-indexeddb": "^1.2.2",
|
||||
"bootstrap": "4.0.0-beta.2",
|
||||
"core-js": "^2.4.1",
|
||||
"d3-ng2-service": "^1.16.0",
|
||||
"ng2-toasty": "^4.0.3",
|
||||
@ -34,25 +46,29 @@
|
||||
"zone.js": "^0.8.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/cli": "^1.4.7",
|
||||
"@angular/compiler-cli": "^4.0.0",
|
||||
"@angular/language-service": "^4.0.0",
|
||||
"@types/jasmine": "~2.6.0",
|
||||
"@angular/cli": "^1.6.3",
|
||||
"@angular/compiler-cli": "^5.1.2",
|
||||
"@angular/language-service": "^5.1.2",
|
||||
"@types/jasmine": "~2.8.3",
|
||||
"@types/jasminewd2": "~2.0.2",
|
||||
"@types/node": "~8.0.44",
|
||||
"codelyzer": "~3.2.1",
|
||||
"@types/node": "~8.5.2",
|
||||
"codelyzer": "~4.0.2",
|
||||
"electron": "1.7.10",
|
||||
"electron-builder": "^19.52.1",
|
||||
"jasmine-core": "~2.8.0",
|
||||
"jasmine-spec-reporter": "~4.2.1",
|
||||
"karma": "~1.7.0",
|
||||
"jquery": "1.9.1 - 3",
|
||||
"karma": "~2.0.0",
|
||||
"karma-chrome-launcher": "~2.2.0",
|
||||
"karma-cli": "~1.0.1",
|
||||
"karma-coverage-istanbul-reporter": "^1.2.1",
|
||||
"karma-jasmine": "~1.1.0",
|
||||
"karma-jasmine-html-reporter": "^0.2.2",
|
||||
"node-sass": "^4.5.3",
|
||||
"popper.js": "^1.12.3",
|
||||
"protractor": "~5.2.0",
|
||||
"ts-node": "~3.3.0",
|
||||
"tslint": "~5.7.0",
|
||||
"typescript": "^2.3.4"
|
||||
"ts-node": "~4.1.0",
|
||||
"tslint": "~5.8.0",
|
||||
"typescript": ">=2.4.0 <2.6.0"
|
||||
}
|
||||
}
|
||||
|
3
renderer.js
Normal file
@ -0,0 +1,3 @@
|
||||
// This file is required by the index.html file and will
|
||||
// be executed in the renderer process for that window.
|
||||
// All of the Node.js APIs are available in this process.
|
257
scripts/build.py
Normal file
@ -0,0 +1,257 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2018 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import re
|
||||
import pip
|
||||
import sys
|
||||
import shutil
|
||||
import psutil
|
||||
import zipfile
|
||||
import requests
|
||||
import platform
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
from multiprocessing import Process, Queue
|
||||
from multiprocessing.queues import Empty
|
||||
|
||||
from cx_Freeze import setup, Executable
|
||||
|
||||
|
||||
FILE_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
WORKING_DIR = os.path.join(FILE_DIR, 'tmp')
|
||||
|
||||
SOURCE_ZIP = os.path.join(WORKING_DIR, 'gns3-server.source.zip')
|
||||
SOURCE_DESTINATION = os.path.join(WORKING_DIR, 'source')
|
||||
BINARIES_EXTENSION = platform.system() == "Windows" and ".exe" or ""
|
||||
|
||||
|
||||
def download(url, output):
|
||||
print("Downloading {} to {}".format(url, output))
|
||||
|
||||
if os.path.exists(output):
|
||||
print("{} already exist skip downloading".format(output))
|
||||
return
|
||||
r = requests.get(url, stream=True)
|
||||
if r.status_code == 200:
|
||||
with open(output, 'wb') as f:
|
||||
for chunk in r.iter_content():
|
||||
f.write(chunk)
|
||||
else:
|
||||
print("Download error for {} status {}".format(url, r.status_code))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def unzip(filename, directory):
|
||||
zip = zipfile.ZipFile(filename, 'r')
|
||||
zip.extractall(directory)
|
||||
zip.close()
|
||||
return zip.filelist
|
||||
|
||||
|
||||
def getversion(version):
|
||||
match = re.search("^(\d+\.\d+(.\d+)?).*$", version)
|
||||
assert match
|
||||
return match.group(1)
|
||||
|
||||
|
||||
def getsource_directory():
|
||||
files = os.listdir(SOURCE_DESTINATION)
|
||||
if len(files) > 0:
|
||||
return os.path.join(SOURCE_DESTINATION, files[0])
|
||||
raise Exception("Cannot find sources for gns3server")
|
||||
|
||||
|
||||
def prepare():
|
||||
os.makedirs(WORKING_DIR, exist_ok=True)
|
||||
|
||||
|
||||
def download_command(arguments):
|
||||
shutil.rmtree(SOURCE_DESTINATION, ignore_errors=True)
|
||||
os.makedirs(SOURCE_DESTINATION)
|
||||
|
||||
download("https://github.com/GNS3/gns3-server/archive/2.1.zip", SOURCE_ZIP)
|
||||
|
||||
files = unzip(SOURCE_ZIP, SOURCE_DESTINATION)
|
||||
source_directory = os.path.join(SOURCE_DESTINATION, files[0].filename)
|
||||
|
||||
if platform.system() == "Windows":
|
||||
requirements = 'win-requirements.txt'
|
||||
else:
|
||||
requirements = 'requirements.txt'
|
||||
|
||||
pip.main(['install', '-r', os.path.join(source_directory, requirements)])
|
||||
|
||||
|
||||
def build_command(arguments):
|
||||
source_directory = getsource_directory()
|
||||
|
||||
sys.path.append(source_directory)
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
# this fixes cx_freeze bug for OSX and python 3.6, see:
|
||||
# https://bitbucket.org/ronaldoussoren/pyobjc/issues/185/python-36-modulenotfounderror-no-module
|
||||
with open(os.path.join(source_directory, 'gns3server', 'main.py')) as f:
|
||||
main_content = f.read()
|
||||
|
||||
if 'cx_freeze_and_python_3_6_missing_library' not in main_content:
|
||||
main_content += "\ndef cx_freeze_and_python_3_6_missing_library():\n import _sysconfigdata_m_darwin_darwin\n\n"
|
||||
|
||||
with open(os.path.join(source_directory, 'gns3server', 'main.py'), 'w') as f:
|
||||
f.write(main_content)
|
||||
|
||||
from gns3server.version import __version__
|
||||
|
||||
# cx_Freeze on Windows requires version to be in format a.b.c.d
|
||||
server_version = getversion(__version__)
|
||||
|
||||
executables = [
|
||||
Executable(
|
||||
os.path.join(source_directory, "gns3server/main.py"),
|
||||
targetName="gns3server{}".format(BINARIES_EXTENSION)
|
||||
),
|
||||
Executable(
|
||||
os.path.join(source_directory, "gns3server/utils/vmnet.py"),
|
||||
targetName="gns3vmnet{}".format(BINARIES_EXTENSION)
|
||||
)
|
||||
]
|
||||
|
||||
excludes = [
|
||||
"raven.deprecation", # reported problem in raven package
|
||||
"distutils", # issue on macOS
|
||||
"tkinter", # issue on Windows
|
||||
]
|
||||
|
||||
packages = [
|
||||
"raven",
|
||||
"psutil",
|
||||
"asyncio",
|
||||
"packaging", # needed for linux
|
||||
"appdirs"
|
||||
]
|
||||
|
||||
include_files = [
|
||||
("gns3server/configs", "configs"),
|
||||
("gns3server/appliances", "appliances"),
|
||||
("gns3server/templates", "templates"),
|
||||
("gns3server/symbols", "symbols"),
|
||||
]
|
||||
|
||||
include_files = [(os.path.join(source_directory, x), y) for x, y in include_files]
|
||||
|
||||
setup(
|
||||
name="GNS3",
|
||||
version=server_version,
|
||||
description="GNS3 Network simulator",
|
||||
executables=executables,
|
||||
options={
|
||||
"build_exe": {
|
||||
"includes": [],
|
||||
"excludes": excludes,
|
||||
"packages": packages,
|
||||
"include_files": include_files
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def execute(exe, queue, pid_q):
|
||||
binary_process = subprocess.Popen(
|
||||
[exe],
|
||||
bufsize=1, shell=False,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||
)
|
||||
|
||||
pid_q.put(binary_process.pid)
|
||||
|
||||
while True:
|
||||
out = binary_process.stdout.read(1)
|
||||
if out == b'' and binary_process.poll() is not None:
|
||||
break
|
||||
queue.put(out)
|
||||
|
||||
|
||||
def validate_command(arguments):
|
||||
output_directory = os.path.join(os.getcwd(), arguments.b)
|
||||
files = os.listdir(output_directory)
|
||||
matching = [f for f in files if f.startswith('exe.')]
|
||||
if len(matching) == 0:
|
||||
raise Exception("Cannot find binaries of gns3server")
|
||||
binary = os.path.join(output_directory, matching[0], 'gns3server{}'.format(BINARIES_EXTENSION))
|
||||
|
||||
print("Validating: {}".format(binary))
|
||||
|
||||
pid_queue = Queue()
|
||||
output_queue = Queue()
|
||||
|
||||
process = Process(target=execute, args=(binary, output_queue, pid_queue))
|
||||
process.start()
|
||||
|
||||
pid = pid_queue.get()
|
||||
|
||||
print("Process is running on pid: " + str(pid))
|
||||
|
||||
output = ""
|
||||
while True:
|
||||
try:
|
||||
char = output_queue.get(timeout=3)
|
||||
output += char.decode()
|
||||
except Empty:
|
||||
break
|
||||
|
||||
process.terminate()
|
||||
|
||||
print("Output of process:")
|
||||
print(output)
|
||||
|
||||
parent = psutil.Process(pid)
|
||||
parent.kill()
|
||||
|
||||
result = "GNS3 Technologies Inc" not in output and 1 or 0
|
||||
sys.exit(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Building gns3server for distribution')
|
||||
subparsers = parser.add_subparsers(
|
||||
dest='command',
|
||||
help="Command which needs to be executed")
|
||||
|
||||
download_parser = subparsers.add_parser(
|
||||
'download', help="Downloads source code of gns3server")
|
||||
|
||||
build_parser = subparsers.add_parser(
|
||||
'build', help="Build gns3server")
|
||||
build_parser.add_argument('-b', default=None, help="Output directory")
|
||||
|
||||
validate_parser = subparsers.add_parser(
|
||||
'validate', help="Validate build")
|
||||
validate_parser.add_argument('-b', default=None, help="Output directory")
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.command == 'build':
|
||||
prepare()
|
||||
build_command(args)
|
||||
elif args.command == 'download':
|
||||
prepare()
|
||||
download_command(args)
|
||||
elif args.command == 'validate':
|
||||
prepare()
|
||||
validate_command(args)
|
||||
|
6
scripts/requirements.txt
Normal file
@ -0,0 +1,6 @@
|
||||
setuptools==38.4
|
||||
cx_Freeze==5.1.1
|
||||
requests==2.18.4
|
||||
packaging==16.8
|
||||
appdirs==1.4.3
|
||||
psutil==5.4.0
|
@ -1,3 +1,5 @@
|
||||
import { environment } from "../environments/environment";
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
@ -6,6 +8,7 @@ import { ServersComponent } from "./servers/servers.component";
|
||||
import { ProjectsComponent } from "./projects/projects.component";
|
||||
import { DefaultLayoutComponent } from "./default-layout/default-layout.component";
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: DefaultLayoutComponent,
|
||||
children: [
|
||||
@ -17,8 +20,17 @@ const routes: Routes = [
|
||||
{ path: 'server/:server_id/project/:project_id', component: ProjectMapComponent },
|
||||
];
|
||||
|
||||
let routerModule;
|
||||
if (environment.electron) {
|
||||
// angular in electron has problem with base-href and links separated by slashes, because of that
|
||||
// we use simply hashes
|
||||
routerModule = RouterModule.forRoot(routes, {useHash: true});
|
||||
} else {
|
||||
routerModule = RouterModule.forRoot(routes);
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [ RouterModule.forRoot(routes) ],
|
||||
imports: [ routerModule ],
|
||||
exports: [ RouterModule ]
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
|
@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from "@angular/cdk/table";
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import {
|
||||
@ -41,7 +42,7 @@ import { ProjectsComponent } from './projects/projects.component';
|
||||
import { DefaultLayoutComponent } from './default-layout/default-layout.component';
|
||||
import { ProgressDialogComponent } from './shared/progress-dialog/progress-dialog.component';
|
||||
import { AppComponent } from './app.component';
|
||||
import { MapComponent } from './cartography/map/map.component';
|
||||
//import { MapComponent } from './cartography/map/map.component';
|
||||
import { CreateSnapshotDialogComponent, ProjectMapComponent } from './project-map/project-map.component';
|
||||
import { ServersComponent, AddServerDialogComponent } from './servers/servers.component';
|
||||
import { NodeContextMenuComponent } from './shared/node-context-menu/node-context-menu.component';
|
||||
@ -50,13 +51,12 @@ import { StopNodeActionComponent } from './shared/node-context-menu/actions/stop
|
||||
import { ApplianceComponent } from './appliance/appliance.component';
|
||||
import { ApplianceListDialogComponent } from './appliance/appliance-list-dialog/appliance-list-dialog.component';
|
||||
import { NodeSelectInterfaceComponent } from './shared/node-select-interface/node-select-interface.component';
|
||||
|
||||
import { CartographyModule } from './cartography/cartography.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
MapComponent,
|
||||
ProjectMapComponent,
|
||||
ServersComponent,
|
||||
AddServerDialogComponent,
|
||||
@ -76,6 +76,7 @@ import { NodeSelectInterfaceComponent } from './shared/node-select-interface/nod
|
||||
ToastyModule.forRoot(),
|
||||
BrowserModule,
|
||||
HttpModule,
|
||||
HttpClientModule,
|
||||
AppRoutingModule,
|
||||
FormsModule,
|
||||
BrowserAnimationsModule,
|
||||
@ -90,7 +91,8 @@ import { NodeSelectInterfaceComponent } from './shared/node-select-interface/nod
|
||||
MatDialogModule,
|
||||
MatProgressBarModule,
|
||||
MatProgressSpinnerModule,
|
||||
CdkTableModule
|
||||
CdkTableModule,
|
||||
CartographyModule
|
||||
],
|
||||
providers: [
|
||||
D3Service,
|
||||
|
@ -6,6 +6,7 @@ import { MapComponent } from './map/map.component';
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: [MapComponent]
|
||||
declarations: [MapComponent],
|
||||
exports: [MapComponent]
|
||||
})
|
||||
export class CartographyModule { }
|
||||
|
@ -120,7 +120,7 @@ export class LinksWidget implements Widget {
|
||||
.attr('map-source', (l: Link) => l.source.node_id)
|
||||
.attr('map-target', (l: Link) => l.target.node_id)
|
||||
|
||||
this.revise(link.merge(link_enter));
|
||||
//this.revise(link.merge(link_enter));
|
||||
|
||||
link
|
||||
.exit()
|
||||
|
@ -39,9 +39,9 @@ export class NodesWidget implements Widget {
|
||||
}
|
||||
|
||||
private executeOnNodeDraggingCallback(n: Node) {
|
||||
this.onNodeDraggingCallbacks.forEach((callback: (n: Node) => void) => {
|
||||
callback(n);
|
||||
});
|
||||
// this.onNodeDraggingCallbacks.forEach((callback: (n: Node) => void) => {
|
||||
// callback(n);
|
||||
// });
|
||||
}
|
||||
|
||||
public revise(selection: SVGSelection) {
|
||||
|
@ -17,7 +17,7 @@ export class NodeContextMenuComponent implements OnInit {
|
||||
|
||||
private topPosition;
|
||||
private leftPosition;
|
||||
private node: Node;
|
||||
public node: Node;
|
||||
|
||||
constructor(
|
||||
private sanitizer: DomSanitizer,
|
||||
|
@ -17,7 +17,7 @@ export class NodeSelectInterfaceComponent implements OnInit {
|
||||
|
||||
private topPosition;
|
||||
private leftPosition;
|
||||
private node: Node;
|
||||
public node: Node;
|
||||
|
||||
constructor(
|
||||
private sanitizer: DomSanitizer,
|
||||
|
@ -10,7 +10,7 @@ export class ServerService {
|
||||
private ready: Promise<any>;
|
||||
|
||||
constructor(private indexedDbService: IndexedDbService) {
|
||||
this.ready = indexedDbService.get().createStore(1, (evt) => {
|
||||
this.ready = indexedDbService.get().openDatabase(1, (evt) => {
|
||||
const store = evt.currentTarget.result.createObjectStore(
|
||||
this.tablename, { keyPath: "id", autoIncrement: true });
|
||||
});
|
||||
|
BIN
src/assets/icons/mac/icon.icns
Normal file
BIN
src/assets/icons/png/1024x1024.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
src/assets/icons/png/128x128.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/assets/icons/png/16x16.png
Normal file
After Width: | Height: | Size: 734 B |
BIN
src/assets/icons/png/24x24.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/assets/icons/png/256x256.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/assets/icons/png/32x32.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/assets/icons/png/48x48.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
src/assets/icons/png/512x512.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
src/assets/icons/png/64x64.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
src/assets/icons/win/icon.ico
Normal file
After Width: | Height: | Size: 353 KiB |
4
src/environments/environment.electron.prod.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
electron: true
|
||||
};
|
4
src/environments/environment.electron.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
electron: true
|
||||
};
|
@ -4,5 +4,6 @@
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false
|
||||
production: false,
|
||||
electron: false
|
||||
};
|
||||
|
@ -3,11 +3,22 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>GNS3 Web UI Demo</title>
|
||||
<base href="/">
|
||||
<script>
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
// in case we're running in electron because we need it for resources
|
||||
if (userAgent.indexOf(' electron/') > -1) {
|
||||
document.write('<base href="' + document.location + '" />');
|
||||
}
|
||||
// in case base href is not set, when not defined during the build time (for instance github.io pages)
|
||||
else if (document.getElementsByTagName('base').length == 0) {
|
||||
document.write('<base href="/" />');
|
||||
}
|
||||
</script>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="assets/favicon.ico">
|
||||
|
||||
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css">
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto+Slab:400,700" type="text/css">
|
||||
|
||||
|
@ -9,5 +9,9 @@
|
||||
"exclude": [
|
||||
"test.ts",
|
||||
"**/*.spec.ts"
|
||||
],
|
||||
"include": [
|
||||
"../src/**/*",
|
||||
"../node_modules/angular2-indexeddb/index.ts"
|
||||
]
|
||||
}
|
||||
|
@ -14,6 +14,9 @@
|
||||
"lib": [
|
||||
"es2016",
|
||||
"dom"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
"include": [
|
||||
"./node_modules/angular2-indexeddb/index.ts"
|
||||
]
|
||||
}
|
||||
|