Skip to content

Commit

Permalink
ADMINUI-2331 Support for viewing and update of service configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
andyYatskov committed Sep 21, 2016
1 parent 9898211 commit f2ab26f
Show file tree
Hide file tree
Showing 13 changed files with 446 additions and 157 deletions.
113 changes: 91 additions & 22 deletions less/services.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,79 @@
*/

/*
* Copyright (c) 2014, Joyent, Inc.
* Copyright (c) 2016, Joyent, Inc.
*/

@import "__vms-list";

#page-services {
.application {
.info {
h4 {
color: #555;
text-transform: uppercase;
ul.service-filters {
padding: 20px;
li {
font-size: 12px;
display: block;
padding: 5px;
a:hover {
text-decoration: none;
}
.number-of-services {
font-weight: bold;
width: 22px;
text-align: right;
padding-right: 5px;
padding-top: 5px;
padding-bottom: 4px;
font-size: 9px;
background: #b8b8b8;
color: #fff;
line-height: 1;
display: inline-block;
}
}
li:hover {
cursor: pointer;
}
li.active {
background: #fff;
a {
color: #333;
}
}
margin-bottom: 1em;
clear: both;
overflow: hidden;
}
.services {
.service-name {
.widget-header;
font-size: 12px;
padding: 5px 10px;
padding: 6px;
.service-type {
width: 60px;
margin: 0 10px;
display: inline-block;
background-color: @gray-light;
font-size: 12px;
color: #fff;
text-align: center;
text-transform: uppercase;
}
}
}
.service+.service { margin-top: 1em;}
.instance {
a {color: #0098b2; cursor: pointer;}
.widget-content;
font-size: 12px;
padding: 8px;
.state { color: @state-danger-text; }
.state.running { color: @state-success-text; }
.alias, .uuid, .state, .ram { display: inline-block;}
.alias { color: @gray-light; width: 100px;}
padding: 1% 0 1% 15%;
.state {
width: 70px;
margin: 0 10px;
vertical-align: top;
text-align: center;
.__vms-list.state;
}
.alias, .uuid, .state, .ram {display: inline-block;}
.alias {
width: 280px;
margin-left: 30px;
vertical-align: top;
}
.uuid {
width: 280px;
font-style: italic;
Expand All @@ -45,12 +87,39 @@
font-weight: normal;
line-height: 1.2;
}
.state { width: 100px;}
a {
cursor: pointer;
}

.ram { width: 100px;}
}
}

#page-service {
h1 .type {
margin-top: -10px;
padding: 3px 4px;
color: #FFF;
font-weight: normal;
text-transform: uppercase;
font-size: 10px;
background: #00a8ff;
}
.overview {
.table;
th { padding-left: 13px; }
tbody {
th { width: 120px; }
td .mutate { visibility: hidden; }
td:hover .mutate { visibility: visible; }
td>*:first-child {
max-height: 360px;
width: 100%;
display: inline-block;
overflow: auto;
white-space: pre;
};
}
.uuid {
font-size: 8px;
margin-top: 4px;
color: @gray-light;
}
}
}
1 change: 0 additions & 1 deletion less/vm.less
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ section.fwrules {
}
}


.overview {
.table;

Expand Down
20 changes: 7 additions & 13 deletions lib/adminui.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ ADMINUI.prototype.createServer = function () {
});
});



server.use(sdcClients.handler);

server.use((function attachOtherClients(req, res, next) {
Expand Down Expand Up @@ -283,14 +281,12 @@ ADMINUI.prototype.createServer = function () {
auth.requireRole('operators'),
vms.del);


var jobs = require('./jobs');
server.get('/api/jobs', auth.requireAuth, jobs.listJobs);
server.get('/api/jobs/:uuid', auth.requireAuth, jobs.getJob);
server.get('/api/jobs/:uuid/info', auth.requireAuth, jobs.getJobInfo);
server.post('/api/jobs/:uuid/cancel', auth.requireAuth, jobs.cancelJob);


var images = require('./images');
server.patch('/api/images/:uuid',
auth.requireAuth,
Expand All @@ -314,17 +310,13 @@ ADMINUI.prototype.createServer = function () {
bodyParser,
images.action);


server.post('/api/images/:uuid/acl',
auth.requireAuth,
auth.requireRole('operators'),
resume,
bodyParser,
images.aclAction);




var packages = require('./packages');
server.get('/api/packages', auth.requireAuth, packages.list);
server.get('/api/packages/:uuid', auth.requireAuth, packages.get);
Expand Down Expand Up @@ -789,14 +781,17 @@ ADMINUI.prototype.createServer = function () {
setUfds,
users.deleteUser);


var services = require('./services');
server.get('/api/services', auth.requireAuth, services.listServices);
server.get('/api/services/:uuid', auth.requireAuth, services.getService);
server.get('/api/applications', auth.requireAuth, services.listApplications);
server.get('/api/instances', auth.requireAuth, services.listInstances);



server.post('/api/services/:uuid',
auth.requireAuth,
auth.requireRole('operators'),
resume,
bodyParser,
services.updateService);

require('./api/manta').mount(server, [auth.requireAuth]);
require('./api/page-vm').mount(server, [auth.requireAuth]);
Expand All @@ -806,7 +801,6 @@ ADMINUI.prototype.createServer = function () {
require('./api/vm-stop').mount(server, [auth.requireAuth, auth.requireRole('operators'), resume, bodyParser]);
require('./api/vm-metadata').mount(server, [auth.requireAuth, auth.requireRole('operators'), resume, bodyParser]);


var amon = require('./amon');
server.post('/api/amon/probes',
auth.requireAuth,
Expand Down
38 changes: 22 additions & 16 deletions lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,51 @@ module.exports = {
listApplications: function (req, res, next) {
req.sdc[req.dc].sapi.listApplications(req.query, function (err, obj) {
if (err) {
req.log.fatal(err, 'Error retreiving applications');
req.log.error(err, 'Error retreiving applications');
return next(err);
} else {
res.send(obj);
return next();
}
res.send(obj);
return next();
});
},
listInstances: function (req, res, next) {
req.sdc[req.dc].sapi.listInstances(req.query, function (err, obj) {
if (err) {
req.log.fatal(err, 'Error retreiving instances');
req.log.error(err, 'Error retreiving instances');
return next(err);
} else {
res.send(obj);
return next();
}
res.send(obj);
return next();
});
},
listServices: function (req, res, next) {
req.sdc[req.dc].sapi.listServices(req.query, function (err, services) {
if (err) {
req.log.fatal(err, 'Error retrieving services');
req.log.error(err, 'Error retrieving services');
return next(err);
} else {
res.send(services);
return next();
}
res.send(services);
return next();
});
},
getService: function (req, res, next) {
req.sdc[req.dc].sapi.getService(req.params.uuid, function (err, service) {
if (err) {
req.log.fatal(err, 'Error retrieving service');
req.log.error(err, 'Error retrieving service');
return next(err);
} else {
res.send(service);
return next();
}
res.send(service);
return next();
});
},
updateService: function (req, res, next) {
req.sdc[req.dc].sapi.updateService(req.params.uuid, req.body, function (err, service) {
if (err) {
req.log.error(err, 'Error updating service');
return next(err);
}
res.send(service);
return next();
});
}
};
Loading

0 comments on commit f2ab26f

Please sign in to comment.