blob: 009073493f3baf96c4df0c80c5d5010673b8f04a [file] [log] [blame]
/*
* Copyright 2017-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { Injectable } from '@angular/core';
import { LogService } from '../../log.service';
import { WebSocketService } from '../remote/websocket.service';
/**
* A definition of Lion data
*/
interface Lion {
locale: any;
lion: any;
}
/**
* ONOS GUI -- Lion -- Localization Utilities
*/
@Injectable()
export class LionService {
ubercache: any[];
constructor(
private log: LogService,
private wss: WebSocketService
) {
this.log.debug('LionService constructed');
}
/* returns a lion bundle (function) for the given bundle ID
* returns a function that takes a string and returns a string
*/
bundle(bundleId: string): (string) => string {
let bundle = this.ubercache[bundleId];
if (!bundle) {
this.log.warn('No lion bundle registered:', bundleId);
bundle = {};
}
return this.getKey;
}
getKey(key: string): string {
return this.bundle[key] || '%' + key + '%';
}
/* handler for uberlion event..
*/
uberlion(data: Lion) {
this.ubercache = data.lion;
this.log.info('LION service: Locale... [' + data.locale + ']');
this.log.info('LION service: Bundles installed...');
for (let p in this.ubercache) {
if (this.ubercache[p]) {
this.log.info(' :=> ', p);
}
}
this.log.debug('LION service: uber-lion bundle received:', data);
}
}