Skip to content
This repository was archived by the owner on Mar 21, 2022. It is now read-only.

Commit 94e69a5

Browse files
author
Helge Müller
committed
mock landscapeservice
1 parent 20a743a commit 94e69a5

File tree

9 files changed

+110
-103
lines changed

9 files changed

+110
-103
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Interaction from 'explorviz-frontend/utils/application-rendering/interaction'
22
import { inject as service } from "@ember/service";
3+
import AlertifyHandler from 'explorviz-frontend/mixins/alertify-handler';
34

4-
export default Interaction.extend({
5+
export default Interaction.extend(AlertifyHandler,{
56
landscapeService: service()
67
});
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Interaction from 'explorviz-frontend/utils/landscape-rendering/interaction'
22
import { inject as service } from "@ember/service";
3+
import AlertifyHandler from 'explorviz-frontend/mixins/alertify-handler';
34

4-
export default Interaction.extend({
5+
export default Interaction.extend(AlertifyHandler,{
56
landscapeService: service()
67
});

addon/components/landscape-visualization.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import layout from '../templates/components/landscape-visualization';
22
import LandscapeRendering from 'explorviz-frontend/components/visualization/rendering/landscape-rendering'
33
import { inject as service } from '@ember/service';
44
import { getOwner } from '@ember/application';
5+
import AlertifyHandler from 'explorviz-frontend/mixins/alertify-handler';
56

67

7-
export default LandscapeRendering.extend({
8+
export default LandscapeRendering.extend(AlertifyHandler,{
89
layout,
910
landscapeService:service(),
1011
tutorialService:service(),
@@ -31,7 +32,7 @@ export default LandscapeRendering.extend({
3132
this.get('interaction').on('showApplication', function (emberModel) {
3233
self.set('landscapeService.application', emberModel);
3334
});
34-
35+
3536
this.get('interaction').on('singleClick', this.get('clickListenerSingle'));
3637
this.get('interaction').on('doubleClick', this.get('clickListenerDouble'));
3738
},

addon/components/step-form.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export default Component.extend(AlertifyHandler,{
5151
toggleSelectTarget(){
5252
this.set('landscapeService.landscapeinteraction.selectTarget',!this.get('landscapeService.landscapeinteraction.selectTarget'));
5353
this.set('landscapeService.applicationinteraction.selectTarget',!this.get('landscapeService.applicationinteraction.selectTarget'));
54+
},
55+
removeTarget(){
56+
this.set('model.targetType',"");
57+
this.set('model.targetId',"");
58+
this.set('model.actionType',"");
5459
}
5560
},
5661
showReasonErrorAlert(reason) {

addon/serializers/tutoriallandscape.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ import SaveRelationshipsMixin from 'ember-data-save-relationships';
66

77
export default LandscapeSerializer.extend(SaveRelationshipsMixin,{
88
attrs: {
9+
events:{serialize:true},
910
systems:{serialize:true},
1011
totalApplicationCommunications:{serialize:true}
1112
},
1213
payloadKeyFromModelName(model){
1314
return model;
1415
},
1516
serializeRecordForIncluded(key,relationship){
17+
if(this.serializedTypes.indexOf(key)!==-1){
18+
return;
19+
}
1620
if (relationship.kind === 'belongsTo') {
1721
var nextSnapshot = this.belongsTo(key);
1822
nextSnapshot.serializedTypes=this.serializedTypes;
1923
nextSnapshot.included=this.included;
2024
if(nextSnapshot.record.threeJSModel!=undefined){
2125
nextSnapshot.record.set('threeJSModel', null);
2226
}
23-
if(this.serializedTypes.indexOf(nextSnapshot.get('id'))==-1){
24-
this.serializedTypes.push(nextSnapshot.get('id'));
27+
if(this.serializedTypes.indexOf(key)==-1){
28+
this.serializedTypes.push(key);
2529
nextSnapshot.serializeRecordForIncluded=this.serializeRecordForIncluded;
2630
if(nextSnapshot.record.get('id')!=undefined){
2731
this.included.push(nextSnapshot.record.serialize({includeId:true}).data);
@@ -33,9 +37,10 @@ export default LandscapeSerializer.extend(SaveRelationshipsMixin,{
3337
var self=this;
3438
var nkey=key;
3539
var hasmany=this.hasMany(nkey);
40+
if(hasmany!=undefined){
3641
hasmany.forEach(function(v){
3742
if(v.record.threeJSModel!=undefined){
38-
v.record.set('threeJSModel', null);
43+
v.record.set('threeJSModel', null);
3944
}
4045
if(self.included==undefined){
4146
self.included=[];
@@ -45,31 +50,34 @@ export default LandscapeSerializer.extend(SaveRelationshipsMixin,{
4550
hasmany.forEach(function(value){
4651
value.serializedTypes=self.serializedTypes;
4752
value.included=self.included;
53+
if(self.serializedTypes.indexOf(nkey)==-1){
54+
self.serializedTypes.push(nkey);
55+
}
4856
value.serializeRecordForIncluded=self.serializeRecordForIncluded;
4957
value.eachRelationship(self.serializeRecordForIncluded,value);
5058
self.included.concat(value.included);
5159
});
5260
}
5361
});
5462
}
63+
}
5564
},
5665
serialize(snapshot) {
5766
let json = this._super(...arguments);
67+
// snapshot.hasMany('systems').forEach(function(v,k){
68+
// delete json.data.relationships.systems.data[k].attributes.threeJSModel;
69+
// });
70+
//
71+
// snapshot.hasMany('totalApplicationCommunications').forEach(function(v,k){
72+
// delete json.data.relationships.totalApplicationCommunications.data[k].attributes.threeJSModel;
73+
// });
5874

5975
snapshot.serializeRecordForIncluded=this.serializeRecordForIncluded;
6076
snapshot.serializedTypes=[];
6177
snapshot.included=[];
6278
snapshot.eachRelationship(this.serializeRecordForIncluded,snapshot);
6379

64-
snapshot.hasMany('systems').forEach(function(v,k){
65-
delete json.data.relationships.systems.data[k].attributes.threeJSModel;
66-
});
67-
68-
snapshot.hasMany('totalApplicationCommunications').forEach(function(v,k){
69-
delete json.data.relationships.totalApplicationCommunications.data[k].attributes.threeJSModel;
70-
});
71-
72-
json.included=snapshot.included;
80+
json.included=snapshot.included;
7381
var newjson={
7482
data:{
7583
id: snapshot.record.get('id'),
@@ -100,7 +108,7 @@ json.included=snapshot.included;
100108
},
101109
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
102110
var json = {};
103-
if(Array.isArray(payload.data) ){
111+
if(Array.isArray(payload.data)){
104112
json = {data:[]};
105113
payload.data.forEach(function(v,k){
106114
json.data[k]=JSON.parse(v.attributes.landscape).data;
@@ -119,10 +127,6 @@ json.included=snapshot.included;
119127
json.included=payload.included;
120128
}
121129
}
122-
// if(requestType=="queryRecord"){
123-
// json.data=json.data[0];
124-
// return this._super(store, primaryModelClass, json, id, requestType);
125-
// }
126130
return this._super(store, primaryModelClass, json, id, requestType);
127131
}
128132
});

addon/services/landscape-service.js

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,48 @@ export default Service.extend(Evented, {
5151
}
5252
},
5353
importLandscape(landscapeTimestamp,name){
54-
this.get('store').queryRecord('tutoriallandscape', { timestamp: landscapeTimestamp }).then((tutlandscape) => {
55-
this.set('landscape',tutlandscape);
56-
}, () => {
57-
this.get('store').queryRecord('landscape', { timestamp: landscapeTimestamp }).then((landscape) => {
58-
if(!this.get('store').hasRecordForId('tutoriallandscape',landscape.get('id'))){
59-
if(name=="" ||name == undefined){
60-
name="new landscape";
61-
}
62-
var timestamprecord=this.get('store').createRecord("tutorialtimestamp",{
63-
id:landscape.get('timestamp.id'),
64-
timestamp:landscape.get('timestamp.timestamp'),
65-
totalRequests:landscape.get('timestamp.totalRequests'),
66-
name:name,
67-
});
68-
var landscaperecord = this.get('store').createRecord("tutoriallandscape",{
69-
id:landscape.get('id'),
70-
systems:landscape.get('systems'),
71-
events:landscape.get('events'),
72-
totalApplicationCommunications:landscape.get('totalApplicationCommunications'),
73-
timestamp:timestamprecord
74-
});
75-
timestamprecord.save();
76-
landscaperecord.save();
77-
this.set('landscape',landscaperecord);
78-
}else{
79-
this.set('landscape',landscape);
80-
}
81-
});
82-
});
54+
var mockBackend= true;
55+
if(mockBackend){
56+
this.get('store').queryRecord('landscape', { timestamp: landscapeTimestamp }).then((landscape) => {
57+
var timestamprecord=this.get('store').createRecord("tutorialtimestamp",{
58+
id:landscape.get('timestamp.id'),
59+
timestamp:landscape.get('timestamp.timestamp'),
60+
totalRequests:landscape.get('timestamp.totalRequests'),
61+
name:name,
62+
});
63+
timestamprecord.save();
64+
this.set('landscape',landscape);
65+
});
66+
}else{
67+
this.get('store').queryRecord('tutoriallandscape', { timestamp: landscapeTimestamp }).then((tutlandscape) => {
68+
this.set('landscape',tutlandscape);
69+
}, () => {
70+
this.get('store').queryRecord('landscape', { timestamp: landscapeTimestamp }).then((landscape) => {
71+
if(!this.get('store').hasRecordForId('tutoriallandscape',landscape.get('id'))){
72+
if(name=="" ||name == undefined){
73+
name="new landscape";
74+
}
75+
var timestamprecord=this.get('store').createRecord("tutorialtimestamp",{
76+
id:landscape.get('timestamp.id'),
77+
timestamp:landscape.get('timestamp.timestamp'),
78+
totalRequests:landscape.get('timestamp.totalRequests'),
79+
name:name,
80+
});
81+
var landscaperecord = this.get('store').createRecord("tutoriallandscape",{
82+
id:landscape.get('id'),
83+
systems:landscape.get('systems'),
84+
events:landscape.get('events'),
85+
totalApplicationCommunications:landscape.get('totalApplicationCommunications'),
86+
timestamp:timestamprecord
87+
});
88+
timestamprecord.save();
89+
landscaperecord.save();
90+
this.set('landscape',landscaperecord);
91+
}else{
92+
this.set('landscape',landscape);
93+
}
94+
});
95+
});
96+
}
8397
},
8498
})

addon/templates/components/sequence-form.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{{#link-to "tutorial.list"}}{{svg-jar "reply" class="octicon align-middle"}}{{/link-to}}
22
{{#bs-form model=model onSubmit=(action "saveSequenceChanges" model) as |form|}}
3-
{{form.element controlType="text" label="ID" property="id" disabled=true}}
43
{{form.element controlType="text" label="Title" placeholder="Enter New Sequence Title" property="title"}}
54
{{bs-button defaultText="Save" type="primary" buttonType="submit"}}
65
{{/bs-form}}

addon/templates/components/step-form.hbs

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,40 @@
55
{{form.element controlType="text" label="ID" property="id" disabled=true}}
66
{{form.element controlType="text" label="Title" placeholder="Enter New Step Title" property="title"}}
77
{{form.element controlType="textarea" label="Text" placeholder="Text" property="text"}}
8-
<div>
9-
{{#unless model.targetType}}
10-
{{#unless model.actionType}}
11-
{{#unless model.targetId}}
12-
no target selected
13-
{{/unless}}
14-
{{/unless}}
15-
{{/unless}}
16-
{{#if model.targetType}}
17-
Target: {{model.targetType}}
18-
{{/if}}
19-
<br>
20-
{{#if model.actionType}}
21-
Action: {{model.actionType}}
22-
{{/if}}
23-
</div>
248
{{bs-button defaultText="Save" type="primary" buttonType="submit"}}
259
{{/bs-form}}
26-
{{#unless landscapeService.application}}
27-
{{#bs-button
28-
onClick=(action "toggleSelectTarget")
29-
type="secondary"
30-
outline=true
31-
title="select target"
32-
}}
33-
{{if landscapeService.landscapeinteraction.selectTarget "selecting" "select target"}}
34-
{{/bs-button}}
35-
{{else}}
36-
{{#bs-button
37-
onClick=(action "toggleSelectTarget")
38-
type="secondary"
39-
outline=true
40-
title="select target"
41-
}}
42-
{{if landscapeService.applicationinteraction.selectTarget "selecting" "select target"}}
43-
{{/bs-button}}
44-
{{/unless}}
10+
{{#bs-dropdown as |dd|}}
11+
{{#dd.button class="removecaret d-flex-center" size="sm" title="Options"}}
12+
{{svg-jar "kebab-vertical" class="octicon"}}
13+
{{/dd.button}}
14+
{{#dd.menu as |ddm|}}
15+
{{#ddm.item title="Run"}}
16+
<a class="dropdown-item d-flex-center" style="cursor: pointer" title="Run" {{action "toggleSelectTarget"}}>
17+
{{svg-jar "play" class="octicon" id="run-button"}}<span>Select Target</span>
18+
</a>
19+
{{/ddm.item}}
20+
{{#ddm.item title="Run"}}
21+
<a class="dropdown-item d-flex-center" style="cursor: pointer" title="Run" {{action "removeTarget"}}>
22+
{{svg-jar "trashcan" class="octicon" id="run-button"}}<span>Remove target</span>
23+
</a>
24+
{{/ddm.item}}
25+
{{#ddm.item title="Info"}}
26+
{{#unless model.targetType}}
27+
{{#unless model.actionType}}
28+
{{#unless model.targetId}}
29+
<span class='dropdown-item d-flex-center'>no target selected</span>
30+
{{/unless}}
31+
{{/unless}}
32+
{{/unless}}
33+
{{#if model.targetType}}
34+
<span class='dropdown-item d-flex-center'>Target: {{model.targetType}}</span>
35+
{{/if}}
36+
{{#if model.actionType}}
37+
<span class='dropdown-item d-flex-center'>Action: {{model.actionType}}</span>
38+
{{/if}}
39+
{{/ddm.item}}
40+
{{/dd.menu}}
41+
{{/bs-dropdown}}
4542
{{else}}
4643
{{#unless model.targetType}}
4744
{{#unless model.actionType}}
@@ -57,17 +54,9 @@
5754
{{/unless}}
5855
{{/unless}}
5956
{{/unless}}
60-
{{#if model.targetType}}
61-
Target: {{model.targetType}}
62-
{{/if}}
63-
<br>
64-
{{#if model.actionType}}
65-
Action: {{model.actionType}}
66-
{{/if}}
67-
6857
<h2>{{model.title}}</h2>
6958
<p>{{model.text}}</p>
7059
{{/unless}}
7160
{{else}}
7261
no step loaded
73-
{{/if}}
62+
{{/if}}

addon/templates/components/tutorial-form.hbs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
{{#link-to "tutorial.list"}}{{svg-jar "reply" class="octicon align-middle"}}{{/link-to}}
2-
{{form.element controlType="text" label="Landscape" placeholder="Enter landscape timestamp" property="landscapeTimestamp"}}
32
{{#bs-form model=model onSubmit=(action "saveTutorialChanges" model) as |form|}}
4-
{{form.element controlType="text" label="ID" property="id" disabled=true}}
53
{{form.element controlType="text" label="Title" placeholder="Enter new tutorial title" property="title"}}
6-
7-
{{!-- {{#link-to "tutorial.edit.tutorial.landscape" model}}
8-
{{#if landscapeService.landscape}}edit landscape{{else}}select landscape{{/if}}
9-
{{/link-to}} --}}
10-
{{bs-button defaultText="Save" type="primary" buttonType="submit"}}
11-
4+
{{bs-button defaultText="Save it" type="primary" buttonType="submit"}}
125
{{/bs-form}}
136
{{#bs-dropdown as |dd|}}
147
{{#dd.button class="removecaret d-flex-center" size="sm" title="Options"}}

0 commit comments

Comments
 (0)