Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="">
- <meta name="author" content="">
- <!-- Custom sidebar styles -->
- <link href="css/simple-sidebar.css" rel="stylesheet">
- <link rel="stylesheet" href="https://bootswatch.com/3/paper/bootstrap.css">
- <link rel="stylesheet" href="css/bootstrap.css">
- <link rel="stylesheet" href="css/mystyles.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.4.0/gridstack.css"/>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.0/lodash.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.4.0/gridstack.all.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
- </head>
- <body>
- <div id="wrapper">
- <!-- Sidebar -->
- <div id="sidebar-wrapper">
- <ul class="sidebar-nav">
- <li class="sidebar-brand">
- <a href="#">
- CAT 1
- </a>
- </li>
- <li>
- <a href="#">Dashboard</a>
- </li>
- <li>
- <a href="#">System Overview</a>
- </li>
- <li class="sidebar-brand">
- <a href="#">
- CAT 2
- </a>
- </li>
- <li>
- <a href="#">Analysis 1</a>
- </li>
- <li>
- <a href="#">Analysis 2</a>
- </li>
- <li>
- <a href="#">Analysis 3</a>
- </li>
- <li>
- <a href="#">Support</a>
- </li>
- <li>
- <a href="#">Contact</a>
- </li>
- </ul>
- </div>
- <!-- /#sidebar-wrapper -->
- <!-- Page Content -->
- <div id="page-content-wrapper">
- <div class="container-fluid">
- <div class="">
- <div class="row" style="margin-left: 0px">
- <div class="col-2 col-sm-1">
- <a href="#menu-toggle" class="btn btn-secondary" id="menu-toggle" style="box-shadow: 0px 0px"><h1 style="padding-top: 5%">☰</h1></a>
- </div>
- <div class="col-10 col-sm-11">
- <!--title, logo and stats-->
- <h2 style="text-align: center;"> Some logo & title </h2>
- <p style="text-align: center;">LIVE STATS</p>
- <p style="text-align: center;">demo for features - mobile friendly, collapsable sidebar, widget bar and dynamic widgets</p>
- </div>
- </div>
- <div class="row" style="margin-left: 0px; padding-left: 0px; padding-right: 0px">
- <div class="col-2 col-sm-1">
- <!--should contain drag panel-->
- <div class="card" style="border-radius: 0px; height: 100%; background-color: #000000 ">
- <button data-bind="click: addNewGraph" style="background-color: transparent; border:none; background-repeat: no-repeat; overflow: hidden;cursor: pointer; margin-top: 1vh; height:10vh; width: 100%"><img src="https://images.vexels.com/media/users/3/153553/isolated/preview/986a2e5c42953d6151c0e7a1f025a932-business-line-graph-icon-by-vexels.png" style=" width: 7vh;"></button>
- <button data-bind="click: addNewAlert" style="background-color: transparent; border:none; background-repeat: no-repeat; overflow: hidden;cursor: pointer; margin-top: 1vh; height:10vh; width: 100%"><img src="https://images.vexels.com/media/users/3/136062/isolated/preview/53b3faeae4a626df1e5b1e2469de5ab7-graph-pie-chart-icon-by-vexels.png" style=" width: 6vh;"></button>
- </div>
- </div>
- <div class="col-10 col-sm-11" style="padding-right: 15px">
- <div data-bind="component: {name: 'dashboard-grid', params: $data}" style="height: 2000px;"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- /#page-content-wrapper -->
- </div>
- <!-- /#wrapper -->
- <!-- Menu Toggle Script -->
- <script>
- $("#menu-toggle").click(function(e) {
- e.preventDefault();
- $("#wrapper").toggleClass("toggled");
- });
- </script>
- <script type="text/javascript">
- $(function () {
- $('.grid-stack').gridstack();
- });
- </script>
- <!-- script for generating widgets -->
- <script type="text/javascript">
- ko.components.register('dashboard-grid', {
- viewModel: {
- createViewModel: function (controller, componentInfo) {
- var ViewModel = function (controller, componentInfo) {
- var grid = null;
- this.widgets = controller.widgets;
- this.afterAddWidget = function (items) {
- if (grid == null) {
- grid = $(componentInfo.element).find('.grid-stack').gridstack({
- auto: false
- }).data('gridstack');
- }
- var item = _.find(items, function (i) { return i.nodeType == 1 });
- grid.addWidget(item);
- ko.utils.domNodeDisposal.addDisposeCallback(item, function () {
- grid.removeWidget(item);
- });
- };
- };
- return new ViewModel(controller, componentInfo);
- }
- },
- template:
- [
- '<div class="grid-stack" data-bind="foreach: {data: widgets, afterRender: afterAddWidget}">',
- '<div class="grid-stack-item" data-bind="attr: {\'data-gs-x\': $data.x, \'data-gs-y\': $data.y, \'data-gs-width\': $data.width, \'data-gs-height\': $data.height, \'data-gs-auto-position\': $data.auto_position}">',
- '<div class="grid-stack-item-content panel panel-primary" style="overflow:hidden">',
- '<div class="panel-heading">',
- '<h3 class="panel-title"><span data-bind="text: myMessage"></h3>',
- '<button class="close" data-bind="click: $root.deleteWidget"></button>',
- '</div>',
- '<div data-bind="css: divClass">COLOUR = DIV CLASS</br>DASH ELEMENT GOES HERE</div>',
- '</div>',
- '</div>'
- ].join('')
- });
- $(function () {
- var Controller = function (widgets) {
- var self = this;
- this.widgets = ko.observableArray(widgets);
- this.addNewAlert = function () {
- this.widgets.push({
- x: 0,
- y: 0,
- width: 6, //Math.floor(1 + 3 * Math.random()),
- height: 3, //Math.floor(1 + 3 * Math.random()),
- auto_position: true,
- myMessage: 'Alerts',
- divClass: 'divclass1'
- });
- return false;
- };
- this.addNewGraph = function () {
- this.widgets.push({
- x: 0,
- y: 0,
- width: 12, //Math.floor(1 + 3 * Math.random()),
- height: 4, //Math.floor(1 + 3 * Math.random()),
- auto_position: true,
- myMessage: 'Live Graph',
- divClass: 'divclass3'
- });
- return false;
- };
- this.deleteWidget = function (item) {
- self.widgets.remove(item);
- return false;
- };
- };
- var widgets = [
- {x: 0, y: 0, width: 12, height: 4,myMessage:'Live Graph - drag and resize me',divClass:'divclass1'},
- {x: 0, y: 4, width: 6, height: 3,myMessage:'Sensor Map',divClass:'divclass2'},
- {x: 6, y: 4, width: 6, height: 3,myMessage:'Alerts',divClass:'divclass3'},
- ];
- var controller = new Controller(widgets);
- ko.applyBindings(controller);
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement