YUKI Hiroshi
null+****@clear*****
Wed Sep 21 19:21:05 JST 2016
YUKI Hiroshi 2016-09-21 19:21:05 +0900 (Wed, 21 Sep 2016) New Revision: c7ff68202a7cad908f406f57292f4c60eaa2ff34 https://github.com/groonga/groonga-admin/commit/c7ff68202a7cad908f406f57292f4c60eaa2ff34 Merged 2dd9aa7: Merge pull request #11 from groonga/features/migrate-column_list-to-schema Message: Build columns from "schema" result (WIP) Modified files: app/scripts/services/schema-loader.js Modified: app/scripts/services/schema-loader.js (+52 -21) =================================================================== --- app/scripts/services/schema-loader.js 2016-09-21 17:26:55 +0900 (ddb7d0f) +++ app/scripts/services/schema-loader.js 2016-09-21 19:21:05 +0900 (7b246dd) @@ -184,34 +184,65 @@ angular.module('groongaAdminApp') }); } - function addColumn(table, column) { - column.table = table; + function buildColumn(table, rawColumn) { + var column = {}; + column.id = 0; // XXX it exists in a table_list response but missing in a schema response. + column.name = rawColumn.name; + column.path = ''; // XXX it exists in a table_list response but missing in a schema response. + column.type = rawColumn.type; + column.sizeType = rawColumn.type; + column.sources = rawColumn.sources.join('|'); // XXX what is the correct delimiter? + column.table = table; + + column.flags = []; + if (rawColumn.command && + rawColumn.command.arguments && + rawColumn.command.arguments.flags) + column.flags = rawColumn.command.arguments.flags.split('|'); + + column.valeuType = null; + if (column.value_type) + column.valueType = column.value_type.name; + + column.isScalar = column.type == 'scalar'; + column.isVector = column.type == 'vector'; + column.isIndex = column.type == 'index'; + + column.range = column.valueType; // for backward compatibility + column.domain = table.name; // for backward compatibility + column.source = column.sources; // for backward compatibility + column.indexes = []; - table.columns[column.name] = column; + return column; + } + + function buildColumns(table) { + var columns = {}; + + columns._id = { + name: '_id', + id: table.id, + path: table.path, + type: 'fix', + flags: ['COLUMN_SCALAR', 'PERSISTENT'], + domain: table.name, + range: 'UInt32', + source: null + }; + + angular.forEach(columns, function(column, name) { + columns[name] = buildColumn(table, column); + }); + + return columns; } function fetchColumns(table) { table.columns = {}; - return client.execute('column_list', {table: table.name}) + return client.execute('schema') .success(function(response) { - var columns = response.columns(); - - var rawIDColumn = [ - table.id, // id - '_id', // name - table.path, // path - 'fix', // type - 'COLUMN_SCALAR|PERSISTENT', // flags - table.name, // domain - 'UInt32', // range - [] // source - ]; - columns.unshift(response.parseRawColumn(rawIDColumn)); - - columns.forEach(function(column) { - addColumn(table, column); - }); + table.columns = buildColumns(response.tables()[table.name]); }); } -------------- next part -------------- HTML����������������������������...Download