From b9a820061de6152a23074b9e38bb48f734f9992f Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 17 May 2017 11:26:05 +0100 Subject: [PATCH 1/9] Move admin part to es6 --- .../js/admin/vue-components/AccountingView.js | 89 +++++++------ .../admin/vue-components/ApplicationsView.js | 83 ++++++------ .../js/admin/vue-components/ContainersView.js | 62 +++++---- .../js/admin/vue-components/MainView.js | 78 ++++++------ .../js/admin/vue-components/UsersView.js | 73 ++++++----- .../accounting/NewAccountingDialog.js | 118 +++++++++--------- .../applications/NewApplicationDialog.js | 50 ++++---- .../vue-components/users/NewUserDialog.js | 44 +++---- 8 files changed, 293 insertions(+), 304 deletions(-) diff --git a/remoteappmanager/static/js/admin/vue-components/AccountingView.js b/remoteappmanager/static/js/admin/vue-components/AccountingView.js index 8dd2fb25a..79b7dc999 100644 --- a/remoteappmanager/static/js/admin/vue-components/AccountingView.js +++ b/remoteappmanager/static/js/admin/vue-components/AccountingView.js @@ -7,39 +7,38 @@ module.exports = { }, template: - '' + - '
Accounting for user {{ $route.params.id }}
' + - '
' + - '
' + - ' Error: {{communicationError}}' + - '
' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - '
Do you want to remove accounting ' + - ' {{ removeAccountingDialog.accountingToRemove }}?' + - '
' + - '
' + - '
' + - '
', + ` +
Accounting for user {{ $route.params.id }}
+
+
+ Error: {{communicationError}} +
+ + + + + +
Do you want to remove accounting + {{ removeAccountingDialog.accountingToRemove }}? +
+
+
+
`, data: function () { - var self = this; return { table: { headers: [ @@ -48,7 +47,7 @@ module.exports = { rows: [], globalActions: [{ label: "Create New Entry", - callback: function() { self.newAccountingDialog.show = true; } + callback: () => { this.newAccountingDialog.show = true; } }], rowActions: [{ label: "Remove", @@ -76,14 +75,13 @@ module.exports = { methods: { updateTable: function() { - var self = this; this.communicationError = null; resources.Accounting.items({filter: JSON.stringify({user_id: this.$route.params.id })}) - .done(function (identifiers, items) { - self.table.rows = []; - identifiers.forEach(function(id) { + .done((identifiers, items) => { + this.table.rows = []; + identifiers.forEach((id) => { var item = items[id]; - self.table.rows.push([ + this.table.rows.push([ id, item.image_name, item.allow_home, @@ -93,8 +91,8 @@ module.exports = { ]); }); }) - .fail(function () { - self.communicationError = "The request could not be executed successfully"; + .fail(() => { + this.communicationError = "The request could not be executed successfully"; }); }, @@ -114,15 +112,14 @@ module.exports = { }, removeAccounting: function () { - var self = this; resources.Accounting.delete(this.removeAccountingDialog.accountingToRemove) - .done(function () { - self.closeRemoveAccountingDialog(); - self.updateTable(); + .done(() => { + this.closeRemoveAccountingDialog(); + this.updateTable(); }) - .fail(function () { - self.closeRemoveAccountingDialog(); - self.communicationError = "The request could not be executed successfully"; + .fail(() => { + this.closeRemoveAccountingDialog(); + this.communicationError = "The request could not be executed successfully"; }); } } diff --git a/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js b/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js index 82b85d25d..929805efc 100644 --- a/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js +++ b/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js @@ -7,44 +7,43 @@ module.exports = { }, template: - '' + - '
' + - '
' + - ' Error: {{communicationError}}' + - '
' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - '
Do you want to remove Application ' + - ' {{removeApplicationDialog.applicationToRemove.name}} ' + - ' ({{removeApplicationDialog.applicationToRemove.id}})
' + - '
' + - '
' + - '
', + ` +
+
+ Error: {{communicationError}} +
+ + + + + +
Do you want to remove Application + {{removeApplicationDialog.applicationToRemove.name}} + ({{removeApplicationDialog.applicationToRemove.id}})
+
+
+
`, data: function () { - var self=this; return { table: { headers: ["ID", "Image"], rows: [], globalActions: [{ label: "Create New Entry", - callback: function() { self.newApplicationDialog.show = true; } + callback: () => { this.newApplicationDialog.show = true; } }], rowActions: [{ label: "Remove", @@ -74,21 +73,20 @@ module.exports = { methods: { updateTable: function() { - var self = this; this.communicationError = null; resources.Application.items() - .done(function (identifiers, items) { - self.table.rows = []; - identifiers.forEach(function(id) { + .done((identifiers, items) => { + this.table.rows = []; + identifiers.forEach((id) => { var item = items[id]; - self.table.rows.push([ + this.table.rows.push([ id, item.image_name ]); }); }) - .fail(function () { - self.communicationError = "The request could not be executed successfully"; + .fail(() => { + this.communicationError = "The request could not be executed successfully"; }); }, @@ -110,14 +108,13 @@ module.exports = { }, removeApplication: function () { - var self = this; resources.Application.delete(this.removeApplicationDialog.applicationToRemove.id) - .done(function () { - self.closeRemoveApplicationDialog(); - self.updateTable(); + .done(() => { + this.closeRemoveApplicationDialog(); + this.updateTable(); }) - .fail(function () { - self.closeRemoveApplicationDialog(); + .fail(() => { + this.closeRemoveApplicationDialog(); this.communicationError = "The request could not be executed successfully"; }); }, diff --git a/remoteappmanager/static/js/admin/vue-components/ContainersView.js b/remoteappmanager/static/js/admin/vue-components/ContainersView.js index 7a2c067ea..71285ef26 100644 --- a/remoteappmanager/static/js/admin/vue-components/ContainersView.js +++ b/remoteappmanager/static/js/admin/vue-components/ContainersView.js @@ -2,24 +2,24 @@ var resources = require("admin-resources"); module.exports = { template: - '' + - '
' + - ' Error: {{communicationError}}' + - '
' + - ' ' + - ' ' + - ' ' + - '
Do you want to stop container {{ stopContainerDialog.containerToStop }}?
' + - '
' + - '
', + ` +
+ Error: {{communicationError}} +
+ + + +
Do you want to stop container {{ stopContainerDialog.containerToStop }}?
+
+
`, data: function () { return { @@ -45,14 +45,13 @@ module.exports = { methods: { updateTable: function() { - var self = this; this.communicationError = null; resources.Container.items() - .done(function (identifiers, items) { - self.table.rows = []; - identifiers.forEach(function(id) { + .done((identifiers, items) => { + this.table.rows = []; + identifiers.forEach((id) => { var item = items[id]; - self.table.rows.push([ + this.table.rows.push([ id, item.user, item.image_name, @@ -61,8 +60,8 @@ module.exports = { ]); }); }) - .fail(function () { - self.communicationError = "The request could not be executed successfully"; + .fail(() => { + this.communicationError = "The request could not be executed successfully"; }); }, @@ -72,15 +71,14 @@ module.exports = { }, stopContainer: function () { - var self = this; resources.Container.delete(this.stopContainerDialog.containerToStop) - .done(function () { - self.updateTable(); - self.closeStopContainerDialog(); + .done(() => { + this.updateTable(); + this.closeStopContainerDialog(); }) - .fail(function () { - self.closeStopContainerDialog(); - self.communicationError = "The request could not be executed successfully"; + .fail(() => { + this.closeStopContainerDialog(); + this.communicationError = "The request could not be executed successfully"; }); }, diff --git a/remoteappmanager/static/js/admin/vue-components/MainView.js b/remoteappmanager/static/js/admin/vue-components/MainView.js index b82cba9e4..ac7c3d051 100644 --- a/remoteappmanager/static/js/admin/vue-components/MainView.js +++ b/remoteappmanager/static/js/admin/vue-components/MainView.js @@ -2,41 +2,41 @@ var resources = require("admin-resources"); module.exports = { template: - '
' + - '
' + - '
' + - '
Statistics
' + - '
' + - '
' + - ' Error: {{communicationError}}' + - '
' + - '
' + - '
' + - '
Realm
' + - '
{{ realm }}
' + - '
' + - '
' + - '
Total users
' + - '
{{ num_total_users }}
' + - '
' + - '
' + - '
Number of applications
' + - '
{{ num_applications }}
' + - '
' + - '
' + - '
' + - '
Active users
' + - '
{{ num_active_users }}
' + - '
' + - '
' + - '
Running containers
' + - '
{{ num_running_containers }}
' + - '
' + - '
' + - '
' + - '
' + - '
' + - '
', + `
+
+
+
Statistics
+
+
+ Error: {{communicationError}} +
+
+
+
Realm
+
{{ realm }}
+
+
+
Total users
+
{{ num_total_users }}
+
+
+
Number of applications
+
{{ num_applications }}
+
+
+
+
Active users
+
{{ num_active_users }}
+
+
+
Running containers
+
{{ num_running_containers }}
+
+
+
+
+
+
`, data: function() { return { @@ -51,15 +51,15 @@ module.exports = { mounted: function() { resources.Stats.retrieve() - .done(function(rep) { + .done((rep) => { this.realm = rep.realm; this.num_total_users = rep.num_total_users; this.num_applications = rep.num_applications; this.num_active_users = rep.num_active_users; this.num_running_containers = rep.num_running_containers; - }.bind(this)) - .fail(function() { + }) + .fail(() => { this.communicationError = "The request could not be executed successfully"; - }.bind(this)); + }); } }; diff --git a/remoteappmanager/static/js/admin/vue-components/UsersView.js b/remoteappmanager/static/js/admin/vue-components/UsersView.js index b915f1d89..9fbc94301 100644 --- a/remoteappmanager/static/js/admin/vue-components/UsersView.js +++ b/remoteappmanager/static/js/admin/vue-components/UsersView.js @@ -7,39 +7,38 @@ module.exports = { }, template: - '' + - '
' + - ' Error: {{communicationError}}' + - '
' + - ' ' + - ' ' + - ' ' + - ' ' + - '
Do you want to remove User {{removeUserDialog.userToRemove.name}} ' + - ' ({{removeUserDialog.userToRemove.id}})
' + - '
' + - '
', + ` +
+ Error: {{communicationError}} +
+ + + + +
Do you want to remove User {{removeUserDialog.userToRemove.name}} + ({{removeUserDialog.userToRemove.id}})
+
+
`, data: function () { - var self = this; return { table: { headers: ["ID", "Username"], rows: [], globalActions: [{ label: "Create New Entry", - callback: function() { self.newUserDialog.show = true; } + callback: () => { this.newUserDialog.show = true; } }], rowActions: [{ label: "Policies", @@ -71,21 +70,20 @@ module.exports = { methods: { updateTable: function() { - var self = this; this.communicationError = null; resources.User.items() - .done(function (identifiers, items){ - self.table.rows = []; - identifiers.forEach(function(id) { + .done((identifiers, items) => { + this.table.rows = []; + identifiers.forEach((id) => { var item = items[id]; - self.table.rows.push([ + this.table.rows.push([ id, item.name ]); }); }) - .fail(function () { - self.communicationError = "The request could not be executed successfully"; + .fail(() => { + this.communicationError = "The request could not be executed successfully"; }); }, @@ -116,14 +114,13 @@ module.exports = { }, removeUser: function () { - var self = this; resources.User.delete(this.removeUserDialog.userToRemove.id) - .done(function() { - self.closeRemoveUserDialog(); - self.updateTable(); + .done(() => { + this.closeRemoveUserDialog(); + this.updateTable(); }) - .fail(function() { - self.closeRemoveUserDialog(); + .fail(() => { + this.closeRemoveUserDialog(); }); } } diff --git a/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js b/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js index 2da67a9df..d5b5d9282 100644 --- a/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js +++ b/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js @@ -2,61 +2,61 @@ var resources = require("admin-resources"); module.exports = { template: - ' ' + - ' ' + - ' ' + - '', + ` + + + `, props: ['show', "userId"], @@ -115,12 +115,12 @@ module.exports = { }; resources.Accounting.create(rep) - .done(function () { + .done(() => { this.$emit('created'); - }.bind(this)) - .fail(function () { + }) + .fail(() => { this.communicationError = "The request could not be executed successfully"; - }.bind(this)); + }); }, reset: function () { diff --git a/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js b/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js index 85f45aa72..2fd9f4145 100644 --- a/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js +++ b/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js @@ -2,27 +2,27 @@ var resources = require("admin-resources"); module.exports = { template: - ' ' + - ' ' + - ' ' + - ' ', + ` + + + `, props: ['show'], @@ -57,12 +57,12 @@ module.exports = { return; } resources.Application.create({image_name: this.model.name}) - .done(function () { + .done(() => { this.$emit('created'); - }.bind(this)) - .fail(function () { + }) + .fail(() => { this.communicationError = "The request could not be executed successfully"; - }.bind(this)); + }); }, reset: function () { diff --git a/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js b/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js index 46d481d36..a136c0f15 100644 --- a/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js +++ b/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js @@ -2,24 +2,24 @@ var resources = require("admin-resources"); module.exports = { template: - '' + - ' ' + - ' ' + - '', + ` + + + `, props: ['show'], @@ -53,12 +53,12 @@ module.exports = { return; } resources.User.create({name: this.model.name}) - .done((function () { + .done(() => { this.$emit('created'); - }).bind(this)) - .fail(function () { + }) + .fail(() => { this.$emit("closed"); - }.bind(this)); + }); }, reset: function () { From dfb05674c246aa7500df658dbeb22a56302ba263 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 17 May 2017 11:56:03 +0100 Subject: [PATCH 2/9] Change use part --- .../static/js/user/configurables.js | 46 +-- remoteappmanager/static/js/user/models.js | 278 +++++++++--------- .../js/user/views/application_list_view.js | 114 +++---- .../static/js/user/views/application_view.js | 167 ++++++----- 4 files changed, 304 insertions(+), 301 deletions(-) diff --git a/remoteappmanager/static/js/user/configurables.js b/remoteappmanager/static/js/user/configurables.js index 1a1f20e83..36514984b 100644 --- a/remoteappmanager/static/js/user/configurables.js +++ b/remoteappmanager/static/js/user/configurables.js @@ -7,14 +7,14 @@ var resolutionComponent = Vue.component(resolutionTag + '-component', { props: ['configDict'], template: - '
' + - ' ' + - ' ' + - '
', + `
+ + +
`, data: function() { return { @@ -30,20 +30,22 @@ var resolutionComponent = Vue.component(resolutionTag + '-component', { }); // Your configurable class must implement a tag and default configDict -var ResolutionModel = function() { - this.tag = resolutionTag; - this.configDict = { resolution: 'Window' }; -}; - -ResolutionModel.prototype.asConfigDict = function() { - var resolution = this.configDict.resolution; - - if (resolution === 'Window') { - var maxSize = utils.maxIframeSize(); - resolution = maxSize[0] + 'x' + maxSize[1]; - } - - return { resolution: resolution }; +class ResolutionModel { + constructor() { + this.tag = resolutionTag; + this.configDict = { resolution: 'Window' }; + }; + + asConfigDict() { + var resolution = this.configDict.resolution; + + if (resolution === 'Window') { + var maxSize = utils.maxIframeSize(); + resolution = maxSize[0] + 'x' + maxSize[1]; + } + + return { resolution: resolution }; + }; }; var outputConfigurables = {}; diff --git a/remoteappmanager/static/js/user/models.js b/remoteappmanager/static/js/user/models.js index 5e8516106..7429c2f1f 100644 --- a/remoteappmanager/static/js/user/models.js +++ b/remoteappmanager/static/js/user/models.js @@ -21,183 +21,185 @@ var availableApplicationsInfo = function () { var promise = $.Deferred(); resources.Application.items() - .done(function (identifiers, items) { + .done((identifiers, items) => { var result = []; - Object.keys(items).forEach(function(key) { + Object.keys(items).forEach((key) => { result.push(items[key]); }); promise.resolve(result); }) - .fail(function() { + .fail(() => { promise.resolve([]); }); return promise; }; -var ApplicationListModel = function() { - // (constructor) Model for the application list. - this.appList = []; - // Selection index for when we click on one entry. - // Should be the index of the selected application, - // or null if no application available (first app is clicked by default). - this.selectedIndex = null; +class ApplicationListModel { + constructor() { + this.appList = []; + + // Selection index for when we click on one entry. + // Should be the index of the selected application, + // or null if no application available (first app is clicked by default). + this.selectedIndex = null; + + this.loading = true; + }; + + update() { + // Requests an update of the object internal data. + // This method returns a jQuery Promise object. + // When resolved, this.data will contain a list of the retrieved + // data. Note that, in error conditions, this routine resolves + // successfully in any case, and the data is set to empty list + return $.when( + availableApplicationsInfo() + ).done((appData) => { + // appData contains the data retrieved from the remote API + + var appList = []; + + // Sort application list by names + appData.sort((app1, app2) => { + var app1Name = app1.image.ui_name? app1.image.ui_name: app1.image.name; + var app2Name = app2.image.ui_name? app2.image.ui_name: app2.image.name; + return app1Name < app2Name? -1: 1; + }); - this.loading = true; -}; + // Add the options for some image types + appData.forEach((applicationData) => { + var app = { + appData: applicationData, + // Default values, will be overwritten + status: Status.STOPPED, + // If true the user will see the loading spinner (when starting the application) + delayed: true, + configurables: [], + isRunning: function() {return this.status === Status.RUNNING;}, + isStopped: function() {return this.status === Status.STOPPED;}, + isStarting: function() {return this.status === Status.STARTING;}, + isStopping: function() {return this.status === Status.STOPPING;} + }; + + this._updateConfigurables(app); + this._updateStatus(app); + + app.delayed = !app.isRunning(); + appList.push(app); + }); -ApplicationListModel.prototype.update = function() { - // Requests an update of the object internal data. - // This method returns a jQuery Promise object. - // When resolved, this.data will contain a list of the retrieved - // data. Note that, in error conditions, this routine resolves - // successfully in any case, and the data is set to empty list - return $.when( - availableApplicationsInfo() - ).done(function (appData) { - // appData contains the data retrieved from the remote API - - var appList = []; - - // Sort application list by names - appData.sort(function(app1, app2) { - var app1Name = app1.image.ui_name? app1.image.ui_name: app1.image.name; - var app2Name = app2.image.ui_name? app2.image.ui_name: app2.image.name; - return app1Name < app2Name? -1: 1; - }); + this.appList = appList; - // Add the options for some image types - appData.forEach(function(applicationData) { - var app = { - appData: applicationData, - // Default values, will be overwritten - status: Status.STOPPED, - // If true the user will see the loading spinner (when starting the application) - delayed: true, - configurables: [], - isRunning: function() {return this.status === Status.RUNNING;}, - isStopped: function() {return this.status === Status.STOPPED;}, - isStarting: function() {return this.status === Status.STARTING;}, - isStopping: function() {return this.status === Status.STOPPING;} - }; - - this._updateConfigurables(app); - this._updateStatus(app); + if(appList.length) {this.selectedIndex = 0;} - app.delayed = !app.isRunning(); - appList.push(app); - }.bind(this)); + this.loading = false; + }); + }; - this.appList = appList; + updateIdx(index) { + // Refetches and updates the entry at the given index. + var app = this.appList[index]; + var mapping_id = app.appData.mapping_id; - if(appList.length) {this.selectedIndex = 0;} + return resources.Application.retrieve(mapping_id) + .done((newData) => { + app.appData = newData; - this.loading = false; - }.bind(this)); -}; + this._updateStatus(app); + }); + }; + + _updateConfigurables(app) { + // Contains the submodels for the configurables. + // It is a dictionary that maps a supported (by the image) configurable tag + // to its client-side model. + app.configurables = []; + + app.appData.image.configurables.forEach(function(tag) { + // If this returns null, the tag has not been recognized + // by the client. skip it and let the server deal with the + // missing data, either by using a default or throwing + // an error. + var ConfigurableCls = configurables[tag].model; + + if (ConfigurableCls !== undefined) { + app.configurables.push(new ConfigurableCls()); + } + }); + }; -ApplicationListModel.prototype.updateIdx = function(index) { - // Refetches and updates the entry at the given index. - var app = this.appList[index]; - var mapping_id = app.appData.mapping_id; + _updateStatus(app) { + if (app.appData.container === undefined) { + app.status = Status.STOPPED; + } else { + app.status = Status.RUNNING; + } + }; - return resources.Application.retrieve(mapping_id) - .done(function(newData) { - app.appData = newData; + startApplication() { + var selectedIndex = this.selectedIndex; + var currentApp = this.appList[selectedIndex]; - this._updateStatus(app); - }.bind(this)); -}; + currentApp.status = Status.STARTING; + currentApp.delayed = true; -ApplicationListModel.prototype._updateConfigurables = function(app) { - // Contains the submodels for the configurables. - // It is a dictionary that maps a supported (by the image) configurable tag - // to its client-side model. - app.configurables = []; - - app.appData.image.configurables.forEach(function(tag) { - // If this returns null, the tag has not been recognized - // by the client. skip it and let the server deal with the - // missing data, either by using a default or throwing - // an error. - var ConfigurableCls = configurables[tag].model; - - if (ConfigurableCls !== undefined) { - app.configurables.push(new ConfigurableCls()); - } - }); -}; + var configurablesData = {}; + currentApp.configurables.forEach(function(configurable) { + var tag = configurable.tag; + configurablesData[tag] = configurable.asConfigDict(); + }); -ApplicationListModel.prototype._updateStatus = function(app) { - if (app.appData.container === undefined) { - app.status = Status.STOPPED; - } else { - app.status = Status.RUNNING; - } -}; + var startPromise = $.Deferred(); -ApplicationListModel.prototype.startApplication = function() { - var selectedIndex = this.selectedIndex; - var currentApp = this.appList[selectedIndex]; - - currentApp.status = Status.STARTING; - currentApp.delayed = true; - - var configurablesData = {}; - currentApp.configurables.forEach(function(configurable) { - var tag = configurable.tag; - configurablesData[tag] = configurable.asConfigDict(); - }); - - var startPromise = $.Deferred(); - - resources.Container.create({ - mapping_id: currentApp.appData.mapping_id, - configurables: configurablesData - }) - .done(function() { - this.updateIdx(selectedIndex) - .done(startPromise.resolve) - .fail(function(error) { + resources.Container.create({ + mapping_id: currentApp.appData.mapping_id, + configurables: configurablesData + }) + .done(() => { + this.updateIdx(selectedIndex) + .done(startPromise.resolve) + .fail((error) => { + currentApp.status = Status.STOPPED; + startPromise.reject(error); + }); + }) + .fail((error) => { currentApp.status = Status.STOPPED; startPromise.reject(error); }); - }.bind(this)) - .fail(function(error) { - currentApp.status = Status.STOPPED; - startPromise.reject(error); - }); - return startPromise; -}; + return startPromise; + }; -ApplicationListModel.prototype.stopApplication = function(index) { - var appStopping = this.appList[index]; - appStopping.status = Status.STOPPING; + stopApplication(index) { + var appStopping = this.appList[index]; + appStopping.status = Status.STOPPING; - var url_id = appStopping.appData.container.url_id; + var url_id = appStopping.appData.container.url_id; - var stopPromise = $.Deferred(); + var stopPromise = $.Deferred(); - resources.Container.delete(url_id) - .done(function() { - this.updateIdx(index) - .done(stopPromise.resolve) - .fail(function(error) { + resources.Container.delete(url_id) + .done(() => { + this.updateIdx(index) + .done(stopPromise.resolve) + .fail(function(error) { + appStopping.status = Status.STOPPED; + stopPromise.reject(error); + }); + }) + .fail((error) => { appStopping.status = Status.STOPPED; stopPromise.reject(error); }); - }.bind(this)) - .fail(function(error) { - appStopping.status = Status.STOPPED; - stopPromise.reject(error); - }); - return stopPromise; + return stopPromise; + }; }; module.exports = { - ApplicationListModel: ApplicationListModel + ApplicationListModel }; diff --git a/remoteappmanager/static/js/user/views/application_list_view.js b/remoteappmanager/static/js/user/views/application_list_view.js index 4a0ee8a46..00a58c846 100644 --- a/remoteappmanager/static/js/user/views/application_list_view.js +++ b/remoteappmanager/static/js/user/views/application_list_view.js @@ -3,66 +3,66 @@ require("toolkit"); var ApplicationListView = Vue.extend({ template: - ' + `, data: function() { return { @@ -73,10 +73,10 @@ var ApplicationListView = Vue.extend({ computed: { visibleList: function() { - return this.model.appList.filter(function(app) { + return this.model.appList.filter((app) => { var appName = this.$options.filters.appName(app.appData.image).toLowerCase(); return appName.indexOf(this.searchInput.toLowerCase()) !== -1; - }.bind(this)); + }); } }, @@ -84,12 +84,12 @@ var ApplicationListView = Vue.extend({ stopApplication: function(index) { var stoppingAppName = this.$options.filters.appName( this.model.appList[index].appData.image); - this.model.stopApplication(index).fail(function(error) { + this.model.stopApplication(index).fail((error) => { this.stoppingError.code = error.code; this.stoppingError.message = error.message; this.stoppingError.appName = stoppingAppName; this.stoppingError.show = true; - }.bind(this)); + }); }, closeDialog: function() { this.stoppingError.show = false; @@ -101,5 +101,5 @@ var ApplicationListView = Vue.extend({ }); module.exports = { - ApplicationListView : ApplicationListView + ApplicationListView }; diff --git a/remoteappmanager/static/js/user/views/application_view.js b/remoteappmanager/static/js/user/views/application_view.js index 5b3ce899c..01b634356 100644 --- a/remoteappmanager/static/js/user/views/application_view.js +++ b/remoteappmanager/static/js/user/views/application_view.js @@ -5,85 +5,84 @@ require("toolkit"); var ApplicationView = Vue.extend({ template: - '' + - '
' + - ' ' + - ' ' + - '
' + - ' Code: {{startingError.code}}' + - ' {{startingError.message}}' + - '
' + - '
' + - - ' ' + - '
' + - '
' + - '
' + - '
' + - '

{{ currentApp.appData.image | appName }}

' + - '
' + - '
' + - '
' + - '

Description

' + - ' {{ currentApp.appData.image.description }}' + - - '

Policy

' + - - '
    ' + - ' ' + - '
  • ' + - ' Workspace accessible' + - '
  • ' + - '
  • ' + - ' Workspace not accessible' + - '
  • ' + - - ' ' + - '
  • ' + - ' Volume mounted: {{ appPolicy.volume_source }} → {{ appPolicy.volume_target }} ({{ appPolicy.volume_mode }})' + - '
  • ' + - '
  • ' + - ' No volumes mounted' + - '
  • ' + - '
' + - - '

Configuration

' + - '
' + - '
No configurable options for this image
' + - '
' + - ' ' + - '
' + - '
' + - '
' + - - ' ' + - ' ' + - '
' + - '
' + - '
' + - - - ' ' + - ' ' + - '
', + ` +
+ + +
+ Code: {{startingError.code}} + {{startingError.message}} +
+
+ + +
+
+
+
+

{{ currentApp.appData.image | appName }}

+
+
+
+

Description

+ {{ currentApp.appData.image.description }} + +

Policy

+ +
    + +
  • + Workspace accessible +
  • +
  • + Workspace not accessible +
  • + + +
  • + Volume mounted: {{ appPolicy.volume_source }} → {{ appPolicy.volume_target }} ({{ appPolicy.volume_mode }}) +
  • +
  • + No volumes mounted +
  • +
+ +

Configuration

+
+
No configurable options for this image
+
+ +
+
+
+ + + +
+
+
+ + + +
`, data: function() { return { @@ -117,15 +116,15 @@ var ApplicationView = Vue.extend({ var startingApp = this.currentApp; var startingAppName = this.$options.filters.appName(startingApp.appData.image); this.model.startApplication() - .done(function() { + .done(() => { this.$emit('startApplication', startingApp); - }.bind(this)) - .fail(function(error) { + }) + .fail((error) => { this.startingError.code = error.code; this.startingError.message = error.message; this.startingError.appName = startingAppName; this.startingError.show = true; - }.bind(this)); + }); }, closeDialog: function() { this.startingError.show = false; @@ -145,5 +144,5 @@ var ApplicationView = Vue.extend({ }); module.exports = { - ApplicationView : ApplicationView + ApplicationView }; From 8a925a08b6b8b84d5c708b8b440f6726925f0191 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 17 May 2017 12:06:45 +0100 Subject: [PATCH 3/9] Change vue components --- .../static/js/vue/toolkit/AdminLTEBox.js | 16 ++--- .../static/js/vue/toolkit/ConfirmDialog.js | 28 ++++----- .../static/js/vue/toolkit/DataTable.js | 59 +++++++++---------- .../static/js/vue/toolkit/ModalDialog.js | 20 +++---- .../static/js/vue/toolkit/toolkit.js | 8 +-- 5 files changed, 64 insertions(+), 67 deletions(-) diff --git a/remoteappmanager/static/js/vue/toolkit/AdminLTEBox.js b/remoteappmanager/static/js/vue/toolkit/AdminLTEBox.js index 83aa72b84..ad564fc13 100644 --- a/remoteappmanager/static/js/vue/toolkit/AdminLTEBox.js +++ b/remoteappmanager/static/js/vue/toolkit/AdminLTEBox.js @@ -6,12 +6,12 @@ module.exports = { } }, template: - '
' + - '
' + - '
' + - '
{{title}}
' + - '
' + - '
' + - '
' + - '
' + `
+
+
+
{{title}}
+
+
+
+
` }; diff --git a/remoteappmanager/static/js/vue/toolkit/ConfirmDialog.js b/remoteappmanager/static/js/vue/toolkit/ConfirmDialog.js index c82188cf3..3a366de09 100644 --- a/remoteappmanager/static/js/vue/toolkit/ConfirmDialog.js +++ b/remoteappmanager/static/js/vue/toolkit/ConfirmDialog.js @@ -13,18 +13,18 @@ module.exports = { default: function() {} } }, - template: '' + - ' ' + - '' + template: ` + + ` }; diff --git a/remoteappmanager/static/js/vue/toolkit/DataTable.js b/remoteappmanager/static/js/vue/toolkit/DataTable.js index 3845ddac9..f3b119f1c 100644 --- a/remoteappmanager/static/js/vue/toolkit/DataTable.js +++ b/remoteappmanager/static/js/vue/toolkit/DataTable.js @@ -6,41 +6,38 @@ module.exports = { isBoolean: function(value) { return typeof(value) === "boolean"; }, - buttonClassFromType: function(value) { + buttonClassFromType: function(value = "danger") { var cls = {"btn": true}; - if (value === undefined) { - value = "danger"; - } cls["btn-" + value] = true; return cls; } }, template: - '
' + - '
' + - ' ' + - '
' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - '
{{header}}Actions
' + - ' ' + - '
' + - '
' + `
+
+ +
+ + + + + + + + + + + + + +
{{header}}Actions
+ +
+
` }; diff --git a/remoteappmanager/static/js/vue/toolkit/ModalDialog.js b/remoteappmanager/static/js/vue/toolkit/ModalDialog.js index 61a7059a6..129fb0d5d 100644 --- a/remoteappmanager/static/js/vue/toolkit/ModalDialog.js +++ b/remoteappmanager/static/js/vue/toolkit/ModalDialog.js @@ -1,12 +1,12 @@ module.exports = { - template: '' + - ' ' + - '' + template: ` + + ` }; \ No newline at end of file diff --git a/remoteappmanager/static/js/vue/toolkit/toolkit.js b/remoteappmanager/static/js/vue/toolkit/toolkit.js index b1018e319..b10fe9317 100644 --- a/remoteappmanager/static/js/vue/toolkit/toolkit.js +++ b/remoteappmanager/static/js/vue/toolkit/toolkit.js @@ -10,8 +10,8 @@ Vue.component("adminlte-box", AdminLTEBox); Vue.component("data-table", DataTable); module.exports = { - ConfirmDialog: ConfirmDialog, - AdminLTEBox: AdminLTEBox, - ModalDialog: ModalDialog, - DataTable: DataTable + ConfirmDialog, + AdminLTEBox, + ModalDialog, + DataTable }; From 210ec0ab964b0c25032e5e26eb5c2182ccfab73e Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 17 May 2017 12:10:45 +0100 Subject: [PATCH 4/9] Change utils --- remoteappmanager/static/js/gamodule.js | 24 +++++++++++++----------- remoteappmanager/static/js/urlutils.js | 6 +++--- remoteappmanager/static/js/utils.js | 6 +++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/remoteappmanager/static/js/gamodule.js b/remoteappmanager/static/js/gamodule.js index cd71bd96e..bd31cd7a9 100644 --- a/remoteappmanager/static/js/gamodule.js +++ b/remoteappmanager/static/js/gamodule.js @@ -14,19 +14,21 @@ function init() { }; } -var GaObserver = function() { - this.ga = init(); -}; +class GaObserver { + constructor() { + this.ga = init(); + }; -GaObserver.prototype.triggerApplicationStarting = function(name) { - this.ga("send", "event", { - eventCategory: "Application", - eventAction: "start", - eventLabel: name - }); + triggerApplicationStarting(name) { + this.ga("send", "event", { + eventCategory: "Application", + eventAction: "start", + eventLabel: name + }); + }; }; module.exports = { - init: init, // For testing purpose - GaObserver: GaObserver + init, // For testing purpose + GaObserver }; diff --git a/remoteappmanager/static/js/urlutils.js b/remoteappmanager/static/js/urlutils.js index 700c7400b..fc3602c32 100644 --- a/remoteappmanager/static/js/urlutils.js +++ b/remoteappmanager/static/js/urlutils.js @@ -44,7 +44,7 @@ var encodeUriComponents = function (uri) { }; module.exports = { - pathJoin: pathJoin, - encodeUriComponents: encodeUriComponents, - parse: parse + pathJoin, + encodeUriComponents, + parse }; diff --git a/remoteappmanager/static/js/utils.js b/remoteappmanager/static/js/utils.js index ebdb3077b..902322cf9 100644 --- a/remoteappmanager/static/js/utils.js +++ b/remoteappmanager/static/js/utils.js @@ -41,7 +41,7 @@ var maxIframeSize = function () { }; module.exports = { - all : all, - update : update, - maxIframeSize: maxIframeSize + all, + update, + maxIframeSize }; From dffd7c75b363bd24e83be50bd1443a2d6bc7f540 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 17 May 2017 12:14:11 +0100 Subject: [PATCH 5/9] Change es version for jshint --- .jshintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index cc77b267f..a12e6147d 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,4 +1,5 @@ { + "esversion": 6, "passfail" : false, "maxerr" : 100, "browser" : true, @@ -8,7 +9,6 @@ ], "debug" : false, "devel" : true, - "es5" : true, "strict" : false, "globalstrict" : false, "asi" : false, From 6966e9ad603b6cea41e00e3929b7ad875ae3a538 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 17 May 2017 12:16:35 +0100 Subject: [PATCH 6/9] Fix jstest --- remoteappmanager/static/js/gamodule.js | 6 +++--- remoteappmanager/static/js/user/configurables.js | 6 +++--- remoteappmanager/static/js/user/models.js | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/remoteappmanager/static/js/gamodule.js b/remoteappmanager/static/js/gamodule.js index bd31cd7a9..90e2f1443 100644 --- a/remoteappmanager/static/js/gamodule.js +++ b/remoteappmanager/static/js/gamodule.js @@ -17,7 +17,7 @@ function init() { class GaObserver { constructor() { this.ga = init(); - }; + } triggerApplicationStarting(name) { this.ga("send", "event", { @@ -25,8 +25,8 @@ class GaObserver { eventAction: "start", eventLabel: name }); - }; -}; + } +} module.exports = { init, // For testing purpose diff --git a/remoteappmanager/static/js/user/configurables.js b/remoteappmanager/static/js/user/configurables.js index 36514984b..02de9cbe4 100644 --- a/remoteappmanager/static/js/user/configurables.js +++ b/remoteappmanager/static/js/user/configurables.js @@ -34,7 +34,7 @@ class ResolutionModel { constructor() { this.tag = resolutionTag; this.configDict = { resolution: 'Window' }; - }; + } asConfigDict() { var resolution = this.configDict.resolution; @@ -45,8 +45,8 @@ class ResolutionModel { } return { resolution: resolution }; - }; -}; + } +} var outputConfigurables = {}; diff --git a/remoteappmanager/static/js/user/models.js b/remoteappmanager/static/js/user/models.js index 7429c2f1f..dd7426777 100644 --- a/remoteappmanager/static/js/user/models.js +++ b/remoteappmanager/static/js/user/models.js @@ -47,7 +47,7 @@ class ApplicationListModel { this.selectedIndex = null; this.loading = true; - }; + } update() { // Requests an update of the object internal data. @@ -97,7 +97,7 @@ class ApplicationListModel { this.loading = false; }); - }; + } updateIdx(index) { // Refetches and updates the entry at the given index. @@ -110,7 +110,7 @@ class ApplicationListModel { this._updateStatus(app); }); - }; + } _updateConfigurables(app) { // Contains the submodels for the configurables. @@ -129,7 +129,7 @@ class ApplicationListModel { app.configurables.push(new ConfigurableCls()); } }); - }; + } _updateStatus(app) { if (app.appData.container === undefined) { @@ -137,7 +137,7 @@ class ApplicationListModel { } else { app.status = Status.RUNNING; } - }; + } startApplication() { var selectedIndex = this.selectedIndex; @@ -172,7 +172,7 @@ class ApplicationListModel { }); return startPromise; - }; + } stopApplication(index) { var appStopping = this.appList[index]; @@ -197,8 +197,8 @@ class ApplicationListModel { }); return stopPromise; - }; -}; + } +} module.exports = { ApplicationListModel From a2843ef53b14531f84fa525da155fd11eeb530c6 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 17 May 2017 12:44:37 +0100 Subject: [PATCH 7/9] var -> let --- remoteappmanager/static/js/admin/main.js | 22 ++++----- .../js/admin/vue-components/AccountingView.js | 6 +-- .../admin/vue-components/ApplicationsView.js | 6 +-- .../js/admin/vue-components/ContainersView.js | 4 +- .../js/admin/vue-components/MainView.js | 2 +- .../js/admin/vue-components/UsersView.js | 6 +-- .../accounting/NewAccountingDialog.js | 8 ++-- .../applications/NewApplicationDialog.js | 2 +- .../vue-components/users/NewUserDialog.js | 2 +- remoteappmanager/static/js/urlutils.js | 10 ++-- .../static/js/user/configurables.js | 14 +++--- remoteappmanager/static/js/user/main.js | 16 +++---- remoteappmanager/static/js/user/models.js | 48 +++++++++---------- .../js/user/views/application_list_view.js | 8 ++-- .../static/js/user/views/application_view.js | 18 +++---- remoteappmanager/static/js/utils.js | 10 ++-- remoteappmanager/static/js/vue/filters.js | 4 +- .../static/js/vue/toolkit/DataTable.js | 2 +- .../static/js/vue/toolkit/toolkit.js | 10 ++-- 19 files changed, 99 insertions(+), 99 deletions(-) diff --git a/remoteappmanager/static/js/admin/main.js b/remoteappmanager/static/js/admin/main.js index 7d680f022..df96b730d 100644 --- a/remoteappmanager/static/js/admin/main.js +++ b/remoteappmanager/static/js/admin/main.js @@ -1,13 +1,13 @@ -var _ = require("lodash"); -var Vue = require("vuejs"); -var VueRouter = require("vue-router"); -var VueForm = require("vue-form"); +let _ = require("lodash"); +let Vue = require("vuejs"); +let VueRouter = require("vue-router"); +let VueForm = require("vue-form"); require("toolkit"); -var MainView = require("./vue-components/MainView"); -var ContainersView = require("./vue-components/ContainersView"); -var UsersView = require("./vue-components/UsersView"); -var ApplicationsView = require("./vue-components/ApplicationsView"); -var AccountingView = require("./vue-components/AccountingView"); +let MainView = require("./vue-components/MainView"); +let ContainersView = require("./vue-components/ContainersView"); +let UsersView = require("./vue-components/UsersView"); +let ApplicationsView = require("./vue-components/ApplicationsView"); +let AccountingView = require("./vue-components/AccountingView"); // install router Vue.use(VueRouter); @@ -22,7 +22,7 @@ Vue.filter("truncate", function(value) { return _.truncate(value, {'length': 12 }); }); -var router = new VueRouter({ +let router = new VueRouter({ routes: [ { path: '/', component: MainView }, { path: '/containers', component: ContainersView }, @@ -32,7 +32,7 @@ var router = new VueRouter({ ] }); -var vm; +let vm; vm = new Vue({ el: "#app", router: router diff --git a/remoteappmanager/static/js/admin/vue-components/AccountingView.js b/remoteappmanager/static/js/admin/vue-components/AccountingView.js index 79b7dc999..0bf9dbc7a 100644 --- a/remoteappmanager/static/js/admin/vue-components/AccountingView.js +++ b/remoteappmanager/static/js/admin/vue-components/AccountingView.js @@ -1,5 +1,5 @@ -var resources = require("admin-resources"); -var NewAccountingDialog = require("./accounting/NewAccountingDialog"); +let resources = require("admin-resources"); +let NewAccountingDialog = require("./accounting/NewAccountingDialog"); module.exports = { components: { @@ -80,7 +80,7 @@ module.exports = { .done((identifiers, items) => { this.table.rows = []; identifiers.forEach((id) => { - var item = items[id]; + let item = items[id]; this.table.rows.push([ id, item.image_name, diff --git a/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js b/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js index 929805efc..b193d6477 100644 --- a/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js +++ b/remoteappmanager/static/js/admin/vue-components/ApplicationsView.js @@ -1,5 +1,5 @@ -var resources = require("admin-resources"); -var NewApplicationDialog = require("./applications/NewApplicationDialog"); +let resources = require("admin-resources"); +let NewApplicationDialog = require("./applications/NewApplicationDialog"); module.exports = { components: { @@ -78,7 +78,7 @@ module.exports = { .done((identifiers, items) => { this.table.rows = []; identifiers.forEach((id) => { - var item = items[id]; + let item = items[id]; this.table.rows.push([ id, item.image_name diff --git a/remoteappmanager/static/js/admin/vue-components/ContainersView.js b/remoteappmanager/static/js/admin/vue-components/ContainersView.js index 71285ef26..9e9e28f3f 100644 --- a/remoteappmanager/static/js/admin/vue-components/ContainersView.js +++ b/remoteappmanager/static/js/admin/vue-components/ContainersView.js @@ -1,4 +1,4 @@ -var resources = require("admin-resources"); +let resources = require("admin-resources"); module.exports = { template: @@ -50,7 +50,7 @@ module.exports = { .done((identifiers, items) => { this.table.rows = []; identifiers.forEach((id) => { - var item = items[id]; + let item = items[id]; this.table.rows.push([ id, item.user, diff --git a/remoteappmanager/static/js/admin/vue-components/MainView.js b/remoteappmanager/static/js/admin/vue-components/MainView.js index ac7c3d051..c53b583a9 100644 --- a/remoteappmanager/static/js/admin/vue-components/MainView.js +++ b/remoteappmanager/static/js/admin/vue-components/MainView.js @@ -1,4 +1,4 @@ -var resources = require("admin-resources"); +let resources = require("admin-resources"); module.exports = { template: diff --git a/remoteappmanager/static/js/admin/vue-components/UsersView.js b/remoteappmanager/static/js/admin/vue-components/UsersView.js index 9fbc94301..1de805ab7 100644 --- a/remoteappmanager/static/js/admin/vue-components/UsersView.js +++ b/remoteappmanager/static/js/admin/vue-components/UsersView.js @@ -1,5 +1,5 @@ -var resources = require("admin-resources"); -var NewUserDialog = require("./users/NewUserDialog"); +let resources = require("admin-resources"); +let NewUserDialog = require("./users/NewUserDialog"); module.exports = { components: { @@ -75,7 +75,7 @@ module.exports = { .done((identifiers, items) => { this.table.rows = []; identifiers.forEach((id) => { - var item = items[id]; + let item = items[id]; this.table.rows.push([ id, item.name diff --git a/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js b/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js index d5b5d9282..9481570e3 100644 --- a/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js +++ b/remoteappmanager/static/js/admin/vue-components/accounting/NewAccountingDialog.js @@ -1,4 +1,4 @@ -var resources = require("admin-resources"); +let resources = require("admin-resources"); module.exports = { template: @@ -93,8 +93,8 @@ module.exports = { }, createNewAccounting: function () { - var model = this.model; - var formstate = this.formstate; + let model = this.model; + let formstate = this.formstate; if (formstate.$invalid) { return; @@ -105,7 +105,7 @@ module.exports = { return; } - var rep = { + let rep = { user_id: this.userId, image_name: this.model.image_name, allow_home: this.model.allow_home, diff --git a/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js b/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js index 2fd9f4145..ebd6b27fc 100644 --- a/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js +++ b/remoteappmanager/static/js/admin/vue-components/applications/NewApplicationDialog.js @@ -1,4 +1,4 @@ -var resources = require("admin-resources"); +let resources = require("admin-resources"); module.exports = { template: diff --git a/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js b/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js index a136c0f15..0f172876b 100644 --- a/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js +++ b/remoteappmanager/static/js/admin/vue-components/users/NewUserDialog.js @@ -1,4 +1,4 @@ -var resources = require("admin-resources"); +let resources = require("admin-resources"); module.exports = { template: diff --git a/remoteappmanager/static/js/urlutils.js b/remoteappmanager/static/js/urlutils.js index fc3602c32..d50ceda38 100644 --- a/remoteappmanager/static/js/urlutils.js +++ b/remoteappmanager/static/js/urlutils.js @@ -5,9 +5,9 @@ // Modifications Copyright (c) Juptyer Development Team. // Distributed under the terms of the Modified BSD License. -var pathJoin = function () { +let pathJoin = function () { // join a sequence of url components with '/' - var url = '', i = 0; + let url = '', i = 0; for (i = 0; i < arguments.length; i += 1) { if (arguments[i] === '') { @@ -23,7 +23,7 @@ var pathJoin = function () { return url; }; -var parse = function (url) { +let parse = function (url) { // an `a` element with an href allows attr-access to the parsed segments of a URL // a = parse_url("http://localhost:8888/path/name#hash") // a.protocol = "http:" @@ -32,12 +32,12 @@ var parse = function (url) { // a.port = 8888 // a.pathname = "/path/name" // a.hash = "#hash" - var a = document.createElement("a"); + let a = document.createElement("a"); a.href = url; return a; }; -var encodeUriComponents = function (uri) { +let encodeUriComponents = function (uri) { // encode just the components of a multi-segment uri, // leaving '/' separators return uri.split('/').map(encodeURIComponent).join('/'); diff --git a/remoteappmanager/static/js/user/configurables.js b/remoteappmanager/static/js/user/configurables.js index 02de9cbe4..219640374 100644 --- a/remoteappmanager/static/js/user/configurables.js +++ b/remoteappmanager/static/js/user/configurables.js @@ -1,8 +1,8 @@ -var Vue = require("vuejs"); -var utils = require("utils"); +let Vue = require("vuejs"); +let utils = require("utils"); -var resolutionTag = 'resolution'; -var resolutionComponent = Vue.component(resolutionTag + '-component', { +let resolutionTag = 'resolution'; +const resolutionComponent = Vue.component(resolutionTag + '-component', { // Your configurable must have a "configDict" property from the model props: ['configDict'], @@ -37,10 +37,10 @@ class ResolutionModel { } asConfigDict() { - var resolution = this.configDict.resolution; + let resolution = this.configDict.resolution; if (resolution === 'Window') { - var maxSize = utils.maxIframeSize(); + let maxSize = utils.maxIframeSize(); resolution = maxSize[0] + 'x' + maxSize[1]; } @@ -48,7 +48,7 @@ class ResolutionModel { } } -var outputConfigurables = {}; +let outputConfigurables = {}; // Export all your configurable models here outputConfigurables[resolutionTag] = { diff --git a/remoteappmanager/static/js/user/main.js b/remoteappmanager/static/js/user/main.js index 2e06abbae..7e30c94b4 100644 --- a/remoteappmanager/static/js/user/main.js +++ b/remoteappmanager/static/js/user/main.js @@ -1,26 +1,26 @@ -var gamodule = require("gamodule"); -var models = require("./models"); -var applicationListView = require("./views/application_list_view"); -var applicationView = require("./views/application_view"); +let gamodule = require("gamodule"); +let models = require("./models"); +let applicationListView = require("./views/application_list_view"); +let applicationView = require("./views/application_view"); require("filters"); // This model keeps the retrieved content from the REST query locally. // It is only synchronized at initial load. -var model = new models.ApplicationListModel(); +let model = new models.ApplicationListModel(); // Initialize views -var appListView = new applicationListView.ApplicationListView({ +let appListView = new applicationListView.ApplicationListView({ el: '#applist', data: function() { return { model: model }; } }); -var appView = new applicationView.ApplicationView({ +let appView = new applicationView.ApplicationView({ el: '#appview', data: function() { return { model: model }; } }); // Create GA observer -var gaObserver = new gamodule.GaObserver(); +let gaObserver = new gamodule.GaObserver(); appView.$on('startApplication', function(application) { gaObserver.triggerApplicationStarting(application.appData.image.name); diff --git a/remoteappmanager/static/js/user/models.js b/remoteappmanager/static/js/user/models.js index dd7426777..ca744342b 100644 --- a/remoteappmanager/static/js/user/models.js +++ b/remoteappmanager/static/js/user/models.js @@ -1,28 +1,28 @@ -var $ = require("jquery"); -var resources = require("user-resources"); -var configurables = require("./configurables"); +let $ = require("jquery"); +let resources = require("user-resources"); +let configurables = require("./configurables"); -var Status = { +let Status = { RUNNING: "RUNNING", STARTING: "STARTING", STOPPING: "STOPPING", STOPPED: "STOPPED" }; -var availableApplicationsInfo = function () { - // Retrieve information from the various applications and +let availableApplicationsInfo = function () { + // Retrieve information from the letious applications and // connect the cascading callbacks. // Returns a single promise. When resolved, the attached - // callbacks will be passed an array of the promises for the various + // callbacks will be passed an array of the promises for the letious // retrieve operations, successful or not. // This routine will go away when we provide the representation data // inline with the items at tornado-webapi level. - var promise = $.Deferred(); + let promise = $.Deferred(); resources.Application.items() .done((identifiers, items) => { - var result = []; + let result = []; Object.keys(items).forEach((key) => { result.push(items[key]); }); @@ -60,18 +60,18 @@ class ApplicationListModel { ).done((appData) => { // appData contains the data retrieved from the remote API - var appList = []; + let appList = []; // Sort application list by names appData.sort((app1, app2) => { - var app1Name = app1.image.ui_name? app1.image.ui_name: app1.image.name; - var app2Name = app2.image.ui_name? app2.image.ui_name: app2.image.name; + let app1Name = app1.image.ui_name? app1.image.ui_name: app1.image.name; + let app2Name = app2.image.ui_name? app2.image.ui_name: app2.image.name; return app1Name < app2Name? -1: 1; }); // Add the options for some image types appData.forEach((applicationData) => { - var app = { + let app = { appData: applicationData, // Default values, will be overwritten status: Status.STOPPED, @@ -101,8 +101,8 @@ class ApplicationListModel { updateIdx(index) { // Refetches and updates the entry at the given index. - var app = this.appList[index]; - var mapping_id = app.appData.mapping_id; + let app = this.appList[index]; + let mapping_id = app.appData.mapping_id; return resources.Application.retrieve(mapping_id) .done((newData) => { @@ -123,7 +123,7 @@ class ApplicationListModel { // by the client. skip it and let the server deal with the // missing data, either by using a default or throwing // an error. - var ConfigurableCls = configurables[tag].model; + let ConfigurableCls = configurables[tag].model; if (ConfigurableCls !== undefined) { app.configurables.push(new ConfigurableCls()); @@ -140,19 +140,19 @@ class ApplicationListModel { } startApplication() { - var selectedIndex = this.selectedIndex; - var currentApp = this.appList[selectedIndex]; + let selectedIndex = this.selectedIndex; + let currentApp = this.appList[selectedIndex]; currentApp.status = Status.STARTING; currentApp.delayed = true; - var configurablesData = {}; + let configurablesData = {}; currentApp.configurables.forEach(function(configurable) { - var tag = configurable.tag; + let tag = configurable.tag; configurablesData[tag] = configurable.asConfigDict(); }); - var startPromise = $.Deferred(); + let startPromise = $.Deferred(); resources.Container.create({ mapping_id: currentApp.appData.mapping_id, @@ -175,12 +175,12 @@ class ApplicationListModel { } stopApplication(index) { - var appStopping = this.appList[index]; + let appStopping = this.appList[index]; appStopping.status = Status.STOPPING; - var url_id = appStopping.appData.container.url_id; + let url_id = appStopping.appData.container.url_id; - var stopPromise = $.Deferred(); + let stopPromise = $.Deferred(); resources.Container.delete(url_id) .done(() => { diff --git a/remoteappmanager/static/js/user/views/application_list_view.js b/remoteappmanager/static/js/user/views/application_list_view.js index 00a58c846..0e0b4ae3f 100644 --- a/remoteappmanager/static/js/user/views/application_list_view.js +++ b/remoteappmanager/static/js/user/views/application_list_view.js @@ -1,7 +1,7 @@ -var Vue = require("vuejs"); +let Vue = require("vuejs"); require("toolkit"); -var ApplicationListView = Vue.extend({ +const ApplicationListView = Vue.extend({ template: `