This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
src_app_custom-elements_announcement-bar_announcement-bar_module_ts-es2015.1dfa5c83d1421fab040b.js.map
1 lines (1 loc) · 4.7 KB
/
src_app_custom-elements_announcement-bar_announcement-bar_module_ts-es2015.1dfa5c83d1421fab040b.js.map
1
{"version":3,"sources":["webpack:///src/app/custom-elements/announcement-bar/announcement-bar.component.ts","webpack:///src/app/custom-elements/announcement-bar/announcement-bar.module.ts"],"names":["announcementsPath","AnnouncementBarComponent","http","logger","this","get","pipe","catchError","error","Error","message","map","announcements","findCurrentAnnouncement","subscribe","announcement","filter","Date","startDate","valueOf","now","endDate","AnnouncementBarModule","customElementComponent"],"mappings":"sVA8CE,iBACE,iBACE,iBACA,eACA,eAAgD,sBAAU,QAC5D,QACF,S,qBAJS,oDACF,yDACe,qDA7CxB,MAAMA,EAAoB,KAAqB,qBAiDxC,Y,MAAMC,EAGX,YAAoBC,EAA0BC,GAA1B,KAAAD,OAA0B,KAAAC,SAE9C,WACEC,KAAKF,KAAKG,IAAoBL,GAC3BM,MACC,EAAAC,EAAA,GAAWC,IACTJ,KAAKD,OAAOK,MAAM,IAAIC,MAAM,GAAGT,qBAAqCQ,EAAME,YACnE,MAET,EAAAC,EAAA,GAAIC,GAAiBR,KAAKS,wBAAwBD,KAClD,EAAAL,EAAA,GAAWC,IACTJ,KAAKD,OAAOK,MAAM,IAAIC,MAAM,GAAGT,4BAA4CQ,EAAME,YAC1E,MAGVI,UAAUC,GAAgBX,KAAKW,aAAeA,GAM3C,wBAAwBH,GAC9B,OAAOA,EACJI,OAAOD,GAAgB,IAAIE,KAAKF,EAAaG,WAAWC,UAAYF,KAAKG,OACzEJ,OAAOD,GAAgB,IAAIE,KAAKF,EAAaM,SAASF,UAAYF,KAAKG,OACvE,I,6CA5BMnB,GAAwB,yB,wBAAxBA,EAAwB,0OARnC,uB,KAAiC,8B,uCAQ5B,GC1CA,Q,MAAMqB,EALb,cAME,KAAAC,uBAAoCtB,G,6CADzBqB,I,wBAAAA,I,4BAJF,CAAE,KAAc,IAAc,S,GAIlC","file":"x","sourcesContent":["import { Component, OnInit } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { catchError, map } from 'rxjs/operators';\nimport { Logger } from 'app/shared/logger.service';\nimport { CONTENT_URL_PREFIX } from 'app/documents/document.service';\nconst announcementsPath = CONTENT_URL_PREFIX + 'announcements.json';\n\nexport interface Announcement {\n imageUrl: string;\n message: string;\n linkUrl: string;\n startDate: string;\n endDate: string;\n}\n\n/**\n * Display the latest live announcement. This is used on the homepage.\n *\n * The data for the announcements is kept in `aio/content/marketing/announcements.json`.\n *\n * The format for that data file looks like:\n *\n * ```\n * [\n * {\n * \"startDate\": \"2018-02-01\",\n * \"endDate\": \"2018-03-01\",\n * \"message\": \"This is an <b>important</b> announcement\",\n * \"imageUrl\": \"url/to/image\",\n * \"linkUrl\": \"url/to/website\"\n * },\n * ...\n * ]\n * ```\n *\n * Only one announcement will be shown at any time. This is determined as the first \"live\"\n * announcement in the file, where \"live\" means that its start date is before today, and its\n * end date is after today.\n *\n * **Security Note:**\n * The `message` field can contain unsanitized HTML but this field should only updated by\n * verified members of the Angular team.\n */\n@Component({\n selector: 'aio-announcement-bar',\n template: `\n <div class=\"homepage-container\" *ngIf=\"announcement\">\n <div class=\"announcement-bar\">\n <img [src]=\"announcement.imageUrl\" alt=\"\">\n <p [innerHTML]=\"announcement.message\"></p>\n <a class=\"button\" [href]=\"announcement.linkUrl\">Learn More</a>\n </div>\n </div>`\n})\nexport class AnnouncementBarComponent implements OnInit {\n announcement: Announcement;\n\n constructor(private http: HttpClient, private logger: Logger) {}\n\n ngOnInit() {\n this.http.get<Announcement[]>(announcementsPath)\n .pipe(\n catchError(error => {\n this.logger.error(new Error(`${announcementsPath} request failed: ${error.message}`));\n return [];\n }),\n map(announcements => this.findCurrentAnnouncement(announcements)),\n catchError(error => {\n this.logger.error(new Error(`${announcementsPath} contains invalid data: ${error.message}`));\n return [];\n }),\n )\n .subscribe(announcement => this.announcement = announcement);\n }\n\n /**\n * Get the first date in the list that is \"live\" now\n */\n private findCurrentAnnouncement(announcements: Announcement[]) {\n return announcements\n .filter(announcement => new Date(announcement.startDate).valueOf() < Date.now())\n .filter(announcement => new Date(announcement.endDate).valueOf() > Date.now())\n [0];\n }\n}\n","import { NgModule, Type } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { SharedModule } from '../../shared/shared.module';\nimport { AnnouncementBarComponent } from './announcement-bar.component';\nimport { WithCustomElementComponent } from '../element-registry';\n\n@NgModule({\n imports: [ CommonModule, SharedModule, HttpClientModule ],\n declarations: [ AnnouncementBarComponent ],\n entryComponents: [ AnnouncementBarComponent ],\n})\nexport class AnnouncementBarModule implements WithCustomElementComponent {\n customElementComponent: Type<any> = AnnouncementBarComponent;\n}\n"]}