[Major] Implemented UI to manage roles

This commit is contained in:
Robert von Burg 2018-03-19 22:29:46 +01:00
parent f3214042da
commit 682d635f1a
10 changed files with 689 additions and 236 deletions

View File

@ -33,6 +33,7 @@
"paper-listbox": "polymerelements/paper-listbox#^1.1.2",
"paper-item": "PolymerElements/paper-item#^1.2.1",
"paper-input": "PolymerElements/paper-input#^1.1.24",
"paper-checkbox": "PolymerElements/paper-checkbox#^1.4.2",
"paper-radio-group": "PolymerElements/paper-radio-group#^1.2.2"
},
"devDependencies": {

View File

@ -0,0 +1,81 @@
<script>
StrolchInspectorBehavior = {
properties: {
basePath: {
type: String,
value: './'
},
dlgTitle: {
type: String
},
dlgText: {
type: String
}
},
toLocalDateTime: function (val) {
return Strolch.toLocalDateTime(val);
},
arrayToString: function (arr) {
var s = '';
for (var i = 0; i < arr.length; i++) {
s += arr[i];
if (i + 1 < arr.length)
s += ', ';
}
return s;
},
isEmptyArray: function (arr) {
return arr == null || arr.length == 0;
},
isNotEmptyArray: function (list) {
return !this.isEmptyArray(list);
},
isEmptyString: function (v) {
return v != null && v.length == 0
},
isNotEmptyString: function (v) {
return v != null && v.length > 0
},
_handleAjaxError: function (data) {
var dlgText;
if (data.detail.request.response) {
dlgText = data.detail.request.response.msg;
} else {
dlgText = data.detail.error;
}
this.fire('strolch-show-dialog', {
title: this.dlgTitle,
text: dlgText
});
},
onAjaxError: function (data) {
var dlgText;
if (data.detail.request.response) {
if (data.detail.request.response.msg) {
dlgText = data.detail.request.response.msg;
} else if (data.detail.request.response.charAt(0) == '{') {
var json = JSON.parse(data.detail.request.response);
if (json.msg) {
dlgText = json.msg;
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.error;
}
this.fire('strolch-show-dialog', {
title: this.dlgTitle,
text: dlgText
});
}
};
</script>

View File

@ -16,6 +16,8 @@
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<dom-module id="strolch-wc-inspector-object">
<template>
@ -408,7 +410,7 @@
<iron-ajax id="ajax"
content-type="application/json"
on-response="_handleAjaxResponse"
on-error="_handleAjaxError"></iron-ajax>
on-error="onAjaxError"></iron-ajax>
</template>
@ -418,14 +420,11 @@
is: 'strolch-wc-inspector-object',
behaviors: [
StrolchInspectorBehavior
],
properties: {
basePath: {
type: String,
value: './'
},
dlgTitle: {
type: String
},
realm: {
type: String,
value: function () {
@ -648,13 +647,6 @@
_handleAjaxResponse: function (evt) {
console.log('NOT YET DEFINED!');
},
_handleAjaxError: function (data) {
this.fire('strolch-handle-ajax-error', {
title: this.dlgTitle,
detail: data.detail
});
}
});

View File

@ -13,6 +13,7 @@
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<link rel="import" href="strolch-wc-inspector-object.html">
<dom-module id="strolch-wc-inspector-objects">
@ -237,14 +238,14 @@
content-type="application/json"
handle-as="json"
on-response="_handleAjaxResponse"
on-error="_handleAjaxError"></iron-ajax>
on-error="onAjaxError"></iron-ajax>
<iron-ajax id="ajaxXml"
content-type="application/xml"
handle-as="text"
method="GET"
on-response="_handleAjaxResponse"
on-error="_handleAjaxError"></iron-ajax>
on-error="onAjaxError"></iron-ajax>
</template>
@ -254,14 +255,11 @@
is: 'strolch-wc-inspector-objects',
behaviors: [
StrolchInspectorBehavior
],
properties: {
basePath: {
type: String,
value: './'
},
dlgTitle: {
type: String
},
realm: {
type: String,
value: function () {
@ -591,13 +589,6 @@
_handleAjaxResponse: function (evt) {
console.log('NOT YET DEFINED!');
},
_handleAjaxError: function (data) {
this.fire('strolch-handle-ajax-error', {
title: this.dlgTitle,
detail: data.detail
});
}
});

View File

@ -17,6 +17,7 @@
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<link rel="import" href="strolch-wc-inspector-objects.html">
<dom-module id="strolch-wc-inspector">
@ -95,7 +96,7 @@
<div class="toolbar">
<paper-dropdown-menu always-float-label label="select realm" class="custom">
<paper-dropdown-menu no-label-float label="select realm" class="custom">
<paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedRealm}}">
<template is="dom-repeat" items="{{realms}}">
@ -168,14 +169,14 @@
content-type="application/json"
handle-as="json"
on-response="_handleAjaxResponse"
on-error="_handleAjaxError"></iron-ajax>
on-error="onAjaxError"></iron-ajax>
<iron-ajax id="ajaxXml"
content-type="application/xml"
handle-as="text"
method="GET"
on-response="_handleAjaxResponse"
on-error="_handleAjaxError"></iron-ajax>
on-error="onAjaxError"></iron-ajax>
</template>
@ -185,17 +186,11 @@
is: 'strolch-wc-inspector',
behaviors: [
StrolchInspectorBehavior
],
properties: {
basePath: {
type: String,
value: './'
},
dlgTitle: {
type: String
},
dlgText: {
type: String
},
realms: {
type: Array,
value: function () {
@ -258,10 +253,23 @@
},
listeners: {
"strolch-handle-ajax-error": "onAjaxError",
"strolch-show-dialog": "onShowDialog"
},
onStrolchImport: function (event) {
this.reload();
this.showError('Import complete', event.detail.msg);
},
onShowDialog: function (event) {
this.showError(event.detail.title, event.detail.text);
},
showError: function (title, text) {
this.dlgTitle = title;
this.dlgText = text;
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
this.$.dlg.open();
},
selectedRealmChanged: function (newValue, oldValue) {
if (newValue != null) {
console.log('Selected realm changed from ' + oldValue + " to " + newValue);
@ -277,43 +285,6 @@
}
},
onStrolchImport: function (event) {
this.reload();
this.showError('Import complete', event.detail.msg);
},
onAjaxError: function (event) {
var dlgTitle = event.detail.title;
var data = event.detail;
var dlgText;
if (data.detail.request.response) {
if (data.detail.request.response.msg) {
dlgText = data.detail.request.response.msg;
} else if (data.detail.request.response.charAt(0) == '{') {
var json = JSON.parse(data.detail.request.response);
if (json.msg) {
dlgText = json.msg;
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.error;
}
this.fire('strolch-show-dialog', {
title: dlgTitle,
text: dlgText
});
},
onShowDialog: function (event) {
var dlgTitle = event.detail.title;
var dlgText = event.detail.text;
this.showError(dlgTitle, dlgText);
},
ready: function () {
//
},
@ -467,24 +438,6 @@
_handleAjaxResponse: function (evt) {
console.log('NOT YET DEFINED!');
},
_handleAjaxError: function (data) {
var dlgTitle = 'Debug action failed';
var dlgText;
if (data.detail.request.response) {
dlgText = data.detail.request.response.msg;
} else {
dlgText = data.detail.error;
}
this.showError(dlgTitle, dlgText);
},
showError: function (title, text) {
this.dlgTitle = title;
this.dlgText = text;
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
this.$.dlg.open();
}
});

View File

@ -0,0 +1,248 @@
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-ajax/iron-ajax.html">
<link rel="import" href="../iron-pages/iron-pages.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../paper-styles/color.html">
<link rel="import" href="../paper-material/paper-material.html">
<link rel="import" href="../paper-dialog/paper-dialog.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<dom-module id="strolch-wc-role-privilege">
<template>
<style is="strolch-wc-styles">
:host {
display: block;
margin: 0;
padding: 0;
height: 100%;
}
paper-material {
background-color: white;
}
ul {
list-style: none;
}
</style>
<paper-material class="g-m-4" elevation="1">
<h3 class="g-pl-4 g-pt-1 g-pb-1" on-tap="_toggleOpened">
<template is="dom-if" if="[[!opened]]">
<paper-icon-button icon="arrow-drop-down"></paper-icon-button>
</template>
<template is="dom-if" if="[[opened]]">
<paper-icon-button icon="arrow-drop-up"></paper-icon-button>
</template>
[[privilege.name]]
</h3>
<template is="dom-if" if="[[opened]]">
<div class="g-pt-1 g-pl-4 g-pr-4">
<p class="g-mt-0">Policy: [[privilege.policy]]</p>
<paper-checkbox checked="{{privilege.allAllowed}}">All allowed</paper-checkbox>
<template is="dom-if" if="[[!privilege.allAllowed]]">
<br />
<template is="dom-if" if="[[!hasAllows]]">
<p>Allow List: <i>none</i></p>
</template>
<template is="dom-if" if="[[hasAllows]]">
<p>Allow List:</p>
<ul>
<template is="dom-repeat" items="[[privilege.allowList]]">
<li>
<paper-icon-button icon="delete"
title="Remove"
on-tap="_removeAllowValue"></paper-icon-button>
[[item]]
</li>
</template>
</ul>
</template>
<template is="dom-if" if="[[!hasDenies]]">
<p>Deny List: <i>none</i></p>
</template>
<template is="dom-if" if="[[hasDenies]]">
<p>Deny List:</p>
<ul>
<template is="dom-repeat" items="[[privilege.denyList]]">
<li>
<paper-icon-button icon="delete"
title="Remove"
on-tap="_removeDenyValue"></paper-icon-button>
[[item]]
</li>
</template>
</ul>
</template>
<paper-button on-tap="_addAllowValue">Add Allow</paper-button>
<paper-button on-tap="_addDenyValue">Add Deny</paper-button>
</template>
</div>
</template>
</paper-material>
<paper-dialog id="dlg" modal>
<h2>[[dlgTitle]]</h2>
<paper-input value="{{listValue}}"></paper-input>
<div class="buttons">
<paper-button dialog-confirm autofocus>Close</paper-button>
<paper-button on-tap="_saveAllowDenyValue">Add</paper-button>
</div>
</paper-dialog>
<iron-ajax id="ajax"
content-type="application/json"
handle-as="json"
on-response="_handleAjaxResponse"
on-error="onAjaxError"></iron-ajax>
</template>
<script>
Polymer({
is: 'strolch-wc-role-privilege',
behaviors: [
StrolchInspectorBehavior
],
properties: {
opened: {
type: Boolean,
value: false
},
role: {
type: Object
},
privilege: {
type: Object
},
hasAllows: {
type: Boolean,
computed: 'isNotEmptyArray(privilege.allowList)'
},
hasDenies: {
type: Boolean,
computed: 'isNotEmptyArray(privilege.denyList)'
},
listToAddTo: {
type: String
},
listValue: {
type: String
}
},
observers: [],
ready: function () {
//
},
reload: function () {
},
_handleAjaxResponse: function (evt) {
console.log('NOT YET DEFINED!');
},
_toggleOpened: function (e) {
this.opened = !this.opened;
},
_addAllowValue: function (e) {
this.dlgTitle = "Add Allow Value";
this.listToAddTo = 'allowList';
this.$.dlg.open();
},
_addDenyValue: function (e) {
this.dlgTitle = "Add Deny Value";
this.listToAddTo = 'denyList';
this.$.dlg.open();
},
_saveAllowDenyValue: function (e) {
var path = 'privilege.' + this.listToAddTo;
this.push(path, this.listValue);
this.notifyPath(path);
this.listToAddTo = '';
this.listValue = '';
this.$.dlg.close();
},
_removeAllowValue: function (e) {
var value = e.model.item;
var list = this.privilege.allowList;
var path = 'privilege.allowList';
this._removeValue(value, list, path);
},
_removeDenyValue: function (e) {
var value = e.model.item;
var list = this.privilege.denyList;
var path = 'privilege.denyList';
this._removeValue(value, list, path);
},
_removeValue: function (value, list, path) {
console.log('Removing vlaue ' + value + ' for path ' + path);
for (var i = 0; i < list.length; i++) {
if (list[i] === value) {
list.splice(i, 1);
this.notifySplices(path, [
{
index: i,
removed: [value],
addedCount: 0,
obect: list,
type: 'splice'
}
]);
this.notifyPath(path);
}
}
}
});
</script>
</dom-module>

149
strolch-wc-role.html Normal file
View File

@ -0,0 +1,149 @@
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-ajax/iron-ajax.html">
<link rel="import" href="../iron-pages/iron-pages.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../paper-styles/color.html">
<link rel="import" href="../paper-material/paper-material.html">
<link rel="import" href="../paper-dialog/paper-dialog.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<link rel="import" href="strolch-wc-role-privilege.html">
<dom-module id="strolch-wc-role">
<template>
<style is="strolch-wc-styles">
:host {
display: block;
margin: 0;
padding: 0;
height: 100%;
}
paper-material {
background-color: white;
}
</style>
<paper-material elevation="1">
<h3 class="g-m-3 g-p-2" on-tap="_toggleOpened">
<template is="dom-if" if="[[!opened]]">
<paper-icon-button icon="arrow-drop-down"></paper-icon-button>
</template>
<template is="dom-if" if="[[opened]]">
<paper-icon-button icon="arrow-drop-up"></paper-icon-button>
</template>
[[role.name]]
</h3>
<template is="dom-if" if="[[opened]]">
<template is="dom-repeat" items="[[role.privileges]]" as="privilege">
<strolch-wc-role-privilege base-path="[[basePath]]"
role="[[role]]"
privilege="[[privilege]]"></strolch-wc-role-privilege>
</template>
<paper-button on-tap="reload" autofocus>Cancel</paper-button>
<paper-button on-tap="_addOrUpdateRole">Save</paper-button>
</template>
</paper-material>
<iron-ajax id="ajax"
content-type="application/json"
handle-as="json"
on-response="_handleAjaxResponse"
on-error="onAjaxError"></iron-ajax>
</template>
<script>
Polymer({
is: 'strolch-wc-role',
behaviors: [
StrolchInspectorBehavior
],
properties: {
opened: {
type: Boolean,
value: false
},
role: {
type: Object
},
isNew: {
type: Boolean
}
},
listeners: {},
ready: function () {
//
},
reload: function () {
this.dlgTitle = 'Role query failed';
this._handleAjaxResponse = function (data) {
this.role = data.detail.response;
};
this.$.ajax.url = this.basePath + 'rest/strolch/privilege/roles/' + this.role.name;
this.$.ajax.method = 'GET';
this.$.ajax.generateRequest();
},
_handleAjaxResponse: function (evt) {
console.log('NOT YET DEFINED!');
},
_toggleOpened: function (e) {
this.opened = !this.opened;
},
_addOrUpdateRole: function (e) {
this.dlgTitle = 'Save role failed';
this._handleAjaxResponse = function (data) {
this.fire('strolch-role-reload-needed');
};
if (this.isNew) {
this.$.ajax.url = this.basePath + 'rest/strolch/privilege/roles';
this.$.ajax.method = 'POST';
} else {
this.$.ajax.url = this.basePath + 'rest/strolch/privilege/roles/' + this.role.name;
this.$.ajax.method = 'PUT';
}
this.$.ajax.body = this.role;
this.$.ajax.generateRequest();
}
});
</script>
</dom-module>

142
strolch-wc-roles.html Normal file
View File

@ -0,0 +1,142 @@
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-ajax/iron-ajax.html">
<link rel="import" href="../iron-pages/iron-pages.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../paper-styles/color.html">
<link rel="import" href="../paper-material/paper-material.html">
<link rel="import" href="../paper-dialog/paper-dialog.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<link rel="import" href="strolch-wc-role.html">
<dom-module id="strolch-wc-roles">
<template>
<style is="strolch-wc-styles">
:host {
display: block;
margin: 0;
padding: 0;
height: 100%;
}
paper-button, paper-material {
background-color: white;
}
.g-table {
font-size: small;
}
.g-table thead {
font-weight: bold;
}
.g-table th, .g-table td {
vertical-align: inherit;
}
</style>
<!--div class="g-row g-pt-4">
<div class="g-12 g-right">
<paper-button on-tap="_addRole" raised>Add</paper-button>
</div>
</div-->
<template is="dom-repeat" items="[[roles]]" as="role">
<strolch-wc-role base-path="[[basePath]]"
role="[[role]]"
on-strolch-role-reload-needed="onReload"></strolch-wc-role>
</template>
<paper-dialog id="dlg" modal>
<h2>[[dlgTitle]]</h2>
<p>[[dlgText]]</p>
<div class="buttons">
<paper-button dialog-confirm autofocus>Close</paper-button>
</div>
</paper-dialog>
<iron-ajax id="ajax"
content-type="application/json"
handle-as="json"
on-response="_handleAjaxResponse"
on-error="onAjaxError"></iron-ajax>
</template>
<script>
Polymer({
is: 'strolch-wc-roles',
behaviors: [
StrolchInspectorBehavior
],
properties: {
roles: {
type: Array
}
},
listeners: {
"strolch-show-dialog": "onShowDialog"
},
onShowDialog: function (event) {
this.showError(event.detail.title, event.detail.text);
},
showError: function (title, text) {
this.dlgTitle = title;
this.dlgText = text;
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
this.$.dlg.open();
},
ready: function () {
//
},
onReload: function (e) {
this.reload();
},
reload: function () {
this.dlgTitle = 'Role query failed';
this._handleAjaxResponse = function (data) {
this.roles = data.detail.response;
};
this.$.ajax.url = this.basePath + 'rest/strolch/privilege/roles';
this.$.ajax.method = 'GET';
this.$.ajax.generateRequest();
},
_handleAjaxResponse: function (evt) {
console.log('NOT YET DEFINED!');
}
});
</script>
</dom-module>

View File

@ -17,6 +17,8 @@
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<dom-module id="strolch-wc-sessions">
<template>
@ -102,7 +104,7 @@
content-type="application/json"
handle-as="json"
on-response="_handleAjaxResponse"
on-error="_handleAjaxError"></iron-ajax>
on-error="onAjaxError"></iron-ajax>
</template>
@ -112,17 +114,11 @@
is: 'strolch-wc-sessions',
behaviors: [
StrolchInspectorBehavior
],
properties: {
basePath: {
type: String,
value: './'
},
dlgTitle: {
type: String
},
dlgText: {
type: String
},
sessions: {
type: Array
}
@ -145,38 +141,17 @@
return user.firstname + ' ' + user.lastname;
},
listeners: {},
onAjaxError: function (event) {
var dlgTitle = event.detail.title;
var data = event.detail;
var dlgText;
if (data.detail.request.response) {
if (data.detail.request.response.msg) {
dlgText = data.detail.request.response.msg;
} else if (data.detail.request.response.charAt(0) == '{') {
var json = JSON.parse(data.detail.request.response);
if (json.msg) {
dlgText = json.msg;
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.error;
}
this.fire('strolch-show-dialog', {
title: dlgTitle,
text: dlgText
});
listeners: {
"strolch-show-dialog": "onShowDialog"
},
onShowDialog: function (event) {
var dlgTitle = event.detail.title;
var dlgText = event.detail.text;
this.showError(dlgTitle, dlgText);
this.showError(event.detail.title, event.detail.text);
},
showError: function (title, text) {
this.dlgTitle = title;
this.dlgText = text;
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
this.$.dlg.open();
},
ready: function () {
@ -210,24 +185,6 @@
_handleAjaxResponse: function (evt) {
console.log('NOT YET DEFINED!');
},
_handleAjaxError: function (data) {
var dlgTitle = 'Debug action failed';
var dlgText;
if (data.detail.request.response) {
dlgText = data.detail.request.response.msg;
} else {
dlgText = data.detail.error;
}
this.showError(dlgTitle, dlgText);
},
showError: function (title, text) {
this.dlgTitle = title;
this.dlgText = text;
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
this.$.dlg.open();
}
});

View File

@ -20,6 +20,8 @@
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
<link rel="import" href="strolch-wc-inspector-behavior.html">
<dom-module id="strolch-wc-users">
<template>
@ -217,7 +219,7 @@
content-type="application/json"
handle-as="json"
on-response="_handleAjaxResponse"
on-error="_handleAjaxError"></iron-ajax>
on-error="onAjaxError"></iron-ajax>
</template>
@ -227,17 +229,11 @@
is: 'strolch-wc-users',
behaviors: [
StrolchInspectorBehavior
],
properties: {
basePath: {
type: String,
value: './'
},
dlgTitle: {
type: String
},
dlgText: {
type: String
},
roles: {
type: Array
},
@ -253,61 +249,21 @@
}
},
toLocalDateTime: function (val) {
return Strolch.toLocalDateTime(val);
},
arrayToString: function (arr) {
var s = '';
for (var i = 0; i < arr.length; i++) {
s += arr[i];
if (i + 1 < arr.length)
s += ', ';
}
return s;
},
isEmptyString: function (v) {
return v != null && v.length == 0
},
isNotEmptyString: function (v) {
return v != null && v.length > 0
},
_getName: function (user) {
return user.firstname + ' ' + user.lastname;
},
listeners: {},
onAjaxError: function (event) {
var dlgTitle = event.detail.title;
var data = event.detail;
var dlgText;
if (data.detail.request.response) {
if (data.detail.request.response.msg) {
dlgText = data.detail.request.response.msg;
} else if (data.detail.request.response.charAt(0) == '{') {
var json = JSON.parse(data.detail.request.response);
if (json.msg) {
dlgText = json.msg;
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.error;
}
this.fire('strolch-show-dialog', {
title: dlgTitle,
text: dlgText
});
listeners: {
"strolch-show-dialog": "onShowDialog"
},
onShowDialog: function (event) {
var dlgTitle = event.detail.title;
var dlgText = event.detail.text;
this.showError(dlgTitle, dlgText);
this.showError(event.detail.title, event.detail.text);
},
showError: function (title, text) {
this.dlgTitle = title;
this.dlgText = text;
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
this.$.dlg.open();
},
ready: function () {
@ -420,16 +376,6 @@
console.log('NOT YET DEFINED!');
},
_handleAjaxError: function (data) {
var dlgText;
if (data.detail.request.response) {
dlgText = data.detail.request.response.msg;
} else {
dlgText = data.detail.error;
}
this.showError(this.dlgTitle, dlgText);
},
_validateUser: function (user) {
if (this.isEmptyString(user.username))
return 'Username is not set!';
@ -509,13 +455,6 @@
this.selectedRoles = selectedRoles;
this.$.userDlg.open();
},
showError: function (title, text) {
this.dlgTitle = title;
this.dlgText = text;
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
this.$.dlg.open();
}
});