Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Commit

Permalink
plugin list start/stop, still not working, missing uuid for api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
NikZar committed Sep 2, 2014
1 parent 4964133 commit 4dfe473
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/api/boxes.json
Expand Up @@ -103,13 +103,13 @@
"description": "This section lets you manage your Plugins",
"img": "extension",
"iconcolor": "#f66",
"tooltipcolor": "#faa",
"tooltipcolor": "#f66",
"color": "#222",
"bgcolor": "#faa"
"bgcolor": "#f88"
},
{
"title": "Rooms",
"description": "This section lets you define Triggers to handle environment changes",
"description": "This section lets you configure environment Rooms",
"img": "view-quilt",
"iconcolor": "#afa",
"tooltipcolor": "#afa",
Expand All @@ -118,7 +118,7 @@
},
{
"title": "SetupObjects",
"description": "This section lets you define Triggers to handle environment changes",
"description": "This section lets you configure environment Objects",
"img": "image:camera",
"iconcolor": "#adf",
"tooltipcolor": "#adf",
Expand All @@ -127,7 +127,7 @@
},
{
"title": "Marketplace",
"description": "This section lets you define Triggers to handle environment changes",
"description": "This section lets you install extensions from the Marketplace",
"img": "store",
"iconcolor": "#fb8",
"tooltipcolor": "#fb8",
Expand Down
4 changes: 4 additions & 0 deletions app/elements/elements.html
Expand Up @@ -40,3 +40,7 @@
<link rel="import" href="nautes-command-row.html">
<link rel="import" href="nautes-setup-dashboard.html">
<link rel="import" href="nautes-setup-animated-dashboard.html">
<link rel="import" href="nautes-plugins.html">
<link rel="import" href="nautes-plugin-list.html">
<link rel="import" href="nautes-plugin-row.html">
<link rel="import" href="nautes-plugin-add.html">
4 changes: 2 additions & 2 deletions app/elements/nautes-commands.html
Expand Up @@ -88,12 +88,12 @@

showAddCommand: false,

addReaction: function(){
addCommand: function(){
this.showList = false;
this.showAddCommand = !this.showAddCommand;
},

showReactionList: function(){
showCommandList: function(){
this.showList = !this.showList;
this.showAddCommand = false;
}
Expand Down
16 changes: 16 additions & 0 deletions app/elements/nautes-plugin-add.html
@@ -0,0 +1,16 @@
<link rel="import" href="../bower_components/polymer/polymer.html">

<polymer-element name="nautes-plugin-add" attributes="">
<template>
<style>
:host {
display: block;
}
</style>
</template>
<script>
Polymer({

});
</script>
</polymer-element>
43 changes: 43 additions & 0 deletions app/elements/nautes-plugin-list.html
@@ -0,0 +1,43 @@
<link rel="import" href="../bower_components/polymer/polymer.html">

<polymer-element name="nautes-plugin-list" attributes="toast bgColor">
<template>
<style>
:host {
display: block;
background-color: {{bgColor}};
width: 100%;
}
</style>

<fd-rest-element-service id="getPluginsService"
fdtype="plugins"
fditems="{{plugins}}"
toast="{{toast}}">
</fd-rest-element-service>

<div layout vertical center>
<template repeat="{{plugin in plugins}}">
<nautes-plugin-row
toast="{{toast}}"
bgColor="{{bgColor}}"
plugin="{{plugin}}"
on-remove="{{reloadList}}"
on-start="{{reloadList}}"
on-stop="{{reloadList}}">
</nautes-plugin-row>
</template>
</div>
</template>
<script>

Polymer("nautes-plugin-list",{

reloadList: function(){
this.$.getPluginsService.go();
}

});

</script>
</polymer-element>
154 changes: 154 additions & 0 deletions app/elements/nautes-plugin-row.html
@@ -0,0 +1,154 @@
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/core-icon/core-icon.html">
<link rel="import" href="../bower_components/core-icons/core-icons.html">
<link rel="import" href="../bower_components/core-icons/image-icons.html">
<link rel="import" href="../bower_components/core-icons/hardware-icons.html">
<link rel="import" href="../bower_components/paper-shadow/paper-shadow.html">
<link rel="import" href="../bower_components/paper-ripple/paper-ripple.html">

<link rel="import" href="../elements/nautes-open-sans.html">
<link rel="import" href="../elements/fd-rest-element-service.html">


<polymer-element name="nautes-plugin-row" attributes="plugin bgColor">
<template>
<style>

:host {
display: block;
position: relative;
background-color: {{bgColor}};
width: 100%;
font-size: 1.2rem;
font-weight: 300;
font-family: Open Sans;
}

.plugin-row {
margin-bottom: 10px;
padding: 20px;
color: #444;
min-height: 70px;
font-size: 1.5em;
}

.icon{
margin-left: 30px;
color: #444;
width: 80px;
height: 80px;
}

.icon-remove{
color: #444;
position: absolute;
right: 10px;
top: 10px;
border-radius: 50%;
border: 2px solid #444;
}

.receiver{
font-size: 0.5em;
}

paper-ripple {
z-index: 1;
color: #aaaaff;
}

</style>

<fd-rest-element-service id="deletePluginService"
auto="false"
method="DELETE"
fdtype="plugins/{{plugin.uuid}}"
on-rest-response="{{removed}}"
on-rest-error="{{notRemoved}}"
toast="{{toast}}">
</fd-rest-element-service>

<fd-rest-element-service id="startPluginService"
auto="false"
method="POST"
fdtype="plugins/{{plugin.uuid}}/start"
on-rest-response="{{started}}"
toast="{{toast}}">
</fd-rest-element-service>

<fd-rest-element-service id="stopPluginService"
auto="false"
method="POST"
fdtype="plugins/{{plugin.uuid}}/stop"
on-rest-response="{{stopped}}"
toast="{{toast}}">
</fd-rest-element-service>

<div layout horizontal center start>

<core-icon class="icon-remove" icon="clear" on-tap="{{removePlugin}}">
</core-icon>

<template if="{{plugin.status === 'STOPPED'}}">
<core-icon class="icon" icon="av:play-circle-fill" on-tap="{{startPlugin}}">
<paper-ripple class="circle" fit></paper-ripple>
</core-icon>
</template>
<template if="{{plugin.status === 'RUNNING'}}">
<core-icon class="icon" icon="av:pause-circle-fill" on-tap="{{stopPlugin}}">
<paper-ripple class="circle" fit></paper-ripple>
</core-icon>
</template>

<div class="plugin-row" flex>
<div>{{plugin.pluginName}}</div>
</div>

<paper-shadow z="1"></paper-shadow>
</div>

</template>
<script>
Polymer("nautes-plugin-row",{

removePlugin: function(){
this.$.deleteCommandService.go();
this.style.display = "none";
},

removed: function(){
this.fire("remove");
},

notRemoved: function(){
this.style.display = "block";
},

startPlugin: function(){
this.$.startPluginService.go();
},

stopPlugin: function(){
this.$.stopPluginService.go();
},

started: function(event){
if(this.toast){
this.toast.text= this.command.name + " started with success! ";
this.toast.show();
}
this.fire("start");
},

stopped: function(event){
if(this.toast){
this.toast.text= this.command.name + " stopped with success! ";
this.toast.show();
}
this.fire("stop");
}

});
</script>
</polymer-element>

104 changes: 104 additions & 0 deletions app/elements/nautes-plugins.html
@@ -0,0 +1,104 @@
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/core-icons/core-icons.html">
<link rel="import" href="../bower_components/core-icons/hardware-icons.html">
<link rel="import" href="../bower_components/core-icon-button/core-icon-button.html">

<link rel="import" href="../elements/nautes-plugin-list.html">
<link rel="import" href="../elements/nautes-plugin-add.html">
<link rel="import" href="../elements/nautes-open-sans.html">

<polymer-element name="nautes-plugins" attributes="">
<template>
<style>

:host {
display: block;
width: 100%;
font-family: Open Sans;
}

.header{
background-color: rgba(255,50,50,0.1);
padding-top: 10px;
padding-bottom: 10px;
color: #444;
width: 100%;
}

core-icon-button{
border: 1px solid rgba(64,64,64,0.3);
min-width: 110px;
text-align: center;
}

.pluginbtn {
margin: 5px;
background-color: #f88;
}

</style>

<div layout vertical center>

<div class="header" layout vertical center>
<div layout horizontal center>

<template if="{{!showAddPlugin}}">
<core-icon-button
class="pluginbtn"
icon="add-box"
on-tap="{{addPlugin}}">
PLUGIN
</core-icon-button>
</template>

<template if="{{!showList}}">
<core-icon-button
class="pluginbtn"
icon="extension"
on-tap="{{showPluginList}}">
LIST
</core-icon-button>
</template>

</div>
</div>

<template if="{{showList}}">
<nautes-plugin-list
bgColor="{{bgColor}}"
toast="{{toast}}">
</nautes-plugin-list>
</template>

<template if="{{showAddPlugin}}">
<nautes-plugin-add
smallQuery="max-width: 640px"
bgColor="{{bgColor}}"
toast="{{toast}}">
</nautes-plugin-add>
</template>

</div>

</template>
<script>
Polymer("nautes-plugins",{

showList: true,

showAddPlugin: false,

addPlugin: function(){
this.showList = false;
this.showAddPlugin = !this.showAddPlugin;
},

showPluginList: function(){
this.showList = !this.showList;
this.showAddPlugin = false;
}

});
</script>
</polymer-element>
5 changes: 5 additions & 0 deletions app/elements/nautes-setup-animated-dashboard.html
Expand Up @@ -15,6 +15,7 @@
<link rel="import" href="../elements/nautes-trigger-list.html">
<link rel="import" href="../elements/nautes-settings.html">
<link rel="import" href="../elements/nautes-fd-info.html">
<link rel="import" href="../elements/nautes-plugins.html">



Expand Down Expand Up @@ -77,6 +78,10 @@
selected="{{selected}}"
selectedBox="{{selectedBox}}"
hero hero-id="plugins">
<nautes-plugins
bgColor="{{selectedBox.bgcolor}}"
toast="{{$.toast}}">
</nautes-plugins>
</nautes-dashboard-page>
</section>

Expand Down

0 comments on commit 4dfe473

Please sign in to comment.