Revision 57697
Added by Konstantinos Triantafyllou over 4 years ago
home.component.ts | ||
---|---|---|
11 | 11 |
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class"; |
12 | 12 |
import {AlertModal} from "../openaireLibrary/utils/modal/alert"; |
13 | 13 |
import {Subscriber} from "rxjs"; |
14 |
import {FormBuilder, FormGroup, Validators} from "@angular/forms"; |
|
14 | 15 |
|
15 | 16 |
declare var UIkit; |
16 | 17 |
|
... | ... | |
25 | 26 |
public stakeholder: Stakeholder; |
26 | 27 |
public analysisOpen: boolean = true; |
27 | 28 |
private errorMessages: ErrorMessagesComponent; |
28 |
public copyTopic: Topic; |
|
29 |
public valid = true; |
|
29 |
public topicFb: FormGroup; |
|
30 | 30 |
public element: any; |
31 | 31 |
public index: number; |
32 | 32 |
properties: EnvProperties; |
... | ... | |
38 | 38 |
private router: Router, |
39 | 39 |
private title: Title, |
40 | 40 |
private sideBarService: SideBarService, |
41 |
private fb: FormBuilder, |
|
41 | 42 |
private stakeholderService: StakeholderService) { |
42 | 43 |
this.errorCodes = new ErrorCodes(); |
43 | 44 |
this.errorMessages = new ErrorMessagesComponent(); |
... | ... | |
50 | 51 |
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { |
51 | 52 |
if (stakeholder) { |
52 | 53 |
this.stakeholder = HelperFunctions.copy(stakeholder); |
53 |
this.copyTopic = null;
|
|
54 |
this.topicFb = null;
|
|
54 | 55 |
this.title.setTitle(stakeholder.index_name); |
55 | 56 |
} |
56 | 57 |
})); |
... | ... | |
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
public hide(element) { |
73 |
this.valid = true; |
|
74 | 74 |
UIkit.drop(element).hide(); |
75 | 75 |
} |
76 | 76 |
|
... | ... | |
86 | 86 |
} |
87 | 87 |
} |
88 | 88 |
|
89 |
private buildTopic(topic: Topic) { |
|
90 |
this.topicFb = this.fb.group({ |
|
91 |
_id: this.fb.control(topic._id), |
|
92 |
name: this.fb.control(topic.name, Validators.required), |
|
93 |
description: this.fb.control(topic.description), |
|
94 |
alias: this.fb.control(topic.alias), |
|
95 |
isActive: this.fb.control(topic.isActive), |
|
96 |
isPublic: this.fb.control(topic.isPublic), |
|
97 |
isDefault: this.fb.control(topic.isDefault), |
|
98 |
categories: this.fb.control(topic.categories) |
|
99 |
}); |
|
100 |
} |
|
101 |
|
|
89 | 102 |
public saveTopicOpen(element, index = -1) { |
90 | 103 |
if (element.className.indexOf('uk-open') !== -1) { |
91 | 104 |
this.hide(element); |
92 | 105 |
} else { |
93 | 106 |
if (index === -1) { |
94 |
this.copyTopic = new Topic(null, null, null, true, true);
|
|
107 |
this.buildTopic(new Topic(null, null, null, true, true, false));
|
|
95 | 108 |
} else { |
96 |
this.copyTopic = HelperFunctions.copy(this.stakeholder.topics[index]);
|
|
109 |
this.buildTopic(this.stakeholder.topics[index]);
|
|
97 | 110 |
} |
98 | 111 |
this.show(element); |
99 | 112 |
} |
100 | 113 |
} |
101 | 114 |
|
102 | 115 |
public saveTopic(element, index = -1) { |
103 |
if (this.copyTopic.name && this.copyTopic.name !== '') {
|
|
104 |
if (!this.copyTopic.alias) {
|
|
105 |
this.copyTopic.alias = this.copyTopic.name.toLowerCase().trim();
|
|
116 |
if (!this.topicFb.invalid) {
|
|
117 |
if (!this.topicFb.value.alias) {
|
|
118 |
this.topicFb.value.alias = this.topicFb.value.name.toLowerCase().trim();
|
|
106 | 119 |
} |
107 | 120 |
if (index === -1) { |
108 | 121 |
this.save('Topic has been successfully created', element); |
109 | 122 |
} else { |
110 | 123 |
this.save('Topic has been successfully saved', element, index); |
111 | 124 |
} |
112 |
} else { |
|
113 |
this.valid = false; |
|
114 | 125 |
} |
115 | 126 |
} |
116 | 127 |
|
... | ... | |
126 | 137 |
|
127 | 138 |
private save(message: string, element, index: number = -1) { |
128 | 139 |
let path = [this.stakeholder._id]; |
129 |
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.copyTopic, path).subscribe(topic => {
|
|
140 |
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.topicFb.value, path).subscribe(topic => {
|
|
130 | 141 |
if (index === -1) { |
131 | 142 |
this.stakeholder.topics.push(topic); |
132 | 143 |
} else { |
... | ... | |
135 | 146 |
this.stakeholderService.setStakeholder(this.stakeholder); |
136 | 147 |
UIkit.notification(message, { |
137 | 148 |
status: 'success', |
138 |
timeout: 3000, |
|
149 |
timeout: 3000000,
|
|
139 | 150 |
pos: 'top-left' |
140 | 151 |
}); |
141 | 152 |
this.hide(element); |
Also available in: Unified diff
[Monitor Dashboard]: 1. Change inputs to materials. 2. Add fonts. 3. Add uikit.js on index 4. Add reorder functionality on indicators. 5. Fix height of header to 70px