Skip to content

Instantly share code, notes, and snippets.

View kutliev's full-sized avatar

Bulat Kutliev kutliev

View GitHub Profile
<div class="columns">
<div class="column is-two-thirds">
<h2 class="subtitle"><i class="fas fa-car"></i> Spots</h2>
<div>
<app-spotlist [spots] = "spots"></app-spotlist>
</div>
</div>
<div class="column">
"scripts": {
"ng": "ng",
"start": "echo START && npm install && node server.js",
"build": "NODE_ENV=production && ng build --aot --prod && ",
"preinstall": "echo PREINSTALL",
"postinstall": "HOME=/ ./node_modules/@angular/cli/bin/ng build --prod --aot"
},
"engines": {
"node": "9.4.0",
"npm": "5.6.0"
@kutliev
kutliev / server.js
Created February 11, 2018 19:53
Simple NodeJS server
// server.js
const express = require('express');
const app = express();
// Run the app by serving the static files
// in the dist directory
app.use(express.static(__dirname + '/dist'));
// Start the app by listening on the default
// Heroku port
app.listen(process.env.PORT || 5000);
@kutliev
kutliev / spotcard.component.ts
Created February 11, 2018 19:47
Check function
canBeDeleted():boolean{
return this.selectedSpot.cleanings.length == 0 &&
this.selectedSpot.maintenances.length == 0 &&
this.selectedSpot.payments.length == 0;
}
@kutliev
kutliev / data.service.ts
Created February 11, 2018 19:42
Removing entity
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;
@kutliev
kutliev / data.service.ts
Created February 11, 2018 19:40
Spot save
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",
@kutliev
kutliev / spotcard.component.html
Created February 11, 2018 19:39
Angular button
<button class="button is-danger" *ngIf="canBeDeleted(); else deleteWarning" (click)="remove(selectedSpot)">Delete</button>
@kutliev
kutliev / spotlist.component.html
Last active February 11, 2018 19:37
Spot list
<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">
@kutliev
kutliev / data.service.ts
Created February 11, 2018 19:34
Data service
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);
}
@kutliev
kutliev / app.component.html
Created February 11, 2018 19:16
Router-outlet
<section class="section">
<div class="container">
<router-outlet></router-outlet>
</div>
</section>