Project

General

Profile

« Previous | Next » 

Revision 60331

[Library | Trunk]: Admin tools pages add loading and notifications

View differences:

portals.component.ts
13 13
import {properties} from "../../../../environments/environment";
14 14
import {AlertModal} from "../../utils/modal/alert";
15 15

  
16
declare var UIkit;
17

  
16 18
@Component({
17 19
  selector: 'portals',
18 20
  templateUrl: './portals.component.html',
......
164 166
      this.subscriptions.push(this._helpContentService.deleteCommunities(this.selectedPortals, this.properties.adminToolsAPIURL).subscribe(
165 167
        _ => {
166 168
          this.deletePortalsFromArray(this.selectedPortals);
169
          UIkit.notification('Portals have been <b>successfully deleted</b>', {
170
            status: 'success',
171
            timeout: 6000,
172
            pos: 'bottom-right'
173
          });
167 174
          this.showLoading = false;
168 175
        },
169 176
        error => this.handleUpdateError('System error deleting the selected communities', error)
......
220 227
  }
221 228
  
222 229
  public portalSaveConfirmed(data: any) {
230
    this.showLoading = true;
223 231
    if (!Session.isLoggedIn()) {
224 232
      this._router.navigate(['/user-info'], {
225 233
        queryParams: {
......
235 243
          this.properties.adminToolsAPIURL).subscribe(
236 244
          portal => {
237 245
            this.portalUpdatedSuccessfully(portal);
246
            UIkit.notification('Portal <b>' + portal.name + '</b> has been <b>successfully updated</b>', {
247
              status: 'success',
248
              timeout: 6000,
249
              pos: 'bottom-right'
250
            });
238 251
          },
239 252
          error => this.handleUpdateError('System error updating portal', error)
240 253
        ));
......
243 256
          this.properties.adminToolsAPIURL).subscribe(
244 257
          portal => {
245 258
            this.portalSavedSuccessfully(portal);
259
            UIkit.notification('Portal <b>' + portal.name + '</b> has been <b>successfully created</b>', {
260
              status: 'success',
261
              timeout: 6000,
262
              pos: 'bottom-right'
263
            });
246 264
          },
247 265
          error => this.handleUpdateError('System error creating portal', error)
248 266
        ));
......
250 268
    }
251 269
  }
252 270
  
253
  public portalUpdateConfirmed(data: any) {
254
    if (!Session.isLoggedIn()) {
255
      this._router.navigate(['/user-info'], {
256
        queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
257
      });
258
    } else {
259
      this.portalForm.get('type').enable();
260
      this.subscriptions.push(this._helpContentService.updateCommunity(<Portal>this.portalForm.value,
261
        this.properties.adminToolsAPIURL).subscribe(
262
        portal => {
263
          this.portalUpdatedSuccessfully(portal);
264
        },
265
        error => this.handleUpdateError('System error updating portal', error)
266
      ));
267
    }
268
  }
269
  
270 271
  public portalSavedSuccessfully(portal: Portal) {
271 272
    this.portals.push(portal);
272 273
    this.applyFilters();
273 274
    this.applyCheck(false);
275
    this.showLoading = false;
274 276
  }
275 277
  
276 278
  public portalUpdatedSuccessfully(portal: Portal) {
277 279
    this.portals[this.index] = portal;
278 280
    this.applyFilters();
279 281
    this.applyCheck(false);
282
    this.showLoading = false;
280 283
  }
281 284
  
282 285
  public applyFilters() {
......
310 313
      this.updateErrorMessage = message;
311 314
      console.log('Server responded: ' + error);
312 315
    }
316
    UIkit.notification('An error has occurred. Please try again later', {
317
      status: 'danger',
318
      timeout: 6000,
319
      pos: 'bottom-right'
320
    });
313 321
    this.showLoading = false;
314 322
  }
315 323
  

Also available in: Unified diff