[Fix] Fixed trying to show model for activities sub elements
This commit is contained in:
parent
fb00551fe1
commit
c836db0f10
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "strolch-wc-inspector",
|
||||
"description": "Strolch WebComponent Inspector",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"authors": "Robert von Burg",
|
||||
"keywords": [
|
||||
"strolch",
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
|
||||
<link rel="import" href="../paper-header-panel/paper-header-panel.html">
|
||||
<link rel="import" href="../paper-input/paper-textarea.html">
|
||||
<link rel="import" href="../paper-radio-group/paper-radio-group.html">
|
||||
<link rel="import" href="../paper-dialog/paper-dialog.html">
|
||||
<link rel="import" href="../paper-button/paper-button.html">
|
||||
|
||||
<link rel="import" href="../iron-ajax/iron-ajax.html">
|
||||
<link rel="import" href="../iron-pages/iron-pages.html">
|
||||
|
@ -85,7 +86,8 @@
|
|||
<div class="g-11">
|
||||
<h1 class="title"><span style="text-transform: uppercase">[[object.objectType]]</span> <span
|
||||
class="sub g-ml-4">Id:</span> [[object.id]] <span class="sub g-ml-4">Name:</span>
|
||||
[[object.name]] <span class="sub g-ml-4">Type:</span> [[object.type]] </h1>
|
||||
[[object.name]] <span class="sub g-ml-4">Type:</span>
|
||||
[[object.type]] </h1>
|
||||
</div>
|
||||
|
||||
<div class="g-1">
|
||||
|
@ -211,7 +213,7 @@
|
|||
|
||||
<template is="dom-if" if="[[_isEmpty(object.parameterBags)]]">
|
||||
<p class="g-center">No parameters defined on [[object.objectType]]
|
||||
[[object.id]]</p>
|
||||
[[object.id]]</p>
|
||||
</template>
|
||||
<template is="dom-if" if="[[_isNotEmpty(object.parameterBags)]]">
|
||||
|
||||
|
@ -266,7 +268,7 @@
|
|||
|
||||
<template is="dom-if" if="[[_isEmpty(object.policies)]]">
|
||||
<p class="g-pt-4 g-center">No policies defined on [[objectName]]
|
||||
[[object.id]]</p>
|
||||
[[object.id]]</p>
|
||||
</template>
|
||||
<template is="dom-if" if="[[_isNotEmpty(object.policies)]]">
|
||||
|
||||
|
@ -306,7 +308,7 @@
|
|||
|
||||
<template is="dom-if" if="[[_isEmpty(object.timedStates)]]">
|
||||
<p class="g-pt-4 g-center">No timed states defined on [[objectName]]
|
||||
[[object.id]]</p>
|
||||
[[object.id]]</p>
|
||||
</template>
|
||||
<template is="dom-if" if="[[_isNotEmpty(object.timedStates)]]">
|
||||
<template is="dom-repeat"
|
||||
|
@ -362,7 +364,6 @@
|
|||
|
||||
<template is="dom-repeat" items="[[object.elements]]" as="childElement">
|
||||
<strolch-wc-inspector-object base-path="[[basePath]]"
|
||||
app="[[app]]"
|
||||
realm="[[realm]]"
|
||||
object="[[childElement]]"
|
||||
class="g-m-2"></strolch-wc-inspector-object>
|
||||
|
@ -387,13 +388,9 @@
|
|||
<paper-radio-button name="json-flat">JSON Flat</paper-radio-button>
|
||||
</paper-radio-group>
|
||||
|
||||
<paper-button raised
|
||||
class="g-pull-right"
|
||||
on-tap="_saveModel">Save
|
||||
<paper-button raised class="g-pull-right" on-tap="_saveModel">Save
|
||||
</paper-button>
|
||||
<paper-button
|
||||
class="g-pull-right"
|
||||
on-tap="_removeModel">Remove
|
||||
<paper-button class="g-pull-right" on-tap="_removeModel">Remove
|
||||
</paper-button>
|
||||
|
||||
</template>
|
||||
|
@ -422,16 +419,16 @@
|
|||
is: 'strolch-wc-inspector-object',
|
||||
|
||||
properties: {
|
||||
app: {
|
||||
type: Object,
|
||||
value: function () {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
basePath: {
|
||||
type: String,
|
||||
value: './'
|
||||
},
|
||||
dlgTitle: {
|
||||
type: String
|
||||
},
|
||||
dlgText: {
|
||||
type: String
|
||||
},
|
||||
realm: {
|
||||
type: String,
|
||||
value: function () {
|
||||
|
@ -520,8 +517,7 @@
|
|||
},
|
||||
|
||||
_isEmpty: function (obj) {
|
||||
if (obj == null)
|
||||
return true;
|
||||
if (obj == null) return true;
|
||||
if (obj instanceof Array) {
|
||||
return obj.length == 0;
|
||||
} else if (obj instanceof Object) {
|
||||
|
@ -535,8 +531,7 @@
|
|||
},
|
||||
|
||||
_asArray: function (obj) {
|
||||
if (!obj)
|
||||
return [];
|
||||
if (!obj) return [];
|
||||
return Object.keys(obj).map(function (key) {
|
||||
return {
|
||||
key: key,
|
||||
|
@ -579,8 +574,7 @@
|
|||
},
|
||||
|
||||
reloadModel: function () {
|
||||
if (this._isAction(this.object.objectType))
|
||||
return;
|
||||
if (this._isAction(this.object.objectType)) return;
|
||||
|
||||
var accept = this._getAcceptHeader();
|
||||
var url = this._getObjectUrl();
|
||||
|
@ -664,7 +658,14 @@
|
|||
} else {
|
||||
dlgText = data.detail.error;
|
||||
}
|
||||
this.app.showError(dlgTitle, dlgText);
|
||||
this.showError(dlgTitle, dlgText);
|
||||
},
|
||||
|
||||
showError: function (title, text) {
|
||||
this.dlgTitle = title;
|
||||
this.dlgText = text;
|
||||
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
|
||||
this.$.dlg.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
<link rel="import" href="../paper-toolbar/paper-toolbar.html">
|
||||
<link rel="import" href="../paper-input/paper-input.html">
|
||||
<link rel="import" href="../paper-dialog/paper-dialog.html">
|
||||
<link rel="import" href="../paper-button/paper-button.html">
|
||||
|
||||
<link rel="import" href="../iron-ajax/iron-ajax.html">
|
||||
<link rel="import" href="../iron-icon/iron-icon.html">
|
||||
<link rel="import" href="../iron-pages/iron-pages.html">
|
||||
<link rel="import" href="../iron-icon/iron-icon.html">
|
||||
<link rel="import" href="../iron-icons/communication-icons.html">
|
||||
|
||||
<link rel="import" href="../strolch-wc-styles/strolch-wc-styles.html">
|
||||
|
||||
|
@ -45,7 +49,7 @@
|
|||
|
||||
paper-input {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
right: 60px;
|
||||
|
||||
--paper-input-container-color: var(--regular-color);
|
||||
--paper-input-container-focus-color: var(--focus-color);
|
||||
|
@ -81,6 +85,32 @@
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
width: calc(100% - 40px);
|
||||
height: 100%;
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
paper-dialog {
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.g-container {
|
||||
margin: 0 10px 50px 10px;
|
||||
width: calc(100% - 40px);
|
||||
}
|
||||
|
||||
.card-import-btn {
|
||||
background-color: #faebd7;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<template is="dom-if" if="[[_noElements(objectSummaries)]]" restamp>
|
||||
|
@ -93,6 +123,18 @@
|
|||
|
||||
<section name="typesSummary" class="g-pt-4">
|
||||
|
||||
<div class="g-row">
|
||||
<div class="g-offset-4 g-4">
|
||||
<paper-material class="card card-import-btn g-m-2 g-p-4"
|
||||
elevation="1"
|
||||
on-tap="onImportTapped">
|
||||
<iron-icon icon="communication:import-export"></iron-icon>
|
||||
Import
|
||||
</paper-material>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<template is="dom-repeat" items="[[objectSummaries.types]]">
|
||||
<div class="g-row">
|
||||
<div class="g-offset-4 g-4">
|
||||
|
@ -119,11 +161,13 @@
|
|||
<iron-icon suffix icon="clear" id="clear" on-tap="onClearTapped"></iron-icon>
|
||||
</template>
|
||||
</paper-input>
|
||||
<!--paper-icon-button icon="add-box"
|
||||
class="add-btn"
|
||||
on-tap="onAddTapped"></paper-icon-button-->
|
||||
</paper-toolbar>
|
||||
|
||||
<template is="dom-repeat" items="[[objects.data]]">
|
||||
<strolch-wc-inspector-object base-path="[[basePath]]"
|
||||
app="[[app]]"
|
||||
realm="[[realm]]"
|
||||
is-root-element="true"
|
||||
on-strolch-wc-obj-remove="onRemoveElement"
|
||||
|
@ -151,6 +195,31 @@
|
|||
|
||||
</template>
|
||||
|
||||
<paper-dialog class="addDlg" opened="[[addDlgOpen]]" modal>
|
||||
<h3>[[importDlgTitle]]</h3>
|
||||
|
||||
<textarea value="{{modelAsText::input}}"></textarea>
|
||||
|
||||
<div class="g-container">
|
||||
<paper-button class="g-pull-right" on-tap="onSaveTap" raised>
|
||||
<iron-icon icon="add"></iron-icon>
|
||||
Add
|
||||
</paper-button>
|
||||
<paper-button class="g-pull-right" on-tap="onCancelTap" raised>
|
||||
<iron-icon icon="close"></iron-icon>
|
||||
Cancel
|
||||
</paper-button>
|
||||
</div>
|
||||
</paper-dialog>
|
||||
|
||||
<paper-dialog id="dlg" modal on-iron-overlay-closed="onCloseDlg">
|
||||
<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"
|
||||
|
@ -166,16 +235,16 @@
|
|||
is: 'strolch-wc-inspector-objects',
|
||||
|
||||
properties: {
|
||||
app: {
|
||||
type: Object,
|
||||
value: function () {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
basePath: {
|
||||
type: String,
|
||||
value: './'
|
||||
},
|
||||
dlgTitle: {
|
||||
type: String
|
||||
},
|
||||
dlgText: {
|
||||
type: String
|
||||
},
|
||||
realm: {
|
||||
type: String,
|
||||
value: function () {
|
||||
|
@ -231,6 +300,26 @@
|
|||
value: function () {
|
||||
return 20;
|
||||
}
|
||||
},
|
||||
|
||||
addDlgOpen: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
importType: {
|
||||
type: String,
|
||||
value: 'import'
|
||||
},
|
||||
modelAsText: {
|
||||
type: String,
|
||||
value: ''
|
||||
},
|
||||
modelType: {
|
||||
type: String,
|
||||
value: function () {
|
||||
return 'xml';
|
||||
},
|
||||
observer: "_modelTypeChanged"
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -243,8 +332,7 @@
|
|||
},
|
||||
|
||||
observeSearchTerm: function (newValue, oldValue) {
|
||||
if (this.realm == null || this.objectType == null || this.selectedType == null)
|
||||
return;
|
||||
if (this.realm == null || this.objectType == null || this.selectedType == null) return;
|
||||
|
||||
this.debounce("doSearch", function () {
|
||||
this.reloadTypeDetails();
|
||||
|
@ -299,8 +387,7 @@
|
|||
},
|
||||
|
||||
_getEnd: function (objects) {
|
||||
if (this._hasNext(objects))
|
||||
return objects.nextOffset;
|
||||
if (this._hasNext(objects)) return objects.nextOffset;
|
||||
return objects == null ? 0 : objects.size;
|
||||
},
|
||||
|
||||
|
@ -321,6 +408,89 @@
|
|||
this.reloadTypeDetails(this.objects.lastOffset);
|
||||
},
|
||||
|
||||
onImportTapped: function (event) {
|
||||
this.set('importDlgTitle', 'Import Elements as XML');
|
||||
this.importType = 'import';
|
||||
this.addDlgOpen = true;
|
||||
},
|
||||
onAddTapped: function (event) {
|
||||
this.set('importDlgTitle', 'Add ' + this.objectType + ' of type ' + this.selectedType);
|
||||
this.importType = 'add';
|
||||
this.addDlgOpen = true;
|
||||
},
|
||||
onCancelTap: function (event) {
|
||||
this.modelAsText = '';
|
||||
this.addDlgOpen = false;
|
||||
},
|
||||
onSaveTap: function (event) {
|
||||
if (!this.modelAsText || this.modelAsText == null || this.modelAsText == '') {
|
||||
this.showError('Model empty', 'Model can not be empty!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.importType == 'import') {
|
||||
|
||||
this._handleAjaxResponse = function (data) {
|
||||
this.modelAsText = '';
|
||||
this.addDlgOpen = false;
|
||||
this.fire('strolch-import', {msg: data.detail.response.msg});
|
||||
};
|
||||
|
||||
this.$.ajax.url = this.basePath + 'rest/strolch/inspector/' + this.realm + '/import';
|
||||
this.$.ajax.headers = {
|
||||
'Accept': 'application/xml',
|
||||
'Content-Type': 'application/xml'
|
||||
};
|
||||
this.$.ajax.handleAs = 'json';
|
||||
this.$.ajax.method = 'POST';
|
||||
this.$.ajax.body = this.modelAsText;
|
||||
this.$.ajax.generateRequest();
|
||||
} else {
|
||||
|
||||
var accept = this._getAcceptHeader();
|
||||
var url = this._getObjectUrl();
|
||||
if (this.modelType == 'json-flat') {
|
||||
url += '?flat=true';
|
||||
}
|
||||
|
||||
this._handleAjaxResponse = function (data) {
|
||||
console.log(data);
|
||||
};
|
||||
|
||||
this.$.ajax.url = url;
|
||||
this.$.ajax.headers = {
|
||||
'Accept': accept,
|
||||
'Content-Type': accept
|
||||
};
|
||||
this.$.ajax.handleAs = 'text';
|
||||
this.$.ajax.method = 'POST';
|
||||
this.$.ajax.body = this.modelAsText;
|
||||
this.$.ajax.generateRequest();
|
||||
}
|
||||
},
|
||||
|
||||
_getAcceptHeader: function () {
|
||||
if (this.modelType == 'xml') {
|
||||
return 'application/xml'
|
||||
} else if (this.modelType == 'json') {
|
||||
return 'application/json'
|
||||
} else if (this.modelType == 'json-flat') {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return 'application/xml';
|
||||
}
|
||||
},
|
||||
|
||||
_getObjectUrl: function () {
|
||||
var objectType = this.objectType;
|
||||
var type = this.selectedType;
|
||||
var url = this.basePath + 'rest/strolch/inspector/' + this.realm + '/' + this._typeSubPath(objectType);
|
||||
if (this.modelType == 'json-flat') {
|
||||
url += '/' + type + '/';
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
onRemoveElement: function (event) {
|
||||
console.log("Delete element " + event.detail.object.id);
|
||||
|
||||
|
@ -349,6 +519,11 @@
|
|||
|
||||
this.$.ajax.url = url;
|
||||
this.$.ajax.method = 'GET';
|
||||
this.$.ajax.handleAs = 'json';
|
||||
this.$.ajax.headers = {
|
||||
'Accept': 'application/json'
|
||||
};
|
||||
this.$.ajax.contentType = 'application/json';
|
||||
this.$.ajax.generateRequest();
|
||||
},
|
||||
|
||||
|
@ -365,14 +540,25 @@
|
|||
},
|
||||
|
||||
_handleAjaxError: function (data) {
|
||||
var dlgTitle = 'Debug action failed';
|
||||
var dlgTitle = 'Server action failed';
|
||||
var dlgText;
|
||||
if (data.detail.request.response) {
|
||||
dlgText = data.detail.request.response.msg;
|
||||
if (data.detail.request.response.msg) {
|
||||
dlgText = data.detail.request.response.msg;
|
||||
} else {
|
||||
dlgText = data.detail.request.response;
|
||||
}
|
||||
} else {
|
||||
dlgText = data.detail.error;
|
||||
}
|
||||
this.app.showError(dlgTitle, dlgText);
|
||||
this.showError(dlgTitle, dlgText);
|
||||
},
|
||||
|
||||
showError: function (title, text) {
|
||||
this.dlgTitle = title;
|
||||
this.dlgText = text;
|
||||
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
|
||||
this.$.dlg.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
<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-button/paper-button.html">
|
||||
|
||||
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
|
||||
<link rel="import" href="../paper-item/paper-item.html">
|
||||
|
@ -129,21 +131,19 @@
|
|||
<iron-pages selected="{{selectedObjectType}}" attr-for-selected="name">
|
||||
<section name="Resource">
|
||||
<strolch-wc-inspector-objects base-path="[[basePath]]"
|
||||
app="[[app]]"
|
||||
realm="[[selectedRealm]]"
|
||||
object-type="Resource"
|
||||
object-summaries="[[resources]]"></strolch-wc-inspector-objects>
|
||||
object-summaries="[[resources]]"
|
||||
on-strolch-import="onStrolchImport"></strolch-wc-inspector-objects>
|
||||
</section>
|
||||
<section name="Order">
|
||||
<strolch-wc-inspector-objects base-path="[[basePath]]"
|
||||
app="[[app]]"
|
||||
realm="[[selectedRealm]]"
|
||||
object-type="Order"
|
||||
object-summaries="[[orders]]"></strolch-wc-inspector-objects>
|
||||
</section>
|
||||
<section name="Activity">
|
||||
<strolch-wc-inspector-objects base-path="[[basePath]]"
|
||||
app="[[app]]"
|
||||
realm="[[selectedRealm]]"
|
||||
object-type="Activity"
|
||||
object-summaries="[[activities]]"></strolch-wc-inspector-objects>
|
||||
|
@ -153,6 +153,14 @@
|
|||
|
||||
</div>
|
||||
|
||||
<paper-dialog id="dlg" modal on-iron-overlay-closed="onCloseDlg">
|
||||
<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"
|
||||
|
@ -168,16 +176,16 @@
|
|||
is: 'strolch-wc-inspector',
|
||||
|
||||
properties: {
|
||||
app: {
|
||||
type: Object,
|
||||
value: function () {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
basePath: {
|
||||
type: String,
|
||||
value: './'
|
||||
},
|
||||
dlgTitle: {
|
||||
type: String
|
||||
},
|
||||
dlgText: {
|
||||
type: String
|
||||
},
|
||||
realms: {
|
||||
type: Array,
|
||||
value: function () {
|
||||
|
@ -254,6 +262,11 @@
|
|||
}
|
||||
},
|
||||
|
||||
onStrolchImport: function (event) {
|
||||
this.reload();
|
||||
this.showError('Import complete', event.detail.msg);
|
||||
},
|
||||
|
||||
ready: function () {
|
||||
//
|
||||
},
|
||||
|
@ -354,12 +367,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.selectedObjectType == 'Resource' && this.resources != null)
|
||||
return;
|
||||
if (this.selectedObjectType == 'Order' && this.orders != null)
|
||||
return;
|
||||
if (this.selectedObjectType == 'Activity' && this.activities != null)
|
||||
return;
|
||||
if (this.selectedObjectType == 'Resource' && this.resources != null) return;
|
||||
if (this.selectedObjectType == 'Order' && this.orders != null) return;
|
||||
if (this.selectedObjectType == 'Activity' && this.activities != null) return;
|
||||
|
||||
this._handleAjaxResponse = function (data) {
|
||||
switch (data.detail.response.objectType) {
|
||||
|
@ -406,7 +416,14 @@
|
|||
} else {
|
||||
dlgText = data.detail.error;
|
||||
}
|
||||
this.app.showError(dlgTitle, dlgText);
|
||||
this.showError(dlgTitle, dlgText);
|
||||
},
|
||||
|
||||
showError: function (title, text) {
|
||||
this.dlgTitle = title;
|
||||
this.dlgText = text;
|
||||
console.log('ERROR: ' + this.dlgTitle + ': ' + this.dlgText);
|
||||
this.$.dlg.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue