Browse Source

parcial

pull/6/head
Adler Neves 4 years ago
parent
commit
66cca728aa
  1. 1
      .gitignore
  2. 2
      runLocalhostSonar.sh
  3. 2
      sonar-project.properties
  4. 18
      src/app/app.component.ts
  5. 52
      src/app/app.module.ts
  6. 18
      src/entities/Consulta.ts
  7. 7
      src/entities/EntidadeAbstrata.ts
  8. 22
      src/entities/Necessidade.ts
  9. 21
      src/entities/Planejamento.ts
  10. 15
      src/entities/Produto.ts
  11. 15
      src/entities/Supermercado.ts
  12. 11
      src/entities/UnidadeMedida.ts
  13. 20
      src/models/IDao.ts
  14. 23
      src/models/class/Item.spec.ts
  15. 24
      src/models/class/Item.ts
  16. 23
      src/models/class/List.spec.ts
  17. 17
      src/models/class/List.ts
  18. 23
      src/models/class/ListItem.spec.ts
  19. 21
      src/models/class/ListProduct.ts
  20. 23
      src/models/class/Market.spec.ts
  21. 13
      src/models/class/Market.ts
  22. 23
      src/models/class/Product.spec.ts
  23. 14
      src/models/class/Product.ts
  24. 23
      src/models/class/Survey.spec.ts
  25. 21
      src/models/class/Survey.ts
  26. 23
      src/models/class/Unit.spec.ts
  27. 16
      src/models/class/Unit.ts
  28. 0
      src/pages/inicio/main.html
  29. 2
      src/pages/inicio/main.scss
  30. 8
      src/pages/inicio/main.spec.ts
  31. 10
      src/pages/inicio/main.ts
  32. 34
      src/pages/listitem/list-item-create-page/list-item-create-page.html
  33. 16
      src/pages/listitem/list-item-create-page/list-item-create-page.module.ts
  34. 3
      src/pages/listitem/list-item-create-page/list-item-create-page.scss
  35. 24
      src/pages/listitem/list-item-create-page/list-item-create-page.spec.ts
  36. 82
      src/pages/listitem/list-item-create-page/list-item-create-page.ts
  37. 21
      src/pages/listitem/list-item-list-page/list-item-list-page.html
  38. 16
      src/pages/listitem/list-item-list-page/list-item-list-page.module.ts
  39. 3
      src/pages/listitem/list-item-list-page/list-item-list-page.scss
  40. 24
      src/pages/listitem/list-item-list-page/list-item-list-page.spec.ts
  41. 114
      src/pages/listitem/list-item-list-page/list-item-list-page.ts
  42. 24
      src/pages/market/market-create-page/market-create-page.html
  43. 16
      src/pages/market/market-create-page/market-create-page.module.ts
  44. 3
      src/pages/market/market-create-page/market-create-page.scss
  45. 72
      src/pages/market/market-create-page/market-create-page.ts
  46. 19
      src/pages/market/market-list-page/market-list-page.html
  47. 16
      src/pages/market/market-list-page/market-list-page.module.ts
  48. 3
      src/pages/market/market-list-page/market-list-page.scss
  49. 24
      src/pages/market/market-list-page/market-list-page.spec.ts
  50. 113
      src/pages/market/market-list-page/market-list-page.ts
  51. 24
      src/pages/product/product-create-page/product-create-page.html
  52. 16
      src/pages/product/product-create-page/product-create-page.module.ts
  53. 3
      src/pages/product/product-create-page/product-create-page.scss
  54. 72
      src/pages/product/product-create-page/product-create-page.ts
  55. 19
      src/pages/product/product-list-page/product-list-page.html
  56. 16
      src/pages/product/product-list-page/product-list-page.module.ts
  57. 3
      src/pages/product/product-list-page/product-list-page.scss
  58. 24
      src/pages/product/product-list-page/product-list-page.spec.ts
  59. 115
      src/pages/product/product-list-page/product-list-page.ts
  60. 28
      src/pages/unit/unit-create/unit-create.html
  61. 16
      src/pages/unit/unit-create/unit-create.module.ts
  62. 3
      src/pages/unit/unit-create/unit-create.scss
  63. 71
      src/pages/unit/unit-create/unit-create.ts
  64. 19
      src/pages/unit/unit-list-page/unit-list-page.html
  65. 16
      src/pages/unit/unit-list-page/unit-list-page.module.ts
  66. 3
      src/pages/unit/unit-list-page/unit-list-page.scss
  67. 24
      src/pages/unit/unit-list-page/unit-list-page.spec.ts
  68. 121
      src/pages/unit/unit-list-page/unit-list-page.ts
  69. 6
      src/test.ts

1
.gitignore

