Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | /** |
| 4 | * © OpenCORD |
| 5 | * |
| 6 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 7 | * |
| 8 | * Created by teone on 3/24/16. |
| 9 | */ |
| 10 | |
| 11 | (function () { |
| 12 | 'use strict'; |
| 13 | |
| 14 | /** |
| 15 | * @ngdoc overview |
| 16 | * @name xos.uiComponents |
| 17 | * @description |
| 18 | * # xos.uiComponents |
| 19 | * A collection of UI components useful for Dashboard development. <br/> |
| 20 | * Currently available components are: |
| 21 | * - [xosAlert](/#/module/xos.uiComponents.directive:xosAlert) |
| 22 | * - [xosForm](/#/module/xos.uiComponents.directive:xosForm) |
| 23 | * - [xosPagination](/#/module/xos.uiComponents.directive:xosPagination) |
| 24 | * - [xosSmartTable](/#/module/xos.uiComponents.directive:xosSmartTable) |
| 25 | * - [xosTable](/#/module/xos.uiComponents.directive:xosTable) |
| 26 | * - [xosValidation](/#/module/xos.uiComponents.directive:xosValidation) |
| 27 | **/ |
| 28 | |
| 29 | angular.module('xos.uiComponents', ['chart.js', 'RecursionHelper']); |
| 30 | })(); |
| 31 | //# sourceMappingURL=../maps/ui_components/ui-components.module.js.map |
| 32 | |
| 33 | 'use strict'; |
| 34 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 35 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; |
| 36 | |
| 37 | /** |
| 38 | * © OpenCORD |
| 39 | * |
| 40 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 41 | * |
| 42 | * Created by teone on 3/24/16. |
| 43 | */ |
| 44 | |
| 45 | (function () { |
| 46 | 'use strict'; |
| 47 | |
| 48 | angular.module('xos.uiComponents') |
| 49 | |
| 50 | /** |
| 51 | * @ngdoc directive |
| 52 | * @name xos.uiComponents.directive:xosSmartTable |
| 53 | * @link xos.uiComponents.directive:xosTable xosTable |
| 54 | * @link xos.uiComponents.directive:xosForm xosForm |
| 55 | * @restrict E |
| 56 | * @description The xos-table directive |
| 57 | * @param {Object} config The configuration for the component, |
| 58 | * it is composed by the name of an angular [$resource](https://docs.angularjs.org/api/ngResource/service/$resource) |
| 59 | * and an array of fields that shouldn't be printed. |
| 60 | * ``` |
| 61 | * { |
| 62 | resource: 'Users', |
| 63 | hiddenFields: [] |
| 64 | } |
| 65 | * ``` |
| 66 | * @scope |
| 67 | * @example |
| 68 | <example module="sampleSmartTable"> |
| 69 | <file name="index.html"> |
| 70 | <div ng-controller="SampleCtrl as vm"> |
| 71 | <xos-smart-table config="vm.config"></xos-smart-table> |
| 72 | </div> |
| 73 | </file> |
| 74 | <file name="script.js"> |
| 75 | angular.module('sampleSmartTable', ['xos.uiComponents', 'ngResource', 'ngMockE2E']) |
| 76 | // This is only for documentation purpose |
| 77 | .run(function($httpBackend, _){ |
| 78 | let datas = [{id: 1, name: 'Jhon', surname: 'Doe'}]; |
| 79 | let count = 1; |
| 80 | let paramsUrl = new RegExp(/\/test\/(.+)/); |
| 81 | $httpBackend.whenDELETE(paramsUrl, undefined, ['id']).respond((method, url, data, headers, params) => { |
| 82 | data = angular.fromJson(data); |
| 83 | let id = url.match(paramsUrl)[1]; |
| 84 | _.remove(datas, (d) => { |
| 85 | return d.id === parseInt(id); |
| 86 | }) |
| 87 | return [204]; |
| 88 | }); |
| 89 | $httpBackend.whenGET('/test').respond(200, datas) |
| 90 | $httpBackend.whenPOST('/test').respond((method, url, data) => { |
| 91 | data = angular.fromJson(data); |
| 92 | data.id = ++count; |
| 93 | datas.push(data); |
| 94 | return [201, data, {}]; |
| 95 | }); |
| 96 | }) |
| 97 | .factory('_', function($window){ |
| 98 | return $window._; |
| 99 | }) |
| 100 | .service('SampleResource', function($resource){ |
| 101 | return $resource('/test/:id', {id: '@id'}); |
| 102 | }) |
| 103 | // End of documentation purpose, example start |
| 104 | .controller('SampleCtrl', function(){ |
| 105 | this.config = { |
| 106 | resource: 'SampleResource' |
| 107 | }; |
| 108 | }); |
| 109 | </file> |
| 110 | </example> |
| 111 | */ |
| 112 | |
| 113 | .component('xosSmartTable', { |
| 114 | restrict: 'E', |
| 115 | bindings: { |
| 116 | config: '=' |
| 117 | }, |
| 118 | template: '\n <div class="row" ng-show="vm.data.length > 0">\n <div class="col-xs-12 text-right">\n <a href="" class="btn btn-success" ng-click="vm.createItem()">\n Add\n </a>\n </div>\n </div>\n <div class="row">\n <div class="col-xs-12 table-responsive">\n <xos-table config="vm.tableConfig" data="vm.data"></xos-table>\n </div>\n </div>\n <div class="panel panel-default" ng-show="vm.detailedItem">\n <div class="panel-heading">\n <div class="row">\n <div class="col-xs-11">\n <h3 class="panel-title" ng-show="vm.detailedItem.id">Update {{vm.config.resource}} {{vm.detailedItem.id}}</h3>\n <h3 class="panel-title" ng-show="!vm.detailedItem.id">Create {{vm.config.resource}} item</h3>\n </div>\n <div class="col-xs-1">\n <a href="" ng-click="vm.cleanForm()">\n <i class="glyphicon glyphicon-remove pull-right"></i>\n </a>\n </div>\n </div>\n </div>\n <div class="panel-body">\n <xos-form config="vm.formConfig" ng-model="vm.detailedItem"></xos-form>\n </div>\n </div>\n <xos-alert config="{type: \'success\', closeBtn: true}" show="vm.responseMsg">{{vm.responseMsg}}</xos-alert>\n <xos-alert config="{type: \'danger\', closeBtn: true}" show="vm.responseErr">{{vm.responseErr}}</xos-alert>\n ', |
| 119 | bindToController: true, |
| 120 | controllerAs: 'vm', |
| 121 | controller: ["$injector", "LabelFormatter", "_", "XosFormHelpers", function controller($injector, LabelFormatter, _, XosFormHelpers) { |
| 122 | var _this = this; |
| 123 | |
| 124 | // TODO |
| 125 | // - Validate the config (what if resource does not exist?) |
| 126 | |
| 127 | // NOTE |
| 128 | // Corner case |
| 129 | // - if response is empty, how can we generate a form ? |
| 130 | |
| 131 | this.responseMsg = false; |
| 132 | this.responseErr = false; |
| 133 | |
| 134 | this.tableConfig = { |
| 135 | columns: [], |
| 136 | actions: [{ |
| 137 | label: 'delete', |
| 138 | icon: 'remove', |
| 139 | cb: function cb(item) { |
| 140 | _this.Resource.delete({ id: item.id }).$promise.then(function () { |
| 141 | _.remove(_this.data, function (d) { |
| 142 | return d.id === item.id; |
| 143 | }); |
| 144 | _this.responseMsg = _this.config.resource + ' with id ' + item.id + ' successfully deleted'; |
| 145 | }).catch(function (err) { |
| 146 | _this.responseErr = err.data.detail || 'Error while deleting ' + _this.config.resource + ' with id ' + item.id; |
| 147 | }); |
| 148 | }, |
| 149 | color: 'red' |
| 150 | }, { |
| 151 | label: 'details', |
| 152 | icon: 'search', |
| 153 | cb: function cb(item) { |
| 154 | _this.detailedItem = item; |
| 155 | } |
| 156 | }], |
| 157 | classes: 'table table-striped table-bordered table-responsive', |
| 158 | filter: 'field', |
| 159 | order: true, |
| 160 | pagination: { |
| 161 | pageSize: 10 |
| 162 | } |
| 163 | }; |
| 164 | |
| 165 | this.formConfig = { |
| 166 | exclude: this.config.hiddenFields, |
| 167 | fields: {}, |
| 168 | formName: this.config.resource + 'Form', |
| 169 | actions: [{ |
| 170 | label: 'Save', |
| 171 | icon: 'ok', |
| 172 | cb: function cb(item) { |
| 173 | var p = void 0; |
| 174 | var isNew = true; |
| 175 | |
| 176 | if (item.id) { |
| 177 | p = item.$update(); |
| 178 | isNew = false; |
| 179 | } else { |
| 180 | p = item.$save(); |
| 181 | } |
| 182 | |
| 183 | p.then(function (res) { |
| 184 | if (isNew) { |
| 185 | _this.data.push(angular.copy(res)); |
| 186 | } |
| 187 | delete _this.detailedItem; |
| 188 | _this.responseMsg = _this.config.resource + ' with id ' + item.id + ' successfully saved'; |
| 189 | }).catch(function (err) { |
| 190 | _this.responseErr = err.data.detail || 'Error while saving ' + _this.config.resource + ' with id ' + item.id; |
| 191 | }); |
| 192 | }, |
| 193 | class: 'success' |
| 194 | }] |
| 195 | }; |
| 196 | |
| 197 | this.cleanForm = function () { |
| 198 | delete _this.detailedItem; |
| 199 | }; |
| 200 | |
| 201 | this.createItem = function () { |
| 202 | _this.detailedItem = new _this.Resource(); |
| 203 | }; |
| 204 | |
| 205 | this.Resource = $injector.get(this.config.resource); |
| 206 | |
| 207 | var getData = function getData() { |
| 208 | _this.Resource.query().$promise.then(function (res) { |
| 209 | |
| 210 | if (!res[0]) { |
| 211 | _this.data = res; |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | var item = res[0]; |
| 216 | var props = Object.keys(item); |
| 217 | |
| 218 | _.remove(props, function (p) { |
| 219 | return p === 'id' || p === 'validators'; |
| 220 | }); |
| 221 | |
| 222 | // TODO move out cb, non sense triggering a lot of times |
| 223 | if (angular.isArray(_this.config.hiddenFields)) { |
| 224 | props = _.difference(props, _this.config.hiddenFields); |
| 225 | } |
| 226 | |
| 227 | var labels = props.map(function (p) { |
| 228 | return LabelFormatter.format(p); |
| 229 | }); |
| 230 | |
| 231 | props.forEach(function (p, i) { |
| 232 | var fieldConfig = { |
| 233 | label: labels[i], |
| 234 | prop: p |
| 235 | }; |
| 236 | |
| 237 | if (angular.isString(item[p]) && typeof item[p] !== 'undefined') { |
| 238 | fieldConfig.type = _typeof(item[p]); |
| 239 | } |
| 240 | |
| 241 | _this.tableConfig.columns.push(fieldConfig); |
| 242 | }); |
| 243 | |
| 244 | // build form structure |
| 245 | // TODO move in a pure function for testing purposes |
| 246 | props.forEach(function (p, i) { |
| 247 | _this.formConfig.fields[p] = { |
| 248 | label: LabelFormatter.format(labels[i]).replace(':', ''), |
| 249 | type: XosFormHelpers._getFieldFormat(item[p]) |
| 250 | }; |
| 251 | }); |
| 252 | |
| 253 | _this.data = res; |
| 254 | }); |
| 255 | }; |
| 256 | |
| 257 | getData(); |
| 258 | }] |
| 259 | }); |
| 260 | })(); |
| 261 | //# sourceMappingURL=../../../maps/ui_components/smartComponents/smartTable/smartTable.component.js.map |
| 262 | |
| 263 | 'use strict'; |
| 264 | |
| 265 | /** |
| 266 | * © OpenCORD |
| 267 | * |
| 268 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 269 | * |
| 270 | * Created by teone on 3/24/16. |
| 271 | */ |
| 272 | |
| 273 | (function () { |
| 274 | 'use strict'; |
| 275 | |
| 276 | angular.module('xos.uiComponents') |
| 277 | /** |
| 278 | * @ngdoc directive |
| 279 | * @name xos.uiComponents.directive:xosSmartPie |
| 280 | * @restrict E |
| 281 | * @description The xos-table directive |
| 282 | * @param {Object} config The configuration for the component, |
| 283 | * it is composed by the name of an angular [$resource](https://docs.angularjs.org/api/ngResource/service/$resource) |
| 284 | * and a field name that is used to group the data. |
| 285 | * ``` |
| 286 | * { |
| 287 | resource: 'Users', |
| 288 | groupBy: 'fieldName', |
| 289 | classes: 'my-custom-class', |
| 290 | labelFormatter: (labels) => { |
| 291 | // here you can format your label, |
| 292 | // you should return an array with the same order |
| 293 | return labels; |
| 294 | } |
| 295 | } |
| 296 | * ``` |
| 297 | * @scope |
| 298 | * @example |
| 299 | |
| 300 | Displaying Local data |
| 301 | <example module="sampleSmartPieLocal"> |
| 302 | <file name="index.html"> |
| 303 | <div ng-controller="SampleCtrlLocal as vm"> |
| 304 | <xos-smart-pie config="vm.configLocal"></xos-smart-pie> |
| 305 | </div> |
| 306 | </file> |
| 307 | <file name="script.js"> |
| 308 | angular.module('sampleSmartPieLocal', ['xos.uiComponents']) |
| 309 | .factory('_', function($window){ |
| 310 | return $window._; |
| 311 | }) |
| 312 | .controller('SampleCtrlLocal', function($timeout){ |
| 313 | |
| 314 | this.datas = [ |
| 315 | {id: 1, first_name: 'Jon', last_name: 'aaa', category: 2}, |
| 316 | {id: 2, first_name: 'Danaerys', last_name: 'Targaryen', category: 1}, |
| 317 | {id: 3, first_name: 'Aria', last_name: 'Stark', category: 2} |
| 318 | ]; |
| 319 | this.configLocal = { |
| 320 | data: [], |
| 321 | groupBy: 'category', |
| 322 | classes: 'local', |
| 323 | labelFormatter: (labels) => { |
| 324 | return labels.map(l => l === '1' ? 'North' : 'Dragon'); |
| 325 | } |
| 326 | }; |
| 327 | |
| 328 | $timeout(() => { |
| 329 | // this need to be triggered in this way just because of ngDoc, |
| 330 | // otherwise you can assign data directly in the config |
| 331 | this.configLocal.data = this.datas; |
| 332 | }, 1) |
| 333 | }); |
| 334 | </file> |
| 335 | </example> |
| 336 | Fetching data from API |
| 337 | <example module="sampleSmartPieResource"> |
| 338 | <file name="index.html"> |
| 339 | <div ng-controller="SampleCtrl as vm"> |
| 340 | <xos-smart-pie config="vm.config"></xos-smart-pie> |
| 341 | </div> |
| 342 | </file> |
| 343 | <file name="script.js"> |
| 344 | angular.module('sampleSmartPieResource', ['xos.uiComponents', 'ngResource', 'ngMockE2E']) |
| 345 | .controller('SampleCtrl', function(){ |
| 346 | this.config = { |
| 347 | resource: 'SampleResource', |
| 348 | groupBy: 'category', |
| 349 | classes: 'resource', |
| 350 | labelFormatter: (labels) => { |
| 351 | return labels.map(l => l === '1' ? 'North' : 'Dragon'); |
| 352 | } |
| 353 | }; |
| 354 | }); |
| 355 | </file> |
| 356 | <file name="backendPoll.js"> |
| 357 | angular.module('sampleSmartPieResource') |
| 358 | .run(function($httpBackend, _){ |
| 359 | let datas = [ |
| 360 | {id: 1, first_name: 'Jon', last_name: 'Snow', category: 1}, |
| 361 | {id: 2, first_name: 'Danaerys', last_name: 'Targaryen', category: 2}, |
| 362 | {id: 3, first_name: 'Aria', last_name: 'Stark', category: 1} |
| 363 | ]; |
| 364 | $httpBackend.whenGET('/test').respond(200, datas) |
| 365 | }) |
| 366 | .factory('_', function($window){ |
| 367 | return $window._; |
| 368 | }) |
| 369 | .service('SampleResource', function($resource){ |
| 370 | return $resource('/test/:id', {id: '@id'}); |
| 371 | }) |
| 372 | </file> |
| 373 | </example> |
| 374 | Polling data from API |
| 375 | <example module="sampleSmartPiePoll"> |
| 376 | <file name="index.html"> |
| 377 | <div ng-controller="SampleCtrl as vm"> |
| 378 | <xos-smart-pie config="vm.config"></xos-smart-pie> |
| 379 | </div> |
| 380 | </file> |
| 381 | <file name="script.js"> |
| 382 | angular.module('sampleSmartPiePoll', ['xos.uiComponents', 'ngResource', 'ngMockE2E']) |
| 383 | .controller('SampleCtrl', function(){ |
| 384 | this.config = { |
| 385 | resource: 'SampleResource', |
| 386 | groupBy: 'category', |
| 387 | poll: 2, |
| 388 | labelFormatter: (labels) => { |
| 389 | return labels.map(l => l === '1' ? 'Active' : 'Banned'); |
| 390 | } |
| 391 | }; |
| 392 | }); |
| 393 | </file> |
| 394 | <file name="backend.js"> |
| 395 | angular.module('sampleSmartPiePoll') |
| 396 | .run(function($httpBackend, _){ |
| 397 | let mock = [ |
| 398 | [ |
| 399 | {id: 1, first_name: 'Jon', last_name: 'Snow', category: 1}, |
| 400 | {id: 2, first_name: 'Danaerys', last_name: 'Targaryen', category: 2}, |
| 401 | {id: 3, first_name: 'Aria', last_name: 'Stark', category: 1}, |
| 402 | {id: 3, first_name: 'Tyrion', last_name: 'Lannister', category: 1} |
| 403 | ], |
| 404 | [ |
| 405 | {id: 1, first_name: 'Jon', last_name: 'Snow', category: 1}, |
| 406 | {id: 2, first_name: 'Danaerys', last_name: 'Targaryen', category: 2}, |
| 407 | {id: 3, first_name: 'Aria', last_name: 'Stark', category: 2}, |
| 408 | {id: 3, first_name: 'Tyrion', last_name: 'Lannister', category: 2} |
| 409 | ], |
| 410 | [ |
| 411 | {id: 1, first_name: 'Jon', last_name: 'Snow', category: 1}, |
| 412 | {id: 2, first_name: 'Danaerys', last_name: 'Targaryen', category: 2}, |
| 413 | {id: 3, first_name: 'Aria', last_name: 'Stark', category: 1}, |
| 414 | {id: 3, first_name: 'Tyrion', last_name: 'Lannister', category: 2} |
| 415 | ] |
| 416 | ]; |
| 417 | $httpBackend.whenGET('/test').respond(function(method, url, data, headers, params) { |
| 418 | return [200, mock[Math.round(Math.random() * 3)]]; |
| 419 | }); |
| 420 | }) |
| 421 | .factory('_', function($window){ |
| 422 | return $window._; |
| 423 | }) |
| 424 | .service('SampleResource', function($resource){ |
| 425 | return $resource('/test/:id', {id: '@id'}); |
| 426 | }) |
| 427 | </file> |
| 428 | </example> |
| 429 | */ |
| 430 | .component('xosSmartPie', { |
| 431 | restrict: 'E', |
| 432 | bindings: { |
| 433 | config: '=' |
| 434 | }, |
| 435 | template: '\n <canvas\n class="chart chart-pie {{vm.config.classes}}"\n chart-data="vm.data" chart-labels="vm.labels"\n chart-legend="{{vm.config.legend}}">\n </canvas>\n ', |
| 436 | bindToController: true, |
| 437 | controllerAs: 'vm', |
| 438 | controller: ["$injector", "$interval", "$scope", "$timeout", "_", function controller($injector, $interval, $scope, $timeout, _) { |
| 439 | var _this = this; |
| 440 | |
| 441 | if (!this.config.resource && !this.config.data) { |
| 442 | throw new Error('[xosSmartPie] Please provide a resource or an array of data in the configuration'); |
| 443 | } |
| 444 | |
| 445 | var groupData = function groupData(data) { |
| 446 | return _.groupBy(data, _this.config.groupBy); |
| 447 | }; |
| 448 | var formatData = function formatData(data) { |
| 449 | return _.reduce(Object.keys(data), function (list, group) { |
| 450 | return list.concat(data[group].length); |
| 451 | }, []); |
| 452 | }; |
| 453 | var formatLabels = function formatLabels(data) { |
| 454 | return angular.isFunction(_this.config.labelFormatter) ? _this.config.labelFormatter(Object.keys(data)) : Object.keys(data); |
| 455 | }; |
| 456 | |
| 457 | var prepareData = function prepareData(data) { |
| 458 | // group data |
| 459 | var grouped = groupData(data); |
| 460 | _this.data = formatData(grouped); |
| 461 | // create labels |
| 462 | _this.labels = formatLabels(grouped); |
| 463 | }; |
| 464 | |
| 465 | if (this.config.resource) { |
| 466 | (function () { |
| 467 | |
| 468 | _this.Resource = $injector.get(_this.config.resource); |
| 469 | var getData = function getData() { |
| 470 | _this.Resource.query().$promise.then(function (res) { |
| 471 | |
| 472 | if (!res[0]) { |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | prepareData(res); |
| 477 | }); |
| 478 | }; |
| 479 | |
| 480 | getData(); |
| 481 | |
| 482 | if (_this.config.poll) { |
| 483 | $interval(function () { |
| 484 | getData(); |
| 485 | }, _this.config.poll * 1000); |
| 486 | } |
| 487 | })(); |
| 488 | } else { |
| 489 | $scope.$watch(function () { |
| 490 | return _this.config.data; |
| 491 | }, function (data) { |
| 492 | if (data) { |
| 493 | prepareData(_this.config.data); |
| 494 | } |
| 495 | }, true); |
| 496 | } |
| 497 | |
| 498 | $scope.$on('create', function (event, chart) { |
| 499 | console.log('create: ' + chart.id); |
| 500 | }); |
| 501 | |
| 502 | $scope.$on('destroy', function (event, chart) { |
| 503 | console.log('destroy: ' + chart.id); |
| 504 | }); |
| 505 | }] |
| 506 | }); |
| 507 | })(); |
| 508 | //# sourceMappingURL=../../../maps/ui_components/smartComponents/smartPie/smartPie.component.js.map |
| 509 | |
| 510 | 'use strict'; |
| 511 | |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 512 | /** |
| 513 | * © OpenCORD |
| 514 | * |
| 515 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 516 | * |
| 517 | * Created by teone on 4/15/16. |
| 518 | */ |
| 519 | |
| 520 | (function () { |
| 521 | 'use strict'; |
| 522 | |
| 523 | angular.module('xos.uiComponents') |
| 524 | |
| 525 | /** |
| 526 | * @ngdoc directive |
| 527 | * @name xos.uiComponents.directive:xosValidation |
| 528 | * @restrict E |
| 529 | * @description The xos-validation directive |
| 530 | * @param {Object} errors The error object |
| 531 | * @element ANY |
| 532 | * @scope |
| 533 | * @example |
| 534 | <example module="sampleValidation"> |
| 535 | <file name="index.html"> |
| 536 | <div ng-controller="SampleCtrl as vm"> |
| 537 | <div class="row"> |
| 538 | <div class="col-xs-12"> |
| 539 | <label>Set an error type:</label> |
| 540 | </div> |
| 541 | <div class="col-xs-2"> |
| 542 | <a class="btn" |
| 543 | ng-click="vm.field.$error.required = !vm.field.$error.required" |
| 544 | ng-class="{'btn-default': !vm.field.$error.required, 'btn-success': vm.field.$error.required}"> |
| 545 | Required |
| 546 | </a> |
| 547 | </div> |
| 548 | <div class="col-xs-2"> |
| 549 | <a class="btn" |
| 550 | ng-click="vm.field.$error.email = !vm.field.$error.email" |
| 551 | ng-class="{'btn-default': !vm.field.$error.email, 'btn-success': vm.field.$error.email}"> |
| 552 | Email |
| 553 | </a> |
| 554 | </div> |
| 555 | <div class="col-xs-2"> |
| 556 | <a class="btn" |
| 557 | ng-click="vm.field.$error.minlength = !vm.field.$error.minlength" |
| 558 | ng-class="{'btn-default': !vm.field.$error.minlength, 'btn-success': vm.field.$error.minlength}"> |
| 559 | Min Length |
| 560 | </a> |
| 561 | </div> |
| 562 | <div class="col-xs-2"> |
| 563 | <a class="btn" |
| 564 | ng-click="vm.field.$error.maxlength = !vm.field.$error.maxlength" |
| 565 | ng-class="{'btn-default': !vm.field.$error.maxlength, 'btn-success': vm.field.$error.maxlength}"> |
| 566 | Max Length |
| 567 | </a> |
| 568 | </div> |
| 569 | </div> |
| 570 | <xos-validation field ="vm.field" form = "vm.form"></xos-validation> |
| 571 | </div> |
| 572 | </file> |
| 573 | <file name="script.js"> |
| 574 | angular.module('sampleValidation', ['xos.uiComponents']) |
| 575 | .controller('SampleCtrl', function(){ |
| 576 | this.field = { |
| 577 | $error: {} |
| 578 | }; |
| 579 | this.form= { |
| 580 | $submitted:true |
| 581 | } |
| 582 | }); |
| 583 | </file> |
| 584 | </example> |
| 585 | */ |
| 586 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 587 | .component('xosValidation', { |
| 588 | restrict: 'E', |
| 589 | bindings: { |
| 590 | field: '=', |
| 591 | form: '=' |
| 592 | }, |
| 593 | template: '\n <div ng-cloak>\n <xos-alert config="vm.config" show="vm.field.$error.required !== undefined && vm.field.$error.required !== false && (vm.field.$touched || vm.form.$submitted)">\n Field required\n </xos-alert>\n <xos-alert config="vm.config" show="vm.field.$error.email !== undefined && vm.field.$error.email !== false && (vm.field.$touched || vm.form.$submitted)">\n This is not a valid email\n </xos-alert>\n <xos-alert config="vm.config" show="vm.field.$error.minlength !== undefined && vm.field.$error.minlength !== false && (vm.field.$touched || vm.form.$submitted)">\n Too short\n </xos-alert>\n <xos-alert config="vm.config" show="vm.field.$error.maxlength !== undefined && vm.field.$error.maxlength !== false && (vm.field.$touched || vm.form.$submitted)">\n Too long\n </xos-alert>\n <xos-alert config="vm.config" show="vm.field.$error.custom !== undefined && vm.field.$error.custom !== false && (vm.field.$touched || vm.form.$submitted)">\n Field invalid\n </xos-alert>\n </div>\n ', |
| 594 | transclude: true, |
| 595 | bindToController: true, |
| 596 | controllerAs: 'vm', |
| 597 | controller: function controller() { |
| 598 | this.config = { |
| 599 | type: 'danger' |
| 600 | }; |
| 601 | } |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 602 | }); |
| 603 | })(); |
| 604 | //# sourceMappingURL=../../../maps/ui_components/dumbComponents/validation/validation.component.js.map |
| 605 | |
| 606 | 'use strict'; |
| 607 | |
| 608 | /** |
| 609 | * © OpenCORD |
| 610 | * |
| 611 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 612 | * |
| 613 | * Created by teone on 3/24/16. |
| 614 | */ |
| 615 | |
| 616 | (function () { |
| 617 | 'use strict'; |
| 618 | |
| 619 | angular.module('xos.uiComponents') |
| 620 | |
| 621 | /** |
| 622 | * @ngdoc directive |
| 623 | * @name xos.uiComponents.directive:xosTable |
| 624 | * @restrict E |
| 625 | * @description The xos-table directive |
| 626 | * @param {Object} config The configuration for the component. |
| 627 | * ``` |
| 628 | * { |
| 629 | * columns: [ |
| 630 | * { |
| 631 | * label: 'Human readable name', |
| 632 | * prop: 'Property to read in the model object', |
| 633 | * type: 'boolean'| 'array'| 'object'| 'custom'| 'date' | 'icon' // see examples for more details |
| 634 | formatter: fn(), // receive the whole item if tipe is custom and return a string |
| 635 | link: fn() // receive the whole item and return an url |
| 636 | * } |
| 637 | * ], |
| 638 | * classes: 'table table-striped table-bordered', |
| 639 | * actions: [ // if defined add an action column |
| 640 | { |
| 641 | label: 'delete', |
| 642 | icon: 'remove', // refers to bootstraps glyphicon |
| 643 | cb: (user) => { // receive the model |
| 644 | console.log(user); |
| 645 | }, |
| 646 | color: 'red' |
| 647 | } |
| 648 | ], |
| 649 | filter: 'field', // can be by `field` or `fulltext` |
| 650 | order: true | {field: 'property name', reverse: true | false} // whether to show ordering arrows, or a configuration for a default ordering |
| 651 | * } |
| 652 | * ``` |
| 653 | * @param {Array} data The data that should be rendered |
| 654 | * @element ANY |
| 655 | * @scope |
| 656 | * @example |
| 657 | # Basic usage |
| 658 | <example module="sampleTable1"> |
| 659 | <file name="index.html"> |
| 660 | <div ng-controller="SampleCtrl1 as vm"> |
| 661 | <xos-table data="vm.data" config="vm.config"></xos-table> |
| 662 | </div> |
| 663 | </file> |
| 664 | <file name="script.js"> |
| 665 | angular.module('sampleTable1', ['xos.uiComponents']) |
| 666 | .factory('_', function($window){ |
| 667 | return $window._; |
| 668 | }) |
| 669 | .controller('SampleCtrl1', function(){ |
| 670 | this.config = { |
| 671 | columns: [ |
| 672 | { |
| 673 | label: 'First Name', // column title |
| 674 | prop: 'name' // property to read in the data array |
| 675 | }, |
| 676 | { |
| 677 | label: 'Last Name', |
| 678 | prop: 'lastname' |
| 679 | } |
| 680 | ] |
| 681 | }; |
| 682 | this.data = [ |
| 683 | { |
| 684 | name: 'John', |
| 685 | lastname: 'Doe' |
| 686 | }, |
| 687 | { |
| 688 | name: 'Gili', |
| 689 | lastname: 'Fereydoun' |
| 690 | } |
| 691 | ] |
| 692 | }); |
| 693 | </file> |
| 694 | </example> |
| 695 | # Filtering |
| 696 | <example module="sampleTable2" animations="true"> |
| 697 | <file name="index.html"> |
| 698 | <div ng-controller="SampleCtrl2 as vm"> |
| 699 | <xos-table data="vm.data" config="vm.config"></xos-table> |
| 700 | </div> |
| 701 | </file> |
| 702 | <file name="script.js"> |
| 703 | angular.module('sampleTable2', ['xos.uiComponents', 'ngAnimate']) |
| 704 | .factory('_', function($window){ |
| 705 | return $window._; |
| 706 | }) |
| 707 | .controller('SampleCtrl2', function(){ |
| 708 | this.config = { |
| 709 | columns: [ |
| 710 | { |
| 711 | label: 'First Name', // column title |
| 712 | prop: 'name' // property to read in the data array |
| 713 | }, |
| 714 | { |
| 715 | label: 'Last Name', |
| 716 | prop: 'lastname' |
| 717 | } |
| 718 | ], |
| 719 | classes: 'table table-striped table-condensed', // table classes, default to `table table-striped table-bordered` |
| 720 | actions: [ // if defined add an action column |
| 721 | { |
| 722 | label: 'delete', // label |
| 723 | icon: 'remove', // icons, refers to bootstraps glyphicon |
| 724 | cb: (user) => { // callback, get feeded with the full object |
| 725 | console.log(user); |
| 726 | }, |
| 727 | color: 'red' // icon color |
| 728 | } |
| 729 | ], |
| 730 | filter: 'field', // can be by `field` or `fulltext` |
| 731 | order: true |
| 732 | }; |
| 733 | this.data = [ |
| 734 | { |
| 735 | name: 'John', |
| 736 | lastname: 'Doe' |
| 737 | }, |
| 738 | { |
| 739 | name: 'Gili', |
| 740 | lastname: 'Fereydoun' |
| 741 | } |
| 742 | ] |
| 743 | }); |
| 744 | </file> |
| 745 | </example> |
| 746 | # Pagination |
| 747 | <example module="sampleTable3"> |
| 748 | <file name="index.html"> |
| 749 | <div ng-controller="SampleCtrl3 as vm"> |
| 750 | <xos-table data="vm.data" config="vm.config"></xos-table> |
| 751 | </div> |
| 752 | </file> |
| 753 | <file name="script.js"> |
| 754 | angular.module('sampleTable3', ['xos.uiComponents']) |
| 755 | .factory('_', function($window){ |
| 756 | return $window._; |
| 757 | }) |
| 758 | .controller('SampleCtrl3', function(){ |
| 759 | this.config = { |
| 760 | columns: [ |
| 761 | { |
| 762 | label: 'First Name', // column title |
| 763 | prop: 'name' // property to read in the data array |
| 764 | }, |
| 765 | { |
| 766 | label: 'Last Name', |
| 767 | prop: 'lastname' |
| 768 | } |
| 769 | ], |
| 770 | pagination: { |
| 771 | pageSize: 2 |
| 772 | } |
| 773 | }; |
| 774 | this.data = [ |
| 775 | { |
| 776 | name: 'John', |
| 777 | lastname: 'Doe' |
| 778 | }, |
| 779 | { |
| 780 | name: 'Gili', |
| 781 | lastname: 'Fereydoun' |
| 782 | }, |
| 783 | { |
| 784 | name: 'Lucky', |
| 785 | lastname: 'Clarkson' |
| 786 | }, |
| 787 | { |
| 788 | name: 'Tate', |
| 789 | lastname: 'Spalding' |
| 790 | } |
| 791 | ] |
| 792 | }); |
| 793 | </file> |
| 794 | </example> |
| 795 | # Field formatter |
| 796 | <example module="sampleTable4"> |
| 797 | <file name="index.html"> |
| 798 | <div ng-controller="SampleCtrl as vm"> |
| 799 | <xos-table data="vm.data" config="vm.config"></xos-table> |
| 800 | </div> |
| 801 | </file> |
| 802 | <file name="script.js"> |
| 803 | angular.module('sampleTable4', ['xos.uiComponents']) |
| 804 | .factory('_', function($window){ |
| 805 | return $window._; |
| 806 | }) |
| 807 | .controller('SampleCtrl', function(){ |
| 808 | this.config = { |
| 809 | columns: [ |
| 810 | { |
| 811 | label: 'First Name', |
| 812 | prop: 'name', |
| 813 | link: item => `https://www.google.it/#q=${item.name}` |
| 814 | }, |
| 815 | { |
| 816 | label: 'Enabled', |
| 817 | prop: 'enabled', |
| 818 | type: 'boolean' |
| 819 | }, |
| 820 | { |
| 821 | label: 'Services', |
| 822 | prop: 'services', |
| 823 | type: 'array' |
| 824 | }, |
| 825 | { |
| 826 | label: 'Details', |
| 827 | prop: 'details', |
| 828 | type: 'object' |
| 829 | }, |
| 830 | { |
| 831 | label: 'Created', |
| 832 | prop: 'created', |
| 833 | type: 'date' |
| 834 | }, |
| 835 | { |
| 836 | label: 'Icon', |
| 837 | type: 'icon', |
| 838 | formatter: item => item.icon //note that this refer to [Bootstrap Glyphicon](http://getbootstrap.com/components/#glyphicons) |
| 839 | } |
| 840 | ] |
| 841 | }; |
| 842 | this.data = [ |
| 843 | { |
| 844 | name: 'John', |
| 845 | enabled: true, |
| 846 | services: ['Cdn', 'IpTv'], |
| 847 | details: { |
| 848 | c_tag: '243', |
| 849 | s_tag: '444' |
| 850 | }, |
| 851 | created: new Date('December 17, 1995 03:24:00'), |
| 852 | icon: 'music' |
| 853 | }, |
| 854 | { |
| 855 | name: 'Gili', |
| 856 | enabled: false, |
| 857 | services: ['Cdn', 'IpTv', 'Cache'], |
| 858 | details: { |
| 859 | c_tag: '675', |
| 860 | s_tag: '893' |
| 861 | }, |
| 862 | created: new Date(), |
| 863 | icon: 'camera' |
| 864 | } |
| 865 | ] |
| 866 | }); |
| 867 | </file> |
| 868 | </example> |
| 869 | # Custom formatter |
| 870 | <example module="sampleTable5"> |
| 871 | <file name="index.html"> |
| 872 | <div ng-controller="SampleCtrl as vm"> |
| 873 | <xos-table data="vm.data" config="vm.config"></xos-table> |
| 874 | </div> |
| 875 | </file> |
| 876 | <file name="script.js"> |
| 877 | angular.module('sampleTable5', ['xos.uiComponents']) |
| 878 | .factory('_', function($window){ |
| 879 | return $window._; |
| 880 | }) |
| 881 | .controller('SampleCtrl', function(){ |
| 882 | this.config = { |
| 883 | columns: [ |
| 884 | { |
| 885 | label: 'Username', |
| 886 | prop: 'username' |
| 887 | }, |
| 888 | { |
| 889 | label: 'Features', |
| 890 | type: 'custom', |
| 891 | formatter: (val) => { |
| 892 | |
| 893 | let cdnEnabled = val.features.cdn ? 'enabled' : 'disabled'; |
| 894 | return ` |
| 895 | Cdn is ${cdnEnabled}, |
| 896 | uplink speed is ${val.features.uplink_speed} |
| 897 | and downlink speed is ${val.features.downlink_speed} |
| 898 | `; |
| 899 | } |
| 900 | } |
| 901 | ] |
| 902 | }; |
| 903 | this.data = [ |
| 904 | { |
| 905 | username: 'John', |
| 906 | features: { |
| 907 | "cdn": false, |
| 908 | "uplink_speed": 1000000000, |
| 909 | "downlink_speed": 1000000000, |
| 910 | "uverse": true, |
| 911 | "status": "enabled" |
| 912 | } |
| 913 | }, |
| 914 | { |
| 915 | username: 'Gili', |
| 916 | features: { |
| 917 | "cdn": true, |
| 918 | "uplink_speed": 3000000000, |
| 919 | "downlink_speed": 2000000000, |
| 920 | "uverse": true, |
| 921 | "status": "enabled" |
| 922 | } |
| 923 | } |
| 924 | ] |
| 925 | }); |
| 926 | </file> |
| 927 | </example> |
| 928 | **/ |
| 929 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 930 | .component('xosTable', { |
| 931 | restrict: 'E', |
| 932 | bindings: { |
| 933 | data: '=', |
| 934 | config: '=' |
| 935 | }, |
| 936 | template: '\n <div ng-show="vm.data.length > 0 && vm.loader == false">\n <div class="row" ng-if="vm.config.filter == \'fulltext\'">\n <div class="col-xs-12">\n <input\n class="form-control"\n placeholder="Type to search.."\n type="text"\n ng-model="vm.query"/>\n </div>\n </div>\n <table ng-class="vm.classes" ng-hide="vm.data.length == 0">\n <thead>\n <tr>\n <th ng-repeat="col in vm.columns">\n {{col.label}}\n <span ng-if="vm.config.order">\n <a href="" ng-click="vm.orderBy = col.prop; vm.reverse = false">\n <i class="glyphicon glyphicon-chevron-up"></i>\n </a>\n <a href="" ng-click="vm.orderBy = col.prop; vm.reverse = true">\n <i class="glyphicon glyphicon-chevron-down"></i>\n </a>\n </span>\n </th>\n <th ng-if="vm.config.actions">Actions:</th>\n </tr>\n </thead>\n <tbody ng-if="vm.config.filter == \'field\'">\n <tr>\n <td ng-repeat="col in vm.columns">\n <input\n ng-if="col.type !== \'boolean\' && col.type !== \'array\' && col.type !== \'object\' && col.type !== \'custom\'"\n class="form-control"\n placeholder="Type to search by {{col.label}}"\n type="text"\n ng-model="vm.query[col.prop]"/>\n <select\n ng-if="col.type === \'boolean\'"\n class="form-control"\n ng-model="vm.query[col.prop]">\n <option value="">-</option>\n <option value="true">True</option>\n <option value="false">False</option>\n </select>\n </td>\n <td ng-if="vm.config.actions"></td>\n </tr>\n </tbody>\n <tbody>\n <tr ng-repeat="item in vm.data | filter:vm.query:vm.comparator | orderBy:vm.orderBy:vm.reverse | pagination:vm.currentPage * vm.config.pagination.pageSize | limitTo: (vm.config.pagination.pageSize || vm.data.length) track by $index">\n <td ng-repeat="col in vm.columns" xos-link-wrapper>\n <span ng-if="!col.type">{{item[col.prop]}}</span>\n <span ng-if="col.type === \'boolean\'">\n <i class="glyphicon"\n ng-class="{\'glyphicon-ok\': item[col.prop], \'glyphicon-remove\': !item[col.prop]}">\n </i>\n </span>\n <span ng-if="col.type === \'date\'">\n {{item[col.prop] | date:\'H:mm MMM d, yyyy\'}}\n </span>\n <span ng-if="col.type === \'array\'">\n {{item[col.prop] | arrayToList}}\n </span>\n <span ng-if="col.type === \'object\'">\n <dl class="dl-horizontal">\n <span ng-repeat="(k,v) in item[col.prop]">\n <dt>{{k}}</dt>\n <dd>{{v}}</dd>\n </span>\n </dl>\n </span>\n <span ng-if="col.type === \'custom\'">\n {{col.formatter(item)}}\n </span>\n <span ng-if="col.type === \'icon\'">\n <i class="glyphicon glyphicon-{{col.formatter(item)}}">\n </i>\n </span>\n </td>\n <td ng-if="vm.config.actions">\n <a href=""\n ng-repeat="action in vm.config.actions"\n ng-click="action.cb(item)"\n title="{{action.label}}">\n <i\n class="glyphicon glyphicon-{{action.icon}}"\n style="color: {{action.color}};"></i>\n </a>\n </td>\n </tr>\n </tbody>\n </table>\n <xos-pagination\n ng-if="vm.config.pagination"\n page-size="vm.config.pagination.pageSize"\n total-elements="vm.data.length"\n change="vm.goToPage">\n </xos-pagination>\n </div>\n <div ng-show="(vm.data.length == 0 || !vm.data) && vm.loader == false">\n <xos-alert config="{type: \'info\'}">\n No data to show.\n </xos-alert>\n </div>\n <div ng-show="vm.loader == true">\n <div class="loader"></div>\n </div>\n ', |
| 937 | bindToController: true, |
| 938 | controllerAs: 'vm', |
| 939 | controller: ["_", "$scope", "Comparator", function controller(_, $scope, Comparator) { |
| 940 | var _this = this; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 941 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 942 | this.comparator = Comparator; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 943 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 944 | this.loader = true; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 945 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 946 | $scope.$watch(function () { |
| 947 | return _this.data; |
| 948 | }, function (data) { |
| 949 | if (angular.isDefined(data)) { |
| 950 | _this.loader = false; |
| 951 | } |
| 952 | }); |
| 953 | |
| 954 | if (!this.config) { |
| 955 | throw new Error('[xosTable] Please provide a configuration via the "config" attribute'); |
| 956 | } |
| 957 | |
| 958 | if (!this.config.columns) { |
| 959 | throw new Error('[xosTable] Please provide a columns list in the configuration'); |
| 960 | } |
| 961 | |
| 962 | // handle default ordering |
| 963 | if (this.config.order && angular.isObject(this.config.order)) { |
| 964 | this.reverse = this.config.order.reverse || false; |
| 965 | this.orderBy = this.config.order.field || 'id'; |
| 966 | } |
| 967 | |
| 968 | // if columns with type 'custom' are provided |
| 969 | // check that a custom formatte3 is provided too |
| 970 | var customCols = _.filter(this.config.columns, { type: 'custom' }); |
| 971 | if (angular.isArray(customCols) && customCols.length > 0) { |
| 972 | _.forEach(customCols, function (col) { |
| 973 | if (!col.formatter || !angular.isFunction(col.formatter)) { |
| 974 | throw new Error('[xosTable] You have provided a custom field type, a formatter function should provided too.'); |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 975 | } |
| 976 | }); |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 977 | } |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 978 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 979 | // if columns with type 'icon' are provided |
| 980 | // check that a custom formatte3 is provided too |
| 981 | var iconCols = _.filter(this.config.columns, { type: 'icon' }); |
| 982 | if (angular.isArray(iconCols) && iconCols.length > 0) { |
| 983 | _.forEach(iconCols, function (col) { |
| 984 | if (!col.formatter || !angular.isFunction(col.formatter)) { |
| 985 | throw new Error('[xosTable] You have provided an icon field type, a formatter function should provided too.'); |
| 986 | } |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 987 | }); |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 988 | } |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 989 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 990 | // if a link property is passed, |
| 991 | // it should be a function |
| 992 | var linkedColumns = _.filter(this.config.columns, function (col) { |
| 993 | return angular.isDefined(col.link); |
| 994 | }); |
| 995 | if (angular.isArray(linkedColumns) && linkedColumns.length > 0) { |
| 996 | _.forEach(linkedColumns, function (col) { |
| 997 | if (!angular.isFunction(col.link)) { |
| 998 | throw new Error('[xosTable] The link property should be a function.'); |
| 999 | } |
| 1000 | }); |
| 1001 | } |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1002 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1003 | this.columns = this.config.columns; |
| 1004 | this.classes = this.config.classes || 'table table-striped table-bordered'; |
| 1005 | |
| 1006 | if (this.config.actions) { |
| 1007 | // TODO validate action format |
| 1008 | } |
| 1009 | if (this.config.pagination) { |
| 1010 | this.currentPage = 0; |
| 1011 | this.goToPage = function (n) { |
| 1012 | _this.currentPage = n; |
| 1013 | }; |
| 1014 | } |
| 1015 | }] |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1016 | }) |
| 1017 | // TODO move in separate files |
| 1018 | // TODO test |
| 1019 | .filter('arrayToList', function () { |
| 1020 | return function (input) { |
| 1021 | if (!angular.isArray(input)) { |
| 1022 | return input; |
| 1023 | } |
| 1024 | return input.join(', '); |
| 1025 | }; |
| 1026 | }) |
| 1027 | // TODO test |
| 1028 | .directive('xosLinkWrapper', function () { |
| 1029 | return { |
| 1030 | restrict: 'A', |
| 1031 | transclude: true, |
| 1032 | template: '\n <a ng-if="col.link" href="{{col.link(item)}}">\n <div ng-transclude></div>\n </a>\n <div ng-transclude ng-if="!col.link"></div>\n ' |
| 1033 | }; |
| 1034 | }); |
| 1035 | })(); |
| 1036 | //# sourceMappingURL=../../../maps/ui_components/dumbComponents/table/table.component.js.map |
| 1037 | |
| 1038 | 'use strict'; |
| 1039 | |
| 1040 | /** |
| 1041 | * © OpenCORD |
| 1042 | * |
| 1043 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 1044 | * |
| 1045 | * Created by teone on 4/15/16. |
| 1046 | */ |
| 1047 | |
| 1048 | (function () { |
| 1049 | 'use strict'; |
| 1050 | |
| 1051 | angular.module('xos.uiComponents') |
| 1052 | |
| 1053 | /** |
| 1054 | * @ngdoc directive |
| 1055 | * @name xos.uiComponents.directive:xosPagination |
| 1056 | * @restrict E |
| 1057 | * @description The xos-table directive |
| 1058 | * @param {Number} pageSize Number of elements per page |
| 1059 | * @param {Number} totalElements Number of total elements in the collection |
| 1060 | * @param {Function} change The callback to be triggered on page change. |
| 1061 | * * @element ANY |
| 1062 | * @scope |
| 1063 | * @example |
| 1064 | <example module="samplePagination"> |
| 1065 | <file name="index.html"> |
| 1066 | <div ng-controller="SampleCtrl1 as vm"> |
| 1067 | <xos-pagination |
| 1068 | page-size="vm.pageSize" |
| 1069 | total-elements="vm.totalElements" |
| 1070 | change="vm.change"> |
| 1071 | </xos-pagination> |
| 1072 | </div> |
| 1073 | </file> |
| 1074 | <file name="script.js"> |
| 1075 | angular.module('samplePagination', ['xos.uiComponents']) |
| 1076 | .controller('SampleCtrl1', function(){ |
| 1077 | this.pageSize = 10; |
| 1078 | this.totalElements = 35; |
| 1079 | this.change = (pageNumber) => { |
| 1080 | console.log(pageNumber); |
| 1081 | } |
| 1082 | }); |
| 1083 | </file> |
| 1084 | </example> |
| 1085 | **/ |
| 1086 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1087 | .component('xosPagination', { |
| 1088 | restrict: 'E', |
| 1089 | bindings: { |
| 1090 | pageSize: '=', |
| 1091 | totalElements: '=', |
| 1092 | change: '=' |
| 1093 | }, |
| 1094 | template: '\n <div class="row" ng-if="vm.pageList.length > 1">\n <div class="col-xs-12 text-center">\n <ul class="pagination">\n <li\n ng-click="vm.goToPage(vm.currentPage - 1)"\n ng-class="{disabled: vm.currentPage == 0}">\n <a href="" aria-label="Previous">\n <span aria-hidden="true">«</span>\n </a>\n </li>\n <li ng-repeat="i in vm.pageList" ng-class="{active: i === vm.currentPage}">\n <a href="" ng-click="vm.goToPage(i)">{{i + 1}}</a>\n </li>\n <li\n ng-click="vm.goToPage(vm.currentPage + 1)"\n ng-class="{disabled: vm.currentPage == vm.pages - 1}">\n <a href="" aria-label="Next">\n <span aria-hidden="true">»</span>\n </a>\n </li>\n </ul>\n </div>\n </div>\n ', |
| 1095 | bindToController: true, |
| 1096 | controllerAs: 'vm', |
| 1097 | controller: ["$scope", function controller($scope) { |
| 1098 | var _this = this; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1099 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1100 | this.currentPage = 0; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1101 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1102 | this.goToPage = function (n) { |
| 1103 | if (n < 0 || n === _this.pages) { |
| 1104 | return; |
| 1105 | } |
| 1106 | _this.currentPage = n; |
| 1107 | _this.change(n); |
| 1108 | }; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1109 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1110 | this.createPages = function (pages) { |
| 1111 | var arr = []; |
| 1112 | for (var i = 0; i < pages; i++) { |
| 1113 | arr.push(i); |
| 1114 | } |
| 1115 | return arr; |
| 1116 | }; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1117 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1118 | // watch for data changes |
| 1119 | $scope.$watch(function () { |
| 1120 | return _this.totalElements; |
| 1121 | }, function () { |
| 1122 | if (_this.totalElements) { |
| 1123 | _this.pages = Math.ceil(_this.totalElements / _this.pageSize); |
| 1124 | _this.pageList = _this.createPages(_this.pages); |
| 1125 | } |
| 1126 | }); |
| 1127 | }] |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1128 | }).filter('pagination', function () { |
| 1129 | return function (input, start) { |
| 1130 | if (!input || !angular.isArray(input)) { |
| 1131 | return input; |
| 1132 | } |
| 1133 | start = parseInt(start, 10); |
| 1134 | return input.slice(start); |
| 1135 | }; |
| 1136 | }); |
| 1137 | })(); |
| 1138 | //# sourceMappingURL=../../../maps/ui_components/dumbComponents/pagination/pagination.component.js.map |
| 1139 | |
| 1140 | 'use strict'; |
| 1141 | |
| 1142 | /** |
| 1143 | * © OpenCORD |
| 1144 | * |
| 1145 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 1146 | * |
| 1147 | * Created by teone on 4/18/16. |
| 1148 | */ |
| 1149 | |
| 1150 | (function () { |
| 1151 | 'use strict'; |
| 1152 | |
| 1153 | angular.module('xos.uiComponents') |
| 1154 | |
| 1155 | /** |
| 1156 | * @ngdoc directive |
| 1157 | * @name xos.uiComponents.directive:xosForm |
| 1158 | * @restrict E |
| 1159 | * @description The xos-form directive. |
| 1160 | * This components have two usage, given a model it is able to autogenerate a form or it can be configured to create a custom form. |
| 1161 | * @param {Object} config The configuration object |
| 1162 | * ``` |
| 1163 | * { |
| 1164 | * exclude: ['id', 'validators', 'created', 'updated', 'deleted'], //field to be skipped in the form, the provide values are concatenated |
| 1165 | * actions: [ // define the form buttons with related callback |
| 1166 | * { |
| 1167 | label: 'save', |
| 1168 | icon: 'ok', // refers to bootstraps glyphicon |
| 1169 | cb: (user) => { // receive the model |
| 1170 | console.log(user); |
| 1171 | }, |
| 1172 | class: 'success' |
| 1173 | } |
| 1174 | * ], |
| 1175 | * feedback: { |
| 1176 | show: false, |
| 1177 | message: 'Form submitted successfully !!!', |
| 1178 | type: 'success' //refers to bootstrap class |
| 1179 | }, |
| 1180 | * fields: { |
| 1181 | * field_name: { |
| 1182 | * label: 'Field Label', |
| 1183 | * type: 'string' // options are: [date, boolean, number, email, string, select], |
| 1184 | * validators: { |
| 1185 | * minlength: number, |
| 1186 | maxlength: number, |
| 1187 | required: boolean, |
| 1188 | min: number, |
| 1189 | max: number, |
| 1190 | custom: (value) => { |
| 1191 | // do your validation here and return true | false |
| 1192 | // alternatively you can return an array [errorName, true|false] |
| 1193 | } |
| 1194 | * } |
| 1195 | * } |
| 1196 | * } |
| 1197 | * } |
| 1198 | * ``` |
| 1199 | * @element ANY |
| 1200 | * @scope |
| 1201 | * @requires xos.uiComponents.directive:xosField |
| 1202 | * @requires xos.uiComponents.XosFormHelpers |
| 1203 | * @requires xos.helpers._ |
| 1204 | * @example |
| 1205 | |
| 1206 | Autogenerated form |
| 1207 | <example module="sampleForm"> |
| 1208 | <file name="script.js"> |
| 1209 | angular.module('sampleForm', ['xos.uiComponents']) |
| 1210 | .factory('_', function($window){ |
| 1211 | return $window._; |
| 1212 | }) |
| 1213 | .controller('SampleCtrl', function(){ |
| 1214 | this.model = { |
| 1215 | first_name: 'Jhon', |
| 1216 | last_name: 'Doe', |
| 1217 | email: 'jhon.doe@sample.com', |
| 1218 | active: true, |
| 1219 | birthDate: '2015-02-17T22:06:38.059000Z' |
| 1220 | } |
| 1221 | this.config = { |
| 1222 | exclude: ['password', 'last_login'], |
| 1223 | formName: 'sampleForm', |
| 1224 | actions: [ |
| 1225 | { |
| 1226 | label: 'Save', |
| 1227 | icon: 'ok', // refers to bootstraps glyphicon |
| 1228 | cb: (user) => { // receive the model |
| 1229 | console.log(user); |
| 1230 | }, |
| 1231 | class: 'success' |
| 1232 | } |
| 1233 | ] |
| 1234 | }; |
| 1235 | }); |
| 1236 | </file> |
| 1237 | <file name="index.html"> |
| 1238 | <div ng-controller="SampleCtrl as vm"> |
| 1239 | <xos-form ng-model="vm.model" config="vm.config"></xos-form> |
| 1240 | </div> |
| 1241 | </file> |
| 1242 | </example> |
| 1243 | Configuration defined form |
| 1244 | <example module="sampleForm1"> |
| 1245 | <file name="script.js"> |
| 1246 | angular.module('sampleForm1', ['xos.uiComponents','ngResource', 'ngMockE2E']) |
| 1247 | .factory('_', function($window){ |
| 1248 | return $window._; |
| 1249 | }) |
| 1250 | .controller('SampleCtrl1', function(SampleResource){ |
| 1251 | this.model = { |
| 1252 | }; |
| 1253 | this.config = { |
| 1254 | exclude: ['password', 'last_login'], |
| 1255 | formName: 'sampleForm1', |
| 1256 | feedback: { |
| 1257 | show: false, |
| 1258 | message: 'Form submitted successfully !!!', |
| 1259 | type: 'success' |
| 1260 | }, |
| 1261 | actions: [ |
| 1262 | { |
| 1263 | label: 'Save', |
| 1264 | icon: 'ok', // refers to bootstraps glyphicon |
| 1265 | cb: (user) => { // receive the model |
| 1266 | console.log(user); |
| 1267 | this.config.feedback.show = true; |
| 1268 | this.config.feedback.type='success'; |
| 1269 | }, |
| 1270 | class: 'success' |
| 1271 | } |
| 1272 | ], |
| 1273 | fields: { |
| 1274 | first_name: { |
| 1275 | type: 'string', |
| 1276 | validators: { |
| 1277 | required: true |
| 1278 | } |
| 1279 | }, |
| 1280 | last_name: { |
| 1281 | label: 'Surname', |
| 1282 | type: 'string', |
| 1283 | validators: { |
| 1284 | required: true, |
| 1285 | minlength: 10 |
| 1286 | } |
| 1287 | }, |
| 1288 | age: { |
| 1289 | type: 'number', |
| 1290 | validators: { |
| 1291 | required: true, |
| 1292 | min: 21 |
| 1293 | } |
| 1294 | }, |
| 1295 | site: { |
| 1296 | label: 'Site', |
| 1297 | type: 'select', |
| 1298 | validators: { required: true}, |
| 1299 | hint: 'The Site this Slice belongs to', |
| 1300 | options: [] |
| 1301 | }, |
| 1302 | } |
| 1303 | }; |
| 1304 | SampleResource.query().$promise |
| 1305 | .then((users) => { |
| 1306 | //this.users_site = users; |
| 1307 | //console.log(users); |
| 1308 | this.optionVal = users; |
| 1309 | this.config.fields['site'].options = this.optionVal; |
| 1310 | //= this.optionVal; |
| 1311 | }) |
| 1312 | .catch((e) => { |
| 1313 | throw new Error(e); |
| 1314 | }); |
| 1315 | }); |
| 1316 | </file> |
| 1317 | <file name="backend.js"> |
| 1318 | angular.module('sampleForm1') |
| 1319 | .run(function($httpBackend, _){ |
| 1320 | let datas = [{id: 1, label: 'site1'},{id: 4, label: 'site4'},{id: 3, label: 'site3'}]; |
| 1321 | let paramsUrl = new RegExp(/\/test\/(.+)/); |
| 1322 | $httpBackend.whenGET('/test').respond(200, datas) |
| 1323 | }) |
| 1324 | .service('SampleResource', function($resource){ |
| 1325 | return $resource('/test/:id', {id: '@id'}); |
| 1326 | }); |
| 1327 | </file> |
| 1328 | <file name="index.html"> |
| 1329 | <div ng-controller="SampleCtrl1 as vm"> |
| 1330 | <xos-form ng-model="vm.model" config="vm.config"></xos-form> |
| 1331 | </div> |
| 1332 | </file> |
| 1333 | </example> |
| 1334 | **/ |
| 1335 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1336 | .component('xosForm', { |
| 1337 | restrict: 'E', |
| 1338 | bindings: { |
| 1339 | config: '=', |
| 1340 | ngModel: '=' |
| 1341 | }, |
| 1342 | template: '\n <form name="vm.{{vm.config.formName || \'form\'}}" novalidate>\n <div class="form-group" ng-repeat="(name, field) in vm.formField">\n <xos-field name="name" field="field" ng-model="vm.ngModel[name]"></xos-field>\n <xos-validation field="vm[vm.config.formName || \'form\'][name]" form = "vm[vm.config.formName || \'form\']"></xos-validation>\n <div class="alert alert-info" ng-show="(field.hint).length >0" role="alert">{{field.hint}}</div>\n </div>\n <div class="form-group" ng-if="vm.config.actions">\n <xos-alert config="vm.config.feedback" show="vm.config.feedback.show">{{vm.config.feedback.message}}</xos-alert>\n\n <button role="button" href=""\n ng-repeat="action in vm.config.actions"\n ng-click="action.cb(vm.ngModel, vm[vm.config.formName || \'form\'])"\n class="btn btn-{{action.class}}"\n title="{{action.label}}">\n <i class="glyphicon glyphicon-{{action.icon}}"></i>\n {{action.label}}\n </button>\n </div>\n </form>\n ', |
| 1343 | bindToController: true, |
| 1344 | controllerAs: 'vm', |
| 1345 | controller: ["$scope", "$log", "_", "XosFormHelpers", function controller($scope, $log, _, XosFormHelpers) { |
| 1346 | var _this = this; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1347 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1348 | if (!this.config) { |
| 1349 | throw new Error('[xosForm] Please provide a configuration via the "config" attribute'); |
| 1350 | } |
| 1351 | |
| 1352 | if (!this.config.actions) { |
| 1353 | throw new Error('[xosForm] Please provide an action list in the configuration'); |
| 1354 | } |
| 1355 | |
| 1356 | if (!this.config.feedback) { |
| 1357 | this.config.feedback = { |
| 1358 | show: false, |
| 1359 | message: 'Form submitted successfully !!!', |
| 1360 | type: 'success' |
| 1361 | }; |
| 1362 | } |
| 1363 | |
| 1364 | this.excludedField = ['id', 'validators', 'created', 'updated', 'deleted', 'backend_status']; |
| 1365 | if (this.config && this.config.exclude) { |
| 1366 | this.excludedField = this.excludedField.concat(this.config.exclude); |
| 1367 | } |
| 1368 | |
| 1369 | this.formField = []; |
| 1370 | |
| 1371 | $scope.$watch(function () { |
| 1372 | return _this.config; |
| 1373 | }, function () { |
| 1374 | if (!_this.ngModel) { |
| 1375 | return; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1376 | } |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1377 | var diff = _.difference(Object.keys(_this.ngModel), _this.excludedField); |
| 1378 | var modelField = XosFormHelpers.parseModelField(diff); |
| 1379 | _this.formField = XosFormHelpers.buildFormStructure(modelField, _this.config.fields, _this.ngModel); |
| 1380 | }, true); |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1381 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1382 | $scope.$watch(function () { |
| 1383 | return _this.ngModel; |
| 1384 | }, function (model) { |
| 1385 | // empty from old stuff |
| 1386 | _this.formField = {}; |
| 1387 | if (!model) { |
| 1388 | return; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1389 | } |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1390 | var diff = _.difference(Object.keys(model), _this.excludedField); |
| 1391 | var modelField = XosFormHelpers.parseModelField(diff); |
| 1392 | _this.formField = XosFormHelpers.buildFormStructure(modelField, _this.config.fields, model); |
| 1393 | }); |
| 1394 | }] |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1395 | }); |
| 1396 | })(); |
| 1397 | //# sourceMappingURL=../../../maps/ui_components/dumbComponents/form/form.component.js.map |
| 1398 | |
| 1399 | 'use strict'; |
| 1400 | |
| 1401 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } |
| 1402 | |
| 1403 | /** |
| 1404 | * © OpenCORD |
| 1405 | * |
| 1406 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 1407 | * |
| 1408 | * Created by teone on 5/25/16. |
| 1409 | */ |
| 1410 | |
| 1411 | (function () { |
| 1412 | 'use strict'; |
| 1413 | |
| 1414 | angular.module('xos.uiComponents') |
| 1415 | /** |
| 1416 | * @ngdoc directive |
| 1417 | * @name xos.uiComponents.directive:xosField |
| 1418 | * @restrict E |
| 1419 | * @description The xos-field directive. |
| 1420 | * This component decide, give a field wich kind of input it need to print. |
| 1421 | * @param {string} name The field name |
| 1422 | * @param {object} field The field configuration: |
| 1423 | * ``` |
| 1424 | * { |
| 1425 | * label: 'Label', |
| 1426 | * type: 'number', //typeof field |
| 1427 | * validators: {} // see xosForm for more details |
| 1428 | * } |
| 1429 | * ``` |
| 1430 | * @param {mixed} ngModel The field value |
| 1431 | * |
| 1432 | * @example |
| 1433 | |
| 1434 | # Basic Example |
| 1435 | |
| 1436 | <example module="sampleField1"> |
| 1437 | <file name="script.js"> |
| 1438 | angular.module('sampleField1', ['xos.uiComponents']) |
| 1439 | .factory('_', function($window){ |
| 1440 | return $window._; |
| 1441 | }) |
| 1442 | .controller('SampleCtrl', function(){ |
| 1443 | this.name = 'input-name'; |
| 1444 | this.field = {label: 'My String Value:', type: 'string'}; |
| 1445 | this.model = 'my string'; |
| 1446 | }); |
| 1447 | </file> |
| 1448 | <file name="index.html"> |
| 1449 | <div ng-controller="SampleCtrl as vm"> |
| 1450 | <xos-field ng-model="vm.model" name="vm.name" field="vm.field"></xos-field> |
| 1451 | </div> |
| 1452 | </file> |
| 1453 | </example> |
| 1454 | |
| 1455 | # Possible Values |
| 1456 | <example module="sampleField2"> |
| 1457 | <file name="script.js"> |
| 1458 | angular.module('sampleField2', ['xos.uiComponents']) |
| 1459 | .factory('_', function($window){ |
| 1460 | return $window._; |
| 1461 | }) |
| 1462 | .controller('SampleCtrl', function(){ |
| 1463 | this.field1 = { |
| 1464 | name: 'number-field', |
| 1465 | field: {label: 'My Number Value:', type: 'number'}, |
| 1466 | model: 2 |
| 1467 | }; |
| 1468 | this.field2 = { |
| 1469 | name: 'date-field', |
| 1470 | field: {label: 'My Date Value:', type: 'date'}, |
| 1471 | model: new Date() |
| 1472 | }; |
| 1473 | this.field3 = { |
| 1474 | name: 'boolean-field', |
| 1475 | field: {label: 'My Boolean Value:', type: 'boolean'}, |
| 1476 | model: true |
| 1477 | }; |
| 1478 | this.field4 = { |
| 1479 | name: 'email-field', |
| 1480 | field: {label: 'My Email Value:', type: 'email'}, |
| 1481 | model: 'sample@domain.us' |
| 1482 | }; |
| 1483 | }); |
| 1484 | </file> |
| 1485 | <file name="index.html"> |
| 1486 | <div ng-controller="SampleCtrl as vm"> |
| 1487 | <xos-field ng-model="vm.field1.model" name="vm.field1.name" field="vm.field1.field"></xos-field> |
| 1488 | <xos-field ng-model="vm.field2.model" name="vm.field2.name" field="vm.field2.field"></xos-field> |
| 1489 | <xos-field ng-model="vm.field3.model" name="vm.field3.name" field="vm.field3.field"></xos-field> |
| 1490 | <xos-field ng-model="vm.field4.model" name="vm.field4.name" field="vm.field4.field"></xos-field> |
| 1491 | </div> |
| 1492 | </file> |
| 1493 | </example> |
| 1494 | # This element is recursive |
| 1495 | <example module="sampleField3"> |
| 1496 | <file name="script.js"> |
| 1497 | angular.module('sampleField3', ['xos.uiComponents']) |
| 1498 | .factory('_', function($window){ |
| 1499 | return $window._; |
| 1500 | }) |
| 1501 | .controller('SampleCtrl', function(){ |
| 1502 | this.name1 = 'input-name'; |
| 1503 | this.field1 = {label: 'My Object Field:', type: 'object'}; |
| 1504 | this.model1 = { |
| 1505 | name: 'Jhon', |
| 1506 | age: '25', |
| 1507 | email: 'jhon@thewall.ru', |
| 1508 | active: true |
| 1509 | }; |
| 1510 | this.name2 = 'another-name'; |
| 1511 | this.field2 = { |
| 1512 | label: 'Empty Object Field', |
| 1513 | type: 'object', |
| 1514 | properties: { |
| 1515 | foo: { |
| 1516 | label: 'FooLabel:', |
| 1517 | type: 'string', |
| 1518 | validators: { |
| 1519 | required: true |
| 1520 | } |
| 1521 | }, |
| 1522 | bar: { |
| 1523 | type: 'number' |
| 1524 | } |
| 1525 | } |
| 1526 | } |
| 1527 | }); |
| 1528 | </file> |
| 1529 | <file name="index.html"> |
| 1530 | <div ng-controller="SampleCtrl as vm"> |
| 1531 | <h4>Autogenerated object field</h4> |
| 1532 | <xos-field ng-model="vm.model1" name="vm.name1" field="vm.field1"></xos-field> |
| 1533 | <h4>Configured object field</h4> |
| 1534 | <xos-field ng-model="vm.model2" name="vm.name2" field="vm.field2"></xos-field> |
| 1535 | </div> |
| 1536 | </file> |
| 1537 | </example> |
| 1538 | */ |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1539 | .component('xosField', { |
| 1540 | restrict: 'E', |
| 1541 | bindings: { |
| 1542 | name: '=', |
| 1543 | field: '=', |
| 1544 | ngModel: '=' |
| 1545 | }, |
| 1546 | template: '\n <label ng-if="vm.field.type !== \'object\'">{{vm.field.label}}</label>\n <input\n xos-custom-validator custom-validator="vm.field.validators.custom || null"\n ng-if="vm.field.type !== \'boolean\' && vm.field.type !== \'object\' && vm.field.type !== \'select\'"\n type="{{vm.field.type}}"\n name="{{vm.name}}"\n class="form-control"\n ng-model="vm.ngModel"\n ng-minlength="vm.field.validators.minlength || 0"\n ng-maxlength="vm.field.validators.maxlength || 2000"\n ng-required="vm.field.validators.required || false" />\n <select class="form-control" ng-if ="vm.field.type === \'select\'"\n name = "{{vm.name}}"\n ng-options="item.id as item.label for item in vm.field.options"\n ng-model="vm.ngModel"\n ng-required="vm.field.validators.required || false">\n </select>\n <span class="boolean-field" ng-if="vm.field.type === \'boolean\'">\n <a href="#"\n class="btn btn-success"\n ng-show="vm.ngModel"\n ng-click="vm.ngModel = false">\n <i class="glyphicon glyphicon-ok"></i>\n </a>\n <a href="#"\n class="btn btn-danger"\n ng-show="!vm.ngModel"\n ng-click="vm.ngModel = true">\n <i class="glyphicon glyphicon-remove"></i>\n </a>\n </span>\n <div\n class="panel panel-default object-field"\n ng-if="vm.field.type == \'object\' && (!vm.isEmptyObject(vm.ngModel) || !vm.isEmptyObject(vm.field.properties))"\n >\n <div class="panel-heading">{{vm.field.label}}</div>\n <div class="panel-body">\n <div ng-if="!vm.field.properties" ng-repeat="(k, v) in vm.ngModel">\n <xos-field\n name="k"\n field="{label: vm.formatLabel(k), type: vm.getType(v)}"\n ng-model="v">\n </xos-field>\n </div>\n <div ng-if="vm.field.properties" ng-repeat="(k, v) in vm.field.properties">\n <xos-field\n name="k"\n field="{\n label: v.label || vm.formatLabel(k),\n type: v.type,\n validators: v.validators\n }"\n ng-model="vm.ngModel[k]">\n </xos-field>\n </div>\n </div>\n </div>\n ', |
| 1547 | bindToController: true, |
| 1548 | controllerAs: 'vm', |
| 1549 | // the compile cicle is needed to support recursion |
| 1550 | //compile: function (element) { |
| 1551 | // return RecursionHelper.compile(element); |
| 1552 | //}, |
| 1553 | controller: ["$attrs", "XosFormHelpers", "LabelFormatter", function controller($attrs, XosFormHelpers, LabelFormatter) { |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1554 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1555 | if (!this.name) { |
| 1556 | throw new Error('[xosField] Please provide a field name'); |
| 1557 | } |
| 1558 | if (!this.field) { |
| 1559 | throw new Error('[xosField] Please provide a field definition'); |
| 1560 | } |
| 1561 | if (!this.field.type) { |
| 1562 | throw new Error('[xosField] Please provide a type in the field definition'); |
| 1563 | } |
| 1564 | if (!$attrs.ngModel) { |
| 1565 | throw new Error('[xosField] Please provide an ng-model'); |
| 1566 | } |
| 1567 | this.getType = XosFormHelpers._getFieldFormat; |
| 1568 | this.formatLabel = LabelFormatter.format; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1569 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1570 | this.isEmptyObject = function (o) { |
| 1571 | return o ? Object.keys(o).length === 0 : true; |
| 1572 | }; |
| 1573 | }] |
| 1574 | }) |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1575 | |
| 1576 | /** |
| 1577 | * @ngdoc directive |
| 1578 | * @name xos.uiComponents.directive:xosCustomValidator |
| 1579 | * @restrict A |
| 1580 | * @description The xosCustomValidator directive. |
| 1581 | * This component apply a custom validation function |
| 1582 | * @param {function} customValidator The function that execute the validation. |
| 1583 | * |
| 1584 | * You should do your validation here and return true | false, |
| 1585 | * or alternatively you can return an array [errorName, true|false] |
| 1586 | */ |
| 1587 | .directive('xosCustomValidator', function () { |
| 1588 | return { |
| 1589 | restrict: 'A', |
| 1590 | scope: { |
| 1591 | fn: '=customValidator' |
| 1592 | }, |
| 1593 | require: 'ngModel', |
| 1594 | link: function link(scope, element, attr, ctrl) { |
| 1595 | if (!angular.isFunction(scope.fn)) { |
| 1596 | return; |
| 1597 | } |
| 1598 | |
| 1599 | function customValidatorWrapper(ngModelValue) { |
| 1600 | var valid = scope.fn(ngModelValue); |
| 1601 | if (angular.isArray(valid)) { |
| 1602 | // ES6 spread rocks over fn.apply() |
| 1603 | ctrl.$setValidity.apply(ctrl, _toConsumableArray(valid)); |
| 1604 | } else { |
| 1605 | ctrl.$setValidity('custom', valid); |
| 1606 | } |
| 1607 | return ngModelValue; |
| 1608 | } |
| 1609 | |
| 1610 | ctrl.$parsers.push(customValidatorWrapper); |
| 1611 | } |
| 1612 | }; |
| 1613 | }); |
| 1614 | })(); |
| 1615 | //# sourceMappingURL=../../../maps/ui_components/dumbComponents/field/field.component.js.map |
| 1616 | |
| 1617 | 'use strict'; |
| 1618 | |
| 1619 | /** |
| 1620 | * © OpenCORD |
| 1621 | * |
| 1622 | * Visit http://guide.xosproject.org/devguide/addview/ for more information |
| 1623 | * |
| 1624 | * Created by teone on 4/15/16. |
| 1625 | */ |
| 1626 | |
| 1627 | (function () { |
| 1628 | 'use strict'; |
| 1629 | |
| 1630 | angular.module('xos.uiComponents') |
| 1631 | |
| 1632 | /** |
| 1633 | * @ngdoc directive |
| 1634 | * @name xos.uiComponents.directive:xosAlert |
| 1635 | * @restrict E |
| 1636 | * @description The xos-alert directive |
| 1637 | * @param {Object} config The configuration object |
| 1638 | * ``` |
| 1639 | * { |
| 1640 | * type: 'danger', //info, success, warning |
| 1641 | * closeBtn: true, //default false |
| 1642 | * autoHide: 3000 //delay to automatically hide the alert |
| 1643 | * } |
| 1644 | * ``` |
| 1645 | * @param {Boolean=} show Binding to show and hide the alert, default to true |
| 1646 | * @element ANY |
| 1647 | * @scope |
| 1648 | * @example |
| 1649 | <example module="sampleAlert1"> |
| 1650 | <file name="index.html"> |
| 1651 | <div ng-controller="SampleCtrl1 as vm"> |
| 1652 | <xos-alert config="vm.config1"> |
| 1653 | A sample alert message |
| 1654 | </xos-alert> |
| 1655 | <xos-alert config="vm.config2"> |
| 1656 | A sample alert message (with close button) |
| 1657 | </xos-alert> |
| 1658 | <xos-alert config="vm.config3"> |
| 1659 | A sample info message |
| 1660 | </xos-alert> |
| 1661 | <xos-alert config="vm.config4"> |
| 1662 | A sample success message |
| 1663 | </xos-alert> |
| 1664 | <xos-alert config="vm.config5"> |
| 1665 | A sample warning message |
| 1666 | </xos-alert> |
| 1667 | </div> |
| 1668 | </file> |
| 1669 | <file name="script.js"> |
| 1670 | angular.module('sampleAlert1', ['xos.uiComponents']) |
| 1671 | .controller('SampleCtrl1', function(){ |
| 1672 | this.config1 = { |
| 1673 | type: 'danger' |
| 1674 | }; |
| 1675 | this.config2 = { |
| 1676 | type: 'danger', |
| 1677 | closeBtn: true |
| 1678 | }; |
| 1679 | this.config3 = { |
| 1680 | type: 'info' |
| 1681 | }; |
| 1682 | this.config4 = { |
| 1683 | type: 'success' |
| 1684 | }; |
| 1685 | this.config5 = { |
| 1686 | type: 'warning' |
| 1687 | }; |
| 1688 | }); |
| 1689 | </file> |
| 1690 | </example> |
| 1691 | <example module="sampleAlert2" animations="true"> |
| 1692 | <file name="index.html"> |
| 1693 | <div ng-controller="SampleCtrl as vm" class="row"> |
| 1694 | <div class="col-sm-4"> |
| 1695 | <a class="btn btn-default btn-block" ng-show="!vm.show" ng-click="vm.show = true">Show Alert</a> |
| 1696 | <a class="btn btn-default btn-block" ng-show="vm.show" ng-click="vm.show = false">Hide Alert</a> |
| 1697 | </div> |
| 1698 | <div class="col-sm-8"> |
| 1699 | <xos-alert config="vm.config1" show="vm.show"> |
| 1700 | A sample alert message, not displayed by default. |
| 1701 | </xos-alert> |
| 1702 | </div> |
| 1703 | </div> |
| 1704 | </file> |
| 1705 | <file name="script.js"> |
| 1706 | angular.module('sampleAlert2', ['xos.uiComponents', 'ngAnimate']) |
| 1707 | .controller('SampleCtrl', function(){ |
| 1708 | this.config1 = { |
| 1709 | type: 'success' |
| 1710 | }; |
| 1711 | this.show = false; |
| 1712 | }); |
| 1713 | </file> |
| 1714 | </example> |
| 1715 | **/ |
| 1716 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1717 | .component('xosAlert', { |
| 1718 | restrict: 'E', |
| 1719 | bindings: { |
| 1720 | config: '=', |
| 1721 | show: '=?' |
| 1722 | }, |
| 1723 | template: '\n <div ng-cloak class="alert alert-{{vm.config.type}}" ng-hide="!vm.show">\n <button type="button" class="close" ng-if="vm.config.closeBtn" ng-click="vm.dismiss()">\n <span aria-hidden="true">×</span>\n </button>\n <p ng-transclude></p>\n </div>\n ', |
| 1724 | transclude: true, |
| 1725 | bindToController: true, |
| 1726 | controllerAs: 'vm', |
| 1727 | controller: ["$timeout", function controller($timeout) { |
| 1728 | var _this = this; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1729 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1730 | if (!this.config) { |
| 1731 | throw new Error('[xosAlert] Please provide a configuration via the "config" attribute'); |
| 1732 | } |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1733 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1734 | // default the value to true |
| 1735 | this.show = this.show !== false; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1736 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1737 | this.dismiss = function () { |
| 1738 | _this.show = false; |
| 1739 | }; |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1740 | |
Arpit Agarwal | 34b6383 | 2016-08-08 11:59:45 -0700 | [diff] [blame^] | 1741 | if (this.config.autoHide) { |
| 1742 | (function () { |
| 1743 | var to = $timeout(function () { |
| 1744 | _this.dismiss(); |
| 1745 | $timeout.cancel(to); |
| 1746 | }, _this.config.autoHide); |
| 1747 | })(); |
| 1748 | } |
| 1749 | }] |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1750 | }); |
| 1751 | })(); |
| 1752 | //# sourceMappingURL=../../../maps/ui_components/dumbComponents/alert/alert.component.js.map |
| 1753 | |
| 1754 | 'use strict'; |
| 1755 | |
Matteo Scandolo | a71ccfd | 2016-07-22 10:19:15 -0700 | [diff] [blame] | 1756 | (function () { |
| 1757 | 'use strict'; |
| 1758 | |
| 1759 | /** |
| 1760 | * @ngdoc service |
| 1761 | * @name xos.uiComponents.LabelFormatter |
| 1762 | * @description This factory define a set of helper function to format label started from an object property |
| 1763 | **/ |
| 1764 | |
| 1765 | angular.module('xos.uiComponents').factory('LabelFormatter', labelFormatter); |
| 1766 | |
| 1767 | function labelFormatter() { |
| 1768 | |
| 1769 | /** |
| 1770 | * @ngdoc method |
| 1771 | * @name xos.uiComponents.LabelFormatter#_formatByUnderscore |
| 1772 | * @methodOf xos.uiComponents.LabelFormatter |
| 1773 | * @description |
| 1774 | * Convert a `snake_case` string to readable string.<br/> |
| 1775 | * Eg: `this_string` will became `this string` |
| 1776 | * @param {string} string The string to be converted |
| 1777 | * @returns {string} The converten string |
| 1778 | **/ |
| 1779 | |
| 1780 | var _formatByUnderscore = function _formatByUnderscore(string) { |
| 1781 | return string.split('_').join(' ').trim(); |
| 1782 | }; |
| 1783 | |
| 1784 | /** |
| 1785 | * @ngdoc method |
| 1786 | * @name xos.uiComponents.LabelFormatter#_formatByUppercase |
| 1787 | * @methodOf xos.uiComponents.LabelFormatter |
| 1788 | * @description |
| 1789 | * Convert a `camelCase` string to readable string.<br/> |
| 1790 | * Eg: `thisString` will became `this string` |
| 1791 | * @param {string} string The string to be converted |
| 1792 | * @returns {string} The converten string |
| 1793 | **/ |
| 1794 | |
| 1795 | var _formatByUppercase = function _formatByUppercase(string) { |
| 1796 | return string.split(/(?=[A-Z])/).map(function (w) { |
| 1797 | return w.toLowerCase(); |
| 1798 | }).join(' '); |
| 1799 | }; |
| 1800 | |
| 1801 | /** |
| 1802 | * @ngdoc method |
| 1803 | * @name xos.uiComponents.LabelFormatter#_capitalize |
| 1804 | * @methodOf xos.uiComponents.LabelFormatter |
| 1805 | * @description |
| 1806 | * Capitalize the first letter of a string.<br/> |
| 1807 | * Eg: `this string` will became `This string` |
| 1808 | * @param {string} string The string to be converted |
| 1809 | * @returns {string} The converten string |
| 1810 | **/ |
| 1811 | |
| 1812 | var _capitalize = function _capitalize(string) { |
| 1813 | return string.slice(0, 1).toUpperCase() + string.slice(1); |
| 1814 | }; |
| 1815 | |
| 1816 | /** |
| 1817 | * @ngdoc method |
| 1818 | * @name xos.uiComponents.LabelFormatter#format |
| 1819 | * @methodOf xos.uiComponents.LabelFormatter |
| 1820 | * @description |
| 1821 | * Apply in order: |
| 1822 | * - _formatByUnderscore |
| 1823 | * - _formatByUppercase |
| 1824 | * - _capitalize |
| 1825 | * - replace multiple space with a single one |
| 1826 | * - append `:` at the end |
| 1827 | * <br/> |
| 1828 | * Eg: `this_string` will became `This string:`<br/> |
| 1829 | * Eg: `thisString` will became `This string:` |
| 1830 | * @param {string} string The string to be converted |
| 1831 | * @returns {string} The converten string |
| 1832 | **/ |
| 1833 | |
| 1834 | var format = function format(string) { |
| 1835 | string = _formatByUnderscore(string); |
| 1836 | string = _formatByUppercase(string); |
| 1837 | |
| 1838 | string = _capitalize(string).replace(/\s\s+/g, ' ') + ':'; |
| 1839 | return string.replace('::', ':'); |
| 1840 | }; |
| 1841 | |
| 1842 | return { |
| 1843 | // test export |
| 1844 | _formatByUnderscore: _formatByUnderscore, |
| 1845 | _formatByUppercase: _formatByUppercase, |
| 1846 | _capitalize: _capitalize, |
| 1847 | // export to use |
| 1848 | format: format |
| 1849 | }; |
| 1850 | } |
| 1851 | })(); |
| 1852 | //# sourceMappingURL=../../../maps/services/helpers/ui/label_formatter.service.js.map |
| 1853 | |
| 1854 | 'use strict'; |
| 1855 | |
| 1856 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; |
| 1857 | |
| 1858 | (function () { |
| 1859 | |
| 1860 | angular.module('xos.uiComponents') |
| 1861 | |
| 1862 | /** |
| 1863 | * @ngdoc service |
| 1864 | * @name xos.uiComponents.XosFormHelpers |
| 1865 | * @requires xos.uiComponents.LabelFormatter |
| 1866 | * @requires xos.helpers._ |
| 1867 | **/ |
| 1868 | |
| 1869 | .service('XosFormHelpers', ["_", "LabelFormatter", function (_, LabelFormatter) { |
| 1870 | var _this = this; |
| 1871 | |
| 1872 | /** |
| 1873 | * @ngdoc method |
| 1874 | * @name xos.uiComponents.XosFormHelpers#_isEmail |
| 1875 | * @methodOf xos.uiComponents.XosFormHelpers |
| 1876 | * @description |
| 1877 | * Return true if the string is an email address |
| 1878 | * @param {string} text The string to be evaluated |
| 1879 | * @returns {boolean} If the string match an email format |
| 1880 | **/ |
| 1881 | |
| 1882 | this._isEmail = function (text) { |
| 1883 | var re = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/; |
| 1884 | return re.test(text); |
| 1885 | }; |
| 1886 | |
| 1887 | /** |
| 1888 | * @ngdoc method |
| 1889 | * @name xos.uiComponents.XosFormHelpers#_getFieldFormat |
| 1890 | * @methodOf xos.uiComponents.XosFormHelpers |
| 1891 | * @description |
| 1892 | * Return the type of the input |
| 1893 | * @param {mixed} value The data to be evaluated |
| 1894 | * @returns {string} The type of the input |
| 1895 | **/ |
| 1896 | |
| 1897 | this._getFieldFormat = function (value) { |
| 1898 | |
| 1899 | if (angular.isArray(value)) { |
| 1900 | return 'array'; |
| 1901 | } |
| 1902 | |
| 1903 | // check if is date |
| 1904 | if (_.isDate(value) || !Number.isNaN(Date.parse(value)) && new Date(value).getTime() > 631180800000) { |
| 1905 | return 'date'; |
| 1906 | } |
| 1907 | |
| 1908 | // check if is boolean |
| 1909 | // isNaN(false) = false, false is a number (0), true is a number (1) |
| 1910 | if (typeof value === 'boolean') { |
| 1911 | return 'boolean'; |
| 1912 | } |
| 1913 | |
| 1914 | // check if a string is an email |
| 1915 | if (_this._isEmail(value)) { |
| 1916 | return 'email'; |
| 1917 | } |
| 1918 | |
| 1919 | // if null return string |
| 1920 | if (angular.isString(value) || value === null) { |
| 1921 | return 'text'; |
| 1922 | } |
| 1923 | |
| 1924 | return typeof value === 'undefined' ? 'undefined' : _typeof(value); |
| 1925 | }; |
| 1926 | |
| 1927 | /** |
| 1928 | * @ngdoc method |
| 1929 | * @name xos.uiComponents.XosFormHelpers#buildFormStructure |
| 1930 | * @methodOf xos.uiComponents.XosFormHelpers |
| 1931 | * @description |
| 1932 | * Return the type of the input |
| 1933 | * @param {object} modelField An object containing one property for each field of the model |
| 1934 | * @param {object} customField An object containing one property for each field custom field |
| 1935 | * @param {object} model The actual model on wich build the form structure (it is used to determine the type of the input) |
| 1936 | * @returns {object} An object describing the form structure in the form of: |
| 1937 | * ``` |
| 1938 | * { |
| 1939 | * 'field-name': { |
| 1940 | * label: 'Label', |
| 1941 | * type: 'number', //typeof field |
| 1942 | * validators: {}, // see xosForm for more details |
| 1943 | * hint: 'A Custom hint for the field' |
| 1944 | * } |
| 1945 | * } |
| 1946 | * ``` |
| 1947 | **/ |
| 1948 | |
| 1949 | this.buildFormStructure = function (modelField, customField, model) { |
| 1950 | |
| 1951 | modelField = angular.extend(modelField, customField); |
| 1952 | customField = customField || {}; |
| 1953 | |
| 1954 | return _.reduce(Object.keys(modelField), function (form, f) { |
| 1955 | |
| 1956 | form[f] = { |
| 1957 | label: customField[f] && customField[f].label ? customField[f].label + ':' : LabelFormatter.format(f), |
| 1958 | type: customField[f] && customField[f].type ? customField[f].type : _this._getFieldFormat(model[f]), |
| 1959 | validators: customField[f] && customField[f].validators ? customField[f].validators : {}, |
| 1960 | hint: customField[f] && customField[f].hint ? customField[f].hint : '' |
| 1961 | }; |
| 1962 | |
| 1963 | if (customField[f] && customField[f].options) { |
| 1964 | form[f].options = customField[f].options; |
| 1965 | } |
| 1966 | if (customField[f] && customField[f].properties) { |
| 1967 | form[f].properties = customField[f].properties; |
| 1968 | } |
| 1969 | if (form[f].type === 'date') { |
| 1970 | model[f] = new Date(model[f]); |
| 1971 | } |
| 1972 | |
| 1973 | if (form[f].type === 'number') { |
| 1974 | model[f] = parseInt(model[f], 10); |
| 1975 | } |
| 1976 | |
| 1977 | return form; |
| 1978 | }, {}); |
| 1979 | }; |
| 1980 | |
| 1981 | /** |
| 1982 | * @ngdoc method |
| 1983 | * @name xos.uiComponents.XosFormHelpers#parseModelField |
| 1984 | * @methodOf xos.uiComponents.XosFormHelpers |
| 1985 | * @description |
| 1986 | * Helpers for buildFormStructure, convert a list of model properties in an object used to build the form structure, eg: |
| 1987 | * ``` |
| 1988 | * // input: |
| 1989 | * ['id', 'name'm 'mail'] |
| 1990 | * |
| 1991 | * // output |
| 1992 | * { |
| 1993 | * id: {}, |
| 1994 | * name: {}, |
| 1995 | * mail: {} |
| 1996 | * } |
| 1997 | * ``` |
| 1998 | * @param {array} fields An array of fields representing the model properties |
| 1999 | * @returns {object} An object containing one property for each field of the model |
| 2000 | **/ |
| 2001 | |
| 2002 | this.parseModelField = function (fields) { |
| 2003 | return _.reduce(fields, function (form, f) { |
| 2004 | form[f] = {}; |
| 2005 | return form; |
| 2006 | }, {}); |
| 2007 | }; |
| 2008 | }]); |
| 2009 | })(); |
| 2010 | //# sourceMappingURL=../../../maps/services/helpers/ui/form.helpers.js.map |
| 2011 | |
| 2012 | 'use strict'; |
| 2013 | |
| 2014 | (function () { |
| 2015 | 'use strict'; |
| 2016 | |
| 2017 | /** |
| 2018 | * @ngdoc service |
| 2019 | * @name xos.uiComponents.Comparator |
| 2020 | * @description |
| 2021 | * This factory define a function that replace the native angular.filter comparator. |
| 2022 | * |
| 2023 | * It is done to allow the comparation between (0|1) values with booleans. |
| 2024 | * >Note that this factory return a single function, not an object. |
| 2025 | * |
| 2026 | * The tipical usage of this factory is inside an `ng-repeat` |
| 2027 | * @example |
| 2028 | * <example module="comparator"> |
| 2029 | * <file name="index.html"> |
| 2030 | * <div ng-controller="sample as vm"> |
| 2031 | * <div class="row"> |
| 2032 | * <div class="col-xs-6"> |
| 2033 | * <label>Filter by name:</label> |
| 2034 | * <input class="form-control" type="text" ng-model="vm.query.name"/> |
| 2035 | * </div> |
| 2036 | * <div class="col-xs-6"> |
| 2037 | * <label>Filter by status:</label> |
| 2038 | * <select |
| 2039 | * ng-model="vm.query.status" |
| 2040 | * ng-options="i for i in [true, false]"> |
| 2041 | * </select> |
| 2042 | * </div> |
| 2043 | * </div> |
| 2044 | * <div ng-repeat="item in vm.data | filter:vm.query:vm.comparator"> |
| 2045 | * <div class="row"> |
| 2046 | * <div class="col-xs-6">{{item.name}}</div> |
| 2047 | * <div class="col-xs-6">{{item.status}}</div> |
| 2048 | * </div> |
| 2049 | * </div> |
| 2050 | * </div> |
| 2051 | * </file> |
| 2052 | * <file name="script.js"> |
| 2053 | * angular.module('comparator', ['xos.uiComponents']) |
| 2054 | * .controller('sample', function(Comparator){ |
| 2055 | * this.comparator = Comparator; |
| 2056 | * this.data = [ |
| 2057 | * {name: 'Jhon', status: 1}, |
| 2058 | * {name: 'Jack', status: 0}, |
| 2059 | * {name: 'Mike', status: 1}, |
| 2060 | * {name: 'Scott', status: 0} |
| 2061 | * ]; |
| 2062 | * }); |
| 2063 | * </file> |
| 2064 | * </example> |
| 2065 | **/ |
| 2066 | |
| 2067 | comparator.$inject = ["_"]; |
| 2068 | angular.module('xos.uiComponents').factory('Comparator', comparator); |
| 2069 | |
| 2070 | function comparator(_) { |
| 2071 | |
| 2072 | return function (actual, expected) { |
| 2073 | |
| 2074 | if (angular.isUndefined(actual)) { |
| 2075 | // No substring matching against `undefined` |
| 2076 | return false; |
| 2077 | } |
| 2078 | if (actual === null || expected === null) { |
| 2079 | // No substring matching against `null`; only match against `null` |
| 2080 | return actual === expected; |
| 2081 | } |
| 2082 | if (angular.isObject(expected) || angular.isObject(actual)) { |
| 2083 | return angular.equals(expected, actual); |
| 2084 | } |
| 2085 | |
| 2086 | if (_.isBoolean(actual) || _.isBoolean(expected)) { |
| 2087 | if (actual === 0 || actual === 1) { |
| 2088 | actual = !!actual; |
| 2089 | } |
| 2090 | return angular.equals(expected, actual); |
| 2091 | } |
| 2092 | |
| 2093 | if (!angular.isString(actual) || !angular.isString(expected)) { |
| 2094 | if (angular.isDefined(actual.toString) && angular.isDefined(expected.toString)) { |
| 2095 | actual = actual.toString(); |
| 2096 | expected = expected.toString(); |
| 2097 | } else { |
| 2098 | return actual === expected; |
| 2099 | } |
| 2100 | } |
| 2101 | |
| 2102 | actual = actual.toLowerCase() + ''; |
| 2103 | expected = expected.toLowerCase() + ''; |
| 2104 | return actual.indexOf(expected) !== -1; |
| 2105 | }; |
| 2106 | } |
| 2107 | })(); |
| 2108 | //# sourceMappingURL=../../../maps/services/helpers/ui/comparator.service.js.map |
| 2109 | |
| 2110 | 'use strict'; |
| 2111 | |
| 2112 | (function () { |
| 2113 | 'use strict'; |
| 2114 | |
| 2115 | /** |
| 2116 | * @ngdoc overview |
| 2117 | * @name xos.helpers |
| 2118 | * @description |
| 2119 | * # xos.Helpers |
| 2120 | * A collection of helpers to work with XOS <br/> |
| 2121 | * Currently available components are: |
| 2122 | * - [NoHyperlinks](/#/module/xos.helpers.NoHyperlinks) |
| 2123 | * - [SetCSRFToken](/#/module/xos.helpers.SetCSRFToken) |
| 2124 | * - [xosNotification](/#/module/xos.helpers.xosNotification) |
| 2125 | * - [XosUserPrefs](/#/module/xos.helpers.XosUserPrefs) |
| 2126 | * <br/><br/> |
| 2127 | * A set of angular [$resource](https://docs.angularjs.org/api/ngResource/service/$resource) is provided to work with the API.<br> |
| 2128 | * You can find the documentation [here](#/rest-api) |
| 2129 | **/ |
| 2130 | |
| 2131 | config.$inject = ["$httpProvider", "$interpolateProvider", "$resourceProvider"]; |
| 2132 | angular.module('xos.helpers', ['ngCookies', 'ngResource', 'ngAnimate', 'xos.uiComponents']).config(config) |
| 2133 | |
| 2134 | /** |
| 2135 | * @ngdoc service |
| 2136 | * @name xos.helpers._ |
| 2137 | * @description Wrap [lodash](https://lodash.com/docs) in an Angular Service |
| 2138 | **/ |
| 2139 | |
| 2140 | .factory('_', ["$window", function ($window) { |
| 2141 | return $window._; |
| 2142 | }]); |
| 2143 | |
| 2144 | function config($httpProvider, $interpolateProvider, $resourceProvider) { |
| 2145 | $httpProvider.interceptors.push('SetCSRFToken'); |
| 2146 | |
| 2147 | // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html |
| 2148 | $resourceProvider.defaults.stripTrailingSlashes = false; |
| 2149 | } |
| 2150 | })(); |
| 2151 | //# sourceMappingURL=maps/xosHelpers.module.js.map |
| 2152 | |
| 2153 | 'use strict'; |
| 2154 | |
| 2155 | (function () { |
| 2156 | 'use strict'; |
| 2157 | |
| 2158 | angular.module('xos.helpers') |
| 2159 | /** |
| 2160 | * @ngdoc service |
| 2161 | * @name xos.helpers.vSG-Collection |
| 2162 | * @description Angular resource to fetch /api/service/vsg/ |
| 2163 | **/ |
| 2164 | .service('vSG-Collection', ["$resource", function ($resource) { |
| 2165 | return $resource('/api/service/vsg/'); |
| 2166 | }]); |
| 2167 | })(); |
| 2168 | //# sourceMappingURL=../../maps/services/rest/vSG.js.map |
| 2169 | |
| 2170 | 'use strict'; |
| 2171 | |
| 2172 | (function () { |
| 2173 | 'use strict'; |
| 2174 | |
| 2175 | angular.module('xos.helpers') |
| 2176 | /** |
| 2177 | * @ngdoc service |
| 2178 | * @name xos.helpers.vOLT-Collection |
| 2179 | * @description Angular resource to fetch /api/tenant/cord/volt/:volt_id/ |
| 2180 | **/ |
| 2181 | .service('vOLT-Collection', ["$resource", function ($resource) { |
| 2182 | return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id' }, { |
| 2183 | update: { method: 'PUT' } |
| 2184 | }); |
| 2185 | }]); |
| 2186 | })(); |
| 2187 | //# sourceMappingURL=../../maps/services/rest/vOLT.js.map |
| 2188 | |
| 2189 | 'use strict'; |
| 2190 | |
| 2191 | (function () { |
| 2192 | 'use strict'; |
| 2193 | |
| 2194 | angular.module('xos.helpers') |
| 2195 | /** |
| 2196 | * @ngdoc service |
| 2197 | * @name xos.helpers.Login |
| 2198 | * @description Angular resource to fetch /api/utility/login/ |
| 2199 | **/ |
| 2200 | .service('Login', ["$resource", function ($resource) { |
| 2201 | return $resource('/api/utility/login/'); |
| 2202 | }]) |
| 2203 | /** |
| 2204 | * @ngdoc service |
| 2205 | * @name xos.helpers.Logout |
| 2206 | * @description Angular resource to fetch /api/utility/logout/ |
| 2207 | **/ |
| 2208 | .service('Logout', ["$resource", function ($resource) { |
| 2209 | return $resource('/api/utility/logout/'); |
| 2210 | }]); |
| 2211 | })(); |
| 2212 | //# sourceMappingURL=../../maps/services/rest/Utility.js.map |
| 2213 | |
| 2214 | 'use strict'; |
| 2215 | |
| 2216 | (function () { |
| 2217 | 'use strict'; |
| 2218 | |
| 2219 | angular.module('xos.helpers') |
| 2220 | /** |
| 2221 | * @ngdoc service |
| 2222 | * @name xos.helpers.Users |
| 2223 | * @description Angular resource to fetch /api/core/users/:id/ |
| 2224 | **/ |
| 2225 | .service('Users', ["$resource", function ($resource) { |
| 2226 | return $resource('/api/core/users/:id/', { id: '@id' }, { |
| 2227 | update: { method: 'PUT' } |
| 2228 | }); |
| 2229 | }]); |
| 2230 | })(); |
| 2231 | //# sourceMappingURL=../../maps/services/rest/Users.js.map |
| 2232 | |
| 2233 | 'use strict'; |
| 2234 | |
| 2235 | (function () { |
| 2236 | 'use strict'; |
| 2237 | |
| 2238 | angular.module('xos.helpers') |
| 2239 | /** |
| 2240 | * @ngdoc service |
| 2241 | * @name xos.helpers.Truckroll |
| 2242 | * @description Angular resource to fetch /api/tenant/truckroll/:id/ |
| 2243 | **/ |
| 2244 | .service('Truckroll', ["$resource", function ($resource) { |
| 2245 | return $resource('/api/tenant/truckroll/:id/', { id: '@id' }, { |
| 2246 | update: { method: 'PUT' } |
| 2247 | }); |
| 2248 | }]); |
| 2249 | })(); |
| 2250 | //# sourceMappingURL=../../maps/services/rest/Truckroll.js.map |
| 2251 | |
| 2252 | 'use strict'; |
| 2253 | |
| 2254 | (function () { |
| 2255 | 'use strict'; |
| 2256 | |
| 2257 | angular.module('xos.helpers') |
| 2258 | /** |
| 2259 | * @ngdoc service |
| 2260 | * @name xos.helpers.Tenant |
| 2261 | * @description Angular resource to fetch /api/core/tenant/:id/ |
| 2262 | **/ |
| 2263 | .service('Tenants', ["$resource", function ($resource) { |
| 2264 | return $resource('/api/core/tenants/:id/', { id: '@id' }, { |
| 2265 | update: { method: 'PUT' } |
| 2266 | }); |
| 2267 | }]); |
| 2268 | })(); |
| 2269 | //# sourceMappingURL=../../maps/services/rest/Tenant.js.map |
| 2270 | |
| 2271 | 'use strict'; |
| 2272 | |
| 2273 | (function () { |
| 2274 | 'use strict'; |
| 2275 | |
| 2276 | angular.module('xos.helpers') |
| 2277 | /** |
| 2278 | * @ngdoc service |
| 2279 | * @name xos.helpers.Subscribers |
| 2280 | * @description Angular resource to fetch Subscribers |
| 2281 | **/ |
| 2282 | .service('Subscribers', ["$resource", function ($resource) { |
| 2283 | return $resource('/api/tenant/cord/subscriber/:id/', { id: '@id' }, { |
| 2284 | update: { method: 'PUT' }, |
| 2285 | /** |
| 2286 | * @ngdoc method |
| 2287 | * @name xos.helpers.Subscribers#View-a-Subscriber-Features-Detail |
| 2288 | * @methodOf xos.helpers.Subscribers |
| 2289 | * @description |
| 2290 | * View-a-Subscriber-Features-Detail |
| 2291 | **/ |
| 2292 | 'View-a-Subscriber-Features-Detail': { |
| 2293 | method: 'GET', |
| 2294 | isArray: false, |
| 2295 | url: '/api/tenant/cord/subscriber/:id/features/' |
| 2296 | }, |
| 2297 | /** |
| 2298 | * @ngdoc method |
| 2299 | * @name xos.helpers.Subscribers#Read-Subscriber-uplink_speed |
| 2300 | * @methodOf xos.helpers.Subscribers |
| 2301 | * @description |
| 2302 | * Read-Subscriber-uplink_speed |
| 2303 | **/ |
| 2304 | 'Read-Subscriber-uplink_speed': { |
| 2305 | method: 'GET', |
| 2306 | isArray: false, |
| 2307 | url: '/api/tenant/cord/subscriber/:id/features/uplink_speed/' |
| 2308 | }, |
| 2309 | /** |
| 2310 | * @ngdoc method |
| 2311 | * @name xos.helpers.Subscribers#Update-Subscriber-uplink_speed |
| 2312 | * @methodOf xos.helpers.Subscribers |
| 2313 | * @description |
| 2314 | * Update-Subscriber-uplink_speed |
| 2315 | **/ |
| 2316 | 'Update-Subscriber-uplink_speed': { |
| 2317 | method: 'PUT', |
| 2318 | isArray: false, |
| 2319 | url: '/api/tenant/cord/subscriber/:id/features/uplink_speed/' |
| 2320 | }, |
| 2321 | /** |
| 2322 | * @ngdoc method |
| 2323 | * @name xos.helpers.Subscribers#Read-Subscriber-downlink_speed |
| 2324 | * @methodOf xos.helpers.Subscribers |
| 2325 | * @description |
| 2326 | * Read-Subscriber-downlink_speed |
| 2327 | **/ |
| 2328 | 'Read-Subscriber-downlink_speed': { |
| 2329 | method: 'GET', |
| 2330 | isArray: false, |
| 2331 | url: '/api/tenant/cord/subscriber/:id/features/downlink_speed/' |
| 2332 | }, |
| 2333 | /** |
| 2334 | * @ngdoc method |
| 2335 | * @name xos.helpers.Subscribers#Update-Subscriber-downlink_speed |
| 2336 | * @methodOf xos.helpers.Subscribers |
| 2337 | * @description |
| 2338 | * Update-Subscriber-downlink_speed |
| 2339 | **/ |
| 2340 | 'Update-Subscriber-downlink_speed': { |
| 2341 | method: 'PUT', |
| 2342 | isArray: false, |
| 2343 | url: '/api/tenant/cord/subscriber/:id/features/downlink_speed/' |
| 2344 | }, |
| 2345 | /** |
| 2346 | * @ngdoc method |
| 2347 | * @name xos.helpers.Subscribers#Read-Subscriber-cdn |
| 2348 | * @methodOf xos.helpers.Subscribers |
| 2349 | * @description |
| 2350 | * Read-Subscriber-cdn |
| 2351 | **/ |
| 2352 | 'Read-Subscriber-cdn': { |
| 2353 | method: 'GET', |
| 2354 | isArray: false, |
| 2355 | url: '/api/tenant/cord/subscriber/:id/features/cdn/' |
| 2356 | }, |
| 2357 | /** |
| 2358 | * @ngdoc method |
| 2359 | * @name xos.helpers.Subscribers#Update-Subscriber-cdn |
| 2360 | * @methodOf xos.helpers.Subscribers |
| 2361 | * @description |
| 2362 | * Update-Subscriber-cdn |
| 2363 | **/ |
| 2364 | 'Update-Subscriber-cdn': { |
| 2365 | method: 'PUT', |
| 2366 | isArray: false, |
| 2367 | url: '/api/tenant/cord/subscriber/:id/features/cdn/' |
| 2368 | }, |
| 2369 | /** |
| 2370 | * @ngdoc method |
| 2371 | * @name xos.helpers.Subscribers#Read-Subscriber-uverse |
| 2372 | * @methodOf xos.helpers.Subscribers |
| 2373 | * @description |
| 2374 | * Read-Subscriber-uverse |
| 2375 | **/ |
| 2376 | 'Read-Subscriber-uverse': { |
| 2377 | method: 'GET', |
| 2378 | isArray: false, |
| 2379 | url: '/api/tenant/cord/subscriber/:id/features/uverse/' |
| 2380 | }, |
| 2381 | /** |
| 2382 | * @ngdoc method |
| 2383 | * @name xos.helpers.Subscribers#Update-Subscriber-uverse |
| 2384 | * @methodOf xos.helpers.Subscribers |
| 2385 | * @description |
| 2386 | * Update-Subscriber-uverse |
| 2387 | **/ |
| 2388 | 'Update-Subscriber-uverse': { |
| 2389 | method: 'PUT', |
| 2390 | isArray: false, |
| 2391 | url: '/api/tenant/cord/subscriber/:id/features/uverse/' |
| 2392 | }, |
| 2393 | /** |
| 2394 | * @ngdoc method |
| 2395 | * @name xos.helpers.Subscribers#Read-Subscriber-status |
| 2396 | * @methodOf xos.helpers.Subscribers |
| 2397 | * @description |
| 2398 | * Read-Subscriber-status |
| 2399 | **/ |
| 2400 | 'Read-Subscriber-status': { |
| 2401 | method: 'GET', |
| 2402 | isArray: false, |
| 2403 | url: '/api/tenant/cord/subscriber/:id/features/status/' |
| 2404 | }, |
| 2405 | /** |
| 2406 | * @ngdoc method |
| 2407 | * @name xos.helpers.Subscribers#Update-Subscriber-status |
| 2408 | * @methodOf xos.helpers.Subscribers |
| 2409 | * @description |
| 2410 | * Update-Subscriber-status |
| 2411 | **/ |
| 2412 | 'Update-Subscriber-status': { |
| 2413 | method: 'PUT', |
| 2414 | isArray: false, |
| 2415 | url: '/api/tenant/cord/subscriber/:id/features/status/' |
| 2416 | } |
| 2417 | }); |
| 2418 | }]); |
| 2419 | })(); |
| 2420 | //# sourceMappingURL=../../maps/services/rest/Subscribers.js.map |
| 2421 | |
| 2422 | 'use strict'; |
| 2423 | |
| 2424 | (function () { |
| 2425 | 'use strict'; |
| 2426 | |
| 2427 | angular.module('xos.helpers') |
| 2428 | /** |
| 2429 | * @ngdoc service |
| 2430 | * @name xos.helpers.SlicesPlus |
| 2431 | * @description Angular resource to fetch /api/utility/slicesplus/ |
| 2432 | * This is a read-only API and only the `query` method is currently supported. |
| 2433 | **/ |
| 2434 | .service('SlicesPlus', ["$http", "$q", function ($http, $q) { |
| 2435 | this.query = function (params) { |
| 2436 | var deferred = $q.defer(); |
| 2437 | |
| 2438 | $http.get('/api/utility/slicesplus/', { params: params }).then(function (res) { |
| 2439 | deferred.resolve(res.data); |
| 2440 | }).catch(function (res) { |
| 2441 | deferred.reject(res.data); |
| 2442 | }); |
| 2443 | |
| 2444 | return { $promise: deferred.promise }; |
| 2445 | }; |
| 2446 | |
| 2447 | this.get = function (id, params) { |
| 2448 | var deferred = $q.defer(); |
| 2449 | |
| 2450 | $http.get('/api/utility/slicesplus/' + id, { params: params }).then(function (res) { |
| 2451 | deferred.resolve(res.data); |
| 2452 | }).catch(function (res) { |
| 2453 | deferred.reject(res.data); |
| 2454 | }); |
| 2455 | return { $promise: deferred.promise }; |
| 2456 | }; |
| 2457 | }]); |
| 2458 | })(); |
| 2459 | //# sourceMappingURL=../../maps/services/rest/Slices_plus.js.map |
| 2460 | |
| 2461 | 'use strict'; |
| 2462 | |
| 2463 | (function () { |
| 2464 | 'use strict'; |
| 2465 | |
| 2466 | angular.module('xos.helpers') |
| 2467 | /** |
| 2468 | * @ngdoc service |
| 2469 | * @name xos.helpers.Slices |
| 2470 | * @description Angular resource to fetch /api/core/slices/:id/ |
| 2471 | **/ |
| 2472 | .service('Slices', ["$resource", function ($resource) { |
| 2473 | return $resource('/api/core/slices/:id/', { id: '@id' }, { |
| 2474 | update: { method: 'PUT' } |
| 2475 | }); |
| 2476 | }]); |
| 2477 | })(); |
| 2478 | //# sourceMappingURL=../../maps/services/rest/Slices.js.map |
| 2479 | |
| 2480 | 'use strict'; |
| 2481 | |
| 2482 | (function () { |
| 2483 | 'use strict'; |
| 2484 | |
| 2485 | angular.module('xos.helpers') |
| 2486 | /** |
| 2487 | * @ngdoc service |
| 2488 | * @name xos.helpers.Sites |
| 2489 | * @description Angular resource to fetch /api/core/sites/:id/ |
| 2490 | **/ |
| 2491 | .service('Sites', ["$resource", function ($resource) { |
| 2492 | return $resource('/api/core/sites/:id/', { id: '@id' }, { |
| 2493 | update: { method: 'PUT' } |
| 2494 | }); |
| 2495 | }]); |
| 2496 | })(); |
| 2497 | //# sourceMappingURL=../../maps/services/rest/Sites.js.map |
| 2498 | |
| 2499 | 'use strict'; |
| 2500 | |
| 2501 | (function () { |
| 2502 | 'use strict'; |
| 2503 | |
| 2504 | angular.module('xos.helpers') |
| 2505 | /** |
| 2506 | * @ngdoc service |
| 2507 | * @name xos.helpers.Services |
| 2508 | * @description Angular resource to fetch /api/core/services/:id/ |
| 2509 | **/ |
| 2510 | .service('Services', ["$resource", function ($resource) { |
| 2511 | return $resource('/api/core/services/:id/', { id: '@id' }, { |
| 2512 | update: { method: 'PUT' } |
| 2513 | }); |
| 2514 | }]); |
| 2515 | })(); |
| 2516 | //# sourceMappingURL=../../maps/services/rest/Services.js.map |
| 2517 | |
| 2518 | 'use strict'; |
| 2519 | |
| 2520 | (function () { |
| 2521 | 'use strict'; |
| 2522 | |
| 2523 | angular.module('xos.helpers') |
| 2524 | /** |
| 2525 | * @ngdoc service |
| 2526 | * @name xos.helpers.ONOS-Services-Collection |
| 2527 | * @description Angular resource to fetch /api/service/onos/ |
| 2528 | **/ |
| 2529 | .service('ONOS-Services-Collection', ["$resource", function ($resource) { |
| 2530 | return $resource('/api/service/onos/'); |
| 2531 | }]); |
| 2532 | })(); |
| 2533 | //# sourceMappingURL=../../maps/services/rest/ONOS-Services.js.map |
| 2534 | |
| 2535 | 'use strict'; |
| 2536 | |
| 2537 | (function () { |
| 2538 | 'use strict'; |
| 2539 | |
| 2540 | angular.module('xos.helpers') |
| 2541 | /** |
| 2542 | * @ngdoc service |
| 2543 | * @name xos.helpers.ONOS-App-Collection |
| 2544 | * @description Angular resource to fetch /api/tenant/onos/app/ |
| 2545 | **/ |
| 2546 | .service('ONOS-App-Collection', ["$resource", function ($resource) { |
| 2547 | return $resource('/api/tenant/onos/app/'); |
| 2548 | }]); |
| 2549 | })(); |
| 2550 | //# sourceMappingURL=../../maps/services/rest/ONOS-Apps.js.map |
| 2551 | |
| 2552 | 'use strict'; |
| 2553 | |
| 2554 | (function () { |
| 2555 | 'use strict'; |
| 2556 | |
| 2557 | angular.module('xos.helpers') |
| 2558 | /** |
| 2559 | * @ngdoc service |
| 2560 | * @name xos.helpers.Nodes |
| 2561 | * @description Angular resource to fetch /api/core/nodes/:id/ |
| 2562 | **/ |
| 2563 | .service('Nodes', ["$resource", function ($resource) { |
| 2564 | return $resource('/api/core/nodes/:id/', { id: '@id' }, { |
| 2565 | update: { method: 'PUT' } |
| 2566 | }); |
| 2567 | }]); |
| 2568 | })(); |
| 2569 | //# sourceMappingURL=../../maps/services/rest/Nodes.js.map |
| 2570 | |
| 2571 | 'use strict'; |
| 2572 | |
| 2573 | (function () { |
| 2574 | 'use strict'; |
| 2575 | |
| 2576 | angular.module('xos.helpers') |
| 2577 | /** |
| 2578 | * @ngdoc service |
| 2579 | * @name xos.helpers.Networkstemplates |
| 2580 | * @description Angular resource to fetch /api/core/networktemplates/:id/ |
| 2581 | **/ |
| 2582 | .service('Networkstemplates', ["$resource", function ($resource) { |
| 2583 | return $resource('/api/core/networktemplates/:id/', { id: '@id' }, { |
| 2584 | update: { method: 'PUT' } |
| 2585 | }); |
| 2586 | }]); |
| 2587 | })(); |
| 2588 | //# sourceMappingURL=../../maps/services/rest/Networkstemplates.js.map |
| 2589 | |
| 2590 | 'use strict'; |
| 2591 | |
| 2592 | (function () { |
| 2593 | 'use strict'; |
| 2594 | |
| 2595 | angular.module('xos.helpers') |
| 2596 | /** |
| 2597 | * @ngdoc service |
| 2598 | * @name xos.helpers.Networks |
| 2599 | * @description Angular resource to fetch /api/core/networks/:id/ |
| 2600 | **/ |
| 2601 | .service('Networks', ["$resource", function ($resource) { |
| 2602 | return $resource('/api/core/networks/:id/', { id: '@id' }, { |
| 2603 | update: { method: 'PUT' } |
| 2604 | }); |
| 2605 | }]); |
| 2606 | })(); |
| 2607 | //# sourceMappingURL=../../maps/services/rest/Networks.js.map |
| 2608 | |
| 2609 | 'use strict'; |
| 2610 | |
| 2611 | (function () { |
| 2612 | 'use strict'; |
| 2613 | |
| 2614 | angular.module('xos.helpers') |
| 2615 | /**
|
| 2616 | * @ngdoc service
|
| 2617 | * @name xos.helpers.Me
|
| 2618 | * @description Http read-only api to fetch /api/utility/me/
|
| 2619 | **/ |
| 2620 | .service('Me', ["$q", "$http", function ($q, $http) { |
| 2621 | |
| 2622 | this.get = function () { |
| 2623 | var deferred = $q.defer(); |
| 2624 | |
| 2625 | $http.get('/api/utility/me/').then(function (res) { |
| 2626 | deferred.resolve(res.data); |
| 2627 | }).catch(function (e) { |
| 2628 | deferred.reject(e); |
| 2629 | }); |
| 2630 | return deferred.promise; |
| 2631 | }; |
| 2632 | }]); |
| 2633 | })(); |
| 2634 | //# sourceMappingURL=../../maps/services/rest/Me.js.map |
| 2635 | |
| 2636 | 'use strict'; |
| 2637 | |
| 2638 | (function () { |
| 2639 | 'use strict'; |
| 2640 | |
| 2641 | angular.module('xos.helpers') |
| 2642 | /** |
| 2643 | * @ngdoc service |
| 2644 | * @name xos.helpers.Instances |
| 2645 | * @description Angular resource to fetch /api/core/instances/:id/ |
| 2646 | **/ |
| 2647 | .service('Instances', ["$resource", function ($resource) { |
| 2648 | return $resource('/api/core/instances/:id/', { id: '@id' }, { |
| 2649 | update: { method: 'PUT' } |
| 2650 | }); |
| 2651 | }]); |
| 2652 | })(); |
| 2653 | //# sourceMappingURL=../../maps/services/rest/Instances.js.map |
| 2654 | |
| 2655 | 'use strict'; |
| 2656 | |
| 2657 | (function () { |
| 2658 | 'use strict'; |
| 2659 | |
| 2660 | angular.module('xos.helpers') |
| 2661 | /** |
| 2662 | * @ngdoc service |
| 2663 | * @name xos.helpers.Images |
| 2664 | * @description Angular resource to fetch /api/core/images/ |
| 2665 | **/ |
| 2666 | .service('Images', ["$resource", function ($resource) { |
| 2667 | return $resource('/api/core/images/:id/', { id: '@id' }, { |
| 2668 | update: { method: 'PUT' } |
| 2669 | }); |
| 2670 | }]); |
| 2671 | })(); |
| 2672 | //# sourceMappingURL=../../maps/services/rest/Images.js.map |
| 2673 | |
| 2674 | 'use strict'; |
| 2675 | |
| 2676 | (function () { |
| 2677 | 'use strict'; |
| 2678 | |
| 2679 | angular.module('xos.helpers') |
| 2680 | /** |
| 2681 | * @ngdoc service |
| 2682 | * @name xos.helpers.Flavors |
| 2683 | * @description Angular resource to fetch /api/core/flavors/:id/ |
| 2684 | **/ |
| 2685 | .service('Flavors', ["$resource", function ($resource) { |
| 2686 | return $resource('/api/core/flavors/:id/', { id: '@id' }, { |
| 2687 | update: { method: 'PUT' } |
| 2688 | }); |
| 2689 | }]); |
| 2690 | })(); |
| 2691 | //# sourceMappingURL=../../maps/services/rest/Flavors.js.map |
| 2692 | |
| 2693 | 'use strict'; |
| 2694 | |
| 2695 | (function () { |
| 2696 | 'use strict'; |
| 2697 | |
| 2698 | angular.module('xos.helpers') |
| 2699 | /** |
| 2700 | * @ngdoc service |
| 2701 | * @name xos.helpers.Example-Services-Collection |
| 2702 | * @description Angular resource to fetch /api/service/exampleservice/ |
| 2703 | **/ |
| 2704 | .service('Example-Services-Collection', ["$resource", function ($resource) { |
| 2705 | return $resource('/api/service/exampleservice/'); |
| 2706 | }]); |
| 2707 | })(); |
| 2708 | //# sourceMappingURL=../../maps/services/rest/Example.js.map |
| 2709 | |
| 2710 | 'use strict'; |
| 2711 | |
| 2712 | (function () { |
| 2713 | 'use strict'; |
| 2714 | |
| 2715 | angular.module('xos.helpers') |
| 2716 | /** |
| 2717 | * @ngdoc service |
| 2718 | * @name xos.helpers.Deployments |
| 2719 | * @description Angular resource to fetch /api/core/deployments/:id/ |
| 2720 | **/ |
| 2721 | .service('Deployments', ["$resource", function ($resource) { |
| 2722 | return $resource('/api/core/deployments/:id/', { id: '@id' }, { |
| 2723 | update: { method: 'PUT' } |
| 2724 | }); |
| 2725 | }]); |
| 2726 | })(); |
| 2727 | //# sourceMappingURL=../../maps/services/rest/Deployments.js.map |
| 2728 | |
| 2729 | 'use strict'; |
| 2730 | |
| 2731 | (function () { |
| 2732 | 'use strict'; |
| 2733 | |
| 2734 | angular.module('xos.helpers') |
| 2735 | /** |
| 2736 | * @ngdoc service |
| 2737 | * @name xos.helpers.Dashboards |
| 2738 | * @description Angular resource to fetch /api/core/dashboardviews/:id/ |
| 2739 | **/ |
| 2740 | .service('Dashboards', ["$resource", "$q", "$http", function ($resource, $q, $http) { |
| 2741 | var r = $resource('/api/core/dashboardviews/:id/', { id: '@id' }, { |
| 2742 | update: { method: 'PUT' } |
| 2743 | }); |
| 2744 | |
| 2745 | r.prototype.$save = function () { |
| 2746 | var d = $q.defer(); |
| 2747 | |
| 2748 | $http.put('/api/core/dashboardviews/' + this.id + '/', this).then(function (res) { |
| 2749 | d.resolve(res.data); |
| 2750 | }).catch(function (e) { |
| 2751 | d.reject(e.data); |
| 2752 | }); |
| 2753 | |
| 2754 | return d.promise; |
| 2755 | }; |
| 2756 | |
| 2757 | return r; |
| 2758 | }]); |
| 2759 | })(); |
| 2760 | //# sourceMappingURL=../../maps/services/rest/Dashboards.js.map |
| 2761 | |
| 2762 | 'use strict'; |
| 2763 | |
| 2764 | (function () { |
| 2765 | |
| 2766 | angular.module('xos.helpers') |
| 2767 | |
| 2768 | /**
|
| 2769 | * @ngdoc service
|
| 2770 | * @name xos.helpers.XosUserPrefs
|
| 2771 | * @description
|
| 2772 | * This service is used to store the user preferences in cookies, so that they survive to page changes.
|
| 2773 | * The structure of the user preference is:
|
| 2774 | * ```
|
| 2775 | * {
|
| 2776 | * synchronizers: {
|
| 2777 | * notification: {
|
| 2778 | * 'volt': boolean,
|
| 2779 | * 'openstack': boolean,
|
| 2780 | * ...
|
| 2781 | * }
|
| 2782 | * }
|
| 2783 | * userData: {
|
| 2784 | * current_user_site_id: Number,
|
| 2785 | * current_user_site_user_names: Array[1],
|
| 2786 | * ...
|
| 2787 | * }
|
| 2788 | * }
|
| 2789 | * ```
|
| 2790 | **/ |
| 2791 | |
| 2792 | .service('XosUserPrefs', ["$cookies", "Me", "$q", function ($cookies, Me, $q) { |
| 2793 | var _this = this; |
| 2794 | |
| 2795 | var userPrefs = $cookies.get('xosUserPrefs') ? angular.fromJson($cookies.get('xosUserPrefs')) : {}; |
| 2796 | |
| 2797 | /**
|
| 2798 | * @ngdoc method
|
| 2799 | * @name xos.helpers.XosUserPrefs#getAll
|
| 2800 | * @methodOf xos.helpers.XosUserPrefs
|
| 2801 | * @description
|
| 2802 | * Return all the user preferences stored in cookies
|
| 2803 | * @returns {object} The user preferences
|
| 2804 | **/ |
| 2805 | this.getAll = function () { |
| 2806 | userPrefs = $cookies.get('xosUserPrefs') ? angular.fromJson($cookies.get('xosUserPrefs')) : {}; |
| 2807 | return userPrefs; |
| 2808 | }; |
| 2809 | |
| 2810 | /**
|
| 2811 | * @ngdoc method
|
| 2812 | * @name xos.helpers.XosUserPrefs#setAll
|
| 2813 | * @methodOf xos.helpers.XosUserPrefs
|
| 2814 | * @description
|
| 2815 | * Override all user preferences
|
| 2816 | * @param {object} prefs The user preferences
|
| 2817 | **/ |
| 2818 | this.setAll = function (prefs) { |
| 2819 | $cookies.put('xosUserPrefs', angular.toJson(prefs)); |
| 2820 | }; |
| 2821 | |
| 2822 | /**
|
| 2823 | * @ngdoc method
|
| 2824 | * @name xos.helpers.XosUserPrefs#getSynchronizerNotificationStatus
|
| 2825 | * @methodOf xos.helpers.XosUserPrefs
|
| 2826 | * @description
|
| 2827 | * Return the synchronizer notification status, if name is not provided return the status for all synchronizers
|
| 2828 | * @param {string=} prefs The synchronizer name
|
| 2829 | * @returns {object | string} The synchronizer status
|
| 2830 | **/ |
| 2831 | this.getSynchronizerNotificationStatus = function () { |
| 2832 | var name = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; |
| 2833 | |
| 2834 | if (name) { |
| 2835 | return _this.getAll().synchronizers.notification[name]; |
| 2836 | } |
| 2837 | return _this.getAll().synchronizers.notification; |
| 2838 | }; |
| 2839 | |
| 2840 | /**
|
| 2841 | * @ngdoc method
|
| 2842 | * @name xos.helpers.XosUserPrefs#getUserDetailsCookie
|
| 2843 | * @methodOf xos.helpers.XosUserPrefs
|
| 2844 | * @description
|
| 2845 | * Return all the user details stored in cookies or call the service
|
| 2846 | * @returns {object} The user details
|
| 2847 | **/ |
| 2848 | this.getUserDetailsCookie = function () { |
| 2849 | var defer = $q.defer(); |
| 2850 | var localPref = _this.getAll(); |
| 2851 | if (!localPref.userData) { |
| 2852 | _this.setUserDetailsCookie().$promise.then(function (data) { |
| 2853 | defer.resolve(data); |
| 2854 | }); |
| 2855 | } else { |
| 2856 | defer.resolve(localPref.userData); |
| 2857 | } |
| 2858 | return { $promise: defer.promise }; |
| 2859 | }; |
| 2860 | |
| 2861 | /**
|
| 2862 | * @ngdoc method
|
| 2863 | * @name xos.helpers.XosUserPrefs#setUserDetailsCookie
|
| 2864 | * @methodOf xos.helpers.XosUserPrefs
|
| 2865 | * @description
|
| 2866 | * Save the user details in the cookie
|
| 2867 | * @param {object} details stored in cookie
|
| 2868 | * @param {objects} returns the user details as a promise
|
| 2869 | **/ |
| 2870 | this.setUserDetailsCookie = function () { |
| 2871 | var userData = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; |
| 2872 | |
| 2873 | |
| 2874 | var defer = $q.defer(); |
| 2875 | var cookies = _this.getAll(); |
| 2876 | if (!userData) { |
| 2877 | Me.get().then(function (user) { |
| 2878 | cookies.userData = user; |
| 2879 | _this.setAll(cookies); |
| 2880 | defer.resolve(user); |
| 2881 | }).catch(function (e) { |
| 2882 | defer.reject(e); |
| 2883 | }); |
| 2884 | } else { |
| 2885 | cookies.userData = userData; |
| 2886 | _this.setAll(cookies); |
| 2887 | defer.resolve(userData); |
| 2888 | } |
| 2889 | return { $promise: defer.promise }; |
| 2890 | }; |
| 2891 | |
| 2892 | /**
|
| 2893 | * @ngdoc method
|
| 2894 | * @name xos.helpers.XosUserPrefs#setSynchronizerNotificationStatus
|
| 2895 | * @methodOf xos.helpers.XosUserPrefs
|
| 2896 | * @description
|
| 2897 | * Update the notification status for a single synchronizer
|
| 2898 | * @param {string} name The synchronizer name
|
| 2899 | * @param {boolean} value The notification status (true means that it has been sent)
|
| 2900 | **/ |
| 2901 | |
| 2902 | this.setSynchronizerNotificationStatus = function () { |
| 2903 | var name = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; |
| 2904 | var value = arguments[1]; |
| 2905 | |
| 2906 | if (!name) { |
| 2907 | throw new Error('[XosUserPrefs] When updating a synchronizer is mandatory to provide a name.'); |
| 2908 | } |
| 2909 | |
| 2910 | var cookies = _this.getAll(); |
| 2911 | |
| 2912 | if (!cookies.synchronizers) { |
| 2913 | cookies.synchronizers = { |
| 2914 | notification: {} |
| 2915 | }; |
| 2916 | } |
| 2917 | cookies.synchronizers.notification[name] = value; |
| 2918 | _this.setAll(cookies); |
| 2919 | }; |
| 2920 | }]); |
| 2921 | })(); |
| 2922 | //# sourceMappingURL=../../maps/services/helpers/user-prefs.service.js.map |
| 2923 | |
| 2924 | 'use strict'; |
| 2925 | |
| 2926 | (function () { |
| 2927 | 'use strict'; |
| 2928 | |
| 2929 | /** |
| 2930 | * @ngdoc service |
| 2931 | * @name xos.helpers.ServiceGraph |
| 2932 | * @description This factory define a set of helper function to query the service tenancy graph |
| 2933 | **/ |
| 2934 | |
| 2935 | angular.module('xos.helpers').service('GraphService', ["$q", "Tenants", "Services", function ($q, Tenants, Services) { |
| 2936 | var _this = this; |
| 2937 | |
| 2938 | this.loadCoarseData = function () { |
| 2939 | |
| 2940 | var services = void 0; |
| 2941 | |
| 2942 | var deferred = $q.defer(); |
| 2943 | |
| 2944 | Services.query().$promise.then(function (res) { |
| 2945 | services = res; |
| 2946 | return Tenants.query({ kind: 'coarse' }).$promise; |
| 2947 | }).then(function (tenants) { |
| 2948 | deferred.resolve({ |
| 2949 | tenants: tenants, |
| 2950 | services: services |
| 2951 | }); |
| 2952 | }); |
| 2953 | |
| 2954 | return deferred.promise; |
| 2955 | }; |
| 2956 | |
| 2957 | this.getCoarseGraph = function () { |
| 2958 | _this.loadCoarseData().then(function (res) { |
| 2959 | console.log(res); |
| 2960 | }); |
| 2961 | return 'ciao'; |
| 2962 | }; |
| 2963 | }]); |
| 2964 | })(); |
| 2965 | //# sourceMappingURL=../maps/services/service_graph.service.js.map |
| 2966 | |
| 2967 | 'use strict'; |
| 2968 | |
| 2969 | /* eslint-disable angular/ng_window_service*/ |
| 2970 | (function () { |
| 2971 | 'use strict'; |
| 2972 | |
| 2973 | angular.module('xos.helpers').factory('Notification', function () { |
| 2974 | return window.Notification; |
| 2975 | }) |
| 2976 | /** |
| 2977 | * @ngdoc service |
| 2978 | * @name xos.helpers.xosNotification |
| 2979 | * @description This factory define a set of helper function to trigger desktop notification |
| 2980 | **/ |
| 2981 | .service('xosNotification', ["$q", "$log", "Notification", function ($q, $log, Notification) { |
| 2982 | var _this = this; |
| 2983 | |
| 2984 | this.checkPermission = function () { |
| 2985 | var deferred = $q.defer(); |
| 2986 | Notification.requestPermission().then(function (permission) { |
| 2987 | if (permission === 'granted') { |
| 2988 | deferred.resolve(permission); |
| 2989 | } else { |
| 2990 | deferred.reject(permission); |
| 2991 | } |
| 2992 | }); |
| 2993 | return deferred.promise; |
| 2994 | }; |
| 2995 | |
| 2996 | this.sendNotification = function (title, options) { |
| 2997 | var notification = new Notification(title, options); |
| 2998 | notification.onerror = function (err) { |
| 2999 | $log.error(err); |
| 3000 | }; |
| 3001 | }; |
| 3002 | |
| 3003 | /** |
| 3004 | * @ngdoc method |
| 3005 | * @name xos.helpers.xosNotification#notify |
| 3006 | * @methodOf xos.helpers.xosNotification |
| 3007 | * @description |
| 3008 | * This method will check for user permission and if granted will send a browser notification. |
| 3009 | * @param {string} title The notification title |
| 3010 | * @param {object} options The notification options: `{icon: 'url', body: 'Notification body'}` |
| 3011 | **/ |
| 3012 | |
| 3013 | this.notify = function (title, options) { |
| 3014 | if (!('Notification' in window)) { |
| 3015 | $log.info('This browser does not support desktop notification'); |
| 3016 | } else if (Notification.permission !== 'granted') { |
| 3017 | _this.checkPermission().then(function () { |
| 3018 | return _this.sendNotification(title, options); |
| 3019 | }); |
| 3020 | } else if (Notification.permission === 'granted') { |
| 3021 | _this.sendNotification(title, options); |
| 3022 | } |
| 3023 | }; |
| 3024 | }]); |
| 3025 | })(); |
| 3026 | //# sourceMappingURL=../maps/services/notification.service.js.map |
| 3027 | |
| 3028 | 'use strict'; |
| 3029 | |
| 3030 | (function () { |
| 3031 | 'use strict'; |
| 3032 | |
| 3033 | /** |
| 3034 | * @ngdoc service |
| 3035 | * @name xos.helpers.NoHyperlinks |
| 3036 | * @description This factory is automatically loaded trough xos.helpers and will add an $http interceptor that will add ?no_hyperlinks=1 to your api request, that is required by django |
| 3037 | **/ |
| 3038 | |
| 3039 | angular.module('xos.helpers').factory('NoHyperlinks', noHyperlinks); |
| 3040 | |
| 3041 | function noHyperlinks() { |
| 3042 | return { |
| 3043 | request: function request(_request) { |
| 3044 | if (_request.url.indexOf('.html') === -1) { |
| 3045 | _request.url += '?no_hyperlinks=1'; |
| 3046 | } |
| 3047 | return _request; |
| 3048 | } |
| 3049 | }; |
| 3050 | } |
| 3051 | })(); |
| 3052 | //# sourceMappingURL=../maps/services/noHyperlinks.interceptor.js.map |
| 3053 | |
| 3054 | 'use strict'; |
| 3055 | |
| 3056 | // TODO write tests for log |
| 3057 | |
| 3058 | /* eslint-disable angular/ng_window_service*/ |
| 3059 | |
| 3060 | angular.module('xos.helpers').config(['$provide', function ($provide) { |
| 3061 | // Use the `decorator` solution to substitute or attach behaviors to |
| 3062 | // original service instance; @see angular-mocks for more examples.... |
| 3063 | |
| 3064 | $provide.decorator('$log', ['$delegate', function ($delegate) { |
| 3065 | |
| 3066 | var isLogEnabled = function isLogEnabled() { |
| 3067 | return window.location.href.indexOf('debug=true') >= 0; |
| 3068 | }; |
| 3069 | // Save the original $log.debug() |
| 3070 | var logFn = $delegate.log; |
| 3071 | var infoFn = $delegate.info; |
| 3072 | var warnFn = $delegate.warn; |
| 3073 | //let errorFn = $delegate.error; |
| 3074 | var debugFn = $delegate.debug; |
| 3075 | |
| 3076 | // create the replacement function |
| 3077 | var replacement = function replacement(fn) { |
| 3078 | return function () { |
| 3079 | //console.log(`Is Log Enabled: ${isLogEnabled()}`) |
| 3080 | if (!isLogEnabled()) { |
| 3081 | // console.log('logging is disabled'); |
| 3082 | return; |
| 3083 | } |
| 3084 | |
| 3085 | var args = [].slice.call(arguments); |
| 3086 | var now = new Date(); |
| 3087 | |
| 3088 | // Prepend timestamp |
| 3089 | args[0] = '[' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds() + '] ' + args[0]; |
| 3090 | |
| 3091 | // HACK awfull fix for angular mock implementation whithin jasmine test failing issue |
| 3092 | if (angular.isFunction($delegate.reset) && !($delegate.debug.logs instanceof Array)) { |
| 3093 | // if we are within the mock and did not reset yet, we call it to avoid issue |
| 3094 | // console.log('mock log impl fix to avoid logs array not existing...'); |
| 3095 | $delegate.reset(); |
| 3096 | } |
| 3097 | |
| 3098 | // Call the original with the output prepended with formatted timestamp |
| 3099 | |
| 3100 | return fn.apply(null, args); |
| 3101 | }; |
| 3102 | }; |
| 3103 | |
| 3104 | $delegate.info = replacement(infoFn); |
| 3105 | $delegate.log = replacement(logFn); |
| 3106 | $delegate.warn = replacement(warnFn); |
| 3107 | //$delegate.error = replacement(errorFn); // note this will prevent errors to be printed |
| 3108 | $delegate.debug = replacement(debugFn); |
| 3109 | |
| 3110 | return $delegate; |
| 3111 | }]); |
| 3112 | }]); |
| 3113 | //# sourceMappingURL=../maps/services/log.decorator.js.map |
| 3114 | |
| 3115 | 'use strict'; |
| 3116 | |
| 3117 | (function () { |
| 3118 | 'use strict'; |
| 3119 | |
| 3120 | /** |
| 3121 | * @ngdoc service |
| 3122 | * @name xos.helpers.SetCSRFToken |
| 3123 | * @description This factory is automatically loaded trough xos.helpers and will add an $http interceptor that will the CSRF-Token to your request headers |
| 3124 | **/ |
| 3125 | |
| 3126 | setCSRFToken.$inject = ["$cookies"]; |
| 3127 | angular.module('xos.helpers').factory('SetCSRFToken', setCSRFToken); |
| 3128 | |
| 3129 | function setCSRFToken($cookies) { |
| 3130 | return { |
| 3131 | request: function request(_request) { |
| 3132 | if (_request.method !== 'GET') { |
| 3133 | _request.headers['X-CSRFToken'] = $cookies.get('xoscsrftoken'); |
| 3134 | } |
| 3135 | return _request; |
| 3136 | } |
| 3137 | }; |
| 3138 | } |
| 3139 | })(); |
| 3140 | //# sourceMappingURL=../maps/services/csrfToken.interceptor.js.map |
| 3141 | |
| 3142 | /** |
| 3143 | * @ngdoc overview |
| 3144 | * @name ngXosLib |
| 3145 | * @id index |
| 3146 | * @description |
| 3147 | * # Welcome to the ngXosLib documentation! <br/> |
| 3148 | * This is the module that group all the helpers service and UI components for XOS. |
| 3149 | * <br/><br/> |
| 3150 | * You can find all the documentation related to the UI Component Library here: <a href="#/module/xos.uiComponents"> xos.uiComponents</a> <br/> |
| 3151 | * and the documentation related to all the other helpers here: <a href="#/module/xos.helpers"> xos.helpers</a> <br/> |
| 3152 | * ## Issues |
| 3153 | * Please report issues at https://jira.opencord.org |
| 3154 | **/ |
| 3155 | "use strict"; |
| 3156 | //# sourceMappingURL=maps/index.ngdoc.js.map |