Skip to content

Commit

Permalink
feat(startup-message): Startup message from context (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
ameliebernier authored and mbarbeau committed Mar 27, 2019
1 parent a600053 commit d60ebb2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
overflow: hidden;
position: relative;
display: block;
font-family: Times New Roman;
font-family: Roboto, "Helvetica Neue", sans-serif;
font-size: 16px;
}

Expand Down
18 changes: 16 additions & 2 deletions src/app/pages/portal/portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { Notification } from 'angular2-notifications';

import { MediaService, ConfigService } from '@igo2/core';
import { MediaService, ConfigService, MessageService, Message } from '@igo2/core';
import { AuthService } from '@igo2/auth';
import { Context, ContextService, ToolService } from '@igo2/context';
import {
Expand Down Expand Up @@ -60,6 +61,9 @@ export class PortalComponent implements OnInit, OnDestroy {
private contextLoaded = false;
// True after the initial tool is loaded
private toolLoaded = false;
// Reference to last startup message from context
// To remove message on context change
private contextMessage: Notification;

constructor(
private route: ActivatedRoute,
Expand All @@ -75,7 +79,8 @@ export class PortalComponent implements OnInit, OnDestroy {
public dataSourceService: DataSourceService,
public contextService: ContextService,
public cdRef: ChangeDetectorRef,
public capabilitiesService: CapabilitiesService
public capabilitiesService: CapabilitiesService,
public messageService: MessageService
) {}

ngOnInit() {
Expand Down Expand Up @@ -223,6 +228,15 @@ export class PortalComponent implements OnInit, OnDestroy {
if (context !== undefined && this.contextLoaded) {
const tool = this.toolService.getTool('mapDetails');
this.toolService.selectTool(tool);

const message = context['message'];
if (message) {
this.contextMessage = this.messageService.message(<Message>message);
} else {
if (this.contextMessage) {
this.messageService.remove(this.contextMessage.id);
}
}
}

if (context !== undefined) {
Expand Down
4 changes: 4 additions & 0 deletions src/contexts/_contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
{
"uri": "mapOverlay",
"title": "Demo for mapOverlay"
},
{
"uri": "message",
"title": "Demo for startup message"
}
]
89 changes: 89 additions & 0 deletions src/contexts/message.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"uri": "_default",
"title": "Default Context",
"message": {
"title": "Avertissement",
"text": "Toutes les données sont présentées à titre indicatif seulement.",
"type": "info",
"options": {
"timeOut": 20000
}
},
"map": {
"view": {
"projection": "EPSG:3857",
"center": [-72, 52],
"zoom": 6
}
},
"layers": [
{
"title": "OSM",
"baseLayer": true,
"visible": true,
"sourceOptions": {
"type": "osm"
}
}
],
"toolbar": [
"searchResults",
"contextManager",
"mapDetails",
"directions",
"catalog",
"timeAnalysis",
"print",
"shareMap",
"about"
],
"tools": [
{
"name": "searchResults",
"options": {
"focusFirst": true
}
},
{
"name": "contextManager"
},
{
"name": "mapDetails",
"options": {
"toggleLegendOnVisibilityChange": false,
"layerListControls": {
"showToolbar": "always",
"excludeBaseLayers": false,
"keyword": "",
"sortedAlpha": false,
"onlyVisible": false,
"onlyInRange": false
}
}
},
{
"name": "directions"
},
{
"name": "catalog"
},
{
"name": "catalogLayers"
},
{
"name": "timeAnalysis"
},
{
"name": "shareMap"
},
{
"name": "print"
},
{
"name": "about",
"options": {
"html": "<h1>This is a IGO</h1>"
}
}
]
}

0 comments on commit d60ebb2

Please sign in to comment.