Project

General

Profile

« Previous | Next » 

Revision 57618

[Monitor Dashboard]: Fix validation of names in dropdown edit. Move getFullUrl on inidicator Utils

View differences:

modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/monitor/monitor.component.ts
15 15
import {StatisticsService} from "../utils/services/statistics.service";
16 16
import {Item, Sidebar} from "../utils/entities/sidebar";
17 17
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
18
import {IndicatorUtils} from "../utils/indicator-utils";
18 19

  
19 20
@Component({
20 21
  selector: 'monitor',
......
26 27
  public divContents = null;
27 28
  public status: number;
28 29
  public loading: boolean = true;
30
  public indicatorUtils: IndicatorUtils = new IndicatorUtils();
29 31
  public activeTopic: Topic = null;
30 32
  public activeCategory: Category = null;
31 33
  public activeSubCategory: SubCategory = null;
......
221 223
  }
222 224

  
223 225
  public getUrlByStakeHolder(indicatorPath: IndicatorPath) {
224
    return this.sanitizer.bypassSecurityTrustResourceUrl(this.statisticsService.getChartUrl(indicatorPath.source, indicatorPath.getFullUrl()));
226
    return this.sanitizer.bypassSecurityTrustResourceUrl(
227
      this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath)));
225 228
  }
226 229

  
227 230
  public setActiveChart(index, type: string) {
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/home/home.component.html
41 41
                        <div class="uk-width-1-1">
42 42
                          <label class="uk-text-bold">Topic Settings</label>
43 43
                          <input class="uk-input uk-form-small" [(ngModel)]="copyTopic.name"
44
                                 [class.uk-form-danger]="!valid && (!copyTopic.name || copyTopic.name === '')"
44
                                 [class.uk-form-danger]="!valid && !copyTopic.name"
45 45
                                 type="text">
46 46
                        </div>
47 47
                        <div class="uk-width-1-1">
......
96 96
                      <div class="uk-width-1-1">
97 97
                        <label class="uk-text-bold">New Topic</label>
98 98
                        <input class="uk-input uk-form-small" [(ngModel)]="copyTopic.name"
99
                               [class.uk-form-danger]="!valid && (!copyTopic.name || copyTopic.name === '')"
99
                               [class.uk-form-danger]="!valid && !copyTopic.name"
100 100
                               type="text">
101 101
                      </div>
102 102
                      <div class="uk-width-1-1">
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/home/home.component.ts
70 70
  }
71 71

  
72 72
  public hide(element) {
73
    this.valid = true;
73 74
    UIkit.drop(element).hide();
74 75
  }
75 76

  
......
95 96
        this.copyTopic = HelperFunctions.copy(this.stakeholder.topics[index]);
96 97
      }
97 98
      this.show(element);
98
      this.valid = true;
99 99
    }
100 100
  }
101 101

  
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/utils/indicator-utils.ts
18 18

  
19 19
  isActiveIcon: string = 'brightness_1';
20 20

  
21
  public getFullUrl(indicatorPath: IndicatorPath):string{
22
    let replacedUrl = indicatorPath.chartObject;
23
    if(indicatorPath.parameters) {
24
      Object.entries(indicatorPath.parameters).forEach((key, value) => {
25
        replacedUrl = replacedUrl.replace(ChartHelper.prefix + key + ChartHelper.suffix, value.toString());
26
      });
27
    }
28
    return indicatorPath.url + encodeURIComponent(replacedUrl);
29
  }
21 30

  
22
  generateIndicatorByChartUrl(url:string):Indicator{
31
  generateIndicatorByChartUrl(url:string): Indicator{
23 32
    let indicator = new Indicator("","","chart","small",true,true,[]);
24 33
    let indicatorPath = new IndicatorPath("","","","",[]);
25 34
    indicator.indicatorPaths.push(indicatorPath);
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/utils/entities/stakeholder.ts
361 361
    this.parameters = new Map<string, string>();
362 362
    this.filters = new Map<string, Map<string,string>>();
363 363
  }
364

  
364 365
  static createParameters(funderName:string=null, title:string=null, chartType:string=null):Map<string, string>{
365 366
    let parameters = new Map<string, string>();
366 367
    parameters.set("funder_name",funderName);
......
368 369
    parameters.set("type",chartType);
369 370
    return parameters;
370 371
  }
371
  getFullUrl():string{
372
    let replacedUrl = this.chartObject;
373
    this.parameters.forEach((value: string, key: string) => {
374
      replacedUrl = replacedUrl.replace(ChartHelper.prefix+key+ChartHelper.suffix,value);
375
    });
376

  
377
    return this.url + encodeURIComponent(replacedUrl);
378
  }
379

  
380 372
}
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/library/sharedComponents/sidebar/sideBar.service.ts
13 13
  private openSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
