forked from emoncms/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_view.php
112 lines (92 loc) · 3.18 KB
/
list_view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php global $path; ?>
<style>
.app-item {
padding:15px;
border-bottom: 1px solid #ccc;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
}
.app-item:hover {
background-color:#eee;
cursor:pointer;
}
.app-item-title {
font-weight:bold;
font-size:14px;
}
.col1 {
width:100%;
}
.col1-inner { padding:10px; }
</style>
<div style="height:10px"></div>
<div style="padding:20px">
<h2>Available Apps</h2>
<p>Create a new instance of an app by clicking on one of the apps below.</p>
<div id="available-apps"></div>
</div>
<!-------------------------------------------------------------------------------------------
MODALS
-------------------------------------------------------------------------------------------->
<!-- GROUP CREATE -->
<div id="app-new-modal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="app-new-modal-label" aria-hidden="true" data-backdrop="static">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="app-new-modal-label">Please enter name for app</h3>
</div>
<div class="modal-body">
<p>Enter a unique name for the app:<br>
<input id="app-new-name" type="text"></p>
</div>
<div class="modal-footer">
<button id="app-new-cancel" class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button id="app-new-action" class="btn btn-primary">Create</button>
</div>
</div>
<script>
var path = "<?php echo $path; ?>";
var available_apps = JSON.parse('<?php echo json_encode($available_apps); ?>');
var selected_app = "";
var app_new_enable = true;
var out = "";
for (var z in available_apps) {
if (available_apps[z].description=="")
available_apps[z].description = "no description...";
out += '<div class="app-item" app="'+z+'">';
var status = "";
if (available_apps[z].status!="") status = available_apps[z].status+": ";
out += '<div class="app-item-title">'+status+available_apps[z].title+'</div>';
out += '<div class="app-item-description">'+available_apps[z].description+'</div>';
out += '</div>';
}
$("#available-apps").html(out);
$(".app-item").first().css("border-top","1px solid #ccc");
$(".app-item").click(function(){
if (app_new_enable) {
var app = $(this).attr("app");
selected_app = app;
$("#app-new-modal-label").html("Create app: "+available_apps[app].title);
$("#app-new-name").val(available_apps[app].title);
$('#app-new-modal').modal('show');
}
});
$("#app-new-action").click(function(){
app_new_enable = false;
setTimeout(function(){ app_new_enable = true; }, 500);
$('#app-new-modal').modal('hide');
var nicename = $("#app-new-name").val();
$.ajax({
url: path+"app/add?name="+nicename+"&app="+selected_app,
dataType: 'json',
async: true,
success: function(result) {
console.log(result);
window.location = path+"app/view";
}
});
});
$("#app-new-cancel").click(function(){
app_new_enable = false;
setTimeout(function(){ app_new_enable = true; }, 500);
});
</script>