BVB Source Codes

cockpit Show listing.js Source code

Return Download cockpit: download listing.js Source code - Download cockpit Source code - Type:.js
  1. /*
  2.  * This file is part of Cockpit.
  3.  *
  4.  * Copyright (C) 2015 Red Hat, Inc.
  5.  *
  6.  * Cockpit is free software; you can redistribute it and/or modify it
  7.  * under the terms of the GNU Lesser General Public License as published by
  8.  * the Free Software Foundation; either version 2.1 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * Cockpit is distributed in the hope that it will be useful, but
  12.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public License
  17.  * along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19.  
  20. (function() {
  21.     "use strict";
  22.  
  23.     var angular = require('angular');
  24.  
  25.     require('../views/image-panel.html');
  26.     require('../views/user-panel.html');
  27.     require('../views/service-panel.html');
  28.     require('../views/pod-panel.html');
  29.     require('../views/route-panel.html');
  30.     require('../views/pv-panel.html');
  31.     require('../views/imagestream-panel.html');
  32.     require('../views/default-panel.html');
  33.     require('../views/node-panel.html');
  34.     require('../views/project-panel.html');
  35.     require('../views/container-panel.html');
  36.     require('../views/deploymentconfig-panel.html');
  37.     require('../views/group-panel.html');
  38.     require('../views/replicationcontroller-panel.html');
  39.  
  40.     function inClassOrTag(el, cls, tag) {
  41.         return (el && el.classList && el.classList.contains(cls)) ||
  42.                (el && el.tagName === tag) ||
  43.                (el && inClassOrTag(el.parentNode, cls, tag));
  44.     }
  45.  
  46.     angular.module('kubernetes.listing', [])
  47.  
  48.     .directive('listingTable', [
  49.         function() {
  50.             return {
  51.                 restrict: 'A',
  52.                 link: function(scope, element, attrs) {
  53.                 }
  54.             };
  55.         }
  56.     ])
  57.  
  58.     .factory('ListingState', [
  59.         function() {
  60.             return function ListingState(scope) {
  61.                 var self = this;
  62.                 var data = { };
  63.  
  64.                 self.selected = { };
  65.                 self.enableActions = false;
  66.  
  67.                 /* Check that either .btn or li were not clicked */
  68.                 function checkBrowserEvent(ev) {
  69.                     return !(ev && inClassOrTag(ev.target, "btn", "li"));
  70.                 }
  71.  
  72.                 self.hasSelected = function hasSelected(id) {
  73.                     return !angular.equals({}, self.selected);
  74.                 };
  75.  
  76.                 self.expanded = function expanded(id) {
  77.                     if (angular.isUndefined(id)) {
  78.                         for (id in data)
  79.                             return true;
  80.                         return false;
  81.                     } else {
  82.                         return id in data;
  83.                     }
  84.                 };
  85.  
  86.                 self.toggle = function toggle(id, ev) {
  87.                     var value;
  88.                     if (self.enableActions) {
  89.                         ev.stopPropagation();
  90.                         return;
  91.                     }
  92.  
  93.                     if (id) {
  94.                         value = !(id in data);
  95.                         if (value)
  96.                             self.expand(id, ev);
  97.                         else
  98.                             self.collapse(id, ev);
  99.                     }
  100.                 };
  101.  
  102.                 self.expand = function expand(id, ev) {
  103.                     data[id] = true;
  104.                     if (ev)
  105.                         ev.stopPropagation();
  106.                 };
  107.  
  108.                 self.activate = function activate(id, ev) {
  109.                     if (checkBrowserEvent(ev)) {
  110.                         if (self.expanded(id))
  111.                             self.collapse(id);
  112.                         else
  113.                             scope.$emit("activate", id);
  114.                     }
  115.                 };
  116.  
  117.                 self.collapse = function collapse(id, ev) {
  118.                     if (id) {
  119.                         delete data[id];
  120.                     } else {
  121.                         Object.keys(data).forEach(function(old) {
  122.                             delete data[old];
  123.                         });
  124.                     }
  125.                     if (ev)
  126.                         ev.stopPropagation();
  127.                 };
  128.             };
  129.         }
  130.     ])
  131.  
  132.     .directive('listingPanel', [
  133.         function() {
  134.             return {
  135.                 restrict: 'A',
  136.                 scope: true,
  137.                 link: function(scope, element, attrs) {
  138.                     var tab = 'main';
  139.                     scope.tab = function(name, ev) {
  140.                         if (ev) {
  141.                             tab = name;
  142.                             ev.stopPropagation();
  143.                         }
  144.                         return tab === name;
  145.                     };
  146.                 },
  147.                 templateUrl: function(element, attrs) {
  148.                     var kind = attrs.kind;
  149.                     return "views/" + kind.toLowerCase() + "-panel.html";
  150.                 }
  151.             };
  152.         }
  153.     ]);
  154. }());
  155.  
downloadlisting.js Source code - Download cockpit Source code
Related Source Codes/Software:
elasticsearch-kopf - web admin interface for elasticsearch 2017-05-07
xunlei-lixian - Thunderbolt offline download script 2017-05-07
xadmin - Drop-in replacement of Django admin comes with lot... 2017-05-07
p2pspider - DHT Spider + BitTorrent Client = P2P Spider 2017-05-07
Backbone.localStorage - A localStorage adapter for Backbone.j 2017-05-07
phenomic - 2017-05-07
shoulda - Makes tests easy on the fingers and the eyes ... 2017-05-07
mio - Metal IO library for Rust 2017-05-07
nova - OpenStack Compute (Nova) ht... 2017-05-07
gobyexample - Go by Example https://gobye... 2017-05-07
react-boilerplate - 2017-06-07
webtorrent - Streaming torrent client for the web ... 2017-06-06
machine-learning-for-software-engineers - A complete daily plan for studying to become a mac... 2017-06-06
upterm - A terminal emulator for the 21st century. 2017-06-06
huginn - Create agents that monitor and act on your behalf.... 2017-06-06
system-design-primer - Learn how to design large-scale systems. Prep for ... 2017-06-06
design-patterns-for-humans - Design Patterns for Humans - An ultra-simplified e... 2017-06-06
developer-roadmap - Roadmap to becoming a web developer in 2017 2017-06-06
nylas-mail - 2017-06-06

 Back to top