14 14

  
15 15
  /**
16
   *  Set this variable to false on Init of components that is not needed to have sidebar
17
   *  and on Destroy set this to true.
16
   *  Add hasSidebar: false on data of route config, if sidebar is not needed.
18 17
   */
19 18
  private hasSidebarSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
20 19

  
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/topic/topic.component.html
31 31
                  <div class="uk-width-1-1">
32 32
                    <label class="uk-text-bold">Topic Settings</label>
33 33
                    <input class="uk-input uk-form-small" [(ngModel)]="topic.name"
34
                           [class.uk-form-danger]="!valid && (!topic.name || topic.name === '')" type="text">
34
                           [class.uk-form-danger]="!valid && !topic.name" type="text">
35 35
                  </div>
36 36
                  <div class="uk-width-1-1">
37 37
                    <label>Description</label>
......
78 78
            <div class="menu_title uk-inline">
79 79
              {{category.name}}
80 80
              <button class="uk-position-center-right-out uk-margin-right uk-button uk-button-link onHover"
81
                      (click)="$event.stopPropagation();editCategoryOpen(i, editCategory)">
81
                      (click)="$event.stopPropagation();editCategoryOpen(editCategory, i);$event.preventDefault()">
82 82
                <i class="material-icons">more_horiz</i>
83 83
              </button>
84 84
            </div>
......
94 94
                  <div class="uk-grid-small" uk-grid>
95 95
                    <div class="uk-width-1-1">
96 96
                      <label class="uk-text-bold">Category Settings</label>
97
                      <input class="uk-input uk-form-small" [(ngModel)]="copyCategory.name"
98
                             [class.uk-form-danger]="!valid" type="text">
97
                      <input class="uk-input uk-form-small"
98
                             [(ngModel)]="copyCategory.name"
99
                             [class.uk-form-danger]="!valid && !copyCategory.name" type="text">
99 100
                    </div>
100 101
                    <div class="uk-width-1-2">
101 102
                      <select class="uk-select uk-form-small" [(ngModel)]="copyCategory.isPublic">
......
135 136
                  <div class="menu_title uk-inline">
136 137
                    {{subcategory.name}}
137 138
                    <button class="uk-position-center-right-out uk-margin-right uk-button uk-button-link onHover"
138
                            (click)="$event.stopPropagation();editSubCategoryOpen(j, editSubCategory);$event.preventDefault()">
139
                            (click)="$event.stopPropagation();editSubCategoryOpen(editSubCategory, j);$event.preventDefault()">
139 140
                    <i class="material-icons">more_horiz</i>
140 141
                  </button>
141 142
                  </div>
......
152 153
                          <div class="uk-width-1-1">
153 154
                            <label class="uk-text-bold">Subcategory Settings</label>
154 155
                            <input class="uk-input uk-form-small" [(ngModel)]="copySubCategory.name"
155
                                   [class.uk-form-danger]="!valid" type="text">
156
                                   [class.uk-form-danger]="!valid && !copySubCategory.name" type="text">
156 157
                          </div>
157 158
                          <div class="uk-width-1-2">
158 159
                            <select class="uk-select uk-form-small" [(ngModel)]="copySubCategory.isPublic">
......
185 186
              </li>
186 187
            </ng-template>
187 188
            <li>
188
              <a href="#" (click)="editSubCategoryOpen();$event.preventDefault()">
189
              <a href="#" (click)="editSubCategoryOpen(newSubCategory);$event.preventDefault()">
189 190
                <span class="menu_icon"><i class="material-icons">add</i></span>
190 191
                <span class="menu_title">Create new Subcategory</span>
191 192
              </a>
192
              <div uk-drop="mode: click; offset: -2; delay-hide: 0" #newSubCategory
193
              <div uk-drop="mode: none; offset: -2; delay-hide: 0" #newSubCategory
193 194
                   class="uk-padding-large uk-padding-remove-vertical uk-padding-remove-right uk-drop">
194 195
                <div *ngIf="copySubCategory">
195 196
                  <div class="md-card">
......
201 202
                        <div class="uk-width-1-1">
202 203
                          <label class="uk-text-bold">New Subcategory</label>
203 204
                          <input class="uk-input uk-form-small" [(ngModel)]="copySubCategory.name"
204
                                 [class.uk-form-danger]="!valid" type="text">
205
                                 [class.uk-form-danger]="!valid && !copySubCategory.name" type="text">
205 206
                        </div>
206 207
                        <div class="uk-width-1-2">
207 208
                          <select class="uk-select uk-form-small" [(ngModel)]="copySubCategory.isPublic">
