This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Entity { | |
id: string; | |
title: string; | |
slug: string; | |
content: string; | |
constructor(id: string, title: string, slug: string, content: string) { | |
this.id = id; | |
this.title = title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity } from './entity' | |
import { SpotEvent } from './spotevent' | |
export class Spot extends Entity { | |
floor: string; | |
type: string; | |
customer: string; | |
payments: SpotEvent[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { environment } from '../../environments/environment' | |
export class Settings { | |
ApiEndPoint: string = environment.COSMIC_API + environment.COSMIC_BUCKET + "/"; | |
ApiReadKey: string = environment.COSMIC_READ_KEY; | |
ApiWriteKey: string = environment.COSMIC_WRITE_KEY; | |
} | |
export const SpotTypes = ['Vacant', 'Rent', 'Owned']; | |
export const EventTypes = ['Payment', 'Maintenance', 'Cleaning']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const appRoutes = [ | |
{ path: '', component: DashboardComponent }, | |
{ path: 'spots', component: SpotcardComponent }, | |
{ path: 'spots/:spot_slug', component: SpotcardComponent }, | |
{ path: 'spots/:spot_slug/edit', component: SpotcardeditComponent }, | |
{ path: 'spots/:spot_slug/addevent', component: EventcardeditComponent }, | |
{ path: 'spots/:spot_slug/events/', redirectTo: 'spots/:spot_slug' }, | |
{ path: 'spots/:spot_slug/events/:event_slug', component: EventcardeditComponent }, | |
{ path: 'createspot', component: SpotcardeditComponent }, | |
// otherwise redirect to home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="section"> | |
<div class="container"> | |
<router-outlet></router-outlet> | |
</div> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getSpotData(): Observable<any> { | |
let apiEndPoint = this.settings.ApiEndPoint + "object-type/spots" + "?read_key=" + this.settings.ApiReadKey; | |
return this.http.get(apiEndPoint).map((response: Response) => response.json().objects); | |
} | |
getSpotEvents(): Observable<any> { | |
let apiEndPoint = this.settings.ApiEndPoint + "object-type/spotevents" + "?read_key=" + this.settings.ApiReadKey; | |
return this.http.get(apiEndPoint).map((response: Response) => response.json().objects); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tbody> | |
<tr *ngFor="let spot of spots"> | |
<td class="has-text-grey">{{ spot.floor }}</td> | |
<td><a routerLink="/spots/{{ spot.slug }}">{{ spot.title }}</a></td> | |
<td>{{ spot.type }}</td> | |
<td class="has-text-right">{{ spot.payments.length }}</td> | |
<td class="has-text-right">{{ spot.maintenances.length }}</td> | |
<td class="has-text-right">{{ spot.cleanings.length }}</td> | |
<td> | |
<a class="button is-primary is-small" routerLink="/spots/{{ spot.slug }}/addevent" title="Add event"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button class="button is-danger" *ngIf="canBeDeleted(); else deleteWarning" (click)="remove(selectedSpot)">Delete</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
saveSpot(spot: Spot): Observable<any> { | |
let apiEndPoint = this.settings.ApiEndPoint + "add-object"; | |
let payload = { | |
"write_key": this.settings.ApiWriteKey, | |
"title": spot.title, | |
"type_slug": "spots", | |
"content": spot.content, | |
"metafields": [ | |
{ | |
"key": "type", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
removeSpot(spot: Spot) { | |
return this.removeEntity(spot).map((response: Response) => response.json()); | |
} | |
removeEvent(event: SpotEvent) { | |
return this.removeEntity(event).map((response: Response) => response.json()); | |
} | |
removeEntity(entity: Entity) { | |
let apiEndPoint = this.settings.ApiEndPoint + "objects/" + entity.slug; |
OlderNewer