Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 3a32746

Browse files
committed
implement generating services using UI
1 parent 1e35262 commit 3a32746

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed

resources/views/components/add-menu.blade.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
<div id="creation-menu">
88
<ul class="mdl-menu mdl-menu--top-right mdl-js-menu mdl-js-ripple-effect"
99
data-mdl-for="lucid-add-button">
10-
<li class="mdl-menu__item" @click="showCreateJobDialog()">Job</li>
10+
<li class="mdl-menu__item" @click="showCreateServiceDialog()">Service</li>
1111
<li class="mdl-menu__item" @click="showCreateFeatureDialog()">Feature</li>
12+
<li class="mdl-menu__item" @click="showCreateJobDialog()">Job</li>
1213
</ul>
1314
</div>
1415

@@ -24,6 +25,10 @@
2425
2526
showCreateFeatureDialog: function() {
2627
CreateFeatureDialog.show();
28+
},
29+
30+
showCreateServiceDialog: function() {
31+
CreateServiceDialog.show();
2732
}
2833
}
2934
});
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!-- create service form -->
2+
<dialog id="lucid-create-service-dialog" class="mdl-dialog">
3+
<h5 class="mdl-dialog__title">New Service</h5>
4+
<div class="mdl-dialog__content">
5+
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
6+
<input class="mdl-textfield__input" type="text" id="lucid-service-title" v-model="name">
7+
<label class="mdl-textfield__label" for="lucid-service-title">Name your Service</label>
8+
</div>
9+
</div>
10+
<div class="mdl-dialog__actions">
11+
<button type="button" class="mdl-button mdl-js-button
12+
mdl-button--raised mdl-js-ripple-effect mdl-button--colored" @click="createNewService()">Create</button>
13+
<button type="button" class="mdl-button mdl-js-button mdl-textfield--floating-label
14+
mdl-button--raised mdl-js-ripple-effect close" @click="closeCreateServiceForm()">Close</button>
15+
</div>
16+
</dialog>
17+
18+
<script type="text/javascript">
19+
20+
var CreateServiceDialog = new Vue({
21+
el: '#lucid-create-service-dialog',
22+
23+
data: {
24+
name: ''
25+
},
26+
27+
methods: {
28+
show: function() {
29+
this.$el.showModal();
30+
},
31+
32+
closeCreateServiceForm: function() {
33+
this.$el.close();
34+
},
35+
36+
resetForm: function() {
37+
this.name = '';
38+
},
39+
40+
createNewService: function() {
41+
// there must be a name
42+
if (this.name.length <= 0) {
43+
return false;
44+
}
45+
46+
Vue.http.post('services', {name: this.name}).then(
47+
// success
48+
function(response) {
49+
this.closeCreateServiceForm();
50+
51+
var service = response.json();
52+
Toast.show('Service '+service.name+' is now ready');
53+
54+
this.resetForm();
55+
}.bind(this),
56+
// error
57+
function(response) {
58+
console.error('Error creating service:', response.status);
59+
}
60+
);
61+
}
62+
}
63+
});
64+
65+
</script>

resources/views/layout.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
@include('lucid::components.code-preview')
7878
@include('lucid::components.create-job')
7979
@include('lucid::components.create-feature')
80+
@include('lucid::components.create-service')
8081
@include('lucid::components.add-menu')
8182

8283
<script src="/vendor/lucid/js/lib/prism.js"></script>

src/Http/routes.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
return (new Controller())->listFeatures($slug);
3939
});
4040

41+
Route::post('/services', function () {
42+
return app(Lucid\Console\Generators\ServiceGenerator::class)->generate(request()->input('name'))->toArray();
43+
});
44+
4145
Route::get('/features/{name}', function ($name) {
4246
return (new Controller())->findFeature($name)->toArray();
4347
});
@@ -75,7 +79,7 @@
7579
return app(Lucid\Console\Generators\FeatureGenerator::class)->generate($title, $service, $jobs)->toArray();
7680
});
7781

78-
Route::get('/logs', function() {
82+
Route::get('/logs', function () {
7983
$reader = app(Stevebauman\LogReader\LogReader::class);
8084

8185
if (request()->has('level')) {
@@ -86,11 +90,11 @@
8690
->paginate(25);
8791
});
8892

89-
Route::put('/logs/{id}/read', function($id) {
93+
Route::put('/logs/{id}/read', function ($id) {
9094
app(Stevebauman\LogReader\LogReader::class)->find($id)->markRead();
9195
});
9296

93-
Route::get('/analysis', function() {
97+
Route::get('/analysis', function () {
9498
return (new Lucid\Console\Analyser())->analyse();
9599
});
96100

0 commit comments

Comments
 (0)