Skip to content

Commit

Permalink
refactor(web): add basic toggle for show dump
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 20, 2021
1 parent 70078d9 commit f81aa9d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 78 deletions.
31 changes: 27 additions & 4 deletions quake_webapp/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,34 @@ const Router = Vaadin.Router;
const outlet = document.getElementById('outlet');
const router = new Router(outlet);

function PageSearch(options) {
this.options = options;
this.type = '';
}

PageSearch.prototype.index = function (type) {
this.type = type;
return this;
}

PageSearch.prototype.search = function (options) {
return new Promise(async (resolve, reject) => {
let response = await fetch(`/indexes/${this.type}/search`);
let data = await response.json();
resolve({
hits: data
});
})
};

// modify by content
let is_pagedump = false;

const Quake = {
// init flow map
// config for global
pagedump: is_pagedump,
flows: {},
client: new MeiliSearch({
client: is_pagedump ? new PageSearch() : new MeiliSearch({
host: 'http://127.0.0.1:7700'
}),
router: router,
Expand Down Expand Up @@ -118,7 +142,6 @@ const show_entry = async (context, commands) => {

editor.addEventListener("clickPageLink", function (event) {
let data = event.detail;
console.log(data);
Router.go(`/show/${data.type}/${data.id}`);
});

Expand All @@ -128,7 +151,7 @@ const show_entry = async (context, commands) => {
function handleAction(define) {
if (define.action === 'add') {
Router.go(`/entry/${define.object}/new?text=${define.text}`)
} else if(define.action === 'show') {
} else if (define.action === 'show') {
Router.go(`/show/${define.object}/${define.parameters[0]}`);
} else if (define.parameters.length > 0) {
Router.go(`/edit/${define.object}/${define.parameters[0]}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Build} from "@stencil/core";
import init, {flow_to_code, parse_action} from "@quakeworks/quake_wasm";
import axios from "axios";

Expand All @@ -7,20 +6,20 @@ export async function init_wasm() {
}

export async function parseAction(str: string) {
if (!Build.isDev) {
if ((window as any).Quake?.pagedump) {
return JSON.parse(parse_action(str));
} else {
return axios.get('/action/query/', {
params: {
input: this.query.substring(1,)
input: str
}
}).then((res) => {return res.data});
}
}

// demo: from('blog').to(<ion-button>)
export async function createTransflow(flow_name: string, flow: string) {
if (!Build.isDev) {
if ((window as any).Quake?.pagedump) {
let transflow = `transflow ${flow_name} { ${flow} } `
let defines = await axios.get('/entry/defines').then((res) => {
return res.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export class QuakeDashboard {
bubbles: true,
}) dispatchAction: EventEmitter<ActionDefine>;

client = new MeiliSearch({
client = (window as any).Quake?.client ? (window as any).Quake.client : new MeiliSearch({
host: 'http://127.0.0.1:7700'
})
});

componentWillLoad() {
init_wasm().then(() => {
Expand Down
59 changes: 0 additions & 59 deletions quake_webapp/dashboard/src/components/quake-dashboard/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,72 +24,13 @@
### Depends on

- [fetch-api](../fetch-api)
- ion-toast
- ion-app
- ion-header
- ion-toolbar
- ion-item
- ion-chip
- ion-icon
- ion-label
- ion-input
- ion-button
- ion-content
- ion-grid
- ion-row
- ion-infinite-scroll
- ion-infinite-scroll-content
- [simple-layout](../simple-layout)
- ion-col
- ion-text
- ion-list
- ion-card
- ion-card-header
- ion-card-subtitle
- ion-card-title
- ion-card-content
- ion-badge

### Graph
```mermaid
graph TD;
quake-dashboard --> fetch-api
quake-dashboard --> ion-toast
quake-dashboard --> ion-app
quake-dashboard --> ion-header
quake-dashboard --> ion-toolbar
quake-dashboard --> ion-item
quake-dashboard --> ion-chip
quake-dashboard --> ion-icon
quake-dashboard --> ion-label
quake-dashboard --> ion-input
quake-dashboard --> ion-button
quake-dashboard --> ion-content
quake-dashboard --> ion-grid
quake-dashboard --> ion-row
quake-dashboard --> ion-infinite-scroll
quake-dashboard --> ion-infinite-scroll-content
quake-dashboard --> simple-layout
quake-dashboard --> ion-col
quake-dashboard --> ion-text
quake-dashboard --> ion-list
quake-dashboard --> ion-card
quake-dashboard --> ion-card-header
quake-dashboard --> ion-card-subtitle
quake-dashboard --> ion-card-title
quake-dashboard --> ion-card-content
quake-dashboard --> ion-badge
ion-toast --> ion-icon
ion-toast --> ion-ripple-effect
ion-item --> ion-icon
ion-item --> ion-ripple-effect
ion-chip --> ion-ripple-effect
ion-button --> ion-ripple-effect
ion-infinite-scroll-content --> ion-spinner
simple-layout --> ion-grid
simple-layout --> ion-row
simple-layout --> ion-col
ion-card --> ion-ripple-effect
style quake-dashboard fill:#f9f,stroke:#333,stroke-width:4px
```

Expand Down
9 changes: 0 additions & 9 deletions quake_webapp/dashboard/src/components/simple-layout/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,9 @@

- [quake-dashboard](../quake-dashboard)

### Depends on

- ion-grid
- ion-row
- ion-col

### Graph
```mermaid
graph TD;
simple-layout --> ion-grid
simple-layout --> ion-row
simple-layout --> ion-col
quake-dashboard --> simple-layout
style simple-layout fill:#f9f,stroke:#333,stroke-width:4px
```
Expand Down

0 comments on commit f81aa9d

Please sign in to comment.