feat: add basic templates for data list items

This commit is contained in:
Jovan Krunić
2019-03-22 14:26:53 +01:00
parent 9850cf77c2
commit 3e697b17b4
47 changed files with 31480 additions and 95 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12,9 +12,13 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {SCAcademicEvent, SCArticle, SCBook, SCBuilding, SCCatalog,
SCDateSeries, SCDish, SCFavorite, SCMessage, SCPerson, SCRoom,
SCThing, SCThingOriginType, SCThingType, SCToDo, SCToDoPriority} from '@openstapps/core';
import {Observable, of} from 'rxjs';
import {sampleResources} from './resources/test-resources';
const sampleMessages: SCMessage[] = [
{
@@ -45,8 +49,20 @@ const sampleMessages: SCMessage[] = [
const sampleDishes: SCDish[] = [
{
categories: ['main dish'],
categories: ['main dish', 'salad'],
name: 'Foo Dish',
// offers: [
// {
// 'availability': 'in stock',
// 'availabilityStarts': '2017-01-30T00:00:00.000Z',
// 'availabilityEnds': '2017-01-30T23:59:59.999Z',
// 'prices': {
// 'default': 4.85,
// 'student': 2.85,
// 'employee': 3.85,
// 'guest': 4.85,
// },
// ],
origin: {
indexed: 'SOME-DATE',
name: 'some name',
@@ -56,7 +72,7 @@ const sampleDishes: SCDish[] = [
uid: 'dish-123',
},
{
categories: ['side dish'],
categories: ['side dish', 'salad'],
name: 'Bar Dish',
origin: {
indexed: 'SOME-DATE',
@@ -368,3 +384,39 @@ export function getSampleThings(...uids: string[]): SCThing[] {
}
return sampleThings;
}
@Injectable()
export class SampleThings {
http: HttpClient;
constructor(http: HttpClient) {
this.http = http;
}
// getSampleThings(): Observable<any> {
// return this.http.get('http://localhost:8100/assets/json/joined.json');
// // return of(sampleDishes[0]);
// }
getSampleThings(): Observable<any[]> {
// const jsonContent: any[] = await this.http.get('http://localhost:8100/assets/json/joined.json').toPromise();
const sampleThings: any[] = [];
sampleResources.forEach((resource) => {
// tslint:disable-next-line:max-line-length
// if ([SCThingType.Video].includes(resource.instance.type as SCThingType)) {
sampleThings.push(resource.instance);
// }
});
return of(sampleThings);
}
getSampleThing(uid: string): Observable<any[]> {
// const jsonContent: any[] = await this.http.get('http://localhost:8100/assets/json/joined.json').toPromise();
const sampleThings: any[] = [];
for (const resource of sampleResources) {
if (resource.instance.uid as SCThingType === uid) {
sampleThings.push(resource.instance);
return of(sampleThings);
}
}
return of(sampleThings);
}
}