@ -17,6 +17,7 @@ npm-debug.log*
.tmp/
.versions/
.scannerwork/
.toDelete/
coverage/
dist/
node_modules/

2
runLocalhostSonar.sh

@ -1,5 +1,5 @@
#!/bin/bash
~/tocompile/sonarqube/bin/linux-x86-64/sonar.sh start
~/tocompile/sonar-scanner/bin/sonar-scanner -Dsonar.language=ts -Dsonar.sources=src -Dsonar.projectKey=EconoCart_v2
~/tocompile/sonar-scanner/bin/sonar-scanner -Dsonar.host.url=http://127.0.0.1:9000

2
sonar-project.properties

@ -3,6 +3,6 @@ sonar.projectName = EconoCart
sonar.host.url=https://sonarqube.adlerneves.com.br/
sonar.projectVersion = 1
sonar.sources = src
sonar.language = ts
sonar.exclusions = **/node_modules/**,**/*.spec.ts
sonar.language=ts
sonar.ts.coverage.lcovReportPath=coverage/lcov.info

18
src/app/app.component.ts

@ -3,13 +3,7 @@ import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
import { UnitListPage } from "../pages/unit/unit-list-page/unit-list-page";
import { StartService } from "../providers/start/start-service.service";
import { ProductListPage } from "../pages/product/product-list-page/product-list-page";
import { MarketListPage } from "../pages/market/market-list-page/market-list-page";
import { ListItemListPage } from "../pages/listitem/list-item-list-page/list-item-list-page";
import { PageInicio } from '../pages/inicio/main';
@Component({
templateUrl: 'app.html'
@ -17,20 +11,21 @@ import { ListItemListPage } from "../pages/listitem/list-item-list-page/list-ite
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = HomePage;
rootPage: any = PageInicio;
pages: Array<{ title: string, component: any }>;
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen, private _starter: StartService) {
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
this.initializeApp();
// used for an example of ngFor and navigation
this.pages = [
/*
{ title: 'Lista de Itens', component: ListItemListPage },
{ title: 'Supermercados', component: MarketListPage },
{ title: 'Produtos', component: ProductListPage },
{ title: 'Unidades', component: UnitListPage }
*/
];
}
@ -41,7 +36,6 @@ export class MyApp {
// Here you can do any higher level native things you might need.
this.statusBar.styleDefault();
this.splashScreen.hide();
this._starter.start();
});
}
@ -51,6 +45,6 @@ export class MyApp {
this.nav.setRoot(page.component);
}
btnOpenHome(){
this.openPage({component:HomePage})
this.openPage({component:PageInicio})
}
}

52
src/app/app.module.ts

