From 5dd723a864435e8a5480ef32990d37805ef44d08 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Mon, 3 Sep 2018 09:13:17 +1000 Subject: [PATCH] Removed v1 cruft --- manager/.babelrc | 12 -- manager/gulpfile.js | 172 ------------------ manager/package.json | 60 ------ manager/src/frontend/js/app/access/empty.js | 22 --- manager/src/frontend/js/app/access/main.js | 61 ------- manager/src/frontend/js/app/access/row.js | 31 ---- .../src/frontend/js/app/access_list/delete.js | 34 ---- .../src/frontend/js/app/access_list/item.js | 8 - manager/src/frontend/js/app/api.js | 160 ---------------- manager/src/frontend/js/app/controller.js | 171 ----------------- .../src/frontend/js/app/dashboard/empty.js | 34 ---- manager/src/frontend/js/app/dashboard/main.js | 80 -------- manager/src/frontend/js/app/dashboard/row.js | 63 ------- manager/src/frontend/js/app/error/main.js | 32 ---- manager/src/frontend/js/app/host/404_form.js | 77 -------- manager/src/frontend/js/app/host/advanced.js | 38 ---- manager/src/frontend/js/app/host/delete.js | 34 ---- .../src/frontend/js/app/host/proxy_form.js | 107 ----------- .../src/frontend/js/app/host/reconfigure.js | 32 ---- .../frontend/js/app/host/redirection_form.js | 77 -------- .../src/frontend/js/app/host/stream_form.js | 62 ------- manager/src/frontend/js/app/main.js | 119 ------------ manager/src/frontend/js/app/ui/header/main.js | 36 ---- manager/src/frontend/js/app/ui/main.js | 100 ---------- manager/src/frontend/js/lib/helpers.js | 32 ---- manager/src/frontend/js/lib/marionette.js | 46 ----- manager/src/frontend/js/main.js | 22 --- manager/src/frontend/js/models/access_item.js | 22 --- manager/src/frontend/js/models/host.js | 35 ---- manager/webpack.config.js | 95 ---------- 30 files changed, 1874 deletions(-) delete mode 100644 manager/.babelrc delete mode 100644 manager/gulpfile.js delete mode 100644 manager/package.json delete mode 100644 manager/src/frontend/js/app/access/empty.js delete mode 100644 manager/src/frontend/js/app/access/main.js delete mode 100644 manager/src/frontend/js/app/access/row.js delete mode 100644 manager/src/frontend/js/app/access_list/delete.js delete mode 100644 manager/src/frontend/js/app/access_list/item.js delete mode 100644 manager/src/frontend/js/app/api.js delete mode 100644 manager/src/frontend/js/app/controller.js delete mode 100644 manager/src/frontend/js/app/dashboard/empty.js delete mode 100644 manager/src/frontend/js/app/dashboard/main.js delete mode 100644 manager/src/frontend/js/app/dashboard/row.js delete mode 100644 manager/src/frontend/js/app/error/main.js delete mode 100644 manager/src/frontend/js/app/host/404_form.js delete mode 100644 manager/src/frontend/js/app/host/advanced.js delete mode 100644 manager/src/frontend/js/app/host/delete.js delete mode 100644 manager/src/frontend/js/app/host/proxy_form.js delete mode 100644 manager/src/frontend/js/app/host/reconfigure.js delete mode 100644 manager/src/frontend/js/app/host/redirection_form.js delete mode 100644 manager/src/frontend/js/app/host/stream_form.js delete mode 100644 manager/src/frontend/js/app/main.js delete mode 100644 manager/src/frontend/js/app/ui/header/main.js delete mode 100644 manager/src/frontend/js/app/ui/main.js delete mode 100644 manager/src/frontend/js/lib/helpers.js delete mode 100644 manager/src/frontend/js/lib/marionette.js delete mode 100644 manager/src/frontend/js/main.js delete mode 100644 manager/src/frontend/js/models/access_item.js delete mode 100644 manager/src/frontend/js/models/host.js delete mode 100644 manager/webpack.config.js diff --git a/manager/.babelrc b/manager/.babelrc deleted file mode 100644 index 313497cf..00000000 --- a/manager/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - ["env", { - "targets": { - "browsers": ["Chrome >= 65"] - }, - "debug": false, - "modules": false, - "useBuiltIns": "usage" - }] - ] -} diff --git a/manager/gulpfile.js b/manager/gulpfile.js deleted file mode 100644 index 7a6694d8..00000000 --- a/manager/gulpfile.js +++ /dev/null @@ -1,172 +0,0 @@ -/*jshint node:true */ - -'use strict'; - -const path = require('path'); -const gulp = require('gulp'); -const gutil = require('gulp-util'); -const concat = require('gulp-concat-util'); -const runSequence = require('run-sequence'); -const webpack = require('webpack'); -const webpackStream = require('webpack-stream'); -const imagemin = require('gulp-imagemin'); -const del = require('del'); -const bump = require('gulp-bump'); -const sass = require('gulp-sass'); -const ejs = require('gulp-ejs'); -const PACKAGE = require('./package.json'); - -const assets = { - views: { - watch: 'src/frontend/views/**/*.ejs', - src: 'src/frontend/views/*.ejs', - dest: 'dist/' - }, - fonts: { - watch: 'src/frontend/fonts/**/*.{ttf,woff,woff2,eof,eot,svg,otf}', - dest: 'dist/fonts' - }, - images: { - watch: 'src/frontend/images/**/*.{png,jpg,gif}', - dest: 'dist/images' - }, - scss: { - watch: 'src/frontend/scss/**/*.scss', - loadPath: 'src/frontend/scss', - src: 'src/frontend/scss/styles.scss', - dest: 'dist/css' - }, - js: { - watch: 'src/frontend/js/**/*', - src: 'src/frontend/js/main.js', - dest: 'dist/js/' - } -}; - -/** - * @param color - * @param label - * @returns {Function} - */ -function logger (color, label) { - return function () { - let args = Array.prototype.slice.call(arguments); - args.unshift(gutil.colors[color].bold(label.toUpperCase() + ':')); - gutil.log.apply(null, args); - }; -} - -gutil.error = logger('red', 'error'); -gutil.warn = logger('yellow', 'warn'); -gutil.notice = logger('white', 'notice'); - -/** - * @param err - */ -function handleError (err) { - gutil.error(err.stack); -} - -/***************************** - TASKS - ******************************/ - -/** - * clean - */ -gulp.task('clean', function (cb) { - del(['./dist/*']) - .then(function () { - cb(); - }) - .catch(handleError); -}); - -/** - * images - */ -gulp.task('images', function () { - if (process.arch !== 'arm') { - return gulp.src(assets.images.watch) - .pipe(imagemin({ - optimizationLevel: 7 - })) - .pipe(gulp.dest(assets.images.dest)) - .on('error', handleError); - } else { - return gulp.src(assets.images.watch) - .pipe(gulp.dest(assets.images.dest)) - .on('error', handleError); - } -}); - -/** - * fonts - */ -gulp.task('fonts', function () { - return gulp.src(assets.fonts.watch) - .pipe(gulp.dest(assets.fonts.dest)) - .on('error', handleError); -}); - -/** - * scss - */ -gulp.task('scss', function () { - return gulp.src(assets.scss.src) - .pipe(sass().on('error', sass.logError)) - .pipe(concat.header('@import url(\'https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700\');@import url(\'https://fonts.googleapis.com/css?family=Roboto:100,200,300,400,500,600,700|Roboto+Condensed:300,400,700\');')) - .pipe(gulp.dest(path.resolve(assets.scss.dest))); -}); - -/** - * js - */ -gulp.task('js', function () { - return gulp.src(assets.js.src) - .pipe(webpackStream(require('./webpack.config.js'), webpack)) - .pipe(gulp.dest(assets.js.dest)) - .on('error', handleError); -}); - -/** - * views - */ -gulp.task('views', function () { - return gulp.src(assets.views.src) - .pipe(ejs({ - version: PACKAGE.version - }, {}, { - ext: '.html' - })) - .on('error', handleError) - .pipe(gulp.dest(assets.views.dest)); -}); - -/** - * bump - */ -gulp.task('bump', function () { - gulp.src('./package.json') - .pipe(bump({type: 'version'})) - .pipe(gulp.dest('./')); -}); - -/** - * build - */ -gulp.task('build', function (cb) { - runSequence('clean', ['images', 'fonts', 'scss', 'js', 'views'], cb); -}); - -/** - * default - */ -gulp.task('default', ['build'], function () { - gulp.watch(assets.scss.watch, ['scss']); - gulp.watch(assets.images.watch, ['images']); - gulp.watch(assets.fonts.watch, ['fonts']); - gulp.watch(assets.js.watch, ['js']); - gulp.watch(assets.views.watch, ['views']); - gulp.watch('./webpack.config.js', ['js']); -}); diff --git a/manager/package.json b/manager/package.json deleted file mode 100644 index 0f2df432..00000000 --- a/manager/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "nginx-proxy-manager", - "version": "1.1.2", - "description": "Nginx proxt with built in Web based management", - "main": "src/backend/index.js", - "dependencies": { - "ajv": "^5.5.1", - "batchflow": "^0.4.0", - "body-parser": "^1.18.2", - "compression": "^1.7.1", - "diskdb": "^0.1.17", - "ejs": "^2.5.7", - "express": "^4.16.2", - "express-winston": "^2.4.0", - "json-schema-ref-parser": "^4.0.4", - "lodash": "^4.17.4", - "path": "^0.12.7", - "unix-timestamp": "^0.2.0", - "winston": "^2.4.0" - }, - "devDependencies": { - "babel-core": "^6.26.3", - "babel-loader": "^7.1.4", - "babel-minify-webpack-plugin": "^0.3.1", - "babel-preset-env": "^1.7.0", - "backbone": "1.3.3", - "backbone-virtual-collection": "^0.6.15", - "backbone.marionette": "3.4.1", - "backbone.radio": "2.0.0", - "bootstrap": "^3.3.7", - "del": "^3.0.0", - "ejs-loader": "^0.3.0", - "es6-promise": "^4.1.1", - "font-awesome": "^4.7.0", - "form-serializer": "^2.5.0", - "gulp": "^3.9.1", - "gulp-bump": "^2.7.0", - "gulp-concat-util": "^0.5.5", - "gulp-ejs": "^3.0.1", - "gulp-imagemin": "^3.3.0", - "gulp-sass": "^4.0.1", - "gulp-util": "^3.0.8", - "image-size": "^0.6.1", - "jquery": "^3.2.1", - "jquery-serializejson": "^2.8.1", - "normalize-css": "^2.3.1", - "prepack-webpack-plugin": "^1.1.0", - "run-sequence": "^2.2.0", - "underscore": "^1.8.3", - "webpack": "^4.12.0", - "webpack-cli": "^3.0.8", - "webpack-stream": "^4.0.0", - "webpack-visualizer-plugin": "^0.1.11" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Jamie Curnow ", - "license": "MIT" -} diff --git a/manager/src/frontend/js/app/access/empty.js b/manager/src/frontend/js/app/access/empty.js deleted file mode 100644 index 6cc2631c..00000000 --- a/manager/src/frontend/js/app/access/empty.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./empty.ejs'); -const AccessModel = require('../../models/access'); -const Controller = require('../controller'); - -module.exports = Mn.View.extend({ - template: template, - tagName: 'tr', - - ui: { - create: 'button' - }, - - events: { - 'click @ui.create': function (e) { - e.preventDefault(); - Controller.showAccessListForm(new AccessModel.Model); - } - } -}); diff --git a/manager/src/frontend/js/app/access/main.js b/manager/src/frontend/js/app/access/main.js deleted file mode 100644 index 89358fe7..00000000 --- a/manager/src/frontend/js/app/access/main.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const Api = require('../api'); -const template = require('./main.ejs'); -const Controller = require('../controller'); -const RowView = require('./row'); -const AccessListModel = require('../../models/access'); -const EmptyView = require('./empty'); - -const TableBody = Mn.CollectionView.extend({ - tagName: 'tbody', - childView: RowView -}); - -module.exports = Mn.View.extend({ - template: template, - id: 'access', - - regions: { - list_region: { - el: 'tbody', - replaceElement: true - } - }, - - ui: { - 'create': 'th button' - }, - - events: { - 'click @ui.create': function (e) { - e.preventDefault(); - Controller.showAccessListForm(new AccessListModel.Model); - } - }, - - onRender: function () { - let view = this; - - Api.Access.getAll() - .then(response => { - if (!view.isDestroyed()) { - if (response && response.length) { - view.showChildView('list_region', new TableBody({ - collection: new AccessListModel.Collection(response) - })); - } else { - view.showChildView('list_region', new EmptyView()); - } - - view.trigger('loaded'); - } - }) - .catch(err => { - Controller.showError(err, 'Could not fetch Access Lists'); - view.trigger('loaded'); - }); - } -}); - diff --git a/manager/src/frontend/js/app/access/row.js b/manager/src/frontend/js/app/access/row.js deleted file mode 100644 index e3a739f3..00000000 --- a/manager/src/frontend/js/app/access/row.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./row.ejs'); -const Controller = require('../controller'); - -module.exports = Mn.View.extend({ - template: template, - tagName: 'tr', - - ui: { - edit: 'button.edit', - delete: 'button.delete' - }, - - events: { - 'click @ui.edit': function (e) { - e.preventDefault(); - Controller.showAccessListForm(this.model); - }, - - 'click @ui.delete': function (e) { - e.preventDefault(); - Controller.showDeleteAccessList(this.model); - } - }, - - initialize: function () { - this.listenTo(this.model, 'change', this.render); - } -}); diff --git a/manager/src/frontend/js/app/access_list/delete.js b/manager/src/frontend/js/app/access_list/delete.js deleted file mode 100644 index d6e91b20..00000000 --- a/manager/src/frontend/js/app/access_list/delete.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./delete.ejs'); -const Controller = require('../controller'); -const Api = require('../api'); -const App = require('../main'); - -module.exports = Mn.View.extend({ - template: template, - - ui: { - buttons: 'form button', - delete: 'button.delete' - }, - - events: { - 'click @ui.delete': function (e) { - e.preventDefault(); - - this.ui.buttons.prop('disabled', true).addClass('btn-disabled'); - - Api.Access.delete(this.model.get('_id')) - .then((/*result*/) => { - App.UI.closeModal(); - Controller.showAccess(); - }) - .catch(err => { - alert(err.message); - this.ui.buttons.prop('disabled', false).removeClass('btn-disabled'); - }); - } - } -}); diff --git a/manager/src/frontend/js/app/access_list/item.js b/manager/src/frontend/js/app/access_list/item.js deleted file mode 100644 index bb2ec23e..00000000 --- a/manager/src/frontend/js/app/access_list/item.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./item.ejs'); - -module.exports = Mn.View.extend({ - template: template -}); diff --git a/manager/src/frontend/js/app/api.js b/manager/src/frontend/js/app/api.js deleted file mode 100644 index f9d7a893..00000000 --- a/manager/src/frontend/js/app/api.js +++ /dev/null @@ -1,160 +0,0 @@ -'use strict'; - -const $ = require('jquery'); - -/** - * @param {String} message - * @param {*} debug - * @param {Number} code - * @constructor - */ -const ApiError = function (message, debug, code) { - let temp = Error.call(this, message); - temp.name = this.name = 'ApiError'; - - this.stack = temp.stack; - this.message = temp.message; - this.debug = debug; - this.code = code; -}; - -ApiError.prototype = Object.create(Error.prototype, { - constructor: { - value: ApiError, - writable: true, - configurable: true - } -}); - -/** - * - * @param {String} verb - * @param {String} path - * @param {Object} [data] - * @param {Object} [options] - * @returns {Promise} - */ -function fetch (verb, path, data, options) { - options = options || {}; - - return new Promise(function (resolve, reject) { - let api_url = '/api/'; - let url = api_url + path; - - $.ajax({ - url: url, - data: typeof data === 'object' && data !== null ? JSON.stringify(data) : data, - type: verb, - dataType: 'json', - contentType: 'application/json; charset=UTF-8', - crossDomain: true, - timeout: (options.timeout ? options.timeout : 30000), - xhrFields: { - withCredentials: true - }, - - success: function (data, textStatus, response) { - resolve(response); - }, - - error: function (xhr, status, error_thrown) { - let code = 400; - - if (typeof xhr.responseJSON !== 'undefined' && typeof xhr.responseJSON.error !== 'undefined' && typeof xhr.responseJSON.error.message !== 'undefined') { - error_thrown = xhr.responseJSON.error.message; - code = xhr.responseJSON.error.code || 500; - } - - reject(new ApiError(error_thrown, xhr.responseText, code)); - } - }); - }); -} - -module.exports = { - status: function () { - return fetch('get', ''); - }, - - Hosts: { - - /** - * @returns {Promise} - */ - getAll: function () { - return fetch('get', 'hosts'); - }, - - /** - * @param {Object} data - * @returns {Promise} - */ - create: function (data) { - return fetch('post', 'hosts', data); - }, - - /** - * @param {Object} data - * @param {String} data._id - * @returns {Promise} - */ - update: function (data) { - let _id = data._id; - delete data._id; - return fetch('put', 'hosts/' + _id, data); - }, - - /** - * @param {String} _id - * @returns {Promise} - */ - delete: function (_id) { - return fetch('delete', 'hosts/' + _id); - }, - - /** - * @param {String} _id - * @returns {Promise} - */ - reconfigure: function (_id) { - return fetch('post', 'hosts/' + _id + '/reconfigure'); - } - }, - - Access: { - - /** - * @returns {Promise} - */ - getAll: function () { - return fetch('get', 'access'); - }, - - /** - * @param {Object} data - * @returns {Promise} - */ - create: function (data) { - return fetch('post', 'access', data); - }, - - /** - * @param {Object} data - * @param {String} data._id - * @returns {Promise} - */ - update: function (data) { - let _id = data._id; - delete data._id; - return fetch('put', 'access/' + _id, data); - }, - - /** - * @param {String} _id - * @returns {Promise} - */ - delete: function (_id) { - return fetch('delete', 'access/' + _id); - } - } -}; diff --git a/manager/src/frontend/js/app/controller.js b/manager/src/frontend/js/app/controller.js deleted file mode 100644 index b2792895..00000000 --- a/manager/src/frontend/js/app/controller.js +++ /dev/null @@ -1,171 +0,0 @@ -'use strict'; - -const Backbone = require('backbone'); -const Cache = require('./cache'); - -module.exports = { - - /** - * @param {String} route - * @param {Object} [options] - * @returns {Boolean} - */ - navigate: function (route, options) { - options = options || {}; - Backbone.history.navigate(route.toString(), options); - return true; - }, - - /** - * Dashboard - */ - showDashboard: function () { - let controller = this; - require(['./main', './dashboard/main'], (App, View) => { - controller.navigate('/'); - App.UI.showMainLoading(); - - let view = new View(); - - view.on('loaded', function () { - App.UI.hideMainLoading(); - }); - - App.UI.showChildView('main_region', view); - }); - }, - - /** - * Access - */ - showAccess: function () { - let controller = this; - require(['./main', './access/main'], (App, View) => { - controller.navigate('/access'); - App.UI.showMainLoading(); - - let view = new View(); - - view.on('loaded', function () { - App.UI.hideMainLoading(); - }); - - App.UI.showChildView('main_region', view); - }); - }, - - /** - * Show Proxy Host Form - * - * @param model - */ - showProxyHostForm: function (model) { - require(['./main', './host/proxy_form'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Show Redirection Host Form - * - * @param model - */ - showRedirectionHostForm: function (model) { - require(['./main', './host/redirection_form'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Show 404 Host Form - * - * @param model - */ - show404HostForm: function (model) { - require(['./main', './host/404_form'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Show Stream Host Form - * - * @param model - */ - showStreamHostForm: function (model) { - require(['./main', './host/stream_form'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Show Delete Host Confirmation - * - * @param model - */ - showDeleteHost: function (model) { - require(['./main', './host/delete'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Show Reconfigure Host - * - * @param model - */ - showReconfigureHost: function (model) { - require(['./main', './host/reconfigure'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Show Advanced Host - * - * @param model - */ - showAdvancedHost: function (model) { - require(['./main', './host/advanced'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - - /** - * Show Access List Form - * - * @param model - */ - showAccessListForm: function (model) { - require(['./main', './access_list/form'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Show Delete Access List Confirmation - * - * @param model - */ - showDeleteAccessList: function (model) { - require(['./main', './access_list/delete'], function (App, View) { - App.UI.showModalDialog(new View({model: model})); - }); - }, - - /** - * Error - * - * @param {Error} err - * @param {String} nice_msg - */ - showError: function (err, nice_msg) { - require(['./main', './error/main'], (App, View) => { - App.UI.showChildView('main_region', new View({ - err: err, - nice_msg: nice_msg - })); - }); - } -}; diff --git a/manager/src/frontend/js/app/dashboard/empty.js b/manager/src/frontend/js/app/dashboard/empty.js deleted file mode 100644 index 0c6dc081..00000000 --- a/manager/src/frontend/js/app/dashboard/empty.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./empty.ejs'); -const HostModel = require('../../models/host'); -const Controller = require('../controller'); - -module.exports = Mn.View.extend({ - template: template, - tagName: 'tr', - - ui: { - proxy: 'button.proxy', - redirection: 'button.redirection', - '404': 'button.404' - }, - - events: { - 'click @ui.proxy': function (e) { - e.preventDefault(); - Controller.showProxyHostForm(new HostModel.Model); - }, - - 'click @ui.redirection': function (e) { - e.preventDefault(); - Controller.showRedirectionHostForm(new HostModel.Model); - }, - - 'click @ui.404': function (e) { - e.preventDefault(); - Controller.show404HostForm(new HostModel.Model); - } - } -}); diff --git a/manager/src/frontend/js/app/dashboard/main.js b/manager/src/frontend/js/app/dashboard/main.js deleted file mode 100644 index 9c37c388..00000000 --- a/manager/src/frontend/js/app/dashboard/main.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const Api = require('../api'); -const template = require('./main.ejs'); -const Controller = require('../controller'); -const RowView = require('./row'); -const HostModel = require('../../models/host'); -const EmptyView = require('./empty'); - -const TableBody = Mn.CollectionView.extend({ - tagName: 'tbody', - childView: RowView -}); - -module.exports = Mn.View.extend({ - template: template, - id: 'dashboard', - - regions: { - list_region: { - el: 'tbody', - replaceElement: true - } - }, - - ui: { - new_proxy: 'th .new-proxy', - new_redirection: 'th .new-redirection', - new_404: 'th .new-404', - new_stream: 'th .new-stream' - }, - - events: { - 'click @ui.new_proxy': function (e) { - e.preventDefault(); - Controller.showProxyHostForm(new HostModel.Model); - }, - - 'click @ui.new_redirection': function (e) { - e.preventDefault(); - Controller.showRedirectionHostForm(new HostModel.Model); - }, - - 'click @ui.new_404': function (e) { - e.preventDefault(); - Controller.show404HostForm(new HostModel.Model); - }, - - 'click @ui.new_stream': function (e) { - e.preventDefault(); - Controller.showStreamHostForm(new HostModel.Model); - } - }, - - onRender: function () { - let view = this; - - Api.Hosts.getAll() - .then(response => { - if (!view.isDestroyed()) { - if (response && response.length) { - - view.showChildView('list_region', new TableBody({ - collection: new HostModel.Collection(response) - })); - } else { - view.showChildView('list_region', new EmptyView()); - } - - view.trigger('loaded'); - } - }) - .catch(err => { - Controller.showError(err, 'Could not fetch Hosts'); - view.trigger('loaded'); - }); - } -}); - diff --git a/manager/src/frontend/js/app/dashboard/row.js b/manager/src/frontend/js/app/dashboard/row.js deleted file mode 100644 index 43ff108f..00000000 --- a/manager/src/frontend/js/app/dashboard/row.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./row.ejs'); -const Controller = require('../controller'); -const AccessListModel = require('../../models/access'); - -module.exports = Mn.View.extend({ - template: template, - tagName: 'tr', - - ui: { - edit: 'button.edit', - delete: 'button.delete', - access_list: 'a.access_list', - reconfigure: 'button.reconfigure', - advanced: 'button.advanced' - }, - - events: { - 'click @ui.edit': function (e) { - e.preventDefault(); - switch (this.model.get('type')) { - case 'proxy': - Controller.showProxyHostForm(this.model); - break; - case 'redirection': - Controller.showRedirectionHostForm(this.model); - break; - case '404': - Controller.show404HostForm(this.model); - break; - case 'stream': - Controller.showStreamHostForm(this.model); - break; - } - }, - - 'click @ui.delete': function (e) { - e.preventDefault(); - Controller.showDeleteHost(this.model); - }, - - 'click @ui.access_list': function (e) { - e.preventDefault(); - Controller.showAccessListForm(new AccessListModel.Model(this.model.get('access_list'))); - }, - - 'click @ui.reconfigure': function (e) { - e.preventDefault(); - Controller.showReconfigureHost(this.model); - }, - - 'click @ui.advanced': function (e) { - e.preventDefault(); - Controller.showAdvancedHost(this.model); - } - }, - - initialize: function () { - this.listenTo(this.model, 'change', this.render); - } -}); diff --git a/manager/src/frontend/js/app/error/main.js b/manager/src/frontend/js/app/error/main.js deleted file mode 100644 index 5051ce72..00000000 --- a/manager/src/frontend/js/app/error/main.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./main.ejs'); - -module.exports = Mn.View.extend({ - id: 'error', - template: template, - - options: { - err: null, - nice_msg: 'Unknown error' - }, - - templateContext: function () { - let view = this; - return { - getNiceMessage: function () { - return view.options.nice_msg; - }, - - getErrorMessage: function () { - return view.options.err ? view.options.err.message : ''; - } - }; - }, - - initialize: function () { - console.error(this.options.err); - } -}); - diff --git a/manager/src/frontend/js/app/host/404_form.js b/manager/src/frontend/js/app/host/404_form.js deleted file mode 100644 index f19a146d..00000000 --- a/manager/src/frontend/js/app/host/404_form.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const _ = require('lodash'); -const template = require('./404_form.ejs'); -const Controller = require('../controller'); -const Api = require('../api'); -const App = require('../main'); - -require('jquery-serializejson'); - -module.exports = Mn.View.extend({ - template: template, - - ui: { - form: 'form', - buttons: 'form button', - ssl_options: '.ssl_options', - ssl: 'input[name="ssl"]', - letsencrypt_email: 'input[name="letsencrypt_email"]', - accept_tos: 'input[name="accept_tos"]' - }, - - events: { - 'change @ui.ssl': function (e) { - let inputs = this.ui.letsencrypt_email.add(this.ui.accept_tos); - if (this.ui.ssl.prop('checked')) { - this.ui.ssl_options.show(); - inputs.prop('required', true); - } else { - this.ui.ssl_options.hide(); - inputs.prop('required', false); - } - }, - - 'submit @ui.form': function (e) { - e.preventDefault(); - let data = _.extend({}, this.ui.form.serializeJSON()); - - // Change text true's to bools - _.map(data, function (val, key) { - if (val === 'true') { - data[key] = true; - } - }); - - // This is a 404 host - data.type = '404'; - - // accept_tos is not required for backend - delete data.accept_tos; - - if (!data.ssl) { - delete data.letsencrypt_email; - } - - this.ui.buttons.prop('disabled', true).addClass('btn-disabled'); - let method = Api.Hosts.create; - - if (this.model.get('_id')) { - // edit - method = Api.Hosts.update; - data._id = this.model.get('_id'); - } - - method(data) - .then((/*result*/) => { - App.UI.closeModal(); - Controller.showDashboard(); - }) - .catch(err => { - alert(err.message); - this.ui.buttons.prop('disabled', false).removeClass('btn-disabled'); - }); - } - } -}); diff --git a/manager/src/frontend/js/app/host/advanced.js b/manager/src/frontend/js/app/host/advanced.js deleted file mode 100644 index 378bf431..00000000 --- a/manager/src/frontend/js/app/host/advanced.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./advanced.ejs'); -const Controller = require('../controller'); -const Api = require('../api'); -const App = require('../main'); - -require('jquery-serializejson'); - -module.exports = Mn.View.extend({ - template: template, - - ui: { - form: 'form', - buttons: 'form button' - }, - - events: { - 'submit @ui.form': function (e) { - e.preventDefault(); - let data = this.ui.form.serializeJSON(); - data._id = this.model.get('_id'); - - this.ui.buttons.prop('disabled', true).addClass('btn-disabled'); - - Api.Hosts.update(data) - .then((/*result*/) => { - App.UI.closeModal(); - Controller.showDashboard(); - }) - .catch((err) => { - alert(err.message); - this.ui.buttons.prop('disabled', false).removeClass('btn-disabled'); - }); - } - } -}); diff --git a/manager/src/frontend/js/app/host/delete.js b/manager/src/frontend/js/app/host/delete.js deleted file mode 100644 index 5335d282..00000000 --- a/manager/src/frontend/js/app/host/delete.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const template = require('./delete.ejs'); -const Controller = require('../controller'); -const Api = require('../api'); -const App = require('../main'); - -module.exports = Mn.View.extend({ - template: template, - - ui: { - buttons: 'form button', - delete: 'button.delete' - }, - - events: { - 'click @ui.delete': function (e) { - e.preventDefault(); - - this.ui.buttons.prop('disabled', true).addClass('btn-disabled'); - - Api.Hosts.delete(this.model.get('_id')) - .then((/*result*/) => { - App.UI.closeModal(); - Controller.showDashboard(); - }) - .catch(err => { - alert(err.message); - this.ui.buttons.prop('disabled', false).removeClass('btn-disabled'); - }); - } - } -}); diff --git a/manager/src/frontend/js/app/host/proxy_form.js b/manager/src/frontend/js/app/host/proxy_form.js deleted file mode 100644 index 0544be11..00000000 --- a/manager/src/frontend/js/app/host/proxy_form.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -const Mn = require('backbone.marionette'); -const _ = require('lodash'); -const template = require('./proxy_form.ejs'); -const Controller = require('../controller'); -const Api = require('../api'); -const App = require('../main'); - -require('jquery-serializejson'); - -module.exports = Mn.View.extend({ - template: template, - - ui: { - form: 'form', - buttons: 'form button', - ssl_options: '.ssl_options', - ssl: 'input[name="ssl"]', - letsencrypt_email: 'input[name="letsencrypt_email"]', - accept_tos: 'input[name="accept_tos"]', - access_list_id: 'select[name="access_list_id"]' - }, - - events: { - 'change @ui.ssl': function (e) { - let inputs = this.ui.letsencrypt_email.add(this.ui.accept_tos); - if (this.ui.ssl.prop('checked')) { - this.ui.ssl_options.show(); - inputs.prop('required', true); - } else { - this.ui.ssl_options.hide(); - inputs.prop('required', false); - } - }, - - 'submit @ui.form': function (e) { - e.preventDefault(); - let data = _.extend({}, this.ui.form.serializeJSON()); - - // Change text true's to bools - _.map(data, function (val, key) { - if (val === 'true') { - data[key] = true; - } - }); - - data.type = 'proxy'; - - // Port is integer - data.forward_port = parseInt(data.forward_port, 10); - - // accept_tos is not required for backend - delete data.accept_tos; - delete data.access_list; - - if (!data.ssl) { - delete data.letsencrypt_email; - delete data.force_ssl; - } - - this.ui.buttons.prop('disabled', true).addClass('btn-disabled'); - let method = Api.Hosts.create; - - if (this.model.get('_id')) { - // edit - method = Api.Hosts.update; - data._id = this.model.get('_id'); - } - - method(data) - .then((/*result*/) => { - App.UI.closeModal(); - Controller.showDashboard(); - }) - .catch((err) => { - alert(err.message); - this.ui.buttons.prop('disabled', false).removeClass('btn-disabled'); - }); - } - }, - - onRender: function () { - let view = this; - - Api.Access.getAll() - .then(response => { - if (!view.isDestroyed()) { - view.ui.access_list_id.empty().append($('