......
236 237
        </li>
237 238
      </ng-template>
238 239
      <li>
239
        <a href="#" (click)="editCategoryOpen();$event.preventDefault()">
240
        <a href="#" (click)="editCategoryOpen(newCategory);$event.preventDefault()">
240 241
          <span class="menu_icon"><i class="material-icons">add</i></span>
241 242
          <span class="menu_title">Create new Category</span>
242 243
        </a>
243
        <div uk-drop="mode: click; offset: -2; delay-hide: 0" #newCategory
244
        <div uk-drop="mode: none; offset: -2; delay-hide: 0" #newCategory
244 245
             class="uk-padding-large uk-padding-remove-vertical uk-padding-remove-right uk-drop">
245 246
          <div *ngIf="copyCategory">
246 247
            <div class="md-card">
......
252 253
                  <div class="uk-width-1-1">
253 254
                    <label class="uk-text-bold">New Category</label>
254 255
                    <input class="uk-input uk-form-small" [(ngModel)]="copyCategory.name"
255
                           [class.uk-form-danger]="!valid" type="text">
256
                           [class.uk-form-danger]="!valid && !copyCategory.name" type="text">
256 257
                  </div>
257 258
                  <div class="uk-width-1-2">
258 259
                    <select class="uk-select uk-form-small" [(ngModel)]="copyCategory.isPublic">
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/app/topic/topic.component.ts
90 90
  }
91 91

  
92 92
  public hide(element) {
93
    this.valid = true;
93 94
    UIkit.drop(element).hide();
94 95
  }
95 96

  
......
102 103
      this.hide(element);
103 104
    } else {
104 105
      this.topic = HelperFunctions.copy(this.stakeholder.topics[this.topicIndex]);
105
      this.valid = true;
106 106
      this.show(element);
107 107
    }
108 108
  }
......
140 140
    }
141 141
  }
142 142

  
143
  public editCategoryOpen(index:number = -1, element = null) {
144
    if(index === -1) {
145
      this.copyCategory = new Category(null, null, null, true, true);
143
  public editCategoryOpen(element, index:number = -1) {
144
    if(element.className.indexOf('uk-open') !== -1) {
145
      this.hide(element);
146 146
    } else {
147
      if(element.className.indexOf('uk-open') !== -1) {
148
        this.hide(element);
147
      if(index === -1) {
148
        this.copyCategory = new Category(null, null, null, true, true);
149 149
      } else {
150 150
        this.copyCategory = HelperFunctions.copy(this.stakeholder.topics[this.topicIndex].categories[index]);
151
        this.show(element);
152
        this.valid = true;
153 151
      }
152
      this.show(element);
154 153
    }
155 154
  }
156 155

  
......
191 190
    this.delete('Category has been successfully be deleted', path);
192 191
  }
193 192

  
194
  public editSubCategoryOpen(index:number = -1, element = null) {
195
    if(index === -1) {
196
      this.copySubCategory = new SubCategory(null, null, null, true, true);
193
  public editSubCategoryOpen(element, index:number = -1) {
194
    if(element.className.indexOf('uk-open') !== -1) {
195
      this.hide(element);
197 196
    } else {
198
      if(element.className.indexOf('uk-open') !== -1) {
199
        this.hide(element);
197
      if(index === -1) {
198
        this.copySubCategory = new SubCategory(null, null, null, true, true);
200 199
      } else {
201 200
        this.copySubCategory = HelperFunctions.copy(this.stakeholder.topics[this.topicIndex].
202 201
          categories[this.categoryIndex].subCategories[index]);
203
        this.show(element);
204
        this.valid = true;
205 202
      }
203
      this.show(element);
206 204
    }
207 205
  }
208 206

  
modules/uoa-monitor-portal/trunk/monitor_dashboard/src/assets/theme-assets/dashboard-custom.css
40 40

  
41 41
.dashboard #sidebar_main .sidebar_main_header {
42 42
  color: #000000;
43
  height: auto;
44
  min-height: var(--header-height);
43 45
}
44 46

  
47
.dashboard .header_full #sidebar_main .sidebar_main_header {
48
  min-height: auto;
49
}
50

  
45 51
.dashboard #sidebar_main .menu_section > ul > li > a {
46 52
  font-weight: 700;
47
  font-size: var(--sidebar-font-size);
48
  color: rgba(0, 0, 0, 0.7);
49 53
}
50 54

  
51
.dashboard #sidebar_main .menu_section > ul > li ul a {
55
.dashboard #sidebar_main .menu_section > ul li > a {
52 56
  font-size: var(--sidebar-font-size);
53 57
  color: rgba(0, 0, 0, 0.7);
54 58
}

Also available in: Unified diff