@ -2,52 +2,32 @@ import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { PageInicio } from '../pages/inicio/main';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { ActionSheet, ActionSheetOptions } from '@ionic-native/action-sheet';
import { ActionSheet } from '@ionic-native/action-sheet';
import { Toast } from "@ionic-native/toast";
import { HttpModule } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import { UnitCreateModule } from "../pages/unit/unit-create/unit-create.module";
import { UnitListPageModule } from "../pages/unit/unit-list-page/unit-list-page.module";
import { SQLite } from "@ionic-native/sqlite";
import { SQLjsObject, SQLjs } from "../providers/SQLjsDriver/SQLjs.service";
import { DaoUnit } from "../providers/dao/dao-unit.service";
import { StartService } from "../providers/start/start-service.service";
import { DaoProduct } from "../providers/dao/dao-product.service";
import { ProductCreatePageModule } from "../pages/product/product-create-page/product-create-page.module";
import { ProductListPageModule } from "../pages/product/product-list-page/product-list-page.module";
import { MarketListPage } from "../pages/market/market-list-page/market-list-page";
import { MarketCreatePage } from "../pages/market/market-create-page/market-create-page";
import { MarketCreatePageModule } from "../pages/market/market-create-page/market-create-page.module";
import { MarketListPageModule } from "../pages/market/market-list-page/market-list-page.module";
import { DaoMarket } from "../providers/dao/dao-market.service";
import { ListItemListPageModule } from "../pages/listitem/list-item-list-page/list-item-list-page.module";
import { DaoListItem } from "../providers/dao/dao-listitem.service";
import { ListItemCreatePageModule } from "../pages/listitem/list-item-create-page/list-item-create-page.module";
@NgModule({
declarations: [
MyApp, HomePage,
],
imports: [
BrowserModule, IonicModule.forRoot(MyApp), UnitListPageModule, HttpModule, ListItemListPageModule,ListItemCreatePageModule,
UnitCreateModule, ProductListPageModule, ProductCreatePageModule, MarketListPageModule, MarketCreatePageModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp, HomePage,],
providers: [
StatusBar, SplashScreen, ActionSheet, DaoUnit, StartService, SQLite, Toast, DaoProduct, DaoMarket, DaoListItem, SQLjs, SQLjsObject,
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
declarations: [
MyApp, PageInicio,
],
imports: [
BrowserModule, IonicModule.forRoot(MyApp), HttpModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp, PageInicio,
],
providers: [
StatusBar, SplashScreen, ActionSheet, SQLite, Toast, SQLjs, SQLjsObject,
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
})
export class AppModule { }

18
src/entities/Consulta.ts

@ -0,0 +1,18 @@
import { Column, ManyToOne } from "typeorm";
import { EntidadeAbstrata } from "./EntidadeAbstrata";
import { Necessidade } from "./Necessidade";
import { Supermercado } from "./Supermercado";
export class Consulta extends EntidadeAbstrata {
@Column()
modificacao: Date;
@Column('float')
preco: number;
@ManyToOne(type => Necessidade, other => other.consultas)
necessidade: Necessidade;
@ManyToOne(type => Supermercado, other => other.consultas)
supermercado: Supermercado;
}

7
src/entities/EntidadeAbstrata.ts

@ -0,0 +1,7 @@
import {Entity, PrimaryGeneratedColumn} from "typeorm";
@Entity()
export abstract class EntidadeAbstrata {
@PrimaryGeneratedColumn()
id: number;
}

22
src/entities/Necessidade.ts

@ -0,0 +1,22 @@
import { Column, ManyToOne, OneToMany } from "typeorm";
import { EntidadeAbstrata } from "./EntidadeAbstrata";
import { Produto } from "./Produto";
import { Consulta } from "./Consulta";
import { Planejamento } from "./Planejamento";
export class Necessidade extends EntidadeAbstrata {
@Column('float')
quantidade: number;
@Column()
satisfeita: boolean;
@OneToMany(type => Produto, other => other.necessidade)
produtos: Produto[];
@OneToMany(type => Consulta, other => other.necessidade)
consultas: Consulta[];
@ManyToOne(type => Planejamento, other => other.necessidades)
planejamento: Planejamento;
}

21
src/entities/Planejamento.ts

@ -0,0 +1,21 @@
import { Column, ManyToMany, OneToMany } from "typeorm";
import { EntidadeAbstrata } from "./EntidadeAbstrata";
import { Necessidade } from "./Necessidade";
import { Supermercado } from "./Supermercado";
export class Planejamento extends EntidadeAbstrata {
@Column()
nome: string;
@Column()
criacao: Date;
@Column()
modificacao: Date;
@OneToMany(type => Necessidade, other => other.planejamento)
necessidades: Necessidade[];
@ManyToMany(type => Supermercado, other => other.planejamentos)
supermercados: Supermercado[];
}

15
src/entities/Produto.ts

@ -0,0 +1,15 @@
import { Column, ManyToOne } from "typeorm";
import { EntidadeAbstrata } from "./EntidadeAbstrata";
import { UnidadeMedida } from "./UnidadeMedida";
import { Necessidade } from "./Necessidade";
export class Produto extends EntidadeAbstrata {
@Column()
nome: string;
@ManyToOne(type => UnidadeMedida, other => other.produtos)
unidadeMedida: UnidadeMedida;
@ManyToOne(type => Necessidade, other => other.produtos)
necessidade: Necessidade;
}

15
src/entities/Supermercado.ts

@ -0,0 +1,15 @@
import { Column, ManyToMany, OneToMany } from "typeorm";
import { EntidadeAbstrata } from "./EntidadeAbstrata";
import { Planejamento } from "./Planejamento";
import { Consulta } from "./Consulta";
export class Supermercado extends EntidadeAbstrata {
@Column()
nome: string;
@ManyToMany(type => Planejamento, other => other.supermercados)
planejamentos: Planejamento[];
@OneToMany(type => Consulta, other => other.supermercado)
consultas: Consulta[];
}

11
src/entities/UnidadeMedida.ts

@ -0,0 +1,11 @@
import { Column, OneToMany } from "typeorm";
import { EntidadeAbstrata } from "./EntidadeAbstrata";
import { Produto } from "./Produto";
export class UnidadeMedida extends EntidadeAbstrata {
@Column()
nome: string;
@OneToMany(type => Produto, other => other.unidadeMedida)
produtos: Produto[];
}

20
src/models/IDao.ts

@ -1,20 +0,0 @@
import { SQLiteObject } from '@ionic-native/sqlite';
export interface IDao {
db: SQLiteObject;
setDatabase(db: SQLiteObject);
create(element: any);
createTable();
delete(element: any)
getAll(elements: any);
update(element: any);
}

23
src/models/class/Item.spec.ts

@ -1,23 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { Item } from './Item';
let fixture: ComponentFixture<Item> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Model: Item', () => {
beforeEach(async(() => {
instance = new Item();
}));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

24
src/models/class/Item.ts

@ -1,24 +0,0 @@
import 'rxjs/add/operator/map';
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from "typeorm";
import { Product } from "./Product";
import { Unit } from "./Unit";
@Entity()
export class Item {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(type => Product, product => product.items)
product: Product;
@ManyToOne(type => Unit, unit => unit.items)
unit: Unit;
@Column("real")
amount: number;
@Column("real")
price: number;
}

23
src/models/class/List.spec.ts

@ -1,23 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { List } from './List';
let fixture: ComponentFixture<List> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Model: List', () => {
beforeEach(async(() => {
instance = new List();
}));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

17
src/models/class/List.ts

@ -1,17 +0,0 @@
import 'rxjs/add/operator/map';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from "typeorm";
import { Survey } from "./Survey";
@Entity()
export class List {
@PrimaryGeneratedColumn()
id: number;
@Column()
date: Date;
@OneToMany(type => Survey, survey => survey.list)
surveys: Survey[];
}

23
src/models/class/ListItem.spec.ts

@ -1,23 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { ListItem } from './ListItem';
let fixture: ComponentFixture<ListItem> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Model: ListItem', () => {
beforeEach(async(() => {
instance = new ListItem();
}));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

21
src/models/class/ListProduct.ts

@ -1,21 +0,0 @@
import 'rxjs/add/operator/map';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from "typeorm";
import { Product } from "./Product";
@Entity()
export class ListProduct {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column("text")
description: string;
@OneToMany(type => Product, product => product.listItem)
products: Product[];
}

23
src/models/class/Market.spec.ts

@ -1,23 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { Market } from './Market';
let fixture: ComponentFixture<Market> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Model: Market', () => {
beforeEach(async(() => {
instance = new Market();
}));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

13
src/models/class/Market.ts

@ -1,13 +0,0 @@
import 'rxjs/add/operator/map';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from "typeorm";
@Entity()
export class Market {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
}

23
src/models/class/Product.spec.ts

@ -1,23 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { Product } from './Product';
let fixture: ComponentFixture<Product> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Model: Product', () => {
beforeEach(async(() => {
instance = new Product();
}));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

14
src/models/class/Product.ts

@ -1,14 +0,0 @@
import 'rxjs/add/operator/map';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from "typeorm";
@Entity()
export class Product {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
items: Item;
}

23
src/models/class/Survey.spec.ts

@ -1,23 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { Survey } from './Survey';
let fixture: ComponentFixture<Survey> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Model: Survey', () => {
beforeEach(async(() => {
instance = new Survey();
}));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

21
src/models/class/Survey.ts

@ -1,21 +0,0 @@
import 'rxjs/add/operator/map';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne } from "typeorm";
import { Item } from "./Item";
import { Market } from "./Market";
@Entity()
export class Survey {
@PrimaryGeneratedColumn()
id: number;
@Column('text')
description: string;
@OneToMany(type => Item , item => item.survey)
items: Item[];
@ManyToOne(type => Market, market => market.surveys)
market: Market;
}

23
src/models/class/Unit.spec.ts

@ -1,23 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { Unit } from './Unit';
let fixture: ComponentFixture<Unit> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Model: Unit', () => {
beforeEach(async(() => {
instance = new Unit();
}));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

16
src/models/class/Unit.ts

@ -1,16 +0,0 @@
import 'rxjs/add/operator/map';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne } from "typeorm";
@Entity()
export class Unit {
@PrimaryGeneratedColumn()
id: number;
@Column()
description: string;
@Column()
initials: string;
}

