Skip to content

Commit

Permalink
Progress: #160
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingvord committed Jun 12, 2019
1 parent 3b25bb3 commit f045f85
Showing 1 changed file with 107 additions and 8 deletions.
115 changes: 107 additions & 8 deletions resources/webix_widgets/dashboard_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @author Igor Khokhriakov <igor.khokhriakov@hzg.de>
* @since 6/12/19
*/
import {newTableWidgetBody} from "./table_widget.js";

export const DashboardWidgetController = class extends MVC.Controller {
buildUI(platform_api) {
Expand All @@ -29,27 +30,125 @@ export const DashboardWidgetController = class extends MVC.Controller {
//disable Xenv widget for master
DashboardWidgetController.initialize();

function newDashboardToolbar() {
return {
view: "toolbar",
maxHeight: 30,
cols: [
{
view: "select",
id: "profiles",
label: "Profile",
options: [],
on: {
onChange: function (profile) {
this.getTopParentView().selectProfile(profile);
webix.message(`Select profile ${profile}`);
}
}
},
{
view: "button",
type: "icon",
icon: "plus",
maxWidth: 30,
click: function () {
const $$frmProfile = this.getTopParentView().$$('frmProfileSettings');
if ($$frmProfile.isVisible())
$$frmProfile.hide();
else
$$frmProfile.show();
}
},
{}
]
}
}

function newProfileForm() {
return {
view: "form",
id: "frmProfileSettings",
hidden: true,
elements: [
{
cols: [
{
view: "text",
id: "profile",
name: "profile",
label: "Name",
labelAlign: "right",
validate: webix.rules.isNotEmpty
},
{
view: "text",//TODO select
id: "instance_name",
name: "instance_name",
label: "Instance",
labelAlign: "right",
validate: webix.rules.isNotEmpty
}
]
},
{
cols: [
{},
{
view: "button",
id: 'btnAddProfile',
type: "icon",
icon: "save",
maxWidth: 30,
click: async function () {
const $$frm = this.getFormView();
if (!$$frm.validate()) return;

const values = $$frm.getValues();

await this.getTopParentView().createProfile(values.profile, values.tango_host, values.instance_name);
}
},
{
view: "button",
id: 'btnRmProfile',
type: "icon",
icon: "trash",
maxWidth: 30,
click: async function () {
const $$frm = this.getFormView();
if (!$$frm.validate()) return;

const values = $$frm.getValues();
await this.getTopParentView().deleteProfile(values.profile, values.tango_host, values.instance_name);
}
}
]
}
]
}
}

const dashboard_widget = webix.protoUI({
name: "dashboard_widget",
_ui() {
return {
rows: [
newDashboardToolbar(),
newProfileForm(),
{
template: "header toolbar"
},
{
template: "hidden settings"
},
{
template: "multiview"
view: "multiview",
cells: [
newTableWidgetBody({id: "default"})
]
}
]
}
},
$init(config) {
webix.extend(config, this._ui());
}
}, webix.ui.layout);
}, webix.IdSpace, webix.ui.layout);

function newDashboardWidgetBody(config) {
return webix.extend({
Expand Down

0 comments on commit f045f85

Please sign in to comment.