Revision 57673
Added by Konstantinos Triantafyllou over 4 years ago
home.component.ts | ||
---|---|---|
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
public ngOnDestroy() { |
61 |
this.subscriptions.forEach( value => {
|
|
62 |
if(value instanceof Subscriber) { |
|
61 |
this.subscriptions.forEach(value => { |
|
62 |
if (value instanceof Subscriber) {
|
|
63 | 63 |
value.unsubscribe(); |
64 | 64 |
} |
65 | 65 |
}); |
... | ... | |
87 | 87 |
} |
88 | 88 |
|
89 | 89 |
public saveTopicOpen(element, index = -1) { |
90 |
if(element.className.indexOf('uk-open') !== -1) { |
|
90 |
if (element.className.indexOf('uk-open') !== -1) {
|
|
91 | 91 |
this.hide(element); |
92 | 92 |
} else { |
93 | 93 |
if (index === -1) { |
... | ... | |
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
public saveTopic(element, index = -1) { |
103 |
if(this.copyTopic.name && this.copyTopic.name !== '') { |
|
104 |
if(!this.copyTopic.alias) { |
|
103 |
if (this.copyTopic.name && this.copyTopic.name !== '') {
|
|
104 |
if (!this.copyTopic.alias) {
|
|
105 | 105 |
this.copyTopic.alias = this.copyTopic.name.toLowerCase().trim(); |
106 | 106 |
} |
107 |
if(index === -1) { |
|
108 |
this.stakeholder.topics.push(this.copyTopic); |
|
107 |
if (index === -1) { |
|
109 | 108 |
this.save('Topic has been successfully created', element); |
110 | 109 |
} else { |
111 |
this.stakeholder.topics[index] = HelperFunctions.copy(this.copyTopic); |
|
112 |
this.save('Topic has been successfully saved', element); |
|
110 |
this.save('Topic has been successfully saved', element, index); |
|
113 | 111 |
} |
114 | 112 |
} else { |
115 | 113 |
this.valid = false; |
... | ... | |
126 | 124 |
this.deleteTopicModal.open(); |
127 | 125 |
} |
128 | 126 |
|
129 |
private save(message: string, element) { |
|
130 |
this.stakeholderService.saveStakeholder(this.properties.monitorServiceAPIURL, this.stakeholder).subscribe(stakeholder => { |
|
131 |
this.stakeholderService.setStakeholder(stakeholder); |
|
127 |
private save(message: string, element, index: number = -1) { |
|
128 |
let path = [this.stakeholder._id]; |
|
129 |
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.copyTopic, path).subscribe(topic => { |
|
130 |
if (index === -1) { |
|
131 |
this.stakeholder.topics.push(topic); |
|
132 |
} else { |
|
133 |
this.stakeholder.topics[index] = topic; |
|
134 |
} |
|
135 |
this.stakeholderService.setStakeholder(this.stakeholder); |
|
132 | 136 |
UIkit.notification(message, { |
133 | 137 |
status: 'success', |
134 | 138 |
timeout: 3000, |
... | ... | |
147 | 151 |
|
148 | 152 |
deleteTopic() { |
149 | 153 |
let path = [ |
150 |
this.stakeholder.alias,
|
|
151 |
this.stakeholder.topics[this.index].alias
|
|
154 |
this.stakeholder._id,
|
|
155 |
this.stakeholder.topics[this.index]._id
|
|
152 | 156 |
]; |
153 |
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(stakeholder => { |
|
154 |
this.stakeholderService.setStakeholder(stakeholder); |
|
157 |
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(() => { |
|
158 |
this.stakeholder.topics.splice(this.index, 1); |
|
159 |
this.stakeholderService.setStakeholder(this.stakeholder); |
|
155 | 160 |
UIkit.notification('Topic has been successfully deleted', { |
156 | 161 |
status: 'success', |
157 | 162 |
timeout: 3000, |
Also available in: Unified diff
[Monitor Dashboard]: Complete indicator save and reorder.