mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: add basic templates for data list items
This commit is contained in:
30750
src/app/_helpers/data/resources/test-resources.ts
Normal file
30750
src/app/_helpers/data/resources/test-resources.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user