0
src/pages/home/home.html → src/pages/inicio/main.html

2
src/pages/home/home.scss → src/pages/inicio/main.scss

@ -1,4 +1,4 @@
page-home {
page-inicio {
.btnhome {
padding:5%;
margin-top:20%;

8
src/pages/home/home.spec.ts → src/pages/inicio/main.spec.ts

@ -1,8 +1,8 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../test';
import { HomePage } from './home';
import { PageInicio } from './main';
let fixture: ComponentFixture<HomePage> = null;
let fixture: ComponentFixture<PageInicio> = null;
let instance: any = null;
declare var describe: any;
@ -10,9 +10,9 @@ declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Pages: HomePage', () => {
describe('Pages: PageInicio', () => {
beforeEach(async(() => TestUtils.beforeEachCompiler([HomePage]).then(compiled => {
beforeEach(async(() => TestUtils.beforeEachCompiler([PageInicio]).then(compiled => {
fixture = compiled.fixture;
instance = compiled.instance;
})));

10
src/pages/home/home.ts → src/pages/inicio/main.ts

@ -1,13 +1,11 @@
import { Component, ViewChild } from '@angular/core';
import { NavController , Nav} from 'ionic-angular';
import { ListItemListPage } from "../listitem/list-item-list-page/list-item-list-page";
@Component({
selector: 'page-home',
templateUrl: 'home.html'
selector: 'page-inicio',
templateUrl: 'main.html'
})
export class HomePage {
export class PageInicio {
@ViewChild(Nav) nav: Nav;
@ -16,7 +14,7 @@ export class HomePage {
}
openPage() {
return this.navCtrl.setRoot(ListItemListPage);
return this.navCtrl.setRoot(PageInicio);
}
}

34
src/pages/listitem/list-item-create-page/list-item-create-page.html

@ -1,34 +0,0 @@
<!--
Generated template for the ProductCreatePage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar color="tertiary">
<ion-title>Cadastrar Lista de Itens</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item>
<ion-label stacked>Nome da Lista</ion-label>
<ion-input type="text" [(ngModel)]="_listItem.sName"></ion-input>
</ion-item>
<ion-item>
<ion-label>Produtos</ion-label>
<ion-select [(ngModel)]="_listItem.iListProduct" multiple="true">
<ion-option *ngFor="let product of _listProducts" [value]="product">{{product.sName}}</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label stacked>Descrição da Lista</ion-label>
<ion-textarea rows="4" [(ngModel)]="_listItem.sDescription" placeholder="Descreva sobre a Lista"></ion-textarea>
</ion-item>
</ion-list>
<button ion-button full (click)="salvar()">Salvar</button>
</ion-content>

16
src/pages/listitem/list-item-create-page/list-item-create-page.module.ts

@ -1,16 +0,0 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ListItemCreatePage } from './list-item-create-page';
@NgModule({
declarations: [
ListItemCreatePage,
],
imports: [
IonicPageModule.forChild(ListItemCreatePage),
],
exports: [
ListItemCreatePage
]
})
export class ListItemCreatePageModule {}

3
src/pages/listitem/list-item-create-page/list-item-create-page.scss

@ -1,3 +0,0 @@
page-list-item-create-page {
}

24
src/pages/listitem/list-item-create-page/list-item-create-page.spec.ts

@ -1,24 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../../test';
import { ListItemCreatePage } from './list-item-create-page';
let fixture: ComponentFixture<ListItemCreatePage> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Pages: ListItemCreatePage', () => {
beforeEach(async(() => TestUtils.beforeEachCompiler([ListItemCreatePage]).then(compiled => {
fixture = compiled.fixture;
instance = compiled.instance;
})));
/*
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
*/
});

82
src/pages/listitem/list-item-create-page/list-item-create-page.ts

@ -1,82 +0,0 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { ListItem } from "../../../models/class/ListItem";
import { DaoListItem } from "../../../providers/dao/dao-listitem.service";
import { Toast } from "@ionic-native/toast";
import { ListItemListPage } from "../list-item-list-page/list-item-list-page";
import { Product } from "../../../models/class/Product";
import { DaoProduct } from "../../../providers/dao/dao-product.service";
/**
* Generated class for the ListItemCreatePage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-list-item-create-page',
templateUrl: 'list-item-create-page.html',
})
export class ListItemCreatePage {
_listItem: ListItem;
_listProducts: Product[];
constructor(public navCtrl: NavController, public navParams: NavParams,
public alert: AlertController, private _daoListItem: DaoListItem, private _daoProduct: DaoProduct,
private _toast: Toast) {
this._listItem = navParams.get("parametro") || new ListItem();
this._listItem.iListProduct = [];
this._daoProduct.getAll().then((produtos) => {
this._listProducts = produtos;
});
}
salvar() {
if ((typeof (this._listItem.sName) !== 'undefined') && (this._listItem.iListProduct.length > 0)) {
if (this._listItem.nId > 0) {
this._daoListItem.update(this._listItem).then((data) => {
console.log("expected => " + data);
if (data) {
this._toast.show("Lista de Itens editada com sucesso", '1500', 'center').subscribe(
toast => {
console.log(toast);
}
);
this.navCtrl.setRoot(ListItemListPage);
}
}).catch((erro) => {
console.log("erro => " + erro);
})
} else {
this._daoListItem.create(this._listItem).then((data) => {
console.log("expected => " + data);
if (data) {
this._listItem.nId = data.insertId;
this._daoListItem.createAux(this._listItem);
this.navCtrl.setRoot(ListItemListPage);
}
}).catch((erro) => {
console.log("erro => " + erro);
})
}
this.navCtrl.setRoot(ListItemListPage);
} else {
let confirm = this.alert.create({
title: "Ops...",
subTitle: "Por favor verifique se a lista tem um nome ou se você escolheu algum produto.",
buttons: [
{
text: "OK",
handler: () => {
}
}
]
});
confirm.present();
}
}
}

21
src/pages/listitem/list-item-list-page/list-item-list-page.html

@ -1,21 +0,0 @@
<ion-header>
<ion-navbar color="primary">
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Lista de Itens</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item *ngFor="let list of _listItem" class="item-icon-left" (click)="options(list)">
<ion-icon name="cart"></ion-icon> {{list.sName}}
</ion-item>
</ion-list>
<ion-fab right bottom>
<button ion-fab color="secondary" (click)="insert()">
<ion-icon name="add"></ion-icon>
</button>
</ion-fab>
</ion-content>

16
src/pages/listitem/list-item-list-page/list-item-list-page.module.ts

@ -1,16 +0,0 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ListItemListPage } from './list-item-list-page';
@NgModule({
declarations: [
ListItemListPage,
],
imports: [
IonicPageModule.forChild(ListItemListPage),
],
exports: [
ListItemListPage
]
})
export class ListItemListPageModule {}

3
src/pages/listitem/list-item-list-page/list-item-list-page.scss

@ -1,3 +0,0 @@
page-list-item-list-page {
}

24
src/pages/listitem/list-item-list-page/list-item-list-page.spec.ts

@ -1,24 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../../test';
import { ListItemListPage } from './list-item-list-page';
let fixture: ComponentFixture<ListItemListPage> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Pages: ListItemListPage', () => {
beforeEach(async(() => TestUtils.beforeEachCompiler([ListItemListPage]).then(compiled => {
fixture = compiled.fixture;
instance = compiled.instance;
})));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

114
src/pages/listitem/list-item-list-page/list-item-list-page.ts

@ -1,114 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { IonicPage, NavController, NavParams, ActionSheetController, AlertController } from 'ionic-angular';
import { ListItem } from "../../../models/class/ListItem";
import { Toast } from "@ionic-native/toast";
import { DaoListItem } from "../../../providers/dao/dao-listitem.service";
import { ListItemCreatePage } from "../list-item-create-page/list-item-create-page";
/**
* Generated class for the ListItemListPage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-list-item-list-page',
templateUrl: 'list-item-list-page.html',
})
export class ListItemListPage implements OnInit {
ngOnInit(): void {
this.getAllListItem();
}
_listItem: ListItem[] = [];
constructor(public navCtrl: NavController, public navParams: NavParams, public alert: AlertController,
private _daoListItem: DaoListItem, public actionSheetCtrl: ActionSheetController,
private _toast: Toast) {
}
insert() {
this.navCtrl.push(ListItemCreatePage);
}
ionViewDidLoad() {
}
getAllListItem() {
this._daoListItem.getAll()
.then(listItem => {
this._listItem = listItem;
})
.catch(error => {
console.error(error);
});
}
options(listItem: ListItem) {
let actionSheet = this.actionSheetCtrl.create({
title: 'Escolha uma das opções abaixo:',
buttons: [
{
text: 'Deletar',
role: 'destructive',
icon: 'trash',
handler: () => {
let confirm = this.alert.create({
title: "Excluir",
subTitle: "Gostaria de realmente excluir a Lista de Itens " + listItem.sName + "?",
buttons: [
{
text: "Sim",
handler: () => {
let index = this._listItem.indexOf(listItem);
this._daoListItem.delete(listItem)
.then(response => {
console.log(response);
this._daoListItem.deleteAux(listItem);
this._listItem.splice(index, 1);
this._toast.show("Lista de Itens excluído com sucesso", '1500', 'center').subscribe(
toast => {
console.log(toast);
}
);
})
.catch(error => {
console.error(error);
})
}
},
{
text: "Não"
}
]
});
confirm.present();
}
},
/* {
text: 'Editar',
role: 'edit',
icon: 'create',
handler: () => {
this.navCtrl.push(ListItemCreatePage, { parametro: listItem });
}
},*/
{
text: 'Cancelar',
role: 'cancel',
icon: 'close',
handler: () => {
}
}
]
});
actionSheet.present();
}
}

24
src/pages/market/market-create-page/market-create-page.html

@ -1,24 +0,0 @@
<!--
Generated template for the ProductCreatePage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar color="tertiary">
<ion-title>Cadastrar Supermercado</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item>
<ion-label stacked>Nome do Supermercado</ion-label>
<ion-input type="text" [(ngModel)]="_market.sName"></ion-input>
</ion-item>
</ion-list>
<button ion-button full (click)="salvar()">Salvar</button>
</ion-content>

16
src/pages/market/market-create-page/market-create-page.module.ts

@ -1,16 +0,0 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { MarketCreatePage } from './market-create-page';
@NgModule({
declarations: [
MarketCreatePage,
],
imports: [
IonicPageModule.forChild(MarketCreatePage),
],
exports: [
MarketCreatePage
]
})
export class MarketCreatePageModule {}

3
src/pages/market/market-create-page/market-create-page.scss

@ -1,3 +0,0 @@
page-market-create-page {
}

72
src/pages/market/market-create-page/market-create-page.ts

@ -1,72 +0,0 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { Market } from "../../../models/class/Market";
import { DaoMarket } from "../../../providers/dao/dao-market.service";
import { Toast } from "@ionic-native/toast";
import { MarketListPage } from "../market-list-page/market-list-page";
/**
* Generated class for the MarketCreatePage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-market-create-page',
templateUrl: 'market-create-page.html',
})
export class MarketCreatePage {
_market: Market;
constructor(public navCtrl: NavController, public navParams: NavParams,
public alert: AlertController, private _daoMarket: DaoMarket,
private _toast: Toast) {
this._market = navParams.get("parametro") || new Market();
}
ionViewDidLoad() {
console.log('ionViewDidLoad marketCreatePage');
}
salvar() {
if ((typeof (this._market.sName) !== 'undefined')) {
if (this._market.nId > 0) {
this._daoMarket.update(this._market).then((data) => {
console.log("expected => " + data);
if (data) {
this._toast.show("Supermercado editado com sucesso", '1500', 'center').subscribe(
toast => {
console.log(toast);
}
);
this.navCtrl.setRoot(MarketListPage);
}
}).catch((erro) => {
console.log("erro => " + erro);
})
} else {
this._daoMarket.create(this._market).then((data) => {
console.log("expected => " + data);
if (data) {
this.navCtrl.setRoot(MarketListPage);
}
}).catch((erro) => {
console.log("erro => " + erro);
})
}
this.navCtrl.setRoot(MarketListPage);
} else {
let confirm = this.alert.create({
title: "Ops...",
subTitle: "Por favor coloque um nome para o Supermercado.",
buttons: [
{
text: "OK",
handler: () => {
}
}
]
});
confirm.present();
}
}
}

19
src/pages/market/market-list-page/market-list-page.html

@ -1,19 +0,0 @@
<ion-header>
<ion-navbar color="primary">
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Lista de Supermercados</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item *ngFor="let market of _markets" (click)="options(market)">
{{market.sName}}
</ion-item>
</ion-list>
<ion-fab right bottom>
<button ion-fab color="secondary" (click)="insert()"><ion-icon name="add"></ion-icon></button>
</ion-fab>
</ion-content>

16
src/pages/market/market-list-page/market-list-page.module.ts

@ -1,16 +0,0 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { MarketListPage } from './market-list-page';
@NgModule({
declarations: [
MarketListPage,
],
imports: [
IonicPageModule.forChild(MarketListPage),
],
exports: [
MarketListPage
]
})
export class MarketListPageModule {}

3
src/pages/market/market-list-page/market-list-page.scss

@ -1,3 +0,0 @@
page-market-list-page {
}

24
src/pages/market/market-list-page/market-list-page.spec.ts

@ -1,24 +0,0 @@
import { ComponentFixture, async } from '@angular/core/testing';
import { TestUtils } from '../../../test';
import { MarketListPage } from './market-list-page';
let fixture: ComponentFixture<MarketListPage> = null;
let instance: any = null;
declare var describe: any;
declare var it: any;
declare var expect: any;
declare var beforeEach: any;
describe('Pages: MarketListPage', () => {
beforeEach(async(() => TestUtils.beforeEachCompiler([MarketListPage]).then(compiled => {
fixture = compiled.fixture;
instance = compiled.instance;
})));
it('should create the start page', async(() => {
expect(instance).toBeTruthy();
}));
});

113
src/pages/market/market-list-page/market-list-page.ts

@ -1,113 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { IonicPage, NavController, NavParams, ActionSheetController, AlertController } from 'ionic-angular';
import { Market } from "../../../models/class/Market";
import { Toast } from "@ionic-native/toast";
import { DaoMarket } from "../../../providers/dao/dao-market.service";
import { MarketCreatePage } from "../market-create-page/market-create-page";
/**
* Generated class for the MarketListPage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-market-list-page',
templateUrl: 'market-list-page.html',
})
export class MarketListPage implements OnInit {
ngOnInit(): void {
this.getAllMarketts();
}
_markets: Market[] = [];
constructor(public navCtrl: NavController, public navParams: NavParams, public alert: AlertController,
private _daoMarket: DaoMarket, public actionSheetCtrl: ActionSheetController,
private _toast: Toast) {
}
insert() {
this.navCtrl.push(MarketCreatePage);
}
ionViewDidLoad() {
}
getAllMarketts() {
this._daoMarket.getAll()
.then(markets => {
this._markets = markets;
})
.catch(error => {
console.error(error);
});
}
options(market: Market) {
let actionSheet = this.actionSheetCtrl.create({
title: 'Escolha uma das opções abaixo:',
buttons: [
{
text: 'Deletar',
role: 'destructive',
icon: 'trash',
handler: () => {
let confirm = this.alert.create({
title: "Excluir",
subTitle: "Gostaria de realmente excluir o Supermercado " + market.sName + "?",
buttons: [
{
text: "Sim",
handler: () => {
let index = this._markets.indexOf(market);
this._daoMarket.delete(market)
.then(response => {
console.log(response);
this._markets.splice(index, 1);
this._toast.show("Supermercado excluído com sucesso", '1500', 'center').subscribe(
toast => {
console.log(toast);
}
);
})
.catch(error => {
console.error(error);
})
}
},
{
text: "Não"
}
]
});
confirm.present();
}
},
{
text: 'Editar',
role: 'edit',
icon: 'create',
handler: () => {
this.navCtrl.push(MarketCreatePage, { parametro: market });
}
},
{
text: 'Cancelar',
role: 'cancel',
icon: 'close',
handler: () => {
}
}
]
});
actionSheet.present();
}
}

24
src/pages/product/product-create-page/product-create-page.html

@ -1,24 +0,0 @@
<!--
Generated template for the ProductCreatePage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar color="tertiary">
<ion-title>Cadastrar Produto</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item>
<ion-label stacked>Nome do Produto</ion-label>
<ion-input type="text" [(ngModel)]="_product.sName"></ion-input>
</ion-item>
</ion-list>
<button ion-button full (click)="salvar()">Salvar</button>
</ion-content>

16
src/pages/product/product-create-page/product-create-page.module.ts

@ -1,16 +0,0 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ProductCreatePage } from './product-create-page';
@NgModule({
declarations: [
ProductCreatePage,
],
imports: [
IonicPageModule.forChild(ProductCreatePage),
],
exports: [
ProductCreatePage
]
})
export class ProductCreatePageModule {}

3
src/pages/product/product-create-page/product-create-page.scss

@ -1,3 +0,0 @@
page-product-create-page {
}

72
src/pages/product/product-create-page/product-create-page.ts

@ -1,72 +0,0 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { Product } from "../../../models/class/Product";
import { Toast } from "@ionic-native/toast";
import { DaoProduct } from "../../../providers/dao/dao-product.service";
import { ProductListPage } from "../product-list-page/product-list-page";
/**
* Generated class for the ProductCreatePage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-product-create-page',
templateUrl: 'product-create-page.html',
})
export class ProductCreatePage {
_product: Product;
constructor(public navCtrl: NavController, public navParams: NavParams,
public alert: AlertController, private _daoProduct: DaoProduct,
private _toast: Toast) {
this._product = navParams.get("parametro") || new Product();
}
ionViewDidLoad() {
console.log('ionViewDidLoad ProductCreatePage');
}
salvar() {
if ((typeof (this._product.sName) !== 'undefined')) {
if (this._product.nId > 0) {
this._daoProduct.update(this._product).then((data) => {
console.log("expected => " + data);
if (data) {
this._toast.show("Produto editado com sucesso", '1500', 'center').subscribe(
toast => {
console.log(toast);
}
);
this.navCtrl.setRoot(ProductListPage);
}
}).catch((erro) => {
console.log("erro => " + erro);
})
} else {
this._daoProduct.create(this._product).then((data) => {
console.log("expected => " + data);
if (data) {
this.navCtrl.setRoot(ProductListPage);
}
}).catch((erro) => {
console.log("erro => " + erro);
})
}
this.navCtrl.setRoot(ProductListPage);
} else {
let confirm = this.alert.create({
title: "Ops...",
subTitle: "Por favor coloque um nome para o Produto.",
buttons: [
{
text: "OK",
handler: () => {
}
}
]
});
confirm.present();
}
}
}

19
src/pages/product/product-list-page/product-list-page.html

@ -1,19 +0,0 @@
<ion-header>
<ion-navbar color="primary">
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Lista de Produtos</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item *ngFor="let product of _products" (click)="options(product)">
{{product.sName}}
</ion-item>
</ion-list>
<ion-fab right bottom>
<button ion-fab color="secondary" (click)="insert()"><ion-icon name="add"></ion-icon></button>
</ion-fab>
</ion-content>

16
src/pages/product/product-list-page/product-list-page.module.ts

@ -1,16 +0,0 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ProductListPage } from './product-list-page';
@NgModule({
declarations: [
ProductListPage,
],
imports: [
IonicPageModule.forChild(ProductListPage),
],
exports: [
ProductListPage
]
})
export class ProductListPageModule {}

3
src/pages/product/product-list-page/product-list-page.scss