Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions jstests/tests/home/test_application_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ define([
"home/views/application_list_view",
"components/vue/dist/vue",
"vue/filters"
], function (models, application_list_view, Vue) {
], function (models, applicationListView, Vue) {
"use strict";

QUnit.module("home.app_list_view");
QUnit.test("rendering list", function (assert) {
var done = assert.async();

var model = new models.ApplicationListModel();
var app_list_view = new application_list_view.ApplicationListView({
var appListView = new applicationListView.ApplicationListView({
data: function() { return { model: model }; }
}).$mount();

assert.ok(model.loading);
assert.equal(
app_list_view.$el.querySelector("#loading-spinner").style.display,
appListView.$el.querySelector("#loading-spinner").style.display,
""
);

model.update().done(function() { Vue.nextTick(function() {
assert.equal(
app_list_view.$el.querySelector("#no-app-msg").style.display,
appListView.$el.querySelector("#no-app-msg").style.display,
"none"
);
assert.equal(
app_list_view.$el.querySelector("#loading-spinner").style.display,
appListView.$el.querySelector("#loading-spinner").style.display,
"none"
);
assert.equal(
app_list_view.$el.querySelector("#applistentries").children.length,
model.app_list.length
appListView.$el.querySelector("#applistentries").children.length,
model.appList.length
);

done();
Expand All @@ -43,23 +43,23 @@ define([
var done = assert.async();

var model = new models.ApplicationListModel();
var app_list_view = new application_list_view.ApplicationListView({
var appListView = new applicationListView.ApplicationListView({
data: function() { return { model: model }; }
}).$mount();

model.loading = false;

Vue.nextTick(function() {
assert.equal(
app_list_view.$el.querySelector("#no-app-msg").style.display,
appListView.$el.querySelector("#no-app-msg").style.display,
""
);
assert.equal(
app_list_view.$el.querySelector("#loading-spinner").style.display,
appListView.$el.querySelector("#loading-spinner").style.display,
"none"
);
assert.equal(
app_list_view.$el.querySelector("#applistentries").children.length,
appListView.$el.querySelector("#applistentries").children.length,
0
);

Expand All @@ -71,19 +71,19 @@ define([
var done = assert.async();

var model = new models.ApplicationListModel();
var app_list_view = new application_list_view.ApplicationListView({
var appListView = new applicationListView.ApplicationListView({
data: function() { return { model: model }; }
}).$mount();

model.update().done(function() { Vue.nextTick(function() {
assert.notEqual(app_list_view.visible_list.length, 0);
assert.notEqual(appListView.visibleList.length, 0);

app_list_view.search_input = "heho";
appListView.searchInput = "heho";

Vue.nextTick(function() {
assert.equal(app_list_view.visible_list.length, 0);
assert.equal(appListView.visibleList.length, 0);
assert.equal(
app_list_view.$el.querySelector("input[name=q]").value,
appListView.$el.querySelector("input[name=q]").value,
"heho"
);

Expand Down
40 changes: 20 additions & 20 deletions jstests/tests/home/test_application_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ define([
"home/views/application_view",
"components/vue/dist/vue",
"vue/filters"
], function (models, application_view, Vue) {
], function (models, applicationView, Vue) {
"use strict";

QUnit.module("home.app_view");
QUnit.test("rendering form", function (assert) {
var done = assert.async();

var model = new models.ApplicationListModel();
var app_view = new application_view.ApplicationView({
var appView = new applicationView.ApplicationView({
data: function() { return { model: model }; }
}).$mount();

model.update().done(function() { Vue.nextTick(function() {
assert.equal(app_view.$el.children[0].tagName, 'DIV');
assert.ok(app_view.$el.children[0].classList.contains('row'));
assert.equal(appView.$el.children[0].tagName, 'DIV');
assert.ok(appView.$el.children[0].classList.contains('row'));

assert.equal(
app_view.$el.querySelector('.box-title').innerHTML,
model.app_list[0].app_data.image.ui_name
appView.$el.querySelector('.box-title').innerHTML,
model.appList[0].appData.image.ui_name
);

// Simulate application starting
model.app_list[0].status = 'STARTING';
model.appList[0].status = 'STARTING';

assert.equal(
app_view.$el.querySelector('.box-title').innerHTML,
model.app_list[0].app_data.image.ui_name
appView.$el.querySelector('.box-title').innerHTML,
model.appList[0].appData.image.ui_name
);
assert.equal(
app_view.$el.querySelector('#app-description').innerHTML,
model.app_list[0].app_data.image.description
appView.$el.querySelector('#app-description').innerHTML,
model.appList[0].appData.image.description
);

done();
Expand All @@ -44,27 +44,27 @@ define([
var done = assert.async();

var model = new models.ApplicationListModel();
var app_view = new application_view.ApplicationView({
var appView = new applicationView.ApplicationView({
data: function() { return { model: model }; }
}).$mount();

model.update().done(function() {
// Simulate application running
model.app_list[0].status = 'RUNNING';
model.app_list[0].app_data.container = {};
model.app_list[0].app_data.container.url_id = 'https://127.0.0.1:1234/';
model.appList[0].status = 'RUNNING';
model.appList[0].appData.container = {};
model.appList[0].appData.container.url_id = 'https://127.0.0.1:1234/';

Vue.nextTick(function() {
assert.equal(app_view.$el.children[0].tagName, 'IFRAME');
assert.equal(appView.$el.children[0].tagName, 'IFRAME');

// Render form again by selecting the other application which is stopped
model.selected_index = 1;
model.selectedIndex = 1;

Vue.nextTick(function() {
console.log(model.app_list[1].ui_name)
console.log(model.appList[1].ui_name)
assert.equal(
app_view.$el.querySelector('.box-title').innerHTML,
model.app_list[1].app_data.image.ui_name
appView.$el.querySelector('.box-title').innerHTML,
model.appList[1].appData.image.ui_name
);

done();
Expand Down
16 changes: 8 additions & 8 deletions jstests/tests/home/test_configurables.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ define([

QUnit.module("home.configurables");
QUnit.test("instantiation", function (assert) {
var resolution_conf = new configurables.resolution();
var resolutionConf = new configurables.resolution();

assert.equal(resolution_conf.tag, "resolution");
assert.deepEqual(resolution_conf.config_dict, { resolution: "Window" });
assert.notEqual(resolution_conf.as_config_dict().resolution, "Window");
assert.equal(resolutionConf.tag, "resolution");
assert.deepEqual(resolutionConf.configDict, { resolution: "Window" });
assert.notEqual(resolutionConf.asConfigDict().resolution, "Window");

resolution_conf.config_dict = { resolution: '1280x1024' };
assert.equal(resolution_conf.as_config_dict().resolution, '1280x1024');
resolutionConf.configDict = { resolution: '1280x1024' };
assert.equal(resolutionConf.asConfigDict().resolution, '1280x1024');
});

QUnit.test("view", function (assert) {
var propsData = { config_dict: { resolution: "Window" } };
var component = new configurables.resolution_component({propsData: propsData}).$mount();
var propsData = { configDict: { resolution: "Window" } };
var component = new configurables.resolutionComponent({propsData: propsData}).$mount();

assert.notEqual(component.$el.querySelector("select"), null);
assert.equal(component.$el.querySelector("select").children.length, 5);
Expand Down
12 changes: 6 additions & 6 deletions jstests/tests/home/test_models.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ define([
QUnit.test("instantiation", function (assert) {
var model = new models.ApplicationListModel();

assert.equal(model.app_list.length, 0);
assert.equal(model.selected_index, null);
assert.equal(model.appList.length, 0);
assert.equal(model.selectedIndex, null);

model.update().done(function() {
assert.equal(model.app_list.length, 2);
assert.equal(model.selected_index, 0);
assert.equal(model.appList.length, 2);
assert.equal(model.selectedIndex, 0);

assert.equal(model.app_list[0].app_data.image.configurables[0], "resolution");
assert.equal(model.app_list[0].configurables[0].config_dict.resolution, "Window");
assert.equal(model.appList[0].appData.image.configurables[0], "resolution");
assert.equal(model.appList[0].configurables[0].configDict.resolution, "Window");
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion remoteappmanager/static/js/gamodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define([], function () {
this.ga = init();
};

GaObserver.prototype.trigger_application_starting = function(name) {
GaObserver.prototype.triggerApplicationStarting = function(name) {
this.ga("send", "event", {
eventCategory: "Application",
eventAction: "start",
Expand Down
36 changes: 18 additions & 18 deletions remoteappmanager/static/js/home/configurables.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@ define([
], function(utils, Vue) {
"use strict";

var resolution_tag = 'resolution';
var resolution_component = Vue.component(resolution_tag + '-component', {
// Your configurable must have a "config_dict" property from the model
props: ['config_dict'],
var resolutionTag = 'resolution';
var resolutionComponent = Vue.component(resolutionTag + '-component', {
// Your configurable must have a "configDict" property from the model
props: ['configDict'],

template:
'<div class="form-group">' +
' <label>Resolution</label>' +
' <select class="form-control" v-model="resolution">' +
' <option v-for="resolution_option in resolution_options">' +
' {{resolution_option}}' +
' <option v-for="resolutionOption in resolutionOptions">' +
' {{resolutionOption}}' +
' </option>' +
' </select>' +
'</div>',

data: function() {
return {
resolution: this.config_dict.resolution,
resolution_options: ['Window', '1920x1080', '1280x1024', '1280x800', '1024x768']
resolution: this.configDict.resolution,
resolutionOptions: ['Window', '1920x1080', '1280x1024', '1280x800', '1024x768']
};
},

watch: {
config_dict: function() { this.resolution = this.config_dict.resolution; }, // model -> view update
resolution: function() { this.$emit('update:config_dict', { resolution: this.resolution }); } // view -> model update
configDict: function() { this.resolution = this.configDict.resolution; }, // model -> view update
resolution: function() { this.$emit('update:configDict', { resolution: this.resolution }); } // view -> model update
}
});

// Your configurable class must implement a tag and default config_dict
// Your configurable class must implement a tag and default configDict
var ResolutionModel = function() {
this.tag = resolution_tag;
this.config_dict = { resolution: 'Window' };
this.tag = resolutionTag;
this.configDict = { resolution: 'Window' };
};

ResolutionModel.prototype.as_config_dict = function() {
var resolution = this.config_dict.resolution;
ResolutionModel.prototype.asConfigDict = function() {
var resolution = this.configDict.resolution;

if (resolution === 'Window') {
var max_size = utils.max_iframe_size();
resolution = max_size[0] + 'x' + max_size[1];
var maxSize = utils.maxIframeSize();
resolution = maxSize[0] + 'x' + maxSize[1];
}

return { resolution: resolution };
Expand All @@ -52,6 +52,6 @@ define([
// Export all your configurable models here
return {
resolution: ResolutionModel,
resolution_component: resolution_component
resolutionComponent: resolutionComponent
};
});
16 changes: 8 additions & 8 deletions remoteappmanager/static/js/home/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require([
"vue/filters"
], function(
models,
application_list_view,
application_view,
applicationListView,
applicationView,
Vue,
gamodule) {
"use strict";
Expand All @@ -19,24 +19,24 @@ require([
var model = new models.ApplicationListModel();

// Initialize views
var app_list_view = new application_list_view.ApplicationListView({
var appListView = new applicationListView.ApplicationListView({
el: '#applist',
data: function() { return { model: model }; }
});

var app_view = new application_view.ApplicationView({
var appView = new applicationView.ApplicationView({
el: '#appview',
data: function() { return { model: model }; }
});

// Create GA observer
var ga_observer = new gamodule.GaObserver();
var gaObserver = new gamodule.GaObserver();

app_view.$on('start_application', function(application) {
ga_observer.trigger_application_starting(application.app_data.image.name);
appView.$on('startApplication', function(application) {
gaObserver.triggerApplicationStarting(application.appData.image.name);
});

app_list_view.$on('entry_clicked', function() { app_view.focus_iframe(); });
appListView.$on('entryClicked', function() { appView.focusIframe(); });

model.update();
});
Loading