First draft of developer view
diff --git a/views/ngXosLib/xosHelpers/spec/ui/table.test.js b/views/ngXosLib/xosHelpers/spec/ui/table.test.js
index d00d19e..4c19372 100644
--- a/views/ngXosLib/xosHelpers/spec/ui/table.test.js
+++ b/views/ngXosLib/xosHelpers/spec/ui/table.test.js
@@ -228,6 +228,9 @@
});
describe('and is custom', () => {
+
+ let formatterFn = jasmine.createSpy('formatter').and.returnValue('Formatted Content');
+
beforeEach(() => {
scope.data = [
{categories: ['Film', 'Music']}
@@ -238,7 +241,7 @@
label: 'Categories',
prop: 'categories',
type: 'custom',
- formatter: () => 'Formatted Content'
+ formatter: formatterFn
}
]
}
@@ -285,6 +288,8 @@
it('should format data using the formatter property', () => {
let td1 = $(element).find('tbody tr:first-child')[0];
expect($(td1).text().trim()).toEqual('Formatted Content');
+ // the custom formatted should receive the entire object, otherwise is not so custom
+ expect(formatterFn).toHaveBeenCalledWith({categories: ['Film', 'Music']});
});
});
});
@@ -327,7 +332,7 @@
expect(errorFunctionWrapper).toThrow(new Error('[xosTable] The link property should be a function.'));
});
- it('should render a comma separated list', () => {
+ it('should render a link with the correct url', () => {
let link = $(element).find('tbody tr:first-child td a')[0];
expect($(link).attr('href')).toEqual('/link/1');
});
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Networks.js b/views/ngXosLib/xosHelpers/src/services/rest/Networks.js
new file mode 100644
index 0000000..74b73b6
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Networks.js
@@ -0,0 +1,15 @@
+(function() {
+ 'use strict';
+
+ angular.module('xos.helpers')
+ /**
+ * @ngdoc service
+ * @name xos.helpers.Networks
+ * @description Angular resource to fetch /api/core/networks/:id/
+ **/
+ .service('Networks', function($resource){
+ return $resource('/api/core/networks/:id/', { id: '@id' }, {
+ update: { method: 'PUT' }
+ });
+ })
+})();
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Slices_plus.js b/views/ngXosLib/xosHelpers/src/services/rest/Slices_plus.js
new file mode 100644
index 0000000..e744caa
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Slices_plus.js
@@ -0,0 +1,26 @@
+(function() {
+ 'use strict';
+
+ angular.module('xos.helpers')
+ /**
+ * @ngdoc service
+ * @name xos.helpers.SlicesPlus
+ * @description Angular resource to fetch /api/utility/slicesplus/
+ * This is a read-only API and only the `query` method is currently supported.
+ **/
+ .service('SlicesPlus', function($http, $q){
+ this.query = (params) => {
+ let deferred = $q.defer();
+
+ $http.get('/api/utility/slicesplus/', {params: params})
+ .then(res => {
+ deferred.resolve(res.data);
+ })
+ .catch(res => {
+ deferred.reject(res.data);
+ });
+
+ return {$promise: deferred.promise};
+ }
+ })
+})();
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js
index 8b49932..a846bf5 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js
@@ -22,7 +22,10 @@
* columns: [
* {
* label: 'Human readable name',
- * prop: 'Property to read in the model object'
+ * prop: 'Property to read in the model object', // optional if type is custom
+ * type: 'object' | 'array' | 'boolean' | 'date' | 'custom',
+ * formatter: fn(), // receive the whole item if tipe is custom and return a string
+ * link: fn() // receive the whole item and return an url
* }
* ],
* classes: 'table table-striped table-bordered',
@@ -272,15 +275,14 @@
},
{
label: 'Features',
- prop: 'features',
type: 'custom',
formatter: (val) => {
- let cdnEnabled = val.cdn ? 'enabled' : 'disabled';
+ let cdnEnabled = val.features.cdn ? 'enabled' : 'disabled';
return `
Cdn is ${cdnEnabled},
- uplink speed is ${val.uplink_speed}
- and downlink speed is ${val.downlink_speed}
+ uplink speed is ${val.features.uplink_speed}
+ and downlink speed is ${val.features.downlink_speed}
`;
}
}
@@ -385,7 +387,7 @@
</dl>
</span>
<span ng-if="col.type === 'custom'">
- {{col.formatter(item[col.prop])}}
+ {{col.formatter(item)}}
</span>
</td>
<td ng-if="vm.config.actions">
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.scss b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.scss
index 70399a9..d9830d8 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.scss
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.scss
@@ -28,11 +28,17 @@
margin-bottom: 0;
dt {
- width: 50px !important;
+ width: auto !important;
+ margin-right: 10px;
+ }
+
+ dt:after {
+ /*display: block;*/
+ content: ':';
}
dd {
- margin-left: 60px !important;
+ margin-left: 0 !important;
}
}
}
\ No newline at end of file