-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dev-server): Example embedded UI extensions
Relates to #225
- Loading branch information
1 parent
085c7cf
commit 532b952
Showing
8 changed files
with
139 additions
and
13 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/admin-ui/src/app/core/components/notification/notification.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/dev-server/ui-plugin/extensions/js-app/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
<h1>Hello from the plain JS app</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/dev-server/ui-plugin/extensions/vue-app/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Vue App</title> | ||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | ||
<script src="../devkit/ui-devkit.js"></script> | ||
<link rel="stylesheet" href="https://unpkg.com/@clr/ui/clr-ui.min.css" /> | ||
</head> | ||
<body> | ||
<div id="app" style="padding: 1rem;"> | ||
<div> | ||
<h1>Hello from Vue.js!</h1> | ||
<button v-on:click="getProducts" class="btn btn-primary">Get products</button> | ||
<h3>Products</h3> | ||
<ol> | ||
<li v-for="product in products"> | ||
{{ product.name }} | ||
<span class="label label-success" v-if="product.enabled">Enabled</span> | ||
<span class="label label-danger" v-else>Disabled</span> | ||
<button | ||
v-on:click="toggleEnabled(product.id, !product.enabled)" | ||
class="btn btn-sm btn-secondary" | ||
> | ||
toggle | ||
</button> | ||
</li> | ||
</ol> | ||
</div> | ||
</div> | ||
<script> | ||
var app = new Vue({ | ||
el: '#app', | ||
data: { | ||
message: 'Hello Vue!', | ||
products: [], | ||
}, | ||
methods: { | ||
getProducts: function() { | ||
const query = ` | ||
query GetProducts($skip: Int, $take: Int) { | ||
products(options: { skip: $skip, take: $take }) { | ||
items { id, name, enabled }, | ||
totalItems | ||
} | ||
}`; | ||
this.sub = VendureUiDevkit.graphQlQuery(query, { | ||
skip: 0, | ||
take: 10, | ||
}).stream.subscribe( | ||
val => { | ||
this.products = val.products.items; | ||
}, | ||
err => console.error(err), | ||
() => console.log('completed products stream'), | ||
); | ||
}, | ||
toggleEnabled: function(id, enabled) { | ||
const mutation = ` | ||
mutation ToggleEnabled($id: ID!, $enabled: Boolean!) { | ||
updateProduct(input: { id: $id, enabled: $enabled }) { | ||
id | ||
enabled | ||
} | ||
} | ||
`; | ||
VendureUiDevkit.graphQlMutation(mutation, { id, enabled }).then(val => { | ||
VendureUiDevkit.notify({ | ||
message: 'Updated Product', | ||
}); | ||
}); | ||
}, | ||
}, | ||
beforeDestroy: function() { | ||
console.log('destroying!'); | ||
this.sub.unsubscribe(); | ||
}, | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters