diff --git a/examples/demo/rest-sandbox.http b/examples/demo/rest-sandbox.http new file mode 100644 index 000000000..daf79c29b --- /dev/null +++ b/examples/demo/rest-sandbox.http @@ -0,0 +1,49 @@ +# This is for VSCode `REST Client` plugin. Use it, it rocks +# @host = https://rcm-dev-api.9ci.io +@host = http://localhost:8080 +@base_url = {{host}}/api/ar/customer +# @host = localhost:8080 +@contentType = application/json +# @token = dfasfasdfadfs + + +# @name login +POST {{host}}/api/login +Content-Type: application/json + +{"username":"admin","password":"123F"} + +### +@token = {{login.response.body.$.access_token}} + +### Get Customers### Get Customers +GET {{base_url}}?max=20&page=1&sort=org.calc.totalDue +Authorization: Bearer {{token}} + +### get customers query +GET {{base_url}}?q=wal% + +### post/create and put/update + +# @name post_it +POST {{base_url}} +Content-Type: application/json + +{ + "num": {{$randomInt 100 10000}}, + "name": "Test" +} + +### Get it + +@created_id = {{post_it.response.body.$.id}} + +GET {{base_url}}/{{created_id}} + +### update it + +PUT {{base_url}}/{{created_id}} + +{ + "name": "TestUpdate" +} diff --git a/examples/demo/src/app.config.js b/examples/demo/src/app.config.js index 555805b49..a1464ac64 100644 --- a/examples/demo/src/app.config.js +++ b/examples/demo/src/app.config.js @@ -3,8 +3,9 @@ import _ from 'lodash' import appName from './app.module' import './config.router' import appState from 'angle-grinder/src/tools/AppState' -import {setConfig} from 'angle-grinder/src/tools/AppConfig' -import {setClientConfig} from "angle-grinder/src/dataApi/kyApi"; +import { KyFactory } from "angle-grinder/src/stores/ky"; +KyFactory.enableAuthHeader() +KyFactory.defaults.prefixUrl = configData.base_url const app = angular.module(appName) // export default app.name @@ -63,24 +64,10 @@ app.run(function($rootScope, $state, $stateParams) { appState.sidenav.open = true $rootScope.appState = appState - setClientConfig({ - // configData comes from index.html - to be able to change backend url on fly after build, takes data from `config.js` in root folder of the app - // eslint-disable-next-line no-undef - prefixUrl: configData.base_url - }) + // setClientConfig({ + // // configData comes from index.html - to be able to change backend url on fly after build, takes data from `config.js` in root folder of the app + // // eslint-disable-next-line no-undef + // prefixUrl: configData.base_url + // }) - const conf = { - controls: { - ranges: { - fromField: { - name: '$gt' - }, - toField: { - name: '$lt' - } - } - } - } - - setConfig(conf) }) diff --git a/examples/demo/src/grids/customGridList/list/ListCtrl.js b/examples/demo/src/grids/customGridList/list/ListCtrl.js index 8c1f8cc36..f831dce6c 100644 --- a/examples/demo/src/grids/customGridList/list/ListCtrl.js +++ b/examples/demo/src/grids/customGridList/list/ListCtrl.js @@ -1,7 +1,7 @@ // import controller from './listCtrl' // import template from './list.html' import BaseListCtrl from 'angle-grinder/src/ng/gridz/list/BaseListCtrl' -import restStoreApi from '../../../store/RestStoreApi' +import dataApiFactory from '../../../store/dataApiFactory' import toast from 'angle-grinder/src/tools/toast' export default class ListCtrl extends BaseListCtrl { @@ -17,7 +17,7 @@ export default class ListCtrl extends BaseListCtrl { // static $inject = _.union(super.$inject, ['someService']) constructor(...args) { super(...args) - this.dataApi = restStoreApi.invoice + this.dataApi = dataApiFactory.invoice } async $onInit() { diff --git a/examples/demo/src/grids/localStoreGrid/index.js b/examples/demo/src/grids/localStoreGrid/index.js index 661e49cbe..83db3ca93 100644 --- a/examples/demo/src/grids/localStoreGrid/index.js +++ b/examples/demo/src/grids/localStoreGrid/index.js @@ -7,7 +7,7 @@ const template = `\ export default angular .module(compDemoModule) - .component('basicGridIndex', { + .component('localStoreIndex', { template: template, controller: function() { this.rawHtml = require('./list.html') diff --git a/examples/demo/src/grids/localStoreGrid/list.html b/examples/demo/src/grids/localStoreGrid/list.html index ebbbae105..0a0221bc7 100644 --- a/examples/demo/src/grids/localStoreGrid/list.html +++ b/examples/demo/src/grids/localStoreGrid/list.html @@ -1,11 +1,11 @@
vm: {{$ctrl.vm | json}}
Selected Rows data: {{$ctrl.selectedRowsData | json}}diff --git a/examples/demo/src/grids/localStoreGrid/listComp.js b/examples/demo/src/grids/localStoreGrid/listComp.js index 2c3fdf746..1d920e897 100644 --- a/examples/demo/src/grids/localStoreGrid/listComp.js +++ b/examples/demo/src/grids/localStoreGrid/listComp.js @@ -1,13 +1,13 @@ // import controller from './listCtrl' import template from './list.html' -import BaseListCtrl from 'angle-grinder/src/ng/gridz/list/BaseListCtrl' +import ListDataApiCtrl from 'angle-grinder/src/ng/gridz/list-datastore/ListDataApiCtrl' import buildOptions from './listCtrlOptions' -import localStoreApi from '../../store/LocalStoreApi' +import sessionStores from '../../store/sessionServices' import Log from 'angle-grinder/src/utils/Log' import Swal from 'angle-grinder/src/tools/swal' import _ from 'lodash' -class ListCtrl extends BaseListCtrl { +class ListCtrl extends ListDataApiCtrl { isLoaded = false editTemplate = require('./templates/editDialog.html') @@ -15,11 +15,10 @@ class ListCtrl extends BaseListCtrl { constructor(...args) { super(...args) - this.dataApi = localStoreApi.invoice + this.dataApi = sessionStores.invoice } async $onInit() { - // this.dataApi = localStoreApi.invoice this.cfg = buildOptions(this) await this.doConfig(this.cfg) } diff --git a/examples/demo/src/grids/routes.js b/examples/demo/src/grids/routes.js index 70822ee0b..f8b1fa13c 100644 --- a/examples/demo/src/grids/routes.js +++ b/examples/demo/src/grids/routes.js @@ -1,3 +1,5 @@ +import dataApiFactory from '../store/dataApiFactory' + const gridsStates = { name: 'grids', abstract: true, @@ -7,15 +9,15 @@ const gridsStates = { }, children: [ { - name: 'vanilla-agGridList', - data: { title: 'Customer Grid Example' }, - abstract: 'fresh.grid.vanilla-agGridList.list', - url: '/customer', + name: 'agGridDatastore', + data: { title: 'Customer Grid' }, + abstract: 'fresh.grid.agGridDatastore.list', + url: '/customer-ds', children: [{ name: 'list', isMenuItem: false, url: '', - component: 'agGridList' + component: 'agGridDatastore' }, { name: 'Edit Customer', isMenuItem: false, @@ -24,6 +26,11 @@ const gridsStates = { }], resolve: { apiKey: () => 'customer', + dataApi: () => { + let ds = dataApiFactory.customer + console.log("dataApiFactory.customer", ds) + return ds + }, // gridOptions: () => ({multiSort: true}), notification: () => ({ class: 'is-primary is-light', @@ -40,7 +47,7 @@ const gridsStates = { name: 'list', isMenuItem: false, url: '', - component: 'agGridList' + component: 'agGridDatastore' }, { name: 'Edit Customer', isMenuItem: false, @@ -49,6 +56,9 @@ const gridsStates = { }], resolve: { apiKey: () => 'customer', + dataApi: () => { + return dataApiFactory.customer + }, initSearch: () => ({ name: 'Yodo' }), notification: () => ({ class: 'is-primary is-light', @@ -59,10 +69,13 @@ const gridsStates = { { name: 'editOnly-agGridList', url: '/tag', - component: 'agGridList', + component: 'agGridDatastore', data: { title: 'Edit Only agGridList' }, resolve: { apiKey: () => 'tag', + dataApi: () => { + return dataApiFactory.tag + }, notification: () => ({ class: 'is-primary is-light', text: 'Uses ui-router to send rest apiKey to generic agGridList component, configured to only allow editing desc' @@ -80,9 +93,9 @@ const gridsStates = { component: 'basicGridRestIndex' }, { - name: 'basic-grid', - component: 'basicGridIndex', - url: '/foo' + name: 'local-store-grid', + component: 'localStoreIndex', + url: '/localstore' } ] } diff --git a/examples/demo/src/grids/twoGrids/customerList/ListCtrl.js b/examples/demo/src/grids/twoGrids/customerList/ListCtrl.js index 62cdf6841..86a4791c0 100644 --- a/examples/demo/src/grids/twoGrids/customerList/ListCtrl.js +++ b/examples/demo/src/grids/twoGrids/customerList/ListCtrl.js @@ -1,9 +1,9 @@ -import BaseListCtrl from 'angle-grinder/src/ng/gridz/list/BaseListCtrl' -import restStoreApi from '../../../store/RestStoreApi' +import ListDataApiCtrl from 'angle-grinder/src/ng/gridz/list-datastore/ListDataApiCtrl' +import dataApiFactory from '../../../store/dataApiFactory' import _ from 'lodash' -export default class ListCtrl extends BaseListCtrl { - static $inject = _.union(super.$inject, ['dataStoreApi', '$state', 'selectedRow']) +export default class ListCtrl extends ListDataApiCtrl { + static $inject = _.union(super.$inject, ['$state', 'selectedRow']) apiKey = 'customer' eventHandlers = { onSelect: (event, id) => { @@ -13,7 +13,7 @@ export default class ListCtrl extends BaseListCtrl { constructor(...args) { super(...args) - this.dataApi = restStoreApi.customer + this.dataApi = dataApiFactory.customer } async $onInit() { diff --git a/examples/demo/src/grids/twoGrids/customerList/list.html b/examples/demo/src/grids/twoGrids/customerList/list.html index c6d1254a8..e1e7ea849 100644 --- a/examples/demo/src/grids/twoGrids/customerList/list.html +++ b/examples/demo/src/grids/twoGrids/customerList/list.html @@ -1,8 +1